feat: implement automatic update checking and downloading functionality in the desktop app, enhancing user experience with seamless updates and corresponding UI settings

This commit is contained in:
wizardchen
2026-04-11 18:27:08 +08:00
committed by lyingbug
parent c4ebc1f60e
commit 9874fcee7c
13 changed files with 527 additions and 23 deletions
+32
View File
@@ -5,6 +5,7 @@ import { useI18n } from 'vue-i18n'
import { MessagePlugin } from 'tdesign-vue-next'
import ManualKnowledgeEditor from '@/components/manual-knowledge-editor.vue'
import { useAuthStore } from '@/stores/auth'
import { useSettingsStore } from '@/stores/settings'
import { getCurrentUser } from '@/api/auth'
// TDesign locale configs
@@ -16,6 +17,7 @@ import ruRUConfig from 'tdesign-vue-next/esm/locale/ru_RU'
const { locale } = useI18n()
const router = useRouter()
const authStore = useAuthStore()
const settingsStore = useSettingsStore()
const tdLocaleMap: Record<string, object> = {
'en-US': enUSConfig,
@@ -132,8 +134,38 @@ const handleGlobalOIDCCallback = async () => {
}
}
let updateCheckTimer: ReturnType<typeof setInterval> | null = null
onMounted(() => {
handleGlobalOIDCCallback()
// Auto check for updates on startup
setTimeout(() => {
if (settingsStore.isAutoCheckUpdateEnabled) {
// @ts-ignore
if (window.go && window.go.main && window.go.main.App && window.go.main.App.AutoCheckForUpdates) {
// @ts-ignore
window.go.main.App.AutoCheckForUpdates()
}
}
}, 2000)
// Periodically check for updates (every 4 hours)
updateCheckTimer = setInterval(() => {
if (settingsStore.isAutoCheckUpdateEnabled) {
// @ts-ignore
if (window.go && window.go.main && window.go.main.App && window.go.main.App.AutoCheckForUpdates) {
// @ts-ignore
window.go.main.App.AutoCheckForUpdates()
}
}
}, 4 * 60 * 60 * 1000)
})
onUnmounted(() => {
if (updateCheckTimer) {
clearInterval(updateCheckTimer)
}
})
</script>
+2
View File
@@ -569,6 +569,8 @@ export default {
webSearchConfig: 'Web Search',
enableMemory: 'Enable Memory',
enableMemoryDesc: 'When enabled, the system will record your conversation history and automatically recall relevant content in future conversations to provide more personalized answers.',
autoCheckUpdate: 'Auto Download Updates',
autoCheckUpdateDesc: 'When enabled, automatically check and download the latest version in the background.',
memoryRequiresNeo4j: 'Memory feature requires Neo4j graph database. Please configure and enable Neo4j (set NEO4J_ENABLE=true) before enabling this feature.',
memoryHowToEnable: 'View Neo4j Configuration Guide',
parserEngine: 'Parser Engine',
+2
View File
@@ -426,6 +426,8 @@ export default {
webSearchConfig: "웹 검색",
enableMemory: "기억 기능 활성화",
enableMemoryDesc: "활성화하면 시스템이 대화 기록을 저장하고 향후 대화에서 관련 내용을 자동으로 회상하여 더 개인화된 답변을 제공합니다.",
autoCheckUpdate: '업데이트 자동 다운로드',
autoCheckUpdateDesc: '활성화하면 시작 시 최신 버전을 자동으로 확인하고 백그라운드에서 다운로드합니다.',
memoryRequiresNeo4j: "기억 기능은 Neo4j 그래프 데이터베이스가 필요합니다. 이 기능을 활성화하기 전에 Neo4j를 구성하고 활성화해 주세요 (NEO4J_ENABLE=true 설정).",
memoryHowToEnable: "Neo4j 구성 가이드 보기",
parserEngine: "파싱 엔진",
+2
View File
@@ -548,6 +548,8 @@ export default {
webSearchConfig: 'Сетевой поиск',
enableMemory: 'Включить память',
enableMemoryDesc: 'При включении система будет записывать историю ваших разговоров и автоматически вспоминать соответствующий контент в будущих беседах для более персонализированных ответов.',
autoCheckUpdate: 'Автоматическая загрузка обновлений',
autoCheckUpdateDesc: 'При включении автоматически проверять и скачивать последнюю версию в фоновом режиме при запуске.',
memoryRequiresNeo4j: 'Функция памяти требует графовую базу данных Neo4j. Пожалуйста, настройте и включите Neo4j (установите NEO4J_ENABLE=true) перед активацией этой функции.',
memoryHowToEnable: 'Руководство по настройке Neo4j',
parserEngine: 'Движок парсинга',
+2
View File
@@ -423,6 +423,8 @@ export default {
webSearchConfig: "网络搜索",
enableMemory: "开启记忆功能",
enableMemoryDesc: "开启后,系统将记录您的对话历史,并在后续对话中自动回忆相关内容,提供更个性化的回答。",
autoCheckUpdate: '自动下载更新',
autoCheckUpdateDesc: '开启后自动检查并在后台下载最新版本安装包。',
memoryRequiresNeo4j: "记忆功能依赖 Neo4j 图数据库,请先配置并启用 Neo4j(设置环境变量 NEO4J_ENABLE=true)后再开启此功能。",
memoryHowToEnable: "查看 Neo4j 配置指南",
parserEngine: "解析引擎",
+11
View File
@@ -19,6 +19,7 @@ interface Settings {
conversationModels: ConversationModels;
selectedAgentId: string; // 当前选中的智能体ID
selectedAgentSourceTenantId: string | null; // 当使用共享智能体时,来源租户 ID(用于后端 model/KB/MCP 解析)
autoCheckUpdate?: boolean; // 是否自动检查并下载更新
}
// Agent 配置接口
@@ -96,6 +97,7 @@ const defaultSettings: Settings = {
},
selectedAgentId: BUILTIN_QUICK_ANSWER_ID, // 默认选中快速问答模式
selectedAgentSourceTenantId: null as string | null, // 共享智能体来源租户 ID
autoCheckUpdate: true,
};
export const useSettingsStore = defineStore("settings", {
@@ -144,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(可选)
@@ -308,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 = [];
@@ -73,6 +73,19 @@
</t-link>
</template>
</t-alert>
<!-- 自动下载更新开关 (Lite edition only) -->
<div class="setting-row" v-if="authStore.isLiteMode">
<div class="setting-info">
<label>{{ $t('settings.autoCheckUpdate') }}</label>
<p class="desc">{{ $t('settings.autoCheckUpdateDesc') }}</p>
</div>
<div class="setting-control">
<t-switch
v-model="isAutoCheckUpdateEnabled"
/>
</div>
</div>
</div>
</div>
</template>
@@ -82,11 +95,13 @@ import { ref, onMounted, computed } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { useI18n } from 'vue-i18n'
import { useSettingsStore } from '@/stores/settings'
import { useAuthStore } from '@/stores/auth'
import { getSystemInfo } from '@/api/system'
import { useTheme, type ThemeMode } from '@/composables/useTheme'
const { t, locale } = useI18n()
const settingsStore = useSettingsStore()
const authStore = useAuthStore()
const { currentTheme, setTheme } = useTheme()
// 本地状态
@@ -106,6 +121,21 @@ const isMemoryEnabled = computed({
set: (val) => settingsStore.toggleMemory(val)
})
// 自动检查更新状态
const isAutoCheckUpdateEnabled = computed({
get: () => settingsStore.isAutoCheckUpdateEnabled,
set: (val) => {
settingsStore.toggleAutoCheckUpdate(val)
if (val) {
// @ts-ignore
if (window.go && window.go.main && window.go.main.App && window.go.main.App.AutoCheckForUpdates) {
// @ts-ignore
window.go.main.App.AutoCheckForUpdates()
}
}
}
})
// 初始化加载
onMounted(async () => {
// 从 localStorage 加载语言设置
+4
View File
@@ -1,6 +1,10 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export function AutoCheckForUpdates():Promise<void>;
export function CheckForUpdates():Promise<void>;
export function GetAPIBaseURL():Promise<string>;
export function GetAPILanBaseURL():Promise<string>;
+8
View File
@@ -2,6 +2,14 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export function AutoCheckForUpdates() {
return window['go']['main']['App']['AutoCheckForUpdates']();
}
export function CheckForUpdates() {
return window['go']['main']['App']['CheckForUpdates']();
}
export function GetAPIBaseURL() {
return window['go']['main']['App']['GetAPIBaseURL']();
}