feat: add ADMIN_USER_ROLE for user access admin panel (#363)

This commit is contained in:
Dream Hunter
2024-07-27 22:04:18 +08:00
committed by GitHub
parent a0805bc0ce
commit 5faae8796d
21 changed files with 81 additions and 56 deletions

View File

@@ -1,4 +1,4 @@
import { ref } from "vue";
import { computed, ref } from "vue";
import { createGlobalState, useStorage, useDark, useToggle, useLocalStorage } from '@vueuse/core'
export const useGlobalState = createGlobalState(
@@ -74,9 +74,14 @@ export const useGlobalState = createGlobalState(
user_email: '',
/** @type {number} */
user_id: 0,
/** @type {boolean} */
is_admin: false,
/** @type {string | null} */
access_token: null,
/** @type {null | {domains: string[] | undefined | null, role: string, prefix: string | undefined | null}} */
user_role: null,
});
const showAdminPage = computed(() => !!adminAuth.value || userSettings.value.is_admin);
const telegramApp = ref(window.Telegram?.WebApp || {});
const isTelegram = ref(!!window.Telegram?.WebApp?.initData);
return {
@@ -108,6 +113,7 @@ export const useGlobalState = createGlobalState(
useSideMargin,
telegramApp,
isTelegram,
showAdminPage,
}
},
)