跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

[...slug].astro

103 行 · 7.7 KB历史下载
1---
2import '@fontsource-variable/inter';
3import '../../styles/cage.css';
4import '../../styles/guide.css';
5import { guidePages, guideGroups, guideURL, guideHTML } from '../../lib/guide';
6export function getStaticPaths() {
7 return guidePages.map(page => ({ params: { slug: page.slug === 'index' ? undefined : page.slug }, props: { page } }));
8}
9const { page } = Astro.props;
10const base = import.meta.env.BASE_URL;
11const index = guidePages.findIndex(item => item.slug === page.slug);
12const previous = guidePages[index - 1];
13const next = guidePages[index + 1];
14const headings = page.content.getHeadings().filter(heading => heading.depth === 2);
15const html = guideHTML(await page.content.compiledContent());
16const search = guidePages.map(item => ({ title: item.title, description: item.description, url: guideURL(item.slug), text: `${item.keywords || ''} ${item.content.rawContent()}` }));
17const canonical = new URL(guideURL(page.slug), Astro.site);
18---
19<!doctype html>
20<html lang="zh-CN">
21<head>
22 <meta charset="UTF-8" />
23 <meta name="viewport" content="width=device-width, initial-scale=1" />
24 <meta name="description" content={page.description} />
25 <meta name="theme-color" content="#faf8f4" />
26 <title>{page.title} · Cage 使用文档</title>
27 <link rel="canonical" href={canonical} />
28 <link rel="icon" href={`${base}cage-icon.png`} />
29</head>
30<body class="guide-page">
31 <a class="skip-link" href="#article">跳到正文</a>
32 <header class="nav wrap guide-header">
33 <a class="brand" href={base}><img src={`${base}cage-icon.png`} width="36" height="36" alt="" /><span>Claude Cage</span></a>
34 <nav aria-label="网站导航"><a href={base}>官网首页</a><a href={guideURL('index')} aria-current="page">使用文档</a><a class="nav-download" href={`${base}#download`}>下载应用 ↓</a></nav>
35 </header>
36 <div class="guide-shell wrap">
37 <aside class="guide-sidebar" aria-label="文档导航">
38 <a class="guide-home" href={guideURL('index')}>使用文档</a>
39 <div class="guide-search" hidden>
40 <label for="guide-search">搜索文档</label>
41 <div class="search-field"><span aria-hidden="true">⌕</span><input id="guide-search" type="search" placeholder="试试:多账号、手机、断网" autocomplete="off" aria-controls="search-results" /><button type="button" id="clear-search" aria-label="清空搜索" hidden>×</button></div>
42 </div>
43 <details class="guide-mobile-menu">
44 <summary>浏览文档目录 <span aria-hidden="true">⌄</span></summary>
45 <nav aria-label="手机文档目录">{guideGroups.map(group => <section><h2>{group}</h2>{guidePages.filter(item => item.group === group).map(item => <a href={guideURL(item.slug)} aria-current={item.slug === page.slug ? 'page' : undefined}>{item.title}</a>)}</section>)}</nav>
46 </details>
47 <nav class="guide-desktop-menu" aria-label="全部章节">{guideGroups.map(group => <section><h2>{group}</h2>{guidePages.filter(item => item.group === group).map(item => <a href={guideURL(item.slug)} aria-current={item.slug === page.slug ? 'page' : undefined}>{item.title}</a>)}</section>)}</nav>
48 <p class="guide-sidebar-note">选择熟悉的系统,在同一个工作台里开发。<br />本机、云端与手机各有指南。</p>
49 </aside>
50 <main id="article" class="guide-main" tabindex="-1">
51 <section id="search-results" class="guide-results" aria-labelledby="search-title" hidden><div class="search-heading"><h2 id="search-title">搜索结果</h2><button id="close-search" type="button">返回正文</button></div><p id="search-status" role="status" aria-live="polite"></p><ul id="search-list"></ul></section>
52 <article id="guide-article">
53 <div class="guide-breadcrumb"><a href={guideURL('index')}>使用文档</a><span aria-hidden="true">/</span><span>{page.group}</span></div>
54 <header class="guide-title"><span class="eyebrow">CAGE · 使用手册</span><h1>{page.title}</h1><p>{page.description}</p></header>
55 {headings.length > 0 && <details class="article-outline" open><summary>本页内容 <span aria-hidden="true">⌄</span></summary><nav aria-label="本页目录">{headings.map(heading => <a href={`#${heading.slug}`}>{heading.text}</a>)}</nav></details>}
56 <div class="guide-prose" set:html={html} />
57 <nav class="guide-pagination" aria-label="前后章节">{previous ? <a href={guideURL(previous.slug)}><span>← 上一篇</span><strong>{previous.title}</strong></a> : <span />}{next && <a href={guideURL(next.slug)}><span>下一篇 →</span><strong>{next.title}</strong></a>}</nav>
58 <div class="guide-feedback"><p>没有解决你的问题?附上版本、系统与错误原文,帮助我们定位。</p><a href="https://github.com/Lee-xeo/Claude-Cage/issues">反馈问题 ↗</a><a href={`https://github.com/Lee-xeo/Claude-Cage/blob/main/docs/guide/${page.slug}.md`}>查看文档源码 ↗</a></div>
59 </article>
60 </main>
61 </div>
62 <footer class="wrap guide-footer"><a href={base}>Claude Cage</a><small>独立社区项目,与 Anthropic 无隶属关系。</small><a href="#article">回到正文 ↑</a></footer>
63 <script id="guide-search-data" type="application/json" set:html={JSON.stringify(search).replaceAll('<', '\\u003c')} />
64 <script>
65 type SearchPage = { title: string; description: string; url: string; text: string };
66 const searchData: SearchPage[] = JSON.parse(document.querySelector('#guide-search-data')!.textContent!);
67 const input = document.querySelector<HTMLInputElement>('#guide-search')!;
68 const results = document.querySelector<HTMLElement>('#search-results')!;
69 const article = document.querySelector<HTMLElement>('#guide-article')!;
70 const list = document.querySelector<HTMLUListElement>('#search-list')!;
71 const status = document.querySelector<HTMLElement>('#search-status')!;
72 const clear = document.querySelector<HTMLButtonElement>('#clear-search')!;
73 const normalize = (value: string) => value.normalize('NFKC').toLocaleLowerCase().replace(/\s+/g, ' ').trim();
74 const indexed = searchData.map(page => ({ ...page, haystack: normalize(`${page.title} ${page.description} ${page.text}`) }));
75 function search() {
76 const query = normalize(input.value);
77 results.hidden = !query;
78 article.hidden = !!query;
79 clear.hidden = !query;
80 list.replaceChildren();
81 if (!query) return;
82 const tokens = query.split(' ');
83 const found = indexed.filter(page => tokens.every(token => page.haystack.includes(token))).sort((a, b) => Number(normalize(b.title).includes(query)) - Number(normalize(a.title).includes(query)));
84 status.textContent = found.length ? `找到 ${found.length} 篇文档` : '没有找到相关文档。请换个关键词,或清空搜索后浏览目录。';
85 for (const page of found) {
86 const item = document.createElement('li');
87 const link = document.createElement('a'); link.href = page.url; link.textContent = page.title;
88 const summary = document.createElement('p'); summary.textContent = page.description;
89 item.append(link, summary); list.append(item);
90 }
91 }
92 function reset() { input.value = ''; search(); input.focus(); }
93 document.querySelector<HTMLElement>('.guide-search')!.hidden = false;
94 input.addEventListener('input', search);
95 input.addEventListener('keydown', event => { if (event.key === 'Escape') { event.preventDefault(); reset(); } });
96 clear.addEventListener('click', reset);
97 document.querySelector('#close-search')!.addEventListener('click', reset);
98 document.querySelectorAll<HTMLDetailsElement>('.guide-mobile-menu, .article-outline').forEach(menu => menu.addEventListener('keydown', event => {
99 if (event.key === 'Escape' && menu.open) { event.preventDefault(); menu.open = false; menu.querySelector('summary')!.focus(); }
100 }));
101 </script>
102</body>
103</html>