mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
🧑💻 Improve settings ctx, added updateCurrentValue
& beforeSave
This commit is contained in:
parent
f0b00a3df8
commit
8f26f1350e
@ -4,6 +4,7 @@ import { SliderPicker } from "react-color"
|
|||||||
import { Translation } from "react-i18next"
|
import { Translation } from "react-i18next"
|
||||||
import classnames from "classnames"
|
import classnames from "classnames"
|
||||||
import config from "config"
|
import config from "config"
|
||||||
|
import useUrlQueryActiveKey from "hooks/useUrlQueryActiveKey"
|
||||||
|
|
||||||
import AuthModel from "models/auth"
|
import AuthModel from "models/auth"
|
||||||
|
|
||||||
@ -116,6 +117,10 @@ const SettingItem = (props) => {
|
|||||||
await window.app.cores.settings.set(item.id, updateValue)
|
await window.app.cores.settings.set(item.id, updateValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.storaged && typeof item.beforeSave === "function") {
|
||||||
|
await item.beforeSave(updateValue)
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof item.emitEvent !== "undefined") {
|
if (typeof item.emitEvent !== "undefined") {
|
||||||
let emissionPayload = updateValue
|
let emissionPayload = updateValue
|
||||||
|
|
||||||
@ -292,6 +297,7 @@ const SettingItem = (props) => {
|
|||||||
item.props["disabled"] = disabled
|
item.props["disabled"] = disabled
|
||||||
|
|
||||||
const elementsCtx = {
|
const elementsCtx = {
|
||||||
|
updateCurrentValue: (value) => setValue(value),
|
||||||
currentValue: value,
|
currentValue: value,
|
||||||
dispatchUpdate,
|
dispatchUpdate,
|
||||||
onUpdateItem,
|
onUpdateItem,
|
||||||
@ -337,6 +343,7 @@ const SettingItem = (props) => {
|
|||||||
onClick={handleOnClick}
|
onClick={handleOnClick}
|
||||||
icon={action.icon && createIconRender(action.icon)}
|
icon={action.icon && createIconRender(action.icon)}
|
||||||
type={action.type ?? "round"}
|
type={action.type ?? "round"}
|
||||||
|
disabled={item.props.disabled}
|
||||||
>
|
>
|
||||||
{action.title}
|
{action.title}
|
||||||
</antd.Button>
|
</antd.Button>
|
||||||
@ -551,7 +558,11 @@ const generateMenuItems = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const [activeKey, setActiveKey] = React.useState("general")
|
const [activeKey, setActiveKey] = useUrlQueryActiveKey({
|
||||||
|
defaultKey: "general",
|
||||||
|
queryKey: "tab"
|
||||||
|
})
|
||||||
|
|
||||||
const [menuItems, setMenuItems] = React.useState([])
|
const [menuItems, setMenuItems] = React.useState([])
|
||||||
|
|
||||||
const onChangeTab = (event) => {
|
const onChangeTab = (event) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user