fix: 优化页面恢复渲染并统一导航壳配色
- 延迟页面恢复后的版本检查,并移除常驻大面积背景模糊 - 统一侧栏、顶部工具栏和标签栏的导航壳背景色
This commit is contained in:
@@ -20,6 +20,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
});
|
||||
|
||||
let isCheckingUpdates = false;
|
||||
let resumeCheckFrame: number | undefined;
|
||||
const currentVersionTag = ref('');
|
||||
const lastVersionTag = ref('');
|
||||
const timer = ref<ReturnType<typeof setInterval>>();
|
||||
@@ -81,6 +82,7 @@ function handleNotice(versionTag: string) {
|
||||
}
|
||||
|
||||
function start() {
|
||||
stop();
|
||||
if (props.checkUpdatesInterval <= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -92,22 +94,47 @@ function start() {
|
||||
);
|
||||
}
|
||||
|
||||
function handleVisibilitychange() {
|
||||
if (document.hidden) {
|
||||
stop();
|
||||
} else {
|
||||
if (!isCheckingUpdates) {
|
||||
function cancelResumeCheck() {
|
||||
if (resumeCheckFrame === undefined) {
|
||||
return;
|
||||
}
|
||||
cancelAnimationFrame(resumeCheckFrame);
|
||||
resumeCheckFrame = undefined;
|
||||
}
|
||||
|
||||
function scheduleResumeCheck() {
|
||||
cancelResumeCheck();
|
||||
// 页面恢复后先让浏览器完成两帧绘制,再发起版本检查请求。
|
||||
resumeCheckFrame = requestAnimationFrame(() => {
|
||||
resumeCheckFrame = requestAnimationFrame(() => {
|
||||
resumeCheckFrame = undefined;
|
||||
if (document.hidden || isCheckingUpdates) {
|
||||
return;
|
||||
}
|
||||
isCheckingUpdates = true;
|
||||
checkForUpdates().finally(() => {
|
||||
isCheckingUpdates = false;
|
||||
start();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function handleVisibilitychange() {
|
||||
if (document.hidden) {
|
||||
cancelResumeCheck();
|
||||
stop();
|
||||
} else {
|
||||
scheduleResumeCheck();
|
||||
}
|
||||
}
|
||||
|
||||
function stop() {
|
||||
if (timer.value === undefined) {
|
||||
return;
|
||||
}
|
||||
clearInterval(timer.value);
|
||||
timer.value = undefined;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -116,6 +143,7 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
cancelResumeCheck();
|
||||
stop();
|
||||
document.removeEventListener('visibilitychange', handleVisibilitychange);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user