363363 <section ref =" startupSectionRef" >
364364 <div class =" mb-2.5 text-[12px] font-bold text-[#999] tracking-widest" >启动偏好</div >
365365 <div class =" overflow-hidden rounded-[10px] border border-[#e7e7e7] bg-white divide-y divide-[#ececec]" >
366- <div class =" px-3.5 py-3" >
367- <div class =" flex items-center justify-between gap-3" >
368- <div class =" min-w-0 flex-1" >
369- <div class =" text-[13px] font-medium text-[#222]" >启动后自动开启实时获取</div >
370- <div class =" mt-0.5 text-[11px] text-[#909090]" >进入聊天页后自动打开“实时开关”</div >
371- </div >
372- <button
373- type =" button"
374- role =" switch"
375- :aria-checked =" desktopAutoRealtime"
376- class =" settings-switch shrink-0"
377- :class =" switchTrackClass(desktopAutoRealtime)"
378- @click =" toggleDesktopAutoRealtime"
379- >
380- <span class =" settings-switch-thumb" :class =" desktopAutoRealtime ? 'translate-x-[20px]' : 'translate-x-0'" />
381- </button >
382- </div >
383- </div >
384-
385366 <div class =" px-3.5 py-3" >
386367 <div class =" flex items-center justify-between gap-3" >
387368 <div class =" min-w-0 flex-1" >
459440</template >
460441
461442<script setup>
462- import { DESKTOP_SETTING_AUTO_REALTIME_KEY , DESKTOP_SETTING_DEFAULT_TO_CHAT_KEY , SNS_SETTING_USE_CACHE_KEY , readLocalBoolSetting , writeLocalBoolSetting } from ' ~/lib/desktop-settings'
443+ import { DESKTOP_SETTING_DEFAULT_TO_CHAT_KEY , SNS_SETTING_USE_CACHE_KEY , readLocalBoolSetting , writeLocalBoolSetting } from ' ~/lib/desktop-settings'
463444import { readApiBaseOverride , writeApiBaseOverride } from ' ~/lib/api-settings'
464445import { invalidateApiBaseCache } from ' ~/composables/useApiBase'
465446import { reportServerErrorFromError } from ' ~/lib/server-error-logging'
@@ -472,11 +453,12 @@ const props = defineProps({
472453})
473454
474455const emit = defineEmits ([' close' ])
456+ const api = useApi ()
475457
476458const settingNavItems = [
477459 { key: ' desktop' , label: ' 桌面行为' , hint: ' 启动 / 关闭 / 端口' },
478460 { key: ' mcp' , label: ' MCP 接入' , hint: ' 手机 / Skill / 工具' },
479- { key: ' startup' , label: ' 启动偏好' , hint: ' 自动实时 / 默认页面' },
461+ { key: ' startup' , label: ' 启动偏好' , hint: ' 默认页面' },
480462 { key: ' updates' , label: ' 更新' , hint: ' 版本信息 / 检查更新' },
481463 { key: ' sns' , label: ' 朋友圈' , hint: ' 图片缓存策略' },
482464]
@@ -498,7 +480,6 @@ const desktopVersionText = computed(() => {
498480 return v || ' —'
499481})
500482
501- const desktopAutoRealtime = ref (false )
502483const desktopDefaultToChatWhenData = ref (false )
503484const snsUseCache = ref (true )
504485
@@ -1261,12 +1242,6 @@ const onDesktopBackendPortReset = async () => {
12611242 await applyDesktopBackendPort ()
12621243}
12631244
1264- const toggleDesktopAutoRealtime = () => {
1265- const next = ! desktopAutoRealtime .value
1266- desktopAutoRealtime .value = next
1267- writeLocalBoolSetting (DESKTOP_SETTING_AUTO_REALTIME_KEY , next)
1268- }
1269-
12701245const toggleDesktopDefaultToChat = () => {
12711246 const next = ! desktopDefaultToChatWhenData .value
12721247 desktopDefaultToChatWhenData .value = next
@@ -1283,17 +1258,35 @@ const onDesktopCheckUpdates = async () => {
12831258 await desktopUpdate .manualCheck ()
12841259}
12851260
1286- watch (() => props .open , async (isOpen ) => {
1287- if (! isOpen) return
1288- await refreshMcpLanAccess ()
1289- await refreshMcpToken ()
1290- await refreshMcpSkillBundle ()
1291- await refreshBackendLogFileInfo ()
1261+ const refreshSettingsDialogData = async () => {
1262+ if (! process .client || typeof window === ' undefined' ) return
1263+
1264+ const tasks = [
1265+ refreshDesktopBackendPort (),
1266+ refreshMcpLanAccess (),
1267+ refreshMcpToken (),
1268+ refreshBackendLogFileInfo (),
1269+ ]
1270+
1271+
12921272 if (isDesktopEnv .value ) {
1293- await refreshDesktopOutputDir ()
1294- await refreshDesktopOutputDirProgress ()
1273+ void desktopUpdate .initListeners ()
1274+ tasks .push (refreshDesktopAutoLaunch ())
1275+ tasks .push (refreshDesktopCloseBehavior ())
1276+ tasks .push (refreshDesktopOutputDir ())
1277+ tasks .push (refreshDesktopOutputDirProgress ())
12951278 }
1296- }, { immediate: true })
1279+
1280+ await Promise .allSettled (tasks)
1281+
1282+ // skill bundle 依赖 token / access host;先让弹窗可交互,再后台补齐这块文本。
1283+ void refreshMcpSkillBundle ()
1284+ }
1285+
1286+ watch (() => props .open , async (isOpen ) => {
1287+ if (! isOpen) return
1288+ await refreshSettingsDialogData ()
1289+ }, { immediate: false })
12971290
12981291onMounted (async () => {
12991292 if (process .client && typeof window !== ' undefined' ) {
@@ -1307,21 +1300,10 @@ onMounted(async () => {
13071300 }
13081301 }
13091302
1310- desktopAutoRealtime .value = readLocalBoolSetting (DESKTOP_SETTING_AUTO_REALTIME_KEY , false )
13111303 desktopDefaultToChatWhenData .value = readLocalBoolSetting (DESKTOP_SETTING_DEFAULT_TO_CHAT_KEY , false )
13121304 snsUseCache .value = readLocalBoolSetting (SNS_SETTING_USE_CACHE_KEY , true )
13131305
1314- await refreshDesktopBackendPort ()
1315- await refreshMcpLanAccess ()
1316- await refreshMcpToken ()
1317- await refreshMcpSkillBundle ()
1318- if (isDesktopEnv .value ) {
1319- void desktopUpdate .initListeners ()
1320- await refreshDesktopAutoLaunch ()
1321- await refreshDesktopCloseBehavior ()
1322- await refreshDesktopOutputDir ()
1323- await refreshDesktopOutputDirProgress ()
1324- }
1306+ if (props .open ) await refreshSettingsDialogData ()
13251307
13261308 await nextTick ()
13271309 onContentScroll ()
0 commit comments