mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
fix(update, setting): 修复更新弹窗漏弹问题并简化调试模式描述
为更新弹窗组件添加挂载时拉取更新状态的兜底逻辑,解决组件订阅晚于静默检查广播导致的更新弹窗漏弹问题 简化关于设置页面中调试模式开关的描述文字,移除冗余的启动参数和开发环境终端输出说明
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@ import {
|
||||
AlertDialogDescription,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import { onUpdateStatus } from "@/api/update";
|
||||
import { onUpdateStatus, getUpdateState } from "@/api/update";
|
||||
import { useRouteStore } from "@/stores/routeStore";
|
||||
import { useUpdateDialogStore } from "@/stores/updateDialogStore";
|
||||
import { BUILD_MODE } from "@/lib/mode";
|
||||
@@ -59,6 +59,25 @@ export function UpdateAvailableDialog() {
|
||||
return unsub;
|
||||
}, [show]);
|
||||
|
||||
// 兜底:挂载时拉一次状态快照 —— 若启动静默检查的 available 广播早于本组件订阅
|
||||
// (渲染慢/竞态)会漏弹,这里补一次判定
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
getUpdateState()
|
||||
.then((status) => {
|
||||
if (cancelled) return;
|
||||
const alreadyOpen = useUpdateDialogStore.getState().open;
|
||||
if (status.state === "available" && currentRouteRef.current !== "update" && !alreadyOpen) {
|
||||
show(status.version);
|
||||
}
|
||||
prevStateRef.current = status.state;
|
||||
})
|
||||
.catch(() => {});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [show]);
|
||||
|
||||
const goUpdate = () => {
|
||||
hide();
|
||||
// 等关闭动画结束后再切换路由,避免弹窗关闭与 view transition 快照抢帧导致无过渡
|
||||
|
||||
@@ -211,7 +211,7 @@ export function AboutSetting() {
|
||||
<SettingCard>
|
||||
<SettingSwitch
|
||||
label="调试模式"
|
||||
desc="启用后附加 -Dkoring.debugMode=true 并在控制台输出详细日志(dev 运行时会同步输出到终端),可能影响性能"
|
||||
desc="在控制台输出详细日志,可能影响性能"
|
||||
checked={adv?.debugMode ?? false}
|
||||
onChange={(v) => setAdvanced({ debugMode: v })}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user