feat: implement Lite edition support by filtering menu items and adjusting UI elements, enhancing user experience for Lite users
This commit is contained in:
@@ -15,6 +15,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
const selectedTenantId = ref<number | null>(null)
|
||||
const selectedTenantName = ref<string | null>(null)
|
||||
const allTenants = ref<TenantInfoFromAPI[]>([])
|
||||
const isLiteMode = ref(false)
|
||||
|
||||
// 计算属性
|
||||
const isLoggedIn = computed(() => {
|
||||
@@ -102,6 +103,14 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
return selectedTenantId.value
|
||||
}
|
||||
|
||||
const setLiteMode = (value: boolean) => {
|
||||
isLiteMode.value = value
|
||||
if (value) {
|
||||
localStorage.setItem('weknora_lite_mode', 'true')
|
||||
} else {
|
||||
localStorage.removeItem('weknora_lite_mode')
|
||||
}
|
||||
}
|
||||
|
||||
const logout = () => {
|
||||
// 清空状态
|
||||
@@ -124,7 +133,8 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
localStorage.removeItem('weknora_current_kb')
|
||||
localStorage.removeItem('weknora_selected_tenant_id')
|
||||
localStorage.removeItem('weknora_selected_tenant_name')
|
||||
|
||||
localStorage.removeItem('weknora_lite_mode')
|
||||
isLiteMode.value = false
|
||||
}
|
||||
|
||||
const initFromStorage = () => {
|
||||
@@ -192,6 +202,8 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
selectedTenantName.value = null
|
||||
}
|
||||
}
|
||||
|
||||
isLiteMode.value = localStorage.getItem('weknora_lite_mode') === 'true'
|
||||
}
|
||||
|
||||
// 初始化时从localStorage恢复状态
|
||||
@@ -216,6 +228,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
currentUserId,
|
||||
canAccessAllTenants,
|
||||
effectiveTenantId,
|
||||
isLiteMode,
|
||||
|
||||
// 方法
|
||||
setUser,
|
||||
@@ -227,6 +240,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
setSelectedTenant,
|
||||
setAllTenants,
|
||||
getSelectedTenant,
|
||||
setLiteMode,
|
||||
logout,
|
||||
initFromStorage
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { reactive, ref, watch } from 'vue'
|
||||
import { reactive, ref, computed, watch } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
import i18n from '@/i18n'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
type MenuChild = Record<string, any>
|
||||
|
||||
@@ -57,6 +58,16 @@ export const useMenuStore = defineStore('menuStore', () => {
|
||||
}
|
||||
)
|
||||
|
||||
const liteHiddenPaths = new Set(['logout', 'organizations'])
|
||||
|
||||
const visibleMenuArr = computed(() => {
|
||||
const authStore = useAuthStore()
|
||||
if (authStore.isLiteMode) {
|
||||
return menuArr.filter(item => !liteHiddenPaths.has(item.path))
|
||||
}
|
||||
return menuArr
|
||||
})
|
||||
|
||||
const chatMenuIndex = menuArr.findIndex(item => item.path === 'creatChat')
|
||||
|
||||
const clearMenuArr = () => {
|
||||
@@ -118,6 +129,7 @@ export const useMenuStore = defineStore('menuStore', () => {
|
||||
|
||||
return {
|
||||
menuArr,
|
||||
visibleMenuArr,
|
||||
isFirstSession,
|
||||
firstQuery,
|
||||
firstMentionedItems,
|
||||
|
||||
Reference in New Issue
Block a user