This commit is contained in:
2026-03-22 13:55:23 +08:00
parent c3f196ded4
commit 69099986e0
616 changed files with 38942 additions and 3 deletions

View File

@@ -0,0 +1,46 @@
import { defineStore } from 'pinia'
import type { AdminInfo } from '@/services/api/monisuo-admin.api'
export const useAuthStore = defineStore('auth', () => {
const isLogin = ref(false)
const token = ref<string | null>(localStorage.getItem('admin_token'))
const adminInfo = ref<AdminInfo | null>(
localStorage.getItem('admin_info')
? JSON.parse(localStorage.getItem('admin_info')!)
: null,
)
// 初始化时检查 token
if (token.value) {
isLogin.value = true
}
function setToken(newToken: string) {
token.value = newToken
localStorage.setItem('admin_token', newToken)
isLogin.value = true
}
function setAdminInfo(info: AdminInfo) {
adminInfo.value = info
localStorage.setItem('admin_info', JSON.stringify(info))
}
function logout() {
token.value = null
adminInfo.value = null
isLogin.value = false
localStorage.removeItem('admin_token')
localStorage.removeItem('admin_info')
}
return {
isLogin,
token,
adminInfo,
setToken,
setAdminInfo,
logout,
}
})

View File

@@ -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,
})