fix monaco.
This commit is contained in:
13
src/shared/store/login.ts
Normal file
13
src/shared/store/login.ts
Normal 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
45
src/shared/store/user.ts
Normal 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,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user