feat: 配置页面组件

This commit is contained in:
CrescentLeaf
2025-10-07 22:31:34 +08:00
parent 96ca578c70
commit 4eff829a30
7 changed files with 134 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
import React from 'react'
export default class PreferenceStore {
constructor() {
const _ = React.useState<{ [key: string]: unknown }>({})
this.value = _[0]
this.setter = _[1]
}
// 创建一个用于子选项的更新函数
updater(key: string) {
return (value: unknown) => {
const newValue = JSON.parse(JSON.stringify({
...this.value,
[key]: value,
}))
this.setter(newValue)
this.onUpdate?.(newValue)
}
}
setOnUpdate(onUpdate) {
this.onUpdate = onUpdate
}
}