功能:完善通用云管工作台、审计与诊断能力
This commit is contained in:
1 parent
5ac692724d
commit
9f05aa20ea
225 files changed
+14266
-141
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useAuth } from './auth'
|
||||
|
||||
export type Edition = 'common' | 'advanced'
|
||||
export const useEdition = defineStore('edition', () => {
|
||||
const auth = useAuth(), mode = ref<Edition>('common')
|
||||
const key = () => `vdi.console-mode:${auth.user?.id || ''}`
|
||||
watch(() => auth.user?.id, id => {
|
||||
mode.value = 'common'
|
||||
if (id) { try { if (localStorage.getItem(key()) === 'advanced') mode.value = 'advanced' } catch { /* Storage can be unavailable. */ } }
|
||||
}, { immediate: true, flush: 'sync' })
|
||||
function select(value: Edition) {
|
||||
mode.value = value
|
||||
if (auth.user) { try { localStorage.setItem(key(), value) } catch { /* Navigation still works without persistence. */ } }
|
||||
}
|
||||
const home = computed(() => mode.value === 'common' ? '/workbench' : '/overview')
|
||||
return { mode, home, select }
|
||||
})
|
||||
Reference in new issue
Block a user