返回 CodeWhale
page.tsx
根目录 / web / app / [locale] / app / page.tsx
1 import Link from "next/link";
2 import { PageHeader, Section } from "@/components/page-header";
3 import { Status } from "@/components/status-badge";
4 import { DesktopDownloadBlock, LinuxDownloadBlock } from "@/components/desktop-download";
5 import { DesktopShot } from "@/components/desktop-shot";
6 import { AVAILABILITY_ROWS, describeRow } from "@/lib/content/availability";
7 import { APP_COPY, appHeaderCopy } from "@/lib/content/app-page";
8 import { pickText } from "@/lib/i18n/dictionaries";
9 import { stateLabel, STATE_TONE, surfaceState } from "@/lib/surface-states";
10 import { buildPageMetadata } from "@/lib/page-meta";
11
12 export const revalidate = 300;
13
14 export async function generateMetadata({ params }: { params: Promise<{ locale: string }> }) {
15 const { locale } = await params;
16 return buildPageMetadata({
17 path: "/app",
18 locale,
19 title: pickText(APP_COPY.metadata.title, locale),
20 description: appHeaderCopy(locale).description,
21 });
22 }
23
24 /**
25 * /app — the desktop app and the hosted browser app, stated as they are
26 * today: a released macOS app and a surface that is not open yet. Copy lives
27 * in lib/content/app-page.ts and the surface table in
28 * lib/content/availability.ts, which /product reads too.
29 */
30 export default async function AppPage({ params }: { params: Promise<{ locale: string }> }) {
31 const { locale } = await params;
32 const t = (text: { en: string; zh: string }) => pickText(text, locale);
33 const header = appHeaderCopy(locale);
34 const rows = AVAILABILITY_ROWS.filter((row) => row.pages.includes("app"));
35 const desktopState = surfaceState("desktop");
36 const hostedState = surfaceState("hosted-web");
37
38 return (
39 <>
40 <PageHeader
41 title={t(APP_COPY.title)}
42 lede={header.lede}
43 pose="think"
44 meta={
45 <p className="app-status">
46 <Status tone={STATE_TONE[desktopState]}>{t(APP_COPY.surfaces.desktop)}: {stateLabel(desktopState, locale)}</Status>
47 <Status tone={STATE_TONE[hostedState]}>{t(APP_COPY.surfaces.browser)}: {stateLabel(hostedState, locale)}</Status>
48 </p>
49 }
50 actions={
51 <>
52 <Link href={`/${locale}/install`} className="btn btn-primary btn-lg">
53 {t(APP_COPY.actions.install)}
54 </Link>
55 <Link href={`/${locale}${APP_COPY.guidePath}`} className="btn btn-secondary btn-lg">
56 {t(APP_COPY.actions.guide)}
57 </Link>
58 <Link href={`/${locale}/docs/account`} className="btn btn-ghost btn-lg">
59 {t(APP_COPY.actions.signIn)}
60 </Link>
61 </>
62 }
63 />
64
65 <div className="page-body">
66 <Section id="app-shots" title={t(APP_COPY.shotsHeading)} scope={t(APP_COPY.shotsScope)}>
67 <div className="app-shots">
68 {APP_COPY.shots.map((shot, index) => (
69 <figure className="figure" key={shot.file}>
70 <div className="figure-frame">
71 <DesktopShot id={shot.file} alt={t(shot.alt)} eager={index === 0} />
72 </div>
73 <figcaption className="figure-caption">{t(shot.caption)}</figcaption>
74 </figure>
75 ))}
76 </div>
77 </Section>
78
79 <Section id="app-account" title={t(APP_COPY.accountHeading)} scope={t(APP_COPY.accountScope)}>
80 <div className="grid-2">
81 <div className="tile">
82 <h3>{t(APP_COPY.withoutTitle)}</h3>
83 <dl className="ruled-list">
84 {APP_COPY.without.map((row) => (
85 <div key={row.title.en}>
86 <dt>{t(row.title)}</dt>
87 <dd>{t(row.body)}</dd>
88 </div>
89 ))}
90 </dl>
91 </div>
92 <div className="tile">
93 <h3>{t(APP_COPY.withTitle)}</h3>
94 <dl className="ruled-list">
95 {APP_COPY.with.map((row) => (
96 <div key={row.title.en}>
97 <dt>{t(row.title)}</dt>
98 <dd>{t(row.body)}</dd>
99 </div>
100 ))}
101 </dl>
102 </div>
103 </div>
104 <p className="app-note">
105 {t(APP_COPY.signInNote)}{" "}
106 <Link href={`/${locale}/docs/account`} className="link">
107 {t(APP_COPY.actions.signIn)}
108 </Link>
109 </p>
110 </Section>
111
112 <Section id="app-runs" title={t(APP_COPY.runsHeading)}>
113 <div className="data-table-wrap">
114 <table className="data-table app-table">
115 <thead>
116 <tr>
117 <th scope="col">{t(APP_COPY.runsSurface)}</th>
118 <th scope="col">{t(APP_COPY.runsState)}</th>
119 <th scope="col">{t(APP_COPY.runsDetail)}</th>
120 </tr>
121 </thead>
122 <tbody>
123 {rows.map((row) => {
124 const view = describeRow(row, locale);
125 return (
126 <tr key={row.id}>
127 <th scope="row">{t(row.surface)}</th>
128 <td>
129 <Status tone={view.tone}>{view.status}</Status>
130 </td>
131 <td>
132 {view.detail}
133 {view.downloads.length > 0 ? <DesktopDownloadBlock downloads={view.downloads} locale={locale} /> : null}
134 {view.linux ? <LinuxDownloadBlock linux={view.linux} locale={locale} /> : null}
135 {view.link && row.href && row.linkLabel ? (
136 <>
137 {" "}
138 <Link href={`/${locale}${row.href}`} className="link">
139 {t(row.linkLabel)}
140 </Link>
141 </>
142 ) : null}
143 </td>
144 </tr>
145 );
146 })}
147 </tbody>
148 </table>
149 </div>
150 </Section>
151
152 <section className="page-section" aria-labelledby="app-start">
153 <div className="callout">
154 <h2 className="callout-title" id="app-start">{t(APP_COPY.closingTitle)}</h2>
155 <p>{t(APP_COPY.closingBody)}</p>
156 <div className="actions">
157 <Link href={`/${locale}/install`} className="btn btn-primary">{t(APP_COPY.actions.install)}</Link>
158 <Link href={`/${locale}${APP_COPY.guidePath}`} className="btn btn-secondary">
159 {t(APP_COPY.actions.guide)}
160 </Link>
161 </div>
162 </div>
163 </section>
164 </div>
165 </>
166 );
167 }
168
168 lines Plain Text