fix monaco.

This commit is contained in:
2023-01-12 09:36:13 +08:00
parent 75e6906c16
commit ab5cb8610b
20 changed files with 281 additions and 132 deletions

13
src/shared/store/login.ts Normal file
View File

@@ -0,0 +1,13 @@
export const useLoginStore = defineStore("login", () => {
const [visible] = useToggle()
function show() {
visible.value = true
}
function hide() {
visible.value = false
}
return { visible, show, hide }
})

45
src/shared/store/user.ts Normal file
View File

@@ -0,0 +1,45 @@
import {
PROBLEM_PERMISSION,
STORAGE_KEY,
USER_TYPE,
} from "../../utils/constants"
import storage from "../../utils/storage"
import { getUserInfo } from "../api"
export const useUserStore = defineStore("user", () => {
const { data: profile, isFinished, execute } = getUserInfo("")
const user = computed(() => profile.value.user || {})
const isAuthed = computed(() => !!user.value.email)
const isAdminRole = computed(
() =>
user.value.admin_type === USER_TYPE.ADMIN ||
user.value.admin_type === USER_TYPE.SUPER_ADMIN
)
const isSuperAdmin = computed(
() => user.value.admin_type === USER_TYPE.SUPER_ADMIN
)
const hasProblemPermission = computed(
() => user.value.problem_permission !== PROBLEM_PERMISSION.NONE
)
async function getMyProfile() {
await execute()
storage.set(STORAGE_KEY.AUTHED, !!user.value.email)
}
function clearMyProfile() {
profile.value = {}
storage.clear()
}
return {
profile,
isFinished,
user,
isAdminRole,
isSuperAdmin,
hasProblemPermission,
isAuthed,
getMyProfile,
clearMyProfile,
}
})