Skip to content

Commit c7ee96b

Browse files
committed
Add tool doc/home links and fix app routing
1 parent 3209f87 commit c7ee96b

File tree

198 files changed

+4564
-224
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+4564
-224
lines changed

assets/clicks.js

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,76 @@
1010
id = parts[toolsIndex + 1];
1111
}
1212

13-
if (!id) {
13+
if (id) {
14+
const payload = JSON.stringify({ id });
15+
if (navigator.sendBeacon) {
16+
navigator.sendBeacon('/api/clicks', new Blob([payload], { type: 'application/json' }));
17+
} else {
18+
fetch('/api/clicks', {
19+
method: 'POST',
20+
headers: { 'Content-Type': 'application/json' },
21+
body: payload,
22+
keepalive: true
23+
});
24+
}
25+
}
26+
27+
if (toolsIndex !== -1 && parts[toolsIndex + 1] && !path.endsWith('/app.html')) {
28+
const basePath = `/${parts.slice(0, toolsIndex + 2).join('/')}/`;
29+
const appUrl = `${basePath}app.html`;
30+
document.querySelectorAll('a[href]').forEach((link) => {
31+
const href = link.getAttribute('href');
32+
if (!href || /^(https?:)?\/\//i.test(href) || href.startsWith('mailto:') || href.startsWith('#')) {
33+
return;
34+
}
35+
if (href === 'app.html' || href === './app.html' || href === 'app') {
36+
link.setAttribute('href', appUrl);
37+
}
38+
});
39+
document.querySelectorAll('iframe[src]').forEach((frame) => {
40+
const src = frame.getAttribute('src');
41+
if (src === 'app.html' || src === './app.html' || src === 'app') {
42+
frame.setAttribute('src', appUrl);
43+
}
44+
});
45+
}
46+
47+
if (!path.endsWith('/app.html') || toolsIndex === -1) {
1448
return;
1549
}
1650

17-
const payload = JSON.stringify({ id });
18-
if (navigator.sendBeacon) {
19-
navigator.sendBeacon('/api/clicks', new Blob([payload], { type: 'application/json' }));
51+
if (document.querySelector('.tool-doc-link')) {
2052
return;
2153
}
22-
fetch('/api/clicks', {
23-
method: 'POST',
24-
headers: { 'Content-Type': 'application/json' },
25-
body: payload,
26-
keepalive: true
54+
55+
const docLink = document.createElement('a');
56+
docLink.href = path.replace(/app\.html$/, 'index.html');
57+
docLink.className = 'tool-doc-link';
58+
docLink.textContent = '\u8bf4\u660e';
59+
docLink.setAttribute('aria-label', '\u67e5\u770b\u5de5\u5177\u8bf4\u660e');
60+
docLink.style.cssText = [
61+
'position:fixed',
62+
'top:18px',
63+
'right:18px',
64+
'padding:8px 14px',
65+
'border-radius:999px',
66+
'font-size:13px',
67+
'font-weight:600',
68+
'color:#0f172a',
69+
'background:rgba(255,255,255,0.92)',
70+
'text-decoration:none',
71+
'box-shadow:0 10px 30px rgba(0,0,0,0.2)',
72+
'backdrop-filter:blur(6px)',
73+
'z-index:9999'
74+
].join(';');
75+
docLink.addEventListener('mouseenter', () => {
76+
docLink.style.transform = 'translateY(-1px)';
77+
docLink.style.boxShadow = '0 12px 30px rgba(0,0,0,0.25)';
78+
});
79+
docLink.addEventListener('mouseleave', () => {
80+
docLink.style.transform = 'translateY(0)';
81+
docLink.style.boxShadow = '0 10px 30px rgba(0,0,0,0.2)';
2782
});
83+
84+
document.body.appendChild(docLink);
2885
})();

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ <h3>设计理念</h3>
838838
const category = toolsData.categories.find(c => c.id === tool.category);
839839
const updatedAt = tool.updatedAt || tool.createdAt || '未知';
840840
return `
841-
<a href="${tool.detail}" class="tool-card" style="--tool-color: ${tool.color}">
841+
<a href="${tool.entry}" class="tool-card" style="--tool-color: ${tool.color}">
842842
${tool.featured ? '<span class="featured-badge">精选</span>' : ''}
843843
<div class="tool-header">
844844
<div class="tool-icon" style="background: ${tool.color}20; color: ${tool.color};">
@@ -910,6 +910,6 @@ <h3>设计理念</h3>
910910
loadTools();
911911

912912
</script>
913-
<script src="/assets/clicks.js" defer></script>
913+
<script src="assets/clicks.js" defer></script>
914914
</body>
915915
</html>

tools-rank.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ <h1>工具使用排行</h1>
310310
<div class="rank-item">
311311
<div class="rank-badge">${index + 1}</div>
312312
<div class="rank-info">
313-
<a class="rank-name" href="/${item.tool.detail}">${item.tool.name}</a>
313+
<a class="rank-name" href="/${item.tool.entry}">${item.tool.name}</a>
314314
<div class="rank-meta">${item.tool.description}</div>
315315
</div>
316316
<div class="rank-metric">
@@ -339,6 +339,6 @@ <h1>工具使用排行</h1>
339339
init();
340340
</script>
341341

342-
<script src="/assets/clicks.js" defer></script>
342+
<script src="assets/clicks.js" defer></script>
343343
</body>
344344
</html>

tools/base-converter/app.html

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,44 @@
175175
grid-template-columns: 1fr;
176176
}
177177
}
178+
179+
.tool-doc-link,
180+
.tool-home-link {
181+
position: fixed;
182+
top: 16px;
183+
padding: 6px 12px;
184+
border-radius: 999px;
185+
font-size: 12px;
186+
font-weight: 600;
187+
color: #0f172a;
188+
background: rgba(255, 255, 255, 0.9);
189+
border: 1px solid rgba(15, 23, 42, 0.12);
190+
text-decoration: none;
191+
letter-spacing: 0.02em;
192+
z-index: 9999;
193+
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
194+
transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
195+
}
196+
197+
.tool-doc-link {
198+
right: 16px;
199+
}
200+
201+
.tool-home-link {
202+
right: 74px;
203+
}
204+
205+
.tool-doc-link:hover,
206+
.tool-home-link:hover {
207+
background: rgba(255, 255, 255, 1);
208+
border-color: rgba(15, 23, 42, 0.2);
209+
transform: translateY(-1px);
210+
}
178211
</style>
179212
</head>
180213
<body>
214+
<a class="tool-home-link" href="../../index.html">首页</a>
215+
<a class="tool-doc-link" href="index.html">说明</a>
181216
<div class="container">
182217
<div class="header">
183218
<h1>进制转换工具</h1>
@@ -403,6 +438,6 @@ <h1>进制转换工具</h1>
403438
document.head.appendChild(style);
404439
</script>
405440

406-
<script src="/assets/clicks.js" defer></script>
441+
<script src="../../assets/clicks.js" defer></script>
407442
</body>
408443
</html>

tools/base-converter/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,6 @@ <h2>快速预览</h2>
154154
</div>
155155
</div>
156156

157-
<script src="/assets/clicks.js" defer></script>
157+
<script src="../../assets/clicks.js" defer></script>
158158
</body>
159159
</html>

tools/base32-decode/app.html

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,44 @@
183183
min-height: 240px;
184184
}
185185
}
186+
187+
.tool-doc-link,
188+
.tool-home-link {
189+
position: fixed;
190+
top: 16px;
191+
padding: 6px 12px;
192+
border-radius: 999px;
193+
font-size: 12px;
194+
font-weight: 600;
195+
color: #0f172a;
196+
background: rgba(255, 255, 255, 0.9);
197+
border: 1px solid rgba(15, 23, 42, 0.12);
198+
text-decoration: none;
199+
letter-spacing: 0.02em;
200+
z-index: 9999;
201+
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
202+
transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
203+
}
204+
205+
.tool-doc-link {
206+
right: 16px;
207+
}
208+
209+
.tool-home-link {
210+
right: 74px;
211+
}
212+
213+
.tool-doc-link:hover,
214+
.tool-home-link:hover {
215+
background: rgba(255, 255, 255, 1);
216+
border-color: rgba(15, 23, 42, 0.2);
217+
transform: translateY(-1px);
218+
}
186219
</style>
187220
</head>
188221
<body>
222+
<a class="tool-home-link" href="../../index.html">首页</a>
223+
<a class="tool-doc-link" href="index.html">说明</a>
189224
<div class="container">
190225
<div class="header">
191226
<h1>Base32 解码</h1>
@@ -287,6 +322,6 @@ <h1>Base32 解码</h1>
287322
}
288323
</script>
289324

290-
<script src="/assets/clicks.js" defer></script>
325+
<script src="../../assets/clicks.js" defer></script>
291326
</body>
292327
</html>

tools/base32-encode/app.html

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,44 @@
183183
min-height: 240px;
184184
}
185185
}
186+
187+
.tool-doc-link,
188+
.tool-home-link {
189+
position: fixed;
190+
top: 16px;
191+
padding: 6px 12px;
192+
border-radius: 999px;
193+
font-size: 12px;
194+
font-weight: 600;
195+
color: #0f172a;
196+
background: rgba(255, 255, 255, 0.9);
197+
border: 1px solid rgba(15, 23, 42, 0.12);
198+
text-decoration: none;
199+
letter-spacing: 0.02em;
200+
z-index: 9999;
201+
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
202+
transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
203+
}
204+
205+
.tool-doc-link {
206+
right: 16px;
207+
}
208+
209+
.tool-home-link {
210+
right: 74px;
211+
}
212+
213+
.tool-doc-link:hover,
214+
.tool-home-link:hover {
215+
background: rgba(255, 255, 255, 1);
216+
border-color: rgba(15, 23, 42, 0.2);
217+
transform: translateY(-1px);
218+
}
186219
</style>
187220
</head>
188221
<body>
222+
<a class="tool-home-link" href="../../index.html">首页</a>
223+
<a class="tool-doc-link" href="index.html">说明</a>
189224
<div class="container">
190225
<div class="header">
191226
<h1>Base32 编码</h1>
@@ -286,6 +321,6 @@ <h1>Base32 编码</h1>
286321
}
287322
</script>
288323

289-
<script src="/assets/clicks.js" defer></script>
324+
<script src="../../assets/clicks.js" defer></script>
290325
</body>
291326
</html>

tools/base36-decode/app.html

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,44 @@
179179
color: var(--accent);
180180
word-break: break-all;
181181
}
182+
183+
.tool-doc-link,
184+
.tool-home-link {
185+
position: fixed;
186+
top: 16px;
187+
padding: 6px 12px;
188+
border-radius: 999px;
189+
font-size: 12px;
190+
font-weight: 600;
191+
color: #0f172a;
192+
background: rgba(255, 255, 255, 0.9);
193+
border: 1px solid rgba(15, 23, 42, 0.12);
194+
text-decoration: none;
195+
letter-spacing: 0.02em;
196+
z-index: 9999;
197+
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
198+
transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
199+
}
200+
201+
.tool-doc-link {
202+
right: 16px;
203+
}
204+
205+
.tool-home-link {
206+
right: 74px;
207+
}
208+
209+
.tool-doc-link:hover,
210+
.tool-home-link:hover {
211+
background: rgba(255, 255, 255, 1);
212+
border-color: rgba(15, 23, 42, 0.2);
213+
transform: translateY(-1px);
214+
}
182215
</style>
183216
</head>
184217
<body>
218+
<a class="tool-home-link" href="../../index.html">首页</a>
219+
<a class="tool-doc-link" href="index.html">说明</a>
185220
<div class="container">
186221
<div class="header">
187222
<h1>Base36 解码</h1>
@@ -258,6 +293,6 @@ <h1>Base36 解码</h1>
258293
decodeBase36();
259294
});
260295
</script>
261-
<script src="/assets/clicks.js" defer></script>
296+
<script src="../../assets/clicks.js" defer></script>
262297
</body>
263298
</html>

tools/base36-decode/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,6 @@ <h2>快速预览</h2>
160160
</div>
161161
</div>
162162

163-
<script src="/assets/clicks.js" defer></script>
163+
<script src="../../assets/clicks.js" defer></script>
164164
</body>
165165
</html>

0 commit comments

Comments
 (0)