feat(timeout): 添加多语言页面加载超时提示

This commit is contained in:
PKC278
2026-01-03 10:32:58 +08:00
parent 78e2d05730
commit 43d2406ee9
5 changed files with 35 additions and 9 deletions

View File

@@ -301,6 +301,34 @@
setTimeout(function() {
const timeoutEl = document.getElementById('loading-timeout');
if (timeoutEl) {
// 适配多语言
const lang = navigator.language || 'zh-CN';
const messages = {
'zh-CN': {
text: '页面加载似乎遇到了阻碍,请尝试',
btn: '清除缓存'
},
'zh-TW': {
text: '頁面載入似乎遇到了阻礙,請嘗試',
btn: '清除快取'
},
'en-US': {
text: 'Page loading seems to be blocked, please try',
btn: 'Clear Cache'
}
};
// 默认匹配前缀,如 en-GB 匹配 en-US 的逻辑
let msg = messages['zh-CN'];
if (lang.startsWith('zh-TW') || lang.startsWith('zh-HK')) {
msg = messages['zh-TW'];
} else if (lang.startsWith('en')) {
msg = messages['en-US'];
} else if (lang.startsWith('zh')) {
msg = messages['zh-CN'];
}
timeoutEl.innerHTML = msg.text + ' <a href="javascript:void(0)" onclick="window.clearAndReload()" id="timeout-btn">' + msg.btn + '</a>';
timeoutEl.style.display = 'block';
}
}, 15000); // 15秒后显示超时提示
@@ -319,9 +347,7 @@
<div class="effect-3 effects"></div>
</div>
<!-- 超时提示 - 默认隐藏 -->
<div id="loading-timeout">
页面加载似乎遇到了阻碍,请尝试 <a href="javascript:void(0)" onclick="window.clearAndReload()" id="timeout-btn">清除缓存</a>
</div>
<div id="loading-timeout"></div>
</div>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>

View File

@@ -120,7 +120,7 @@ function releaseTime(releaseDate: string) {
}
// 强制清除缓存
async function cleanCache() {
async function clearCache() {
await clearCachesAndServiceWorker()
// 刷新页面,添加时间戳参数以强制更新
reloadWithTimestamp()
@@ -191,12 +191,12 @@ onMounted(() => {
size="x-small"
variant="tonal"
class="ms-2"
@click="cleanCache"
@click="clearCache"
>
<template #prepend>
<VIcon icon="mdi-refresh" size="14" />
</template>
{{ t('setting.about.cleanCache') }}
{{ t('setting.about.clearCache') }}
</VBtn>
</span>
</dd>

View File

@@ -1250,7 +1250,7 @@ export default {
dataDirectory: '/moviepilot',
expand: 'Expand',
collapse: 'Collapse',
cleanCache: 'Clear Cache',
clearCache: 'Clear Cache',
},
system: {
custom: 'Custom',

View File

@@ -1247,7 +1247,7 @@ export default {
dataDirectory: '/moviepilot',
expand: '展开',
collapse: '收起',
cleanCache: '清除缓存',
clearCache: '清除缓存',
},
system: {
custom: '自定义',

View File

@@ -1235,7 +1235,7 @@ export default {
dataDirectory: '/moviepilot',
expand: '展開',
collapse: '收起',
cleanCache: '清除緩存',
clearCache: '清除快取',
},
system: {
custom: '自定義',