Files
FastapiAdmin/frontend/web/src/store/modules/config.store.ts
T
zhangtao 80263e98e1 feat: 重构前端项目结构并优化代码
refactor: 迁移前端资源文件至web目录
feat: 新增多种图标资源
style: 统一代码风格和格式化配置
docs: 更新README和文档说明
chore: 更新依赖和配置文件
fix: 修复部分类型定义和枚举
perf: 优化路由和组件加载逻辑
2026-05-01 01:01:17 +08:00

60 lines
1.5 KiB
TypeScript

import { store } from '@/store';
import ParamsAPI, { ConfigTable } from '@/api/module_system/params';
interface ConfigState {
// 网站信息
sys_web_title: ConfigTable;
sys_web_version: ConfigTable;
sys_web_description: ConfigTable;
// 网站图标
sys_login_background: ConfigTable;
sys_web_favicon: ConfigTable;
sys_web_logo: ConfigTable;
// 安全隐私配置
sys_keep_record: ConfigTable;
sys_web_clause: ConfigTable;
sys_web_copyright: ConfigTable;
sys_web_privacy: ConfigTable;
sys_git_code: ConfigTable;
sys_help_doc: ConfigTable;
// 接口安全配置
white_api_list_path: ConfigTable;
ip_black_list: ConfigTable;
// 演示环境配置
demo_enable: ConfigTable;
ip_white_list: ConfigTable;
}
export const useConfigStore = defineStore('config', {
state: () => ({
configData: {} as ConfigState,
isConfigLoaded: false,
configLoading: false,
}),
actions: {
async getConfig(force = false) {
if ((this.isConfigLoaded && !force) || this.configLoading) {
return;
}
this.configLoading = true;
try {
const response = await ParamsAPI.getInitConfig();
response.data.data.forEach((item: ConfigTable) => {
if (item.config_value !== undefined) {
this.configData[item.config_key as keyof ConfigState] = item;
}
});
this.isConfigLoaded = true;
} finally {
this.configLoading = false;
}
},
},
persist: true,
});
export function useConfigStoreHook() {
return useConfigStore(store);
}