Files
cli/cli-center/src/apps/settings/store.ts
abearxiong 91d4fed474 feat: update README with installation command and add debug logs in deploy command
- Added installation command for the CLI tool in README.
- Enhanced deploy command with debug logging for upload results and query app version.
- Integrated useKey for fetching KEVISUAL_TOKEN in get-config module.
- Added debug logging in queryAppVersion for better traceability.
- Updated temp.md with new dependency and example command for deployment.
2026-01-17 23:28:38 +08:00

55 lines
1.3 KiB
TypeScript

import { clientQuery, queryLogin } from '@/modules/query';
import { create } from 'zustand';
import { toast } from 'react-toastify';
type SettingState = {
username?: string;
initAdmin: () => any;
login: (username: string, password: string) => any;
config?: any;
saveConfig: any;
}
export const useStore = create<SettingState>((set => ({
username: undefined,
config: undefined,
initAdmin: async () => {
const res = await clientQuery.post({
path: 'config'
})
console.log('initAdmin', res);
if (res.code === 200) {
const auth = res.data.auth || {}
if (auth.username) {
set({ username: auth.username });
}
set({ config: res.data });
}
},
login: async (username: string, password: string) => {
const res = await clientQuery.post({
path: 'admin',
key: 'login',
username,
password
});
if (res.code === 200) {
set({ username });
const setToken = await queryLogin.setLoginToken(res.data)
toast.success('登录成功');
}
return res;
},
saveConfig: async (config: any) => {
const res = await clientQuery.post({
path: 'config',
key: 'set',
data: config
})
if (res.code === 200) {
set({ config })
toast.success('配置保存成功');
}
console.log('saveConfig res', res);
return res;
}
})));