Merge upstream main and resolve conflicts

This commit is contained in:
Mao Meng
2026-04-14 14:13:00 +08:00
185 changed files with 13886 additions and 1507 deletions
+20 -1
View File
@@ -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,13 @@ 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
try {
sessionStorage.removeItem('weknora_lite_last_path')
} catch {
/* ignore */
}
}
const initFromStorage = () => {
@@ -192,6 +207,8 @@ export const useAuthStore = defineStore('auth', () => {
selectedTenantName.value = null
}
}
isLiteMode.value = localStorage.getItem('weknora_lite_mode') === 'true'
}
// 初始化时从localStorage恢复状态
@@ -216,6 +233,7 @@ export const useAuthStore = defineStore('auth', () => {
currentUserId,
canAccessAllTenants,
effectiveTenantId,
isLiteMode,
// 方法
setUser,
@@ -227,6 +245,7 @@ export const useAuthStore = defineStore('auth', () => {
setSelectedTenant,
setAllTenants,
getSelectedTenant,
setLiteMode,
logout,
initFromStorage
}
+13 -1
View File
@@ -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>
@@ -58,6 +59,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 = () => {
@@ -120,6 +131,7 @@ export const useMenuStore = defineStore('menuStore', () => {
return {
menuArr,
visibleMenuArr,
isFirstSession,
firstQuery,
firstMentionedItems,
+13 -1
View File
@@ -1,5 +1,6 @@
import { defineStore } from "pinia";
import { BUILTIN_QUICK_ANSWER_ID, BUILTIN_SMART_REASONING_ID } from "@/api/agent";
import { getApiBaseUrl } from "@/utils/api-base";
// 定义设置接口
interface Settings {
@@ -18,6 +19,7 @@ interface Settings {
conversationModels: ConversationModels;
selectedAgentId: string; // 当前选中的智能体ID
selectedAgentSourceTenantId: string | null; // 当使用共享智能体时,来源租户 ID(用于后端 model/KB/MCP 解析)
autoCheckUpdate?: boolean; // 是否自动检查并下载更新
}
// Agent 配置接口
@@ -63,7 +65,7 @@ interface OllamaConfig {
// 默认设置
const defaultSettings: Settings = {
endpoint: import.meta.env.VITE_IS_DOCKER ? "" : "http://localhost:8080",
endpoint: getApiBaseUrl(),
apiKey: "",
knowledgeBaseId: "",
isAgentEnabled: false,
@@ -95,6 +97,7 @@ const defaultSettings: Settings = {
},
selectedAgentId: BUILTIN_QUICK_ANSWER_ID, // 默认选中快速问答模式
selectedAgentSourceTenantId: null as string | null, // 共享智能体来源租户 ID
autoCheckUpdate: true,
};
export const useSettingsStore = defineStore("settings", {
@@ -143,6 +146,9 @@ export const useSettingsStore = defineStore("settings", {
// 记忆功能是否启用
isMemoryEnabled: (state) => state.settings.enableMemory || false,
// 是否自动检查并下载更新
isAutoCheckUpdateEnabled: (state) => state.settings.autoCheckUpdate ?? true,
// 当前选中的智能体ID
selectedAgentId: (state) => state.settings.selectedAgentId || BUILTIN_QUICK_ANSWER_ID,
// 共享智能体来源租户 ID(可选)
@@ -307,6 +313,12 @@ export const useSettingsStore = defineStore("settings", {
localStorage.setItem("WeKnora_settings", JSON.stringify(this.settings));
},
// 启用/禁用自动检查更新
toggleAutoCheckUpdate(enabled: boolean) {
this.settings.autoCheckUpdate = enabled;
localStorage.setItem("WeKnora_settings", JSON.stringify(this.settings));
},
// File selection actions
addFile(fileId: string) {
if (!this.settings.selectedFiles) this.settings.selectedFiles = [];