mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-13 20:51:09 +00:00
refactor: 大规模代码整理与功能优化
1. 重构后端API路由、CRUD与模块结构,整合日志管理,移除废弃demo代码 2. 优化前端组件类型定义、样式与路由配置,修复权限判断逻辑 3. 调整默认排序规则、滚动条样式与工具类函数,更新依赖与配置文件 4. 修复多处类型不匹配与默认值问题,完善表单与菜单验证逻辑
This commit is contained in:
@@ -5,7 +5,12 @@
|
||||
* 保持 App.vue 的 onMounted 为单行调用。
|
||||
*/
|
||||
import { useSiteConfig } from "@/hooks/core/useSiteConfig";
|
||||
import { checkStorageCompatibility, toggleTransition, systemUpgrade } from "@utils";
|
||||
import {
|
||||
checkStorageCompatibility,
|
||||
startVersionPolling,
|
||||
toggleTransition,
|
||||
systemUpgrade,
|
||||
} from "@utils";
|
||||
|
||||
export function useAppBootstrap() {
|
||||
const { initSiteConfig } = useSiteConfig();
|
||||
@@ -14,6 +19,7 @@ export function useAppBootstrap() {
|
||||
checkStorageCompatibility();
|
||||
toggleTransition(false);
|
||||
systemUpgrade();
|
||||
startVersionPolling();
|
||||
initSiteConfig();
|
||||
};
|
||||
|
||||
|
||||
@@ -61,10 +61,13 @@ export const useAuth = () => {
|
||||
const hasAuth = (auth: string): boolean => {
|
||||
if (!auth) return true;
|
||||
|
||||
// 超管直接放行所有权限
|
||||
if (userStore.basicInfo?.is_superuser) return true;
|
||||
|
||||
const userPrems = userStore.prems;
|
||||
const roles = userStore.basicInfo?.roles as { code?: string }[] | undefined;
|
||||
|
||||
// 与 directives/permission hasPerm 一致:超级管理员、通配
|
||||
// 与 directives/permission hasPerm 一致:超级管理员角色、通配
|
||||
if (roles?.some((r) => r.code === ROLE_ROOT)) return true;
|
||||
if (userPrems.includes("*:*:*")) return true;
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import type { CrudDialogState, DialogType } from "./useCrudDialog";
|
||||
* @example
|
||||
* ```ts
|
||||
* const crud = useCrudForm<DeptForm>({
|
||||
* formData: ref({ id: undefined, name: "", status: "0" }),
|
||||
* initialFormData: { id: undefined, name: "", status: "0" },
|
||||
* formData: ref({ id: undefined, name: "", status: 0 }),
|
||||
* initialFormData: { id: undefined, name: "", status: 0 },
|
||||
* dialogVisible, // 来自 useCrudDialog()
|
||||
* dataFormRef, // FaForm 的 ref
|
||||
* formRenderKey, // 用于 :key 重新渲染
|
||||
|
||||
@@ -16,18 +16,18 @@ const updateFavicon = (url: string) => {
|
||||
};
|
||||
|
||||
const syncFromConfig = () => {
|
||||
const { tenant_name, tenant_favicon } = useConfigStore().configData;
|
||||
if (tenant_name?.config_value) document.title = tenant_name.config_value;
|
||||
if (tenant_favicon?.config_value) updateFavicon(tenant_favicon.config_value);
|
||||
const { name, favicon } = useConfigStore().configData;
|
||||
if (name?.config_value) document.title = name.config_value;
|
||||
if (favicon?.config_value) updateFavicon(favicon.config_value);
|
||||
};
|
||||
|
||||
export function useSiteConfig() {
|
||||
const configStore = useConfigStore();
|
||||
|
||||
/** 初始化:拉取配置并同步标题/favicon */
|
||||
/** 初始化:强制拉取配置并同步标题/favicon */
|
||||
const initSiteConfig = async () => {
|
||||
try {
|
||||
await configStore.getConfig();
|
||||
await configStore.getConfig(true);
|
||||
syncFromConfig();
|
||||
} catch (error) {
|
||||
console.error("[SiteConfig] 获取配置失败:", error);
|
||||
|
||||
Reference in New Issue
Block a user