From 57e33781d18c8d04fdbe0301ce06f3e4cf1f8752 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Wed, 4 Dec 2024 17:48:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=BB=98=E8=AE=A4=E5=B8=83=E5=B1=80?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/business/auth.ts | 4 +- src/layouts/modules/global-header/index.vue | 2 +- src/store/modules/auth/shared.ts | 1 - src/theme/settings.ts | 8 +-- src/typings/api.d.ts | 1 - src/views/function/toggle-auth/index.vue | 61 +-------------------- 6 files changed, 8 insertions(+), 69 deletions(-) diff --git a/src/hooks/business/auth.ts b/src/hooks/business/auth.ts index d324223..9baeb0b 100644 --- a/src/hooks/business/auth.ts +++ b/src/hooks/business/auth.ts @@ -9,10 +9,10 @@ export function useAuth() { } if (typeof codes === 'string') { - return authStore.userInfo.buttons.includes(codes); + return authStore.userInfo.permissions.includes(codes); } - return codes.some(code => authStore.userInfo.buttons.includes(code)); + return codes.some(code => authStore.userInfo.permissions.includes(code)); } function hasRole(role: string | string[]) { diff --git a/src/layouts/modules/global-header/index.vue b/src/layouts/modules/global-header/index.vue index 05a4bf0..d5550ea 100644 --- a/src/layouts/modules/global-header/index.vue +++ b/src/layouts/modules/global-header/index.vue @@ -57,7 +57,7 @@ const headerMenus = computed(() => {
- + -import { computed, ref } from 'vue'; -import { useLoading } from '@sa/hooks'; import { $t } from '@/locales'; -import { useAppStore } from '@/store/modules/app'; import { useAuthStore } from '@/store/modules/auth'; import { useAuth } from '@/hooks/business/auth'; -const appStore = useAppStore(); const authStore = useAuthStore(); const { hasAuth } = useAuth(); -const { loading, startLoading, endLoading } = useLoading(); - -type AccountKey = 'super' | 'admin' | 'user'; - -interface Account { - key: AccountKey; - label: string; - username: string; - password: string; -} - -const accounts = computed(() => [ - { - key: 'super', - label: $t('page.login.pwdLogin.superAdmin'), - username: 'Super', - password: '123456' - }, - { - key: 'admin', - label: $t('page.login.pwdLogin.admin'), - username: 'Admin', - password: '123456' - }, - { - key: 'user', - label: $t('page.login.pwdLogin.user'), - username: 'User', - password: '123456' - } -]); - -const loginAccount = ref('super'); - -async function handleToggleAccount(account: Account) { - loginAccount.value = account.key; - - startLoading(); - await authStore.login(account.username, account.password, false); - endLoading(); - appStore.reloadPage(); -}