细节调整及优化(26.8.3)

This commit is contained in:
zhongluofeng
2026-08-21 17:25:47 +08:00
parent 0a19b4b38a
commit 4dd60f42a1
72 changed files with 4779 additions and 1395 deletions
+8 -6
View File
@@ -87,6 +87,9 @@ const loadModule = async (moduleId: string) => {
}
const handleModuleChange = (moduleId: string) => {
// 同模块不重新加载(保留组件状态);搜索/托盘跳转到当前模块时仅触发 tab 导航
if (activeModule.value === moduleId) return
// 调用上一个模块的 onDeactivate 钩子
const prevConfig = moduleRegistry.getConfig(activeModule.value)
prevConfig?.lifecycle?.onDeactivate?.()
@@ -96,10 +99,9 @@ const handleModuleChange = (moduleId: string) => {
loadModule(moduleId)
}
// 搜索跳转与普通切换同路径:补齐 onDeactivate 钩子,避免旧模块资源泄漏
const handleSearch = (moduleId: string) => {
activeModule.value = moduleId
localStorage.setItem(LAST_MODULE_KEY, moduleId)
loadModule(moduleId)
handleModuleChange(moduleId)
}
const getFallbackModule = () => {
@@ -110,14 +112,14 @@ const getFallbackModule = () => {
return fallback?.id || 'settings'
}
watch(() => appStore.enabledModules.length, () => {
// 按 id 列表监听(而非 length):同时禁用一个 + 启用另一个时 length 不变,会漏检回退
watch(() => appStore.enabledModules.map(m => m.id).join(','), () => {
// 启动期间 activeModule 尚未确定,跳过
if (!activeModule.value) return
const enabledIds = appStore.enabledModules.map(m => m.id)
if (activeModule.value !== 'settings' && !enabledIds.includes(activeModule.value)) {
const fallback = getFallbackModule()
activeModule.value = fallback
loadModule(fallback)
handleModuleChange(fallback)
}
// 模块启用/禁用变化时重新同步快速面板命令缓存
quickpanelStore.syncCommands()