From 19fb597bb49fd94d75f0bbd82363e598fcd6925f Mon Sep 17 00:00:00 2001
From: toom1996 <23cm.cn@gmail.com>
Date: Sun, 6 Sep 2026 00:50:52 +0800
Subject: [PATCH] update
---
_tmp_dbg.mjs | 21 ----
nginx.conf | 5 +-
src/components/AuthModal.astro | 150 +++++++++++++++++++++++++
src/components/Index.astro | 4 +-
src/components/Item.astro | 34 +++---
src/components/LoadingScreen.astro | 154 +++++++++----------------
src/components/RunwayLooks.astro | 115 +++++--------------
src/components/StreetSnap.astro | 32 +++---
src/components/StreetSnaps.astro | 96 ++--------------
src/i18n/dictionary.ts | 2 +
src/layouts/Layout.astro | 4 +
src/lib/api.ts | 31 +++---
src/lib/favorites.ts | 16 +--
src/lib/history.ts | 8 +-
src/pages/cn/account.astro | 7 +-
src/pages/cn/item/[id].astro | 6 +-
src/pages/cn/login.astro | 173 ++++++++++++++---------------
src/pages/en/account.astro | 8 +-
src/pages/en/item/[id].astro | 6 +-
src/pages/en/login.astro | 173 ++++++++++++++---------------
20 files changed, 497 insertions(+), 548 deletions(-)
delete mode 100644 _tmp_dbg.mjs
create mode 100644 src/components/AuthModal.astro
diff --git a/_tmp_dbg.mjs b/_tmp_dbg.mjs
deleted file mode 100644
index f0dea11..0000000
--- a/_tmp_dbg.mjs
+++ /dev/null
@@ -1,21 +0,0 @@
-const BASE = "http://localhost:8090";
-const login = await (await fetch(BASE + "/api/v1/auth/login", {
- method: "POST", headers: { "Content-Type": "application/json" },
- body: JSON.stringify({ account: "root", password: "root" }),
-})).json();
-const tok = login.access_token;
-
-async function raw(method, path, body) {
- const res = await fetch(BASE + path, {
- method, headers: { "Content-Type": "application/json", Authorization: "Bearer " + tok },
- body: body ? JSON.stringify(body) : undefined,
- });
- const text = await res.text();
- console.log(method, path, "=>", res.status, text.slice(0, 200));
-}
-
-await raw("POST", "/api/v1/auth/favorites", { target_type: "runway", target_uid: "r0042h1mx", title: "t", cover: "c", brand: "b" });
-await raw("POST", "/api/v1/auth/history", { target_uid: "r0042h1mx" });
-await raw("POST", "/api/v1/auth/history", { target_uid: "r0042h1mx", extra: 1 });
-await raw("POST", "/api/v1/auth/history", JSON.stringify({ target_uid: "r0042h1mx" }));
-process.exit(0);
diff --git a/nginx.conf b/nginx.conf
index 9067475..e751ed6 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -11,8 +11,9 @@ server {
}
# 网关隔离:SSG 内部接口只存在于 backend 的 8091 端口(回环绑定,nginx 不反代)。
- # 若有人从公网域名探测 /api/ssg/*,此处直接 404,确保构建期全量数据绝不从公网出口。
- location /api/v1/ssg/ {
+ # 若有人从公网域名探测 /api/internal/ssg/*(或旧 /api/v1/ssg/*),此处直接 404,
+ # 确保构建期全量数据绝不从公网出口。
+ location ~ ^/api/(internal/ssg/|v1/ssg/) {
return 404;
}
diff --git a/src/components/AuthModal.astro b/src/components/AuthModal.astro
new file mode 100644
index 0000000..6766498
--- /dev/null
+++ b/src/components/AuthModal.astro
@@ -0,0 +1,150 @@
+---
+import { getI18n } from "@/i18n/utils"
+
+// 全站统一登录门禁,两种语义属性(按使用场景二选一,不要混用):
+// - login-required:需要登录的「动作」(收藏/翻页/看完整图…)。点击时若未登录 →
+// 就地弹出本登录层并记住该元素;登录成功后自动重放这次点击(继续原操作)。
+// - login-redirect:需要登录的「完整入口」(想直接去账户/详情受限区…)。未登录 →
+// 跳独立登录页(自动带 redirect 回跳当前页),登录完成后回原处。
+// 已登录时两者都直接放行。本组件挂在 Layout 一次,全站共用同一 store。
+const { t } = getI18n(Astro)
+const title = t('login')
+const prompt = t('login to continue')
+const accountLabel = t('username or email')
+const passwordLabel = t('password')
+const failLabel = t('login failed')
+const closeLabel = t('close')
+const fullLoginLabel = t('go to full login')
+---
+
+
+
+
+
+
{title}
+
+
+
+
{prompt}
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/Index.astro b/src/components/Index.astro
index 41718f7..ca7d91d 100644
--- a/src/components/Index.astro
+++ b/src/components/Index.astro
@@ -10,7 +10,7 @@ import { getSsgStreetSnapPopular } from "@/lib/api"
// 国际化:一行取当前语言 + 翻译函数
const { locale, t } = getI18n(Astro)
-// 首页「热门品牌」区块:构建期走 SSG 内部接口 /api/v1/ssg/index/runway(server-only),
+// 首页「热门品牌」区块:构建期走 SSG 内部接口 /api/internal/ssg/home/runway(server-only),
// 首页 runway 数据含多模块,hotBrand 为其中之一;封面/标题取自每个品牌代表走秀,
// 直接烧入静态 HTML,运行期不再请求;后端不可达则静默留空(区块隐藏)。
const popular = (await getSsgIndexRunway()).hotBrand
@@ -31,7 +31,7 @@ const galleryItems: GalleryItem[] = popular
title: b.title,
}))
-// 首页「Street Style」热门街拍:构建期走 SSG 内部接口 /api/v1/ssg/street-snaps/popular(server-only),
+// 首页「Street Style」热门街拍:构建期走 SSG 内部接口 /api/internal/ssg/street-snaps/popular(server-only),
// 返回按图片数前 N 的街拍(含封面),直接烧入静态 HTML;后端不可达则静默留空(区块回退 ComingSoon)。
const streetPopular = (await getSsgStreetSnapPopular(12)).filter((b) => b.cover && b.id)
const streetItems: { src: string; loc: string; event: string; id: string }[] = streetPopular.map((b) => {
diff --git a/src/components/Item.astro b/src/components/Item.astro
index 4742999..36931aa 100644
--- a/src/components/Item.astro
+++ b/src/components/Item.astro
@@ -111,6 +111,7 @@ if (article?.brand_id) {
{/* 单图收藏:hover 显示,已收藏常驻实心 */}