wip: baseline changes before channel-conversation-task boundary implementation

This commit is contained in:
2026-07-08 16:23:09 +08:00
parent 89c9e6a066
commit 1298a558e8
139 changed files with 11781 additions and 666 deletions

View File

@@ -1,11 +1,21 @@
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
function parseJson(value: string | null): string[] {
if (!value) return []
try {
const parsed = JSON.parse(value)
return Array.isArray(parsed) ? parsed : []
} catch {
return []
}
}
export const useAuthStore = defineStore('auth', () => {
const token = ref(localStorage.getItem('mci-token') || '')
const tenantCode = ref(localStorage.getItem('mci-tenant-code') || '')
const username = ref('')
const roleCodes = ref<string[]>([])
const username = ref(localStorage.getItem('mci-username') || '')
const roleCodes = ref<string[]>(parseJson(localStorage.getItem('mci-role-codes')))
const isLoggedIn = computed(() => !!token.value)
@@ -16,6 +26,8 @@ export const useAuthStore = defineStore('auth', () => {
roleCodes.value = roles
localStorage.setItem('mci-token', t)
localStorage.setItem('mci-tenant-code', tc)
localStorage.setItem('mci-username', user)
localStorage.setItem('mci-role-codes', JSON.stringify(roles))
}
function clearAuth() {
@@ -25,6 +37,8 @@ export const useAuthStore = defineStore('auth', () => {
roleCodes.value = []
localStorage.removeItem('mci-token')
localStorage.removeItem('mci-tenant-code')
localStorage.removeItem('mci-username')
localStorage.removeItem('mci-role-codes')
}
return { token, tenantCode, username, roleCodes, isLoggedIn, setAuth, clearAuth }