mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
use auth logout
This commit is contained in:
parent
a25a82e333
commit
ca0387eee3
@ -29,7 +29,7 @@ const MainSelector = (props) => {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<antd.Button
|
<antd.Button
|
||||||
onClick={() => app.controls.openLoginForm()}
|
onClick={() => app.auth.login()}
|
||||||
icon={<Icons.FiLogIn />}
|
icon={<Icons.FiLogIn />}
|
||||||
type="primary"
|
type="primary"
|
||||||
>
|
>
|
||||||
@ -37,7 +37,7 @@ const MainSelector = (props) => {
|
|||||||
</antd.Button>
|
</antd.Button>
|
||||||
|
|
||||||
<antd.Button
|
<antd.Button
|
||||||
onClick={() => app.controls.openLoginForm()}
|
onClick={() => app.auth.login()}
|
||||||
icon={<Icons.FiLogIn />}
|
icon={<Icons.FiLogIn />}
|
||||||
type="primary"
|
type="primary"
|
||||||
disabled
|
disabled
|
||||||
|
@ -9,9 +9,7 @@ import { createIconRender } from "@components/Icons"
|
|||||||
import useUrlQueryActiveKey from "@hooks/useUrlQueryActiveKey"
|
import useUrlQueryActiveKey from "@hooks/useUrlQueryActiveKey"
|
||||||
import useUserRemoteConfig from "@hooks/useUserRemoteConfig"
|
import useUserRemoteConfig from "@hooks/useUserRemoteConfig"
|
||||||
|
|
||||||
import {
|
import { composedSettingsByGroups as settings } from "@/settings"
|
||||||
composedSettingsByGroups as settings
|
|
||||||
} from "@/settings"
|
|
||||||
|
|
||||||
import menuGroupsDecorators from "@config/settingsMenuGroupsDecorators"
|
import menuGroupsDecorators from "@config/settingsMenuGroupsDecorators"
|
||||||
|
|
||||||
@ -22,30 +20,36 @@ import "./index.less"
|
|||||||
const extraMenuItems = [
|
const extraMenuItems = [
|
||||||
{
|
{
|
||||||
key: "donate",
|
key: "donate",
|
||||||
label: <div style={{
|
label: (
|
||||||
color: "#f72585"
|
<div
|
||||||
}}>
|
style={{
|
||||||
|
color: "#f72585",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{createIconRender("FiHeart")}
|
{createIconRender("FiHeart")}
|
||||||
Support us
|
Support us
|
||||||
</div>,
|
</div>
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "logout",
|
key: "logout",
|
||||||
label: <div>
|
label: (
|
||||||
|
<div>
|
||||||
{createIconRender("MdOutlineLogout")}
|
{createIconRender("MdOutlineLogout")}
|
||||||
Logout
|
Logout
|
||||||
</div>,
|
</div>
|
||||||
|
),
|
||||||
danger: true,
|
danger: true,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const menuEvents = {
|
const menuEvents = {
|
||||||
"donate": () => {
|
donate: () => {
|
||||||
app.layout.modal.open("donate", DonativeSelector)
|
app.layout.modal.open("donate", DonativeSelector)
|
||||||
},
|
},
|
||||||
"logout": () => {
|
logout: () => {
|
||||||
app.eventBus.emit("app.logout_request")
|
app.auth.logout()
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const generateMenuItems = () => {
|
const generateMenuItems = () => {
|
||||||
@ -54,10 +58,12 @@ const generateMenuItems = () => {
|
|||||||
return {
|
return {
|
||||||
key: item.id,
|
key: item.id,
|
||||||
type: "item",
|
type: "item",
|
||||||
label: <div {...item.props} className="menu-item-content">
|
label: (
|
||||||
|
<div {...item.props} className="menu-item-content">
|
||||||
{createIconRender(item.icon ?? "Settings")}
|
{createIconRender(item.icon ?? "Settings")}
|
||||||
{item.label}
|
{item.label}
|
||||||
</div>,
|
</div>
|
||||||
|
),
|
||||||
danger: item.danger,
|
danger: item.danger,
|
||||||
disabled: item.disabled,
|
disabled: item.disabled,
|
||||||
}
|
}
|
||||||
@ -73,16 +79,24 @@ const generateMenuItems = () => {
|
|||||||
key: entry.group,
|
key: entry.group,
|
||||||
type: "group",
|
type: "group",
|
||||||
children: children,
|
children: children,
|
||||||
label: entry.group === "bottom" ? null : <>
|
label:
|
||||||
{
|
entry.group === "bottom" ? null : (
|
||||||
menuGroupsDecorators[entry.group]?.icon && createIconRender(menuGroupsDecorators[groupKey]?.icon ?? "Settings")
|
<>
|
||||||
}
|
{menuGroupsDecorators[entry.group]?.icon &&
|
||||||
|
createIconRender(
|
||||||
|
menuGroupsDecorators[groupKey]?.icon ??
|
||||||
|
"Settings",
|
||||||
|
)}
|
||||||
<Translation>
|
<Translation>
|
||||||
{
|
{(t) =>
|
||||||
t => t(menuGroupsDecorators[entry.group]?.label ?? entry.group)
|
t(
|
||||||
|
menuGroupsDecorators[entry.group]?.label ??
|
||||||
|
entry.group,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
</Translation>
|
</Translation>
|
||||||
</>
|
</>
|
||||||
|
),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -91,7 +105,7 @@ export default () => {
|
|||||||
const [config, setConfig, loading] = useUserRemoteConfig()
|
const [config, setConfig, loading] = useUserRemoteConfig()
|
||||||
const [activeKey, setActiveKey] = useUrlQueryActiveKey({
|
const [activeKey, setActiveKey] = useUrlQueryActiveKey({
|
||||||
defaultKey: "general",
|
defaultKey: "general",
|
||||||
queryKey: "tab"
|
queryKey: "tab",
|
||||||
})
|
})
|
||||||
|
|
||||||
const onChangeTab = (event) => {
|
const onChangeTab = (event) => {
|
||||||
@ -117,7 +131,7 @@ export default () => {
|
|||||||
function handleOnUpdate(key, value) {
|
function handleOnUpdate(key, value) {
|
||||||
setConfig({
|
setConfig({
|
||||||
...config,
|
...config,
|
||||||
[key]: value
|
[key]: value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +149,8 @@ export default () => {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return <div className="settings_wrapper">
|
return (
|
||||||
|
<div className="settings_wrapper">
|
||||||
<div className="settings_menu">
|
<div className="settings_menu">
|
||||||
<antd.Menu
|
<antd.Menu
|
||||||
mode="vertical"
|
mode="vertical"
|
||||||
@ -145,22 +160,18 @@ export default () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{
|
{loading && <antd.Skeleton active />}
|
||||||
loading && <antd.Skeleton active />
|
|
||||||
}
|
|
||||||
|
|
||||||
<PageTransition
|
<PageTransition className="settings_content" key={activeKey}>
|
||||||
className="settings_content"
|
{!loading && (
|
||||||
key={activeKey}
|
<SettingTab
|
||||||
>
|
|
||||||
{
|
|
||||||
!loading && <SettingTab
|
|
||||||
baseConfig={config}
|
baseConfig={config}
|
||||||
onUpdate={handleOnUpdate}
|
onUpdate={handleOnUpdate}
|
||||||
activeKey={activeKey}
|
activeKey={activeKey}
|
||||||
withGroups
|
withGroups
|
||||||
/>
|
/>
|
||||||
}
|
)}
|
||||||
</PageTransition>
|
</PageTransition>
|
||||||
</div>
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user