2.5 KiB
2.5 KiB
2026-08-25 工作日志
新增 /en/ 登录注册页(20:02)
- 用户要求:把 /en/ 下的 login 和 register 做出来,符合当前网站设计。
- 背景:Astro i18n
prefixDefaultLocale: true,导航 Login/Signup 链接解析为/en/login、/en/register,但这两个文件之前不存在(只有根src/pages/login.astro等 ComingSoon 占位),点开 404。 - 改动(加法式,不动根 ComingSoon 页、不动原 Login.astro/Register.astro 组件):
src/lib/api.ts:新增saveSession(token, user),写入fa_token/fa_user(与getUser/fetchMe共用 key),供登录/注册后落地本地会话。- 新建
src/components/pages/AuthForm.astro:登录/注册通用编辑风表单(propsmode: 'login'|'register')。- 设计:沿用全站黑白极简编辑风——monospace 顶边 kicker(Account / Sign In|Create Account)、
font-serif font-black大标题、monospace 副标题、黑底描边 input(auth-input)、黑底白字描边按钮(hover 反白,沿用cs-btn调性)、底部 footer 链接(注册↔登录互链)。容器用w-full max-w-[460px] mx-auto(避免 m-auto shrink-to-fit,见 MEMORY Layout 陷阱)。 - 客户端
<script>(module,可 import):读form.dataset.mode/redirect;提交 POST/api/auth/login或/api/auth/register(body JSON),成功saveSession后location.href = redirect(优先?redirect=,否则/en/);失败/网络错在auth-error内联显示;注册时校验两次密码一致。后端不可用时优雅报错,不破坏设计。
- 设计:沿用全站黑白极简编辑风——monospace 顶边 kicker(Account / Sign In|Create Account)、
- 新建
src/pages/en/login.astro、src/pages/en/register.astro:套<Layout>+<AuthForm>。 src/layouts/Layout.astro:原来<title>{111}</title>硬编码 bug,改为支持titleprop(${title} — Portfolio Studio)。属于让新页面标题正确的必要小修;导航(header)未动。
- 验证:
npm run buildBUILD_EXIT=0;AuthForm/两个 page/Layoutread_lints全 0;dist/client/en/login/index.html、en/register/index.html均含auth-form/auth-input/对应标题;python -m http.server 8088托管 dist/client,/en/login/、/en/register/均 200。 - ⚠️ 范围说明:仅做了 /en/ 版。根
/login、/cn/login(及 register 对应)仍是 ComingSoon 占位,未动。若要补齐 /cn/ 与根版,需再建src/pages/cn/login.astro等(可复用 AuthForm)。后端/api/auth/login|register是否就绪未知,未接时提交会显示内联错误。