fix reactive resume page loading

This commit is contained in:
2026-05-18 18:02:13 +08:00
parent 92eef39c5a
commit 2a2274716e
4 changed files with 1267 additions and 12 deletions

2
.env
View File

@@ -44,7 +44,7 @@ S3_ENDPOINT=
S3_BUCKET=
S3_FORCE_PATH_STYLE=false
REDIS_URL=
ENCRYPTION_SECRET=
ENCRYPTION_SECRET=10ddcad9814eaa5fa5bef8ba85d58a8122f3ede148bad11bc340899b5014af45
CLOUDFLARE_ACCOUNT_ID=
CLOUDFLARE_API_TOKEN=
FLAG_DISABLE_SIGNUPS=false

View File

@@ -8,18 +8,27 @@ set -eu
SSR_FILE="/app/apps/web/.output/server/_ssr/pdf-document-COfeOLVC.mjs"
SW_FILE="/app/apps/web/.output/public/sw.js"
SERVER_INDEX_FILE="/app/apps/web/.output/server/index.mjs"
SSR_RENDERER_FILE="/app/apps/web/.output/server/_chunks/ssr-renderer.mjs"
cp "$SSR_FILE" "$SSR_FILE.bak-sw-cache" 2>/dev/null || true
cp "$SW_FILE" "$SW_FILE.bak-sw-cache" 2>/dev/null || true
test -f "$SSR_FILE.bak-sw-cache" || cp "$SSR_FILE" "$SSR_FILE.bak-sw-cache" 2>/dev/null || true
test -f "$SW_FILE.bak-sw-cache" || cp "$SW_FILE" "$SW_FILE.bak-sw-cache" 2>/dev/null || true
test -f "$SERVER_INDEX_FILE.bak-sw-cache" || cp "$SERVER_INDEX_FILE" "$SERVER_INDEX_FILE.bak-sw-cache" 2>/dev/null || true
test -f "$SSR_RENDERER_FILE.bak-sw-cache" || cp "$SSR_RENDERER_FILE" "$SSR_RENDERER_FILE.bak-sw-cache" 2>/dev/null || true
node - <<'NODE'
const fs = require("fs");
const crypto = require("crypto");
const ssrFile = "/app/apps/web/.output/server/_ssr/pdf-document-COfeOLVC.mjs";
const swFile = "/app/apps/web/.output/public/sw.js";
const serverIndexFile = "/app/apps/web/.output/server/index.mjs";
const ssrRendererFile = "/app/apps/web/.output/server/_chunks/ssr-renderer.mjs";
const registrationScript = `
\tif ("serviceWorker" in navigator) {
\t(() => {
\t\tif (!("serviceWorker" in navigator)) return;
\t\twindow.addEventListener("load", () => {
\t\t\tconst clearReactiveResumeCaches = async () => {
\t\t\t\tif ("caches" in window) {
@@ -33,14 +42,9 @@ const registrationScript = `
\t\t\t\t}
\t\t\t};
\t\t\tclearReactiveResumeCaches().then(() => {
\t\t\t\tif (navigator.serviceWorker.controller && !sessionStorage.getItem("rr-sw-cache-cleared-v1")) {
\t\t\t\t\tsessionStorage.setItem("rr-sw-cache-cleared-v1", "1");
\t\t\t\t\twindow.location.reload();
\t\t\t\t}
\t\t\t}).catch(console.error);
\t\t\tclearReactiveResumeCaches().catch(console.error);
\t\t});
\t}
\t})();
`;
let ssr = fs.readFileSync(ssrFile, "utf8");
@@ -87,8 +91,71 @@ self.addEventListener("activate", (event) => {
self.addEventListener("fetch", () => {});
`;
fs.writeFileSync(swFile, sw);
function makeEtag(buffer) {
const digest = crypto.createHash("sha1").update(buffer).digest("base64").replace(/=+$/g, "");
return `"${buffer.length.toString(16)}-${digest}"`;
}
function patchStaticManifestEntry(source, urlPath, filePath) {
const buffer = fs.readFileSync(filePath);
const startMarker = `"${urlPath}": {`;
const start = source.indexOf(startMarker);
if (start === -1) {
throw new Error(`Static manifest entry not found for ${urlPath}`);
}
const end = source.indexOf("\n\t},", start);
if (end === -1) {
throw new Error(`Static manifest entry end not found for ${urlPath}`);
}
let entry = source.slice(start, end);
entry = entry
.replace(/"etag": "(?:\\.|[^"\\])*"/, `"etag": ${JSON.stringify(makeEtag(buffer))}`)
.replace(/"mtime": "(?:\\.|[^"\\])*"/, `"mtime": ${JSON.stringify(new Date().toISOString())}`)
.replace(/"size": \d+/, `"size": ${buffer.length}`);
return source.slice(0, start) + entry + source.slice(end);
}
let serverIndex = fs.readFileSync(serverIndexFile, "utf8");
serverIndex = patchStaticManifestEntry(serverIndex, "/sw.js", swFile);
fs.writeFileSync(serverIndexFile, serverIndex);
let ssrRenderer = fs.readFileSync(ssrRendererFile, "utf8");
const ssrRendererOriginal = `function ssrRenderer({ req }) {
\treturn fetchViteEnv("ssr", req);
}`;
const ssrRendererPatched = `async function ssrRenderer(event) {
\tconst response = await fetchViteEnv("ssr", event.req);
\tconst headers = new Headers(response.headers);
\tconst accept = event.req.headers.get("accept") || "";
\tif (accept.includes("text/html")) {
\t\theaders.set("Cache-Control", "no-store, max-age=0");
\t\theaders.set("Pragma", "no-cache");
\t\theaders.set("Expires", "0");
\t}
\treturn new Response(response.body, {
\t\tstatus: response.status,
\t\tstatusText: response.statusText,
\t\theaders,
\t});
}`;
if (!ssrRenderer.includes(ssrRendererPatched)) {
if (!ssrRenderer.includes(ssrRendererOriginal)) {
throw new Error("SSR renderer marker not found");
}
ssrRenderer = ssrRenderer.replace(ssrRendererOriginal, ssrRendererPatched);
fs.writeFileSync(ssrRendererFile, ssrRenderer);
}
NODE
node --check "$SSR_FILE" >/dev/null
node --check "$SW_FILE" >/dev/null
node --check "$SERVER_INDEX_FILE" >/dev/null
node --check "$SSR_RENDERER_FILE" >/dev/null
SH

View File

@@ -1113,7 +1113,7 @@
{
"id": "c16accb2-c907-44bf-aa0c-89e0085c6a50",
"hidden": false,
"content": "<p><strong>期刊论文</strong></p><ul><li><p><strong>Frontiers in Oncology, 2025</strong> — Development of an AI-driven digital assistance system for real-time safety evaluation and quality control in laparoscopic liver surgery共同第一作者</p></li><li><p><strong>中华肝脏外科手术学电子杂志, 2023</strong> — 智能化辅助图像实时去雾技术在腹腔镜胆囊切除术中的应用研究(共同一作作者)</p></li><li><p><strong>中华肝脏外科手术学电子杂志, 2023</strong> — 增强现实、虚拟现实与混合现实在腔镜肝脏外科中的应用进展(共同一作作者)</p></li></ul><p><strong>ACS Clinical Congress 2025</strong></p><ul><li><p><strong>Oral</strong> — Biomarker Risk Scoring Algorithm And Preoperative Stratification In Patients With Lung Cancer</p></li><li><p><strong>Oral</strong> — Differences In Perioperative Complications Of Laparoscopic Cholecystectomy Under Voice Risk Alert System (V-RAS)-assisted Monitoring: Results From 48 Hospitals In Western China</p></li><li><p><strong>Oral</strong> — Intraoperative Smart Molecular Imaging And Recognition To Enhance Surgeons&#39; Ability To Identify Lymph Node Metastasis In Thyroid Surgery</p></li><li><p><strong>Oral</strong> — Comparison Of Robot-assisted And Conventional Laparoscopic Hepatectomy For Perioperative Outcomes: A Clinical Randomized Controlled Trial (RCT)</p></li><li><p><strong>ePoster</strong> — Cost-effectiveness Of Endoscopic Magnetic Traction Technology Compared To Laparoscopic Heller Myotomy For The Treatment Of Achalasia</p></li></ul><p></p><p><strong>ACS / CMAIC / FIS 2023</strong></p><ul><li><strong>ePoster</strong> — Application Of Computer Intelligent Surgical Confidential Assistant In Laparoscopic Liver Resection</li><li><strong>ePoster</strong> — Intelligent Surgical Confidential Assistant Helps Precise Magnetic Assisted Vascular Anastomosis</li><li><strong>Poster</strong> — Intelligent Surgery Enters the Blind Spot of Lumpectomy Liver Resection</li><li><strong>Poster</strong> — Intelligent digital fogging technology shows great potential in laparoscopic hepatectomy surgery</li><li><strong>Poster</strong> — Prospects for intelligent surgical machine assistants in precision liver segment resection</li><li><strong>Poster</strong> — Application of Orthogonal Decomposition in Surgical Image Segmentation - for Unsupervised Adaptability in Intraoperative Surgical Image Recognition Navigation</li><li><strong>Poster</strong> — Intraoperative Image Detection and Clearing System Based on Generative Adversarial Network</li></ul>"
"content": "<p><strong>期刊论文</strong></p><ul><li><p><strong>Frontiers in Oncology, 2025</strong> — Development of an AI-driven digital assistance system for real-time safety evaluation and quality control in laparoscopic liver surgery共同第一作者</p></li><li><p><strong>中华肝脏外科手术学电子杂志, 2023</strong> — 智能化辅助图像实时去雾技术在腹腔镜胆囊切除术中的应用研究(共同一作作者)</p></li><li><p><strong>中华肝脏外科手术学电子杂志, 2023</strong> — 增强现实、虚拟现实与混合现实在腔镜肝脏外科中的应用进展(共同一作作者)</p></li></ul><p><strong>ACS Clinical Congress 2025</strong></p><ul><li><p><strong>Oral</strong> — Biomarker Risk Scoring Algorithm And Preoperative Stratification In Patients With Lung Cancer</p></li><li><p><strong>Oral</strong> — Differences In Perioperative Complications Of Laparoscopic Cholecystectomy Under Voice Risk Alert System (V-RAS)-assisted Monitoring: Results From 48 Hospitals In Western China</p></li><li><p><strong>Oral</strong> — Intraoperative Smart Molecular Imaging And Recognition To Enhance Surgeons Ability To Identify Lymph Node Metastasis In Thyroid Surgery</p></li><li><p><strong>Oral</strong> — Comparison Of Robot-assisted And Conventional Laparoscopic Hepatectomy For Perioperative Outcomes: A Clinical Randomized Controlled Trial (RCT)</p></li><li><p><strong>ePoster</strong> — Cost-effectiveness Of Endoscopic Magnetic Traction Technology Compared To Laparoscopic Heller Myotomy For The Treatment Of Achalasia</p></li></ul><p></p><p><strong>ACS / CMAIC / FIS 2023</strong></p><ul><li><strong>ePoster</strong> — Application Of Computer Intelligent Surgical Confidential Assistant In Laparoscopic Liver Resection</li><li><strong>ePoster</strong> — Intelligent Surgical Confidential Assistant Helps Precise Magnetic Assisted Vascular Anastomosis</li><li><strong>Poster</strong> — Intelligent Surgery Enters the Blind Spot of Lumpectomy Liver Resection</li><li><strong>Poster</strong> — Intelligent digital fogging technology shows great potential in laparoscopic hepatectomy surgery</li><li><strong>Poster</strong> — Prospects for intelligent surgical machine assistants in precision liver segment resection</li><li><strong>Poster</strong> — Application of Orthogonal Decomposition in Surgical Image Segmentation - for Unsupervised Adaptability in Intraoperative Surgical Image Recognition Navigation</li><li><strong>Poster</strong> — Intraoperative Image Detection and Clearing System Based on Generative Adversarial Network</li></ul>"
}
],
"title": "论文与会议",