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(); -}