Signed-off-by: 吴文峰 <kevin@lmve.net>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export const useConfigStore = defineStore('config', () => {
|
||||
// API 配置
|
||||
const apiBaseUrl = ref('http://192.168.13.105')
|
||||
|
||||
// 应用配置
|
||||
const appName = ref('OPS')
|
||||
const version = ref('1.0.0')
|
||||
|
||||
// 主题配置
|
||||
const theme = ref('light')
|
||||
|
||||
// 设置 API 地址
|
||||
const setApiBaseUrl = (url) => {
|
||||
apiBaseUrl.value = url
|
||||
}
|
||||
|
||||
// 设置主题
|
||||
const setTheme = (newTheme) => {
|
||||
theme.value = newTheme
|
||||
}
|
||||
|
||||
return {
|
||||
apiBaseUrl,
|
||||
appName,
|
||||
version,
|
||||
theme,
|
||||
setApiBaseUrl,
|
||||
setTheme
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,18 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useUserStore = defineStore('user', {
|
||||
state: () => ({
|
||||
username: '',
|
||||
token: ''
|
||||
}),
|
||||
actions: {
|
||||
setUser(username, token) {
|
||||
this.username = username
|
||||
this.token = token
|
||||
},
|
||||
logout() {
|
||||
this.username = ''
|
||||
this.token = ''
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user