diff --git a/src/api/user.ts b/src/api/user.ts index ded23d1..761464b 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -180,6 +180,9 @@ export interface UserInfo { /** 邮箱 */ email?: string; + /** 性别 */ + gender?: number; + /** 部门名称 */ deptName?: string; diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 27b328a..564edad 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -102,6 +102,7 @@ import { useRouter } from "uni-mini-router"; import { useUserStore } from "@/store"; import { menuConfig } from "@/config/menu"; import { checkLogin, isLoggedIn } from "@/utils/auth"; +import { hasPermission } from "@/utils/permission"; import LogAPI, { type VisitOverview as ApiVisitOverview, type VisitTrend } from "@/api/log"; import NoticeAPI, { type NoticeItem } from "@/api/notice"; @@ -157,12 +158,6 @@ const isLogged = computed(() => isLoggedIn()); const hasAnyPerm = computed(() => userPerms.value.length > 0); -// 检查是否有权限 -const hasPermission = (perm: string) => { - if (!perm) return true; - return userPerms.value.includes(perm) || userPerms.value.includes("*:*:*"); -}; - // 默认菜单(未登录时显示) const defaultNavList = computed(() => { const result: { icon: string; title: string; url: string; perm: string }[] = []; diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue index 210698e..6ac3e86 100644 --- a/src/pages/mine/index.vue +++ b/src/pages/mine/index.vue @@ -208,6 +208,7 @@ import { useToast, useMessage } from "wot-design-uni"; import { useUserStore, useThemeStore } from "@/store"; import { useRouter } from "uni-mini-router"; import { useNavbar } from "@/composables/useNavbar"; +import type { UserInfo } from "@/api/user"; import { getAccessToken } from "@/utils/auth"; const toast = useToast(); @@ -235,11 +236,11 @@ const appVersion = ref("1.0.0"); const navbar = useNavbar({ hasTabbar: true }); const hasUserProfile = computed(() => { - const info = userInfo.value as any; - return !!(info && (info.id || info.userId || info.username || info.nickname)); + const info = userInfo.value; + return !!(info && (info.userId || info.username || info.nickname)); }); -const genderValue = computed(() => (userInfo.value as any)?.gender); +const genderValue = computed(() => userInfo.value?.gender); const normalizedGender = computed(() => { const v = genderValue.value; const n = typeof v === "number" ? v : Number(v); @@ -248,7 +249,7 @@ const normalizedGender = computed(() => { const deptNameText = computed(() => { if (!isLogin.value) return ""; - return (userInfo.value as any)?.deptName || ""; + return userInfo.value?.deptName || ""; }); const genderIconName = computed(() => { @@ -347,7 +348,7 @@ const openAbout = () => { }; const clearing = ref(false); -const cacheSize = ref("计算中..."); +const cacheSize = ref("计算中..."); const formatBytes = (size: number) => { if (size < 1024) { diff --git a/src/router/index.ts b/src/router/index.ts index bc2060a..a753efa 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -72,6 +72,4 @@ router.beforeEach(async (to, from, next) => { next(); }); -router.afterEach(() => {}); - export default router; diff --git a/src/shime-uni.d.ts b/src/shims-uni.d.ts similarity index 90% rename from src/shime-uni.d.ts rename to src/shims-uni.d.ts index f9c2ad8..c80052b 100644 --- a/src/shime-uni.d.ts +++ b/src/shims-uni.d.ts @@ -1,4 +1,4 @@ -export {}; +export {}; declare module "vue" { type Hooks = App.AppInstance & Page.PageInstance; diff --git a/src/utils/storage.ts b/src/utils/storage.ts index 59f0550..17b7e93 100644 --- a/src/utils/storage.ts +++ b/src/utils/storage.ts @@ -14,7 +14,7 @@ /** * localStorage 存储 */ -function set(key: string, value: any): void { +function set(key: string, value: T): void { uni.setStorageSync(key, JSON.stringify(value)); }