feat: 初始化DevOps平台前端
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useSessionStore = defineStore('session', () => {
|
||||
const operator = ref('ops-admin')
|
||||
const role = ref<'admin' | 'operator' | 'viewer'>('admin')
|
||||
const token = ref('mock-session')
|
||||
|
||||
const isAuthenticated = computed(() => Boolean(token.value))
|
||||
|
||||
function login(name: string) {
|
||||
operator.value = name || 'ops-admin'
|
||||
token.value = 'mock-session'
|
||||
}
|
||||
|
||||
function logout() {
|
||||
token.value = ''
|
||||
}
|
||||
|
||||
return {
|
||||
operator,
|
||||
role,
|
||||
token,
|
||||
isAuthenticated,
|
||||
login,
|
||||
logout,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user