feat: 更新页面标题和图标,添加远端配置保存与加载功能

This commit is contained in:
2026-02-27 01:32:39 +08:00
parent 3227c795a3
commit d85fc1154f
6 changed files with 69 additions and 43 deletions

View File

@@ -10,10 +10,9 @@ import { configSchema } from './store/schema';
import { toast } from 'sonner';
import { useLayoutStore } from '../auth/store';
import { useShallow } from 'zustand/shallow';
import { queryLogin } from '@/modules/query';
export const ConfigPage = () => {
const { config, setConfig, resetConfig } = useConfigStore();
const { config, setConfig, resetConfig, saveToRemote, loadFromRemote } = useConfigStore();
const layoutStore = useLayoutStore(useShallow(state => ({ me: state.me })))
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
@@ -31,42 +30,6 @@ export const ConfigPage = () => {
const handleChange = (field: keyof typeof config, value: string | boolean) => {
setConfig({ [field]: value });
};
const saveToRemote = async () => {
const _config = config;
const res = await queryLogin.post({
path: 'config',
key: 'update',
data: {
key: 'cnb_center_config.json',
data: _config,
}
});
if (res.code === 200) {
toast.success('保存到远端成功')
} else {
toast.error('保存到远端失败')
}
}
const loadFromRemote = async () => {
const res = await queryLogin.post({
path: 'config',
key: 'get',
data: {
key: 'cnb_center_config.json',
}
})
if (res.code === 404) {
toast.error('远端配置不存在')
return;
}
if (res.code === 200) {
const config = res.data?.data as typeof config;
setConfig(config);
toast.success('获取远端配置成功')
}
}
return (
<TooltipProvider>