Initial commit: 网络验证平台
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useAuthStore = defineStore('user', () => {
|
||||
const isLogin = ref(false)
|
||||
const user = ref<any>(null)
|
||||
|
||||
function checkAuth() {
|
||||
const token = localStorage.getItem('token')
|
||||
const userStr = localStorage.getItem('user')
|
||||
|
||||
if (token && userStr) {
|
||||
try {
|
||||
user.value = JSON.parse(userStr)
|
||||
isLogin.value = true
|
||||
}
|
||||
catch {
|
||||
isLogin.value = false
|
||||
user.value = null
|
||||
}
|
||||
}
|
||||
else {
|
||||
isLogin.value = false
|
||||
user.value = null
|
||||
}
|
||||
|
||||
return isLogin.value
|
||||
}
|
||||
|
||||
function logout() {
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('user')
|
||||
isLogin.value = false
|
||||
user.value = null
|
||||
}
|
||||
|
||||
return {
|
||||
isLogin,
|
||||
user,
|
||||
checkAuth,
|
||||
logout,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,31 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import type { ContentLayout, Radius, Theme } from '@/constants/themes'
|
||||
|
||||
export const useThemeStore = defineStore('system-config', () => {
|
||||
const radius = ref(0.5)
|
||||
function setRadius(newRadius: Radius) {
|
||||
radius.value = newRadius
|
||||
}
|
||||
const theme = ref<Theme>('zinc')
|
||||
function setTheme(newTheme: Theme) {
|
||||
theme.value = newTheme
|
||||
}
|
||||
|
||||
const contentLayout = ref<ContentLayout>('centered')
|
||||
function setContentLayout(newContentLayout: ContentLayout) {
|
||||
contentLayout.value = newContentLayout
|
||||
}
|
||||
return {
|
||||
radius,
|
||||
setRadius,
|
||||
|
||||
theme,
|
||||
setTheme,
|
||||
|
||||
contentLayout,
|
||||
setContentLayout,
|
||||
}
|
||||
}, {
|
||||
persist: true,
|
||||
})
|
||||
Reference in New Issue
Block a user