Files
frontend_v2/.workbuddy/memory/2026-08-25.md
toom1996 d64a046f82
Some checks failed
deploy / deploy (push) Has been cancelled
update
2026-08-25 21:25:20 +08:00

15 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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 组件):
1. `src/lib/api.ts`:新增 `saveSession(token, user)`,写入 `fa_token`/`fa_user`(与 `getUser`/`fetchMe` 共用 key),供登录/注册后落地本地会话。
2. 新建 `src/components/pages/AuthForm.astro`:登录/注册通用编辑风表单(props `mode: '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` 内联显示;注册时校验两次密码一致。后端不可用时优雅报错,不破坏设计。
3. 新建 `src/pages/en/login.astro`、`src/pages/en/register.astro`:套 `<Layout>` + `<AuthForm>`。
4. `src/layouts/Layout.astro`:原来 `<title>{`111`}</title>` 硬编码 bug,改为支持 `title` prop(`${title} — Portfolio Studio`)。属于让新页面标题正确的必要小修;导航(header)未动。
- 验证:`npm run build` BUILD_EXIT=0;AuthForm/两个 page/Layout `read_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` 是否就绪未知,未接时提交会显示内联错误。