Skip to content

Commit 7281d56

Browse files
committed
fix: reduce GPU-heavy visual effects
1 parent f08eea5 commit 7281d56

4 files changed

Lines changed: 22 additions & 15 deletions

File tree

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
})();
7171
</script>
7272
<link rel="stylesheet" href="./vendor/gitalk.css" />
73-
<link rel="stylesheet" href="./styles/theme.css?v=20260716-9" />
73+
<link rel="stylesheet" href="./styles/theme.css?v=20260716-10" />
7474
</head>
7575
<body>
7676
<a class="skip-link" href="#main">跳到正文</a>
@@ -119,7 +119,7 @@
119119
</noscript>
120120

121121
<script src="./vendor/gitalk.min.js"></script>
122-
<script src="./scripts/site.js?v=20260716-12"></script>
122+
<script src="./scripts/site.js?v=20260716-13"></script>
123123
<script src="./vendor/docsify.min.js"></script>
124124
<script src="./vendor/prism-bash.min.js"></script>
125125
<script src="./vendor/search.min.js"></script>

docs/scripts/site.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
const REPOSITORY = "https://github.com/ArchLinuxStudio/ArchLinuxTutorial";
55
const THEME_STORAGE_KEY = "archtutorial-theme";
66
let lastUpdatedManifestPromise;
7+
let scrollUiFrame = 0;
78
let activeMarkdown = "";
89
let activeFile = "README.md";
910

@@ -236,15 +237,23 @@
236237
if (backToTop) backToTop.classList.toggle("is-visible", window.scrollY > 560);
237238
}
238239

240+
function scheduleScrollUiUpdate() {
241+
if (scrollUiFrame) return;
242+
scrollUiFrame = window.requestAnimationFrame(() => {
243+
scrollUiFrame = 0;
244+
updateScrollUi();
245+
});
246+
}
247+
239248
function bindGlobalInteractions() {
240249
const mobileSidebarQuery = window.matchMedia("(max-width: 900px)");
241250

242251
document.querySelector(".theme-toggle")?.addEventListener("click", toggleTheme);
243252
document.querySelector(".back-to-top")?.addEventListener("click", () => {
244253
window.scrollTo({ top: 0, behavior: "smooth" });
245254
});
246-
window.addEventListener("scroll", updateScrollUi, { passive: true });
247-
window.addEventListener("resize", updateScrollUi, { passive: true });
255+
window.addEventListener("scroll", scheduleScrollUiUpdate, { passive: true });
256+
window.addEventListener("resize", scheduleScrollUiUpdate, { passive: true });
248257
document.addEventListener("keydown", (event) => {
249258
const tag = event.target?.tagName;
250259
const isTyping = tag === "INPUT" || tag === "TEXTAREA" || event.target?.isContentEditable;

docs/styles/theme.css

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
--ink-tertiary: #7b8996;
99
--surface: #ffffff;
1010
--surface-soft: #f5f8fb;
11-
--surface-raised: rgba(255, 255, 255, 0.86);
11+
--surface-raised: #ffffff;
1212
--line: #dce5ec;
1313
--line-strong: #c9d7e1;
1414
--code-surface: #111b25;
1515
--code-ink: #e8f0f6;
1616
--selection: rgba(23, 147, 209, 0.2);
1717
--shadow-sm: 0 1px 2px rgba(17, 33, 45, 0.05);
18-
--shadow-md: 0 12px 32px rgba(27, 48, 63, 0.09);
18+
--shadow-md: 0 8px 24px rgba(27, 48, 63, 0.08);
1919
--header-height: 66px;
2020
--sidebar-width: 304px;
2121
--content-width: 880px;
@@ -37,14 +37,14 @@
3737
--ink-tertiary: #7f909e;
3838
--surface: #0f171f;
3939
--surface-soft: #0b1118;
40-
--surface-raised: rgba(15, 23, 31, 0.88);
40+
--surface-raised: #0f171f;
4141
--line: #26343f;
4242
--line-strong: #344550;
4343
--code-surface: #070c11;
4444
--code-ink: #e6edf3;
4545
--selection: rgba(72, 183, 237, 0.25);
4646
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.22);
47-
--shadow-md: 0 18px 44px rgba(0, 0, 0, 0.28);
47+
--shadow-md: 0 10px 28px rgba(0, 0, 0, 0.24);
4848
}
4949

5050
*,
@@ -63,9 +63,7 @@ body {
6363
min-width: 320px;
6464
margin: 0;
6565
color: var(--ink);
66-
background:
67-
radial-gradient(circle at 82% 0, rgba(23, 147, 209, 0.075), transparent 29rem),
68-
var(--surface-soft);
66+
background: var(--surface-soft);
6967
font-family: var(--font-sans);
7068
font-size: 16px;
7169
line-height: 1.72;
@@ -143,7 +141,6 @@ input:focus-visible,
143141
border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
144142
background: var(--surface-raised);
145143
box-shadow: var(--shadow-sm);
146-
backdrop-filter: blur(18px) saturate(150%);
147144
}
148145

149146
.site-brand {
@@ -253,7 +250,6 @@ input:focus-visible,
253250
background: linear-gradient(90deg, var(--arch-blue-strong), #60c7f5);
254251
transform: scaleX(0);
255252
transform-origin: left;
256-
will-change: transform;
257253
}
258254

259255
.app-nav {
@@ -1389,7 +1385,6 @@ main:has(> .sidebar.show) > .content {
13891385
color: var(--ink-secondary);
13901386
background: var(--surface-raised);
13911387
box-shadow: var(--shadow-md);
1392-
backdrop-filter: blur(14px);
13931388
cursor: pointer;
13941389
visibility: hidden;
13951390
opacity: 0;
@@ -1508,7 +1503,6 @@ main:has(> .sidebar.show) > .content {
15081503
z-index: 40;
15091504
inset: var(--header-height) 0 0 var(--sidebar-width);
15101505
background: rgba(6, 13, 18, 0.35);
1511-
backdrop-filter: blur(2px);
15121506
cursor: pointer;
15131507
pointer-events: auto;
15141508
}

scripts/validate-site.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const files = walk(docsDirectory);
2121
const markdownFiles = files.filter((file) => extname(file).toLowerCase() === ".md");
2222
const index = readFileSync(resolve(docsDirectory, "index.html"), "utf8");
2323
const siteScript = readFileSync(resolve(docsDirectory, "scripts/site.js"), "utf8");
24+
const theme = readFileSync(resolve(docsDirectory, "styles/theme.css"), "utf8");
2425
const workflow = readFileSync(resolve(root, ".github/workflows/pages.yml"), "utf8");
2526
const packageSource = readFileSync(resolve(root, "package.json"), "utf8");
2627
const lastUpdated = JSON.parse(readFileSync(resolve(docsDirectory, "last-updated.json"), "utf8"));
@@ -35,6 +36,9 @@ assert(!siteScript.includes("api.github.com/repos/"), "Last-updated dates must n
3536
assert(siteScript.includes('"/.*/_sidebar.md": "/_sidebar.md"'), "Nested routes must reuse the root sidebar.");
3637
assert(!siteScript.includes("formatUpdated:"), "Unused Docsify update formatting must stay removed.");
3738
assert(!siteScript.includes("topMargin:"), "Deprecated topMargin must not offset chapter navigation.");
39+
assert(!theme.includes("backdrop-filter:"), "Backdrop filters must stay disabled for low-end GPU compatibility.");
40+
assert(!theme.includes("will-change:"), "Persistent compositor hints must stay disabled.");
41+
assert(siteScript.includes("scheduleScrollUiUpdate"), "Scroll UI updates must be frame-throttled.");
3842
assert(workflow.includes("fetch-depth: 0"), "The deployment checkout must include full Git history.");
3943
assert(packageSource.includes("scripts/generate-last-updated.mjs"), "The local preview does not generate last-updated metadata.");
4044

0 commit comments

Comments
 (0)