From 42d197dd2d63a12bd0467b39a7d74588e75afb95 Mon Sep 17 00:00:00 2001 From: tangxinyue <524779910@qq.com> Date: Fri, 24 Jul 2026 15:35:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E7=BB=84=E4=BB=B6=E6=8A=A5=E9=94=99=20(Faile?= =?UTF-8?q?d=20to=20fetch=20dynamically=20imported=20module)=20-=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=20index.html=20no-cache=20=E9=98=B2=E6=97=A7?= =?UTF-8?q?=E7=BC=93=E5=AD=98=EF=BC=8C=E5=A2=9E=E5=8A=A0=20CORS=20?= =?UTF-8?q?=E6=A0=87=E5=A4=B4=E5=8F=8A=20router.onError=20=E9=87=8D?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/core/router/index.cjs | 13 +++++++++++-- src/components/simulator/StatusBar.vue | 8 ++++---- src/router/index.js | 8 +++++++- src/views/Profile.vue | 6 +++--- src/views/wxPage/ChatEdit.vue | 6 +++--- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/service/core/router/index.cjs b/service/core/router/index.cjs index fe35734..df2197d 100644 --- a/service/core/router/index.cjs +++ b/service/core/router/index.cjs @@ -96,7 +96,10 @@ const matchFile = async (request, response) => { fs.readFile(targetPath, (err, file) => { if (!err) { const mimetype = getMimeType(cleanPath) - const responseHeaders = { 'Content-Type': mimetype } + const responseHeaders = { + 'Content-Type': mimetype, + 'Access-Control-Allow-Origin': '*' + } if (cleanPath.endsWith("-sw.js")) { responseHeaders["Service-Worker-Allowed"] = '/' } @@ -115,7 +118,13 @@ const endIndex = async (request, response) => { console.log(dist + '/index.html') fs.readFile(dist + '/index.html', (err, html) => { if (!err) { - response.writeHead(httpOk, { 'Content-type': 'text/html;charset=utf-8' }) + response.writeHead(httpOk, { + 'Content-type': 'text/html;charset=utf-8', + 'Cache-Control': 'no-cache, no-store, must-revalidate', + 'Pragma': 'no-cache', + 'Expires': '0', + 'Access-Control-Allow-Origin': '*' + }) response.end(html) logger.info(`${request.method} ${httpOk} ${request.url}`) } diff --git a/src/components/simulator/StatusBar.vue b/src/components/simulator/StatusBar.vue index 1abecc9..33feda2 100644 --- a/src/components/simulator/StatusBar.vue +++ b/src/components/simulator/StatusBar.vue @@ -2,9 +2,9 @@
{{ time }} - - +
@@ -12,10 +12,10 @@
{{ battery }} - +
- +
diff --git a/src/router/index.js b/src/router/index.js index 5baa6a0..3ae1ffa 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -38,7 +38,6 @@ router.beforeEach(async (to, from, next) => { // 不需要认证的页面,直接放行 if (!to.meta.requiresAuth) return next() - // 需要认证的页面:如果没有 token 或者 token 已失效,跳回首页并唤起登录框 if (!token || !userStore.tokenValid) { return next({ path: '/', query: { showLogin: 1 } }) } @@ -46,4 +45,11 @@ router.beforeEach(async (to, from, next) => { next() }) +router.onError((error) => { + const pattern = /Failed to fetch dynamically imported module|Importing a module script failed/i + if (pattern.test(error?.message || '')) { + window.location.reload() + } +}) + export default router diff --git a/src/views/Profile.vue b/src/views/Profile.vue index 94c7bcc..07decb6 100644 --- a/src/views/Profile.vue +++ b/src/views/Profile.vue @@ -25,8 +25,8 @@
- - + + 我的作品
@@ -67,7 +67,7 @@
- +
diff --git a/src/views/wxPage/ChatEdit.vue b/src/views/wxPage/ChatEdit.vue index f943405..656026b 100644 --- a/src/views/wxPage/ChatEdit.vue +++ b/src/views/wxPage/ChatEdit.vue @@ -468,7 +468,7 @@ const systemMsgTemplates = ref([ { label: '+ 添加成功提示', command: '以上是打招呼的消息' }, { label: '+ 账号安全', command: '对方账号不在常用环境使用,请仔细核实真实身份,涉及汇款、转账等务必电话确认,请保护自身财产和隐私安全。' }, { label: '+ 我要投诉', command: "对方账号安全性未知,如涉及金钱交易务必电话确认,保护个人财产和隐私安全。我要投诉" }, - { label: '+ 红包领取', command: "xxx领取了xxx的红包" } + { label: '+ 红包领取', command: "xxx领取了xxx的红包" } ]) let msgIdCounter = 1 @@ -630,9 +630,9 @@ function onRedpacketStatusChange(status) { let content = "" const theirName = settings.theirName || '对方' if (selectedMsg.value.sender === 'me') { - content = `${theirName}领取了你的红包` + content = `${theirName}领取了你的红包` } else { - content = `你领取了${theirName}的红包` + content = `你领取了${theirName}的红包` } messages.value.push({