merge: 以 pickerel(SQLite 重写)为准合并 main,取代 postgres/steelhead 实验线
# Conflicts: # .env.example # README.md # app/components/common/LoginModal.vue # app/components/common/RegisterModal.vue # app/components/layouts/ArcticNewOneFooter.vue # app/components/layouts/ArcticNewOneHeader.vue # app/pages/contact.vue # app/stores/user.ts # build-and-push.sh # deploy/README.md # deploy/deployment.yaml # i18n/locales/en.json # i18n/locales/zh.json # package.json # pnpm-lock.yaml # server/api/auth/login.post.ts # server/api/auth/logout.post.ts # server/api/auth/me.get.ts # server/api/auth/register.post.ts # server/api/contact.post.ts # server/utils/auth.ts
This commit is contained in:
+6
-1
@@ -1,10 +1,15 @@
|
||||
# 依赖目录
|
||||
node_modules/
|
||||
pnpm-workspace.yaml
|
||||
|
||||
# 编译产出目录
|
||||
.output/
|
||||
.nuxt/
|
||||
.nitro/
|
||||
.cache/
|
||||
dist/
|
||||
|
||||
# 本地数据(开发数据库,不进镜像)
|
||||
.data/
|
||||
|
||||
# 环境变量文件(通常不应该被打包进去)
|
||||
.env
|
||||
|
||||
+38
-13
@@ -1,16 +1,41 @@
|
||||
# 本地开发环境变量示例
|
||||
# 复制为 .env 后按需修改(.env 已被 .gitignore 忽略,不会提交)
|
||||
# =========================================================
|
||||
# Arcticnewone 本地开发环境变量示例
|
||||
# 复制为 .env 使用(.env 已被 gitignore,不会提交)
|
||||
#
|
||||
# Nuxt runtimeConfig 的环境变量映射约定:一律使用 NUXT_ 前缀
|
||||
# =========================================================
|
||||
|
||||
# PostgreSQL 连接串(docker compose 起库后默认可用,宿主机端口 5433)
|
||||
NUXT_DATABASE_URL=postgres://arcticnewone:arcticnewone_dev_password@localhost:5433/arcticnewone
|
||||
# 站点公开地址(用于 sitemap/robots/og 等绝对链接)
|
||||
NUXT_PUBLIC_SITE_URL=https://personal.virtheart.com
|
||||
|
||||
# JWT 签名密钥(生产环境务必改为随机长字符串)
|
||||
NUXT_JWT_SECRET=dev-only-secret-change-in-production
|
||||
# 会话安全密钥(生产必须设置为高强度随机值)
|
||||
# 生成方式: node -e "console.log(require('crypto').randomBytes(48).toString('hex'))"
|
||||
NUXT_SESSION_SECRET=dev-change-me-to-a-long-random-string
|
||||
|
||||
# SMTP 邮件通知(可选;不配置时联系表单/订阅仅入库)
|
||||
# NUXT_SMTP_HOST=smtp.example.com
|
||||
# NUXT_SMTP_PORT=465
|
||||
# NUXT_SMTP_USER=your-smtp-user
|
||||
# NUXT_SMTP_PASS=your-smtp-password
|
||||
# NUXT_SMTP_FROM=北极新一 <noreply@virtheart.com>
|
||||
# NUXT_SMTP_CONTACT_TO=chenchun@virtheart.com
|
||||
# 数据文件路径(默认:生产 /data/arcticnewone.db,开发 .data/arcticnewone.db)
|
||||
# NUXT_DB_PATH=/data/arcticnewone.db
|
||||
|
||||
# ---- SMTP 邮件(可选)----
|
||||
# 未配置时:联系表单与邮箱订阅仍会真实写入数据库,但不会发送邮件
|
||||
NUXT_SMTP_HOST=
|
||||
NUXT_SMTP_PORT=587
|
||||
NUXT_SMTP_USER=
|
||||
NUXT_SMTP_PASS=
|
||||
NUXT_SMTP_FROM=
|
||||
# 联系表单留言的接收邮箱
|
||||
NUXT_CONTACT_TO=chenchun@virtheart.com
|
||||
|
||||
# 管理员邮箱(逗号分隔),命中邮箱的用户在个人中心显示管理面板
|
||||
NUXT_ADMIN_EMAILS=chenchun@virtheart.com
|
||||
|
||||
# 预置管理员初始密码(仅首次初始化数据库时创建 admin 账号用;生产由 deploy.sh 注入)
|
||||
# NUXT_ADMIN_INITIAL_PASSWORD=change-me
|
||||
|
||||
# ---- OSS 文件存储(RustFS / S3 v4 兼容;凭据不写入仓库,生产由 deploy.sh 注入 Secret)----
|
||||
NUXT_OSS_ENDPOINT=oss.virtheart.com
|
||||
NUXT_OSS_ACCESS_KEY=
|
||||
NUXT_OSS_SECRET_KEY=
|
||||
NUXT_OSS_BUCKET=arcticnewone
|
||||
NUXT_OSS_REGION=us-east-1
|
||||
# 若桶公开可读,可填 https://oss.virtheart.com/arcticnewone 用于直链;留空则走 /uploads 代理
|
||||
NUXT_OSS_PUBLIC_BASE=
|
||||
|
||||
+7
-4
@@ -4,16 +4,19 @@
|
||||
# 使用国内可访问的 DaoCloud 镜像源(Docker Hub 在国内不可达)
|
||||
FROM docker.m.daocloud.io/library/node:22-alpine AS builder
|
||||
|
||||
# 启用 corepack 并安装 pnpm
|
||||
RUN corepack enable && corepack prepare pnpm@9 --activate
|
||||
# 启用 corepack 并安装 pnpm(与本地 pnpm 11 保持一致,兼容 pnpm-workspace.yaml 配置)
|
||||
RUN corepack enable && corepack prepare pnpm@11 --activate
|
||||
|
||||
# 安装原生模块编译依赖(better-sqlite3 等,构建期兜底;产物无需运行期依赖)
|
||||
RUN apk add --no-cache python3 make g++
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制依赖相关文件
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
|
||||
# 安装依赖项
|
||||
# 安装依赖项(含原生模块编译;build 需要 devDependencies,故安装全部)
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# 复制项目源代码
|
||||
|
||||
@@ -1,38 +1,26 @@
|
||||
# Arcticnewone 个人网站
|
||||
|
||||
北极新一(Arcticnewone)的个人网站,提供个人介绍、作品集、工作室服务、动态资讯、工具箱与联系页面,是一个现代化的展示型站点。
|
||||
北极新一(Arcticnewone)的个人网站,提供个人介绍、作品集、工作室服务、动态资讯、工具箱与联系页面,是一个现代化的展示型站点。已内置**真实后端**(登录/注册、联系留言、邮箱订阅、作品收藏、新闻评论、管理员收件箱)与 **中英双语、SEO、搜索分页** 等完整功能。
|
||||
|
||||
## 技术栈
|
||||
|
||||
- [Nuxt 4](https://nuxt.com/) — 应用框架(服务端渲染 + 内置 Nitro Server API)
|
||||
- [Nuxt 4](https://nuxt.com/) — 应用框架(服务端渲染 + Nitro 后端 API)
|
||||
- [Vue 3](https://vuejs.org/) — 视图层
|
||||
- [Tailwind CSS](https://tailwindcss.com/) — 样式方案(通过 `@nuxtjs/tailwindcss` 集成)
|
||||
- [GSAP](https://gsap.com/) — 页面动画(配合 Lenis 平滑滚动)
|
||||
- [Pinia](https://pinia.vuejs.org/) — 状态管理
|
||||
- [@nuxtjs/i18n](https://i18n.nuxtjs.org/) — 国际化(中/英双语)
|
||||
- [better-sqlite3](https://github.com/WiseLibs/better-sqlite3) — 数据存储(SQLite,K8s PVC 持久化)
|
||||
- [nodemailer](https://nodemailer.com/) — 邮件发送(SMTP)
|
||||
- [@nuxt/icon](https://nuxt.com/modules/icon) — 图标
|
||||
- [PostgreSQL](https://www.postgresql.org/) — 数据库(用户 / 联系留言 / 资讯订阅)
|
||||
- [node-postgres (pg)](https://node-postgres.com/) — 数据库驱动
|
||||
- [jose](https://github.com/panva/jose) — JWT 会话(httpOnly Cookie)
|
||||
- [bcryptjs](https://github.com/dcodeIO/bcryptjs) — 密码哈希
|
||||
- [nodemailer](https://nodemailer.com/) — SMTP 邮件通知(可选)
|
||||
- [pnpm](https://pnpm.io/) — 包管理器
|
||||
|
||||
## 功能
|
||||
|
||||
- 展示型页面:首页、工作室、作品集、动态资讯、工具箱、联系
|
||||
- 用户系统:注册 / 登录 / 登出(JWT + httpOnly Cookie,密码 bcrypt 哈希)
|
||||
- 联系表单:留言入库 PostgreSQL,可选 SMTP 邮件通知
|
||||
- 资讯订阅:邮箱订阅入库(唯一约束防重复),可选 SMTP 通知
|
||||
- 国际化:中/英双语,默认中文
|
||||
|
||||
## 本地开发
|
||||
|
||||
### 环境要求
|
||||
|
||||
- Node.js ≥ 20(推荐 22,与 Docker 构建镜像一致)
|
||||
- pnpm ≥ 9
|
||||
- Docker(用于本地 PostgreSQL,或自行提供 PostgreSQL 16+)
|
||||
|
||||
### 安装与启动
|
||||
|
||||
@@ -40,13 +28,10 @@
|
||||
# 1. 安装依赖
|
||||
pnpm install
|
||||
|
||||
# 2. 启动本地数据库(PostgreSQL 16,映射宿主机 5433 端口)
|
||||
docker compose up -d postgres
|
||||
|
||||
# 3. 配置环境变量(可写入 .env 文件,已被 .gitignore 忽略)
|
||||
# 2. 配置环境变量(可选,SMTP 未配置时联系/订阅仍会真实落库)
|
||||
cp .env.example .env
|
||||
|
||||
# 4. 启动开发服务器(默认 http://localhost:3000)
|
||||
# 3. 启动开发服务器(默认 http://localhost:3000)
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
@@ -58,107 +43,110 @@ pnpm dev
|
||||
| --- | --- |
|
||||
| `pnpm dev` | 启动开发服务器 |
|
||||
| `pnpm build` | 构建生产版本(生成 `.output/`) |
|
||||
| `pnpm generate` | 静态站点生成(输出到 `dist/`,注意:Server API 需要 Node 运行时不支持静态生成) |
|
||||
| `pnpm generate` | 静态站点生成(输出到 `dist/`) |
|
||||
| `pnpm preview` | 本地预览生产构建 |
|
||||
| `pnpm start` | 以 Node 方式启动 `.output/server/index.mjs` |
|
||||
|
||||
## 环境变量
|
||||
## 功能一览
|
||||
|
||||
所有变量均可通过 `.env` 文件或系统环境变量注入,Nuxt 自动读取 `NUXT_*` 前缀:
|
||||
| 模块 | 说明 |
|
||||
| --- | --- |
|
||||
| 页面 | 首页、工作室、作品(列表/详情)、动态(列表/详情)、工具箱、联系、个人中心 |
|
||||
| **后台管理** | `/admin`:Dashboard、动态/作品增删改(双语 CMS)、用户/评论/联系/订阅管理、图片管理(OSS)、操作审计日志、**站点动态配置** |
|
||||
| **动态配置** | 站点信息/联系方式/社交链接/工具箱/页脚文案/SEO 均可在 `/admin/settings` 后台修改,前台即时生效 |
|
||||
| **文件存储** | 图片上传/管理使用 OSS(RustFS,S3 v4 兼容,桶 `arcticnewone`),经 `/uploads` 代理服务 |
|
||||
| 用户系统 | 注册/登录/登出、修改密码、自助删除账号、预置 admin;个人中心(资料/收藏/评论) |
|
||||
| 交互 | 作品收藏、新闻评论、分享(X/LinkedIn/复制链接)、搜索、加载更多 |
|
||||
| 国际化 | 中/英双语,Header 一键切换;内容双语存于数据库 |
|
||||
| SEO | 动态 `sitemap.xml`/`robots.txt`/`feed.xml`(RSS)、JSON-LD、canonical、`og-image.png` |
|
||||
| 工程 | `pnpm test`(vitest:密码/SigV4/校验器/种子/配置 17 例) |
|
||||
|
||||
| 变量 | 必填 | 默认值 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `NUXT_DATABASE_URL` | ✅ | — | PostgreSQL 连接串,如 `postgres://user:pass@localhost:5433/arcticnewone` |
|
||||
| `NUXT_JWT_SECRET` | ✅(生产) | 开发默认值 | JWT 签名密钥,生产必须设置为随机长字符串(`openssl rand -hex 32`) |
|
||||
| `NUXT_SMTP_HOST` | 否 | — | SMTP 服务器地址(配置后联系表单/订阅会发邮件通知) |
|
||||
| `NUXT_SMTP_PORT` | 否 | 465 | SMTP 端口 |
|
||||
| `NUXT_SMTP_USER` | 否 | — | SMTP 用户名 |
|
||||
| `NUXT_SMTP_PASS` | 否 | — | SMTP 密码 |
|
||||
| `NUXT_SMTP_FROM` | 否 | — | 发件人,如 `北极新一 <noreply@virtheart.com>` |
|
||||
| `NUXT_SMTP_CONTACT_TO` | 否 | SMTP_USER | 收件人(联系表单与订阅通知发往此邮箱) |
|
||||
| `POSTGRES_PASSWORD` | 仅 compose | `arcticnewone_dev_password` | docker-compose 中数据库密码(本地开发) |
|
||||
> **预置管理员**:首次部署设置 `ADMIN_INITIAL_PASSWORD`(或由 `deploy.sh` 自动生成并打印)会自动创建 `admin` 账号,登录后访问 `/admin` 管理内容与配置。
|
||||
|
||||
SMTP 未配置时,联系表单与订阅**仍然正常入库**,只是不发送邮件通知。
|
||||
### 环境变量(详见 `.env.example`,Nuxt runtimeConfig 使用 `NUXT_` 前缀)
|
||||
|
||||
## Server API
|
||||
| 变量 | 说明 |
|
||||
| --- | --- |
|
||||
| `NUXT_PUBLIC_SITE_URL` | 站点公开地址(sitemap/robots/og 绝对链接) |
|
||||
| `NUXT_SESSION_SECRET` | 会话安全密钥(生产必须设置强随机值) |
|
||||
| `NUXT_DB_PATH` | 数据库文件路径(默认生产 `/data/arcticnewone.db`,开发 `.data/`) |
|
||||
| `NUXT_SMTP_HOST/PORT/USER/PASS/FROM` | SMTP 邮件服务(可选) |
|
||||
| `NUXT_CONTACT_TO` | 联系表单留言收件邮箱 |
|
||||
| `NUXT_ADMIN_EMAILS` | 管理员邮箱(逗号分隔),命中者个人中心可见管理面板 |
|
||||
| `NUXT_ADMIN_INITIAL_PASSWORD` | 预置管理员初始密码(仅首次初始化创建 admin 账号用) |
|
||||
| `NUXT_OSS_ENDPOINT/ACCESS_KEY/SECRET_KEY/BUCKET/REGION/PUBLIC_BASE` | OSS 文件存储(RustFS / S3 v4,凭据仅走 Secret,不写入仓库) |
|
||||
|
||||
项目内置 Nitro Server API(`server/` 目录),应用启动时自动建表(幂等):
|
||||
|
||||
| 接口 | 方法 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `/api/auth/register` | POST | 注册(用户名/邮箱唯一校验,成功即自动登录) |
|
||||
| `/api/auth/login` | POST | 登录(支持用户名/邮箱/手机号 + 密码) |
|
||||
| `/api/auth/logout` | POST | 登出(清除 Cookie) |
|
||||
| `/api/auth/me` | GET | 从 Cookie 恢复当前用户 |
|
||||
| `/api/contact` | POST | 提交联系表单(入库 + 可选邮件通知) |
|
||||
| `/api/newsletter/subscribe` | POST | 邮箱订阅资讯(入库,重复订阅返回 409) |
|
||||
|
||||
错误响应统一返回 `{ statusMessage: '<i18n错误码>' }`,前端按错误码显示对应语言的文案。
|
||||
> `deploy.sh` 中的对外变量名(`SESSION_SECRET`/`SMTP_*`/`CONTACT_TO`/`ADMIN_EMAILS`/`ADMIN_INITIAL_PASSWORD`/`OSS_*`)会在写入 K8s Secret 时自动加 `NUXT_` 前缀。
|
||||
|
||||
## 项目结构
|
||||
|
||||
```text
|
||||
.
|
||||
├── app/ # 应用源码(Nuxt 4 约定目录)
|
||||
│ ├── app.vue # 应用入口(全局 SEO / Meta)
|
||||
│ ├── assets/ # 静态资源(样式、图片等)
|
||||
│ ├── components/ # 组件(common / home / layouts)
|
||||
│ ├── composables/ # 组合式函数
|
||||
│ ├── layouts/ # 布局
|
||||
│ ├── pages/ # 页面(首页、工作室、作品、动态、工具、联系)
|
||||
│ ├── plugins/ # 插件(如 Lenis 平滑滚动)
|
||||
│ ├── stores/ # Pinia 状态(user / app)
|
||||
│ └── types/ # 类型定义
|
||||
├── server/ # Nitro Server API(后端)
|
||||
│ ├── api/ # 接口(auth / contact / newsletter)
|
||||
│ ├── db/ # PostgreSQL 连接池 + Schema
|
||||
│ ├── plugins/ # 启动插件(自动建表)
|
||||
│ └── utils/ # JWT 认证、校验、邮件工具
|
||||
├── i18n/
|
||||
│ └── locales/ # 国际化文案(zh.json / en.json)
|
||||
├── public/ # 公开静态文件(favicon、robots.txt 等)
|
||||
├── Dockerfile # 容器镜像构建
|
||||
├── deploy/ # 生产部署配置(Kubernetes Deployment/Service/Ingress/PostgreSQL)
|
||||
├── docker-compose.yml # 本地容器编排(应用 + PostgreSQL)
|
||||
├── nuxt.config.ts # Nuxt 配置(模块、i18n、runtimeConfig 等)
|
||||
├── tailwind.config.js # Tailwind 配置
|
||||
└── package.json # 项目依赖与脚本
|
||||
│ ├── app.vue # 应用入口(全局 SEO / Meta / JSON-LD)
|
||||
│ ├── config/ # 站点配置(品牌、邮箱、社交链接)
|
||||
│ ├── pages/ # 页面(含 account.vue 个人中心、admin/ 后台管理)
|
||||
│ ├── components/ # 组件(common / home / layouts / admin)
|
||||
│ ├── stores/ # Pinia 状态(用户、认证弹窗)
|
||||
│ └── ...
|
||||
├── server/ # Nitro 后端(utils 数据/鉴权/邮件 + api 内容/后台 + sitemap/robots + uploads)
|
||||
├── i18n/locales/ # 国际化文案(zh.json / en.json)
|
||||
├── scripts/ # 工具脚本(generate-og.mjs 生成分享图)
|
||||
├── public/ # 公开静态文件
|
||||
├── deploy/ # 生产部署配置(K8s)
|
||||
├── deploy.sh # 一条命令部署 / 升级
|
||||
├── build-and-push.sh # 版本化镜像构建推送(SWR)
|
||||
└── Dockerfile
|
||||
```
|
||||
|
||||
## 构建与部署
|
||||
## 构建与部署(一条命令)
|
||||
|
||||
构建并推送镜像:
|
||||
镜像版本取自 git tag(如 `0.0.1-dev` → `:0.0.1-dev`,同时更新 `:latest`),构建后推送华为云 SWR。
|
||||
|
||||
> SWR 兼容性:华为云 SWR 无法解析 Docker manifest list(多架构合并会报 `Invalid image`),
|
||||
> 因此版本 tag 与 `latest` 以 **amd64 单架构 manifest** 输出(生产集群为 amd64);
|
||||
> 同时分架构推送 `-amd64`/`-arm64` 标签,arm64 环境可按需使用。
|
||||
|
||||
```bash
|
||||
./build-and-push.sh
|
||||
# 1. 打版本标签
|
||||
git add -A && git commit -m "release: 0.0.1-dev"
|
||||
git tag 0.0.1-dev
|
||||
|
||||
# 2. 设置环境变量(凭据绝不写入仓库)
|
||||
export SWR_REGISTRY="swr.cn-north-4.myhuaweicloud.com"
|
||||
export SWR_NAMESPACE="virtheart"
|
||||
export SWR_USERNAME="<用户名>"
|
||||
export SWR_PASSWORD="<密码>"
|
||||
# 可选:export SESSION_SECRET="$(openssl rand -hex 32)" / SMTP_* / CONTACT_TO / ADMIN_EMAILS
|
||||
|
||||
# 3. 一条命令:构建镜像 + 推送 + 更新集群 + 滚动升级
|
||||
./deploy.sh 0.0.1-dev # 不带参数则自动取最新 git tag
|
||||
```
|
||||
|
||||
脚本从环境变量读取 SWR 凭据(`SWR_REGISTRY`、`SWR_NAMESPACE`、`SWR_USERNAME`、`SWR_PASSWORD`),
|
||||
多架构(`linux/amd64,linux/arm64`)一步构建并推送到华为云 SWR(`--output` 使用 `oci-mediatypes=false` 输出 Docker V2 manifest,SWR 可正常解析)。
|
||||
`deploy.sh` 自动完成:构建推送版本化镜像 → 注入 Secret(会话密钥/SMTP/管理员)与 ConfigMap(站点地址/DB 路径)→ `kubectl apply`(namespace/PVC/Deployment/Service/Ingress)→ 等待滚动更新 → 健康检查。
|
||||
|
||||
Dockerfile 基础镜像使用国内可访问的 DaoCloud 镜像源(`docker.m.daocloud.io/library/node:22-alpine`,Docker Hub 在国内不可达)。
|
||||
|
||||
本地一键启动(应用 + PostgreSQL,与生产一致):
|
||||
### 仅构建镜像(不部署)
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
./build-and-push.sh # 版本取最新 git tag
|
||||
./build-and-push.sh 0.0.1-dev # 显式指定版本
|
||||
```
|
||||
|
||||
生产部署使用 `deploy/` 目录下的 Kubernetes 配置(Deployment / Service / Ingress / 可选 PostgreSQL),
|
||||
镜像统一推送到华为云 SWR(`swr.cn-north-4.myhuaweicloud.com/virtheart/arcticnewone:latest`),
|
||||
部署、Secret 创建与回滚步骤见 [deploy/README.md](deploy/README.md)。
|
||||
### 生产部署说明
|
||||
|
||||
- 域名 `personal.virtheart.com`,Traefik Ingress + cert-manager 自动签发证书
|
||||
- SQLite 数据持久化在 PVC `arcticnewone-data`(挂载 `/data`),Pod 升级/重启不丢数据
|
||||
- 回滚:`kubectl rollout undo deployment/arcticnewone -n arcticnewone`
|
||||
- 详见 [deploy/README.md](deploy/README.md)
|
||||
|
||||
## 国际化(i18n)
|
||||
|
||||
项目使用 `@nuxtjs/i18n` 实现中/英双语:
|
||||
|
||||
- 语言文件位于 `i18n/locales/`:`zh.json`(中文)、`en.json`(英文)
|
||||
- 默认语言为中文(`defaultLocale: 'zh'`),URL 不包含语言前缀(`strategy: 'no_prefix'`),不自动探测浏览器语言
|
||||
- 组件中通过 `useI18n()` 的 `t()` 方法读取文案,例如 `t('nav.home')`
|
||||
- 服务端错误码与文案键一一对应(如 `auth.emailTaken`),新增接口错误时需同步添加中英文键
|
||||
|
||||
新增文案时,在 `zh.json` 和 `en.json` 中同步添加对应键即可。
|
||||
- 默认语言为中文(`defaultLocale: 'zh'`),URL 不包含语言前缀(`strategy: 'no_prefix'`),Header 提供中/EN 切换
|
||||
- 组件中通过 `useI18n()` 的 `t()` 方法读取文案;新增文案时同步更新两个语言文件(可用根目录脚本校验键对齐)
|
||||
|
||||
## 说明
|
||||
|
||||
本项目不含任何密钥或敏感信息;本地环境变量请使用 `.env` 文件(已被 `.gitignore` 忽略)。
|
||||
- 本项目不含任何密钥或敏感信息;本地环境变量请使用 `.env` 文件(已被 `.gitignore` 忽略)
|
||||
- 联系/订阅依赖 SMTP:未配置时数据仍真实写入数据库,仅在管理面板可见但不会发邮件
|
||||
- 社交链接为品牌占位地址(`app/config/site.ts`),正式上线前请替换为真实账号
|
||||
|
||||
+38
-11
@@ -1,29 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import { useHead, useSeoMeta } from '#imports'
|
||||
import { computed } from 'vue'
|
||||
import { useHead, useSeoMeta, useRuntimeConfig, useRoute } from '#imports'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { settings, loc } = useSiteSettings()
|
||||
const { public: publicCfg } = useRuntimeConfig()
|
||||
const route = useRoute()
|
||||
const baseUrl = String(publicCfg.siteUrl || '').replace(/\/$/, '')
|
||||
|
||||
// 站点通用基础信息
|
||||
const siteImage = '/og-image.png'
|
||||
const siteImage = baseUrl ? `${baseUrl}/og-image.png` : '/og-image.png'
|
||||
|
||||
// 配置全局 Title 模板
|
||||
// 配置全局 Title 模板 + canonical(SEO)
|
||||
useHead({
|
||||
titleTemplate: (titleChunk?: string) => {
|
||||
const siteName = t('app.name')
|
||||
const siteName = settings.value?.site.name || t('app.name')
|
||||
return titleChunk ? `${titleChunk} - ${siteName}` : siteName
|
||||
}
|
||||
},
|
||||
link: [
|
||||
{ rel: 'canonical', href: computed(() => (baseUrl ? `${baseUrl}${route.path}` : undefined)) },
|
||||
],
|
||||
// JSON-LD 结构化数据(Organization,取自后台动态配置)
|
||||
script: [
|
||||
{
|
||||
type: 'application/ld+json',
|
||||
innerHTML: JSON.stringify({
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'Organization',
|
||||
name: settings.value?.site.name || t('app.name'),
|
||||
alternateName: settings.value?.site.brand || '',
|
||||
description: loc(settings.value?.site.description) || t('app.description'),
|
||||
url: baseUrl || undefined,
|
||||
logo: siteImage,
|
||||
sameAs: (settings.value?.socials ?? []).map((s) => s.url),
|
||||
}),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
// 配置全局基础 SEO 和 Meta (响应式支持国际化)
|
||||
// 配置全局基础 SEO 和 Meta (取自后台动态配置,响应式国际化)
|
||||
useSeoMeta({
|
||||
description: () => t('app.description'),
|
||||
ogTitle: () => t('app.name'),
|
||||
ogDescription: () => t('app.description'),
|
||||
description: () => loc(settings.value?.site.description) || t('app.description'),
|
||||
keywords: () => loc(settings.value?.seo.keywords) || undefined,
|
||||
ogTitle: () => settings.value?.site.name || t('app.name'),
|
||||
ogDescription: () => loc(settings.value?.site.description) || t('app.description'),
|
||||
ogImage: siteImage,
|
||||
ogType: 'website',
|
||||
twitterCard: 'summary_large_image',
|
||||
twitterTitle: () => t('app.name'),
|
||||
twitterDescription: () => t('app.description'),
|
||||
twitterTitle: () => settings.value?.site.name || t('app.name'),
|
||||
twitterDescription: () => loc(settings.value?.site.description) || t('app.description'),
|
||||
twitterImage: siteImage,
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<span
|
||||
class="inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-semibold"
|
||||
:class="toneClass"
|
||||
>
|
||||
<slot />
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(defineProps<{ tone?: 'gray' | 'green' | 'red' | 'amber' | 'black' | 'blue' }>(), {
|
||||
tone: 'gray',
|
||||
})
|
||||
const toneClass = {
|
||||
gray: 'bg-gray-100 text-gray-600',
|
||||
green: 'bg-green-50 text-green-700',
|
||||
red: 'bg-red-50 text-red-700',
|
||||
amber: 'bg-amber-50 text-amber-700',
|
||||
black: 'bg-black text-white',
|
||||
blue: 'bg-blue-50 text-blue-700',
|
||||
}[props.tone]
|
||||
</script>
|
||||
@@ -0,0 +1,130 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台正文内容块编辑器(动态/作品共用)。
|
||||
* v-model 绑定块数组 `{ type, text }[]`,支持添加/删除/上移/下移。
|
||||
* 图片块以 URL 文本承载。
|
||||
*/
|
||||
import { computed } from 'vue'
|
||||
|
||||
interface Block {
|
||||
type: string
|
||||
text: string
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<{ modelValue?: Block[]; label?: string; placeholder?: string }>(), {
|
||||
modelValue: () => [],
|
||||
label: '正文内容',
|
||||
placeholder: '输入内容…',
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: Block[]] }>()
|
||||
|
||||
const blocks = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => emit('update:modelValue', v),
|
||||
})
|
||||
|
||||
const BLOCK_TYPES = [
|
||||
{ value: 'paragraph', label: '段落' },
|
||||
{ value: 'heading', label: '标题' },
|
||||
{ value: 'quote', label: '引用' },
|
||||
{ value: 'image', label: '图片' },
|
||||
]
|
||||
|
||||
const addBlock = () => {
|
||||
blocks.value = [...blocks.value, { type: 'paragraph', text: '' }]
|
||||
}
|
||||
const removeBlock = (i: number) => {
|
||||
blocks.value = blocks.value.filter((_, idx) => idx !== i)
|
||||
}
|
||||
const moveUp = (i: number) => {
|
||||
if (i === 0) return
|
||||
const arr = [...blocks.value]
|
||||
const tmp = arr[i - 1]
|
||||
arr[i - 1] = arr[i]
|
||||
arr[i] = tmp
|
||||
blocks.value = arr
|
||||
}
|
||||
const moveDown = (i: number) => {
|
||||
if (i >= blocks.value.length - 1) return
|
||||
const arr = [...blocks.value]
|
||||
const tmp = arr[i + 1]
|
||||
arr[i + 1] = arr[i]
|
||||
arr[i] = tmp
|
||||
blocks.value = arr
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<label class="text-sm font-semibold text-gray-800">{{ label }}</label>
|
||||
<button
|
||||
type="button"
|
||||
@click="addBlock"
|
||||
class="flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-gray-200 text-xs font-semibold text-gray-700 hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
<Icon name="ph:plus" class="w-3.5 h-3.5" /> 添加块
|
||||
</button>
|
||||
</div>
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-if="!blocks.length"
|
||||
class="text-sm text-gray-400 py-6 text-center border border-dashed border-gray-200 rounded-xl"
|
||||
>
|
||||
暂无内容块,点击「添加块」开始
|
||||
</div>
|
||||
<div
|
||||
v-for="(block, i) in blocks"
|
||||
:key="i"
|
||||
class="border border-gray-200 rounded-xl bg-white p-3"
|
||||
>
|
||||
<div class="flex items-center gap-2 mb-2">
|
||||
<select
|
||||
v-model="block.type"
|
||||
class="px-2 py-1.5 rounded-lg border border-gray-200 text-xs outline-none focus:border-black bg-white"
|
||||
>
|
||||
<option v-for="t in BLOCK_TYPES" :key="t.value" :value="t.value">{{ t.label }}</option>
|
||||
</select>
|
||||
<span class="text-xs text-gray-400">
|
||||
{{ block.type === 'image' ? '图片 URL' : '文本内容' }}
|
||||
</span>
|
||||
<div class="ml-auto flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="i === 0"
|
||||
@click="moveUp(i)"
|
||||
class="w-7 h-7 rounded-lg hover:bg-gray-100 text-gray-500 disabled:opacity-30 flex items-center justify-center transition-colors"
|
||||
aria-label="上移"
|
||||
>
|
||||
<Icon name="ph:arrow-up" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="i >= blocks.length - 1"
|
||||
@click="moveDown(i)"
|
||||
class="w-7 h-7 rounded-lg hover:bg-gray-100 text-gray-500 disabled:opacity-30 flex items-center justify-center transition-colors"
|
||||
aria-label="下移"
|
||||
>
|
||||
<Icon name="ph:arrow-down" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="removeBlock(i)"
|
||||
class="w-7 h-7 rounded-lg hover:bg-red-50 text-gray-400 hover:text-red-600 flex items-center justify-center transition-colors"
|
||||
aria-label="删除"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<textarea
|
||||
v-model="block.text"
|
||||
:rows="block.type === 'image' ? 2 : 4"
|
||||
:placeholder="block.type === 'image' ? '图片 URL(如 /uploads/xxx 或 https://…)' : placeholder"
|
||||
class="w-full px-3 py-2 rounded-lg border border-gray-200 bg-gray-50 text-sm outline-none transition-all focus:border-black focus:bg-white resize-y"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<button
|
||||
:type="type"
|
||||
:disabled="disabled || loading"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl font-semibold transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-black/10 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:class="[sizeClass, variantClass, block ? 'w-full' : '']"
|
||||
@click="emit('click', $event)"
|
||||
>
|
||||
<Icon v-if="loading" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
<slot />
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
type?: 'button' | 'submit'
|
||||
variant?: 'primary' | 'secondary' | 'danger' | 'ghost'
|
||||
size?: 'sm' | 'md' | 'lg'
|
||||
loading?: boolean
|
||||
disabled?: boolean
|
||||
block?: boolean
|
||||
}>(),
|
||||
{ type: 'button', variant: 'primary', size: 'md', loading: false, disabled: false, block: false },
|
||||
)
|
||||
const emit = defineEmits<{ click: [e: MouseEvent] }>()
|
||||
|
||||
const sizeClass = {
|
||||
sm: 'px-3 py-1.5 text-xs',
|
||||
md: 'px-4 py-2 text-sm',
|
||||
lg: 'px-6 py-3 text-base',
|
||||
}[props.size]
|
||||
|
||||
const variantClass = {
|
||||
primary: 'bg-black text-white hover:bg-gray-800 shadow-sm',
|
||||
secondary: 'bg-gray-100 text-gray-800 hover:bg-gray-200',
|
||||
danger: 'bg-red-600 text-white hover:bg-red-700 shadow-sm',
|
||||
ghost: 'text-gray-600 hover:bg-gray-100',
|
||||
}[props.variant]
|
||||
</script>
|
||||
@@ -0,0 +1,16 @@
|
||||
<template>
|
||||
<div class="rounded-2xl border border-gray-100 bg-white shadow-sm">
|
||||
<div v-if="title || $slots.actions" class="flex items-center justify-between gap-3 border-b border-gray-100 px-5 py-4">
|
||||
<div>
|
||||
<h3 v-if="title" class="text-base font-bold text-black">{{ title }}</h3>
|
||||
<p v-if="subtitle" class="mt-0.5 text-sm text-gray-500">{{ subtitle }}</p>
|
||||
</div>
|
||||
<div v-if="$slots.actions" class="flex items-center gap-2"><slot name="actions" /></div>
|
||||
</div>
|
||||
<div class="p-5"><slot /></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ title?: string; subtitle?: string }>(), { title: '', subtitle: '' })
|
||||
</script>
|
||||
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<AdminModal :open="open" title="确认操作" @update:open="emit('update:open', $event)">
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full"
|
||||
:class="danger ? 'bg-red-50 text-red-600' : 'bg-gray-100 text-gray-600'"
|
||||
>
|
||||
<Icon :name="danger ? 'ph:warning-fill' : 'ph:question-fill'" class="w-5 h-5" />
|
||||
</div>
|
||||
<p class="text-sm text-gray-700 leading-relaxed">{{ message }}</p>
|
||||
</div>
|
||||
<template #footer>
|
||||
<AdminButton variant="secondary" size="sm" :disabled="loading" @click="emit('update:open', false)">取消</AdminButton>
|
||||
<AdminButton :variant="danger ? 'danger' : 'primary'" size="sm" :loading="loading" @click="emit('confirm')">
|
||||
确认
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminModal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ open: boolean; message: string; danger?: boolean; loading?: boolean }>(), {
|
||||
danger: false,
|
||||
loading: false,
|
||||
})
|
||||
const emit = defineEmits<{ 'update:open': [v: boolean]; confirm: [] }>()
|
||||
</script>
|
||||
@@ -0,0 +1,88 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台通用确认弹窗(删除等危险操作)。
|
||||
* 通过 Teleport 渲染到 body,支持危险色与加载态。
|
||||
*/
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
open: boolean
|
||||
title?: string
|
||||
message?: string
|
||||
confirmText?: string
|
||||
danger?: boolean
|
||||
loading?: boolean
|
||||
}>(),
|
||||
{
|
||||
title: '确认操作',
|
||||
message: '确定要执行该操作吗?',
|
||||
confirmText: '确认',
|
||||
danger: true,
|
||||
loading: false,
|
||||
},
|
||||
)
|
||||
|
||||
const emit = defineEmits<{ confirm: []; cancel: [] }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="confirm-fade">
|
||||
<div v-if="open" class="fixed inset-0 z-[100] flex items-center justify-center p-4">
|
||||
<div class="absolute inset-0 bg-black/40 backdrop-blur-sm" @click="emit('cancel')"></div>
|
||||
<div class="relative w-full max-w-sm bg-white rounded-2xl shadow-2xl p-6">
|
||||
<div class="flex items-start gap-4">
|
||||
<div
|
||||
class="w-10 h-10 rounded-full flex items-center justify-center flex-shrink-0"
|
||||
:class="danger ? 'bg-red-50 text-red-600' : 'bg-gray-100 text-gray-600'"
|
||||
>
|
||||
<Icon name="ph:warning-circle" class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-lg font-bold text-black">{{ title }}</h3>
|
||||
<p class="mt-1 text-sm text-gray-600 break-words">{{ message }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-6 flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
@click="emit('cancel')"
|
||||
class="px-4 py-2 rounded-lg border border-gray-200 text-sm font-semibold text-gray-700 hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
取消
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="loading"
|
||||
@click="emit('confirm')"
|
||||
class="px-4 py-2 rounded-lg text-sm font-semibold text-white flex items-center gap-2 transition-colors disabled:opacity-50"
|
||||
:class="danger ? 'bg-red-600 hover:bg-red-700' : 'bg-black hover:bg-gray-800'"
|
||||
>
|
||||
<Icon v-if="loading" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
{{ confirmText }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.confirm-fade-enter-active,
|
||||
.confirm-fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
.confirm-fade-enter-active .relative,
|
||||
.confirm-fade-leave-active .relative {
|
||||
transition: transform 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
.confirm-fade-enter-from,
|
||||
.confirm-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
.confirm-fade-enter-from .relative,
|
||||
.confirm-fade-leave-to .relative {
|
||||
transform: translateY(8px) scale(0.98);
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,17 @@
|
||||
<template>
|
||||
<div class="flex flex-col items-center justify-center gap-3 py-14 text-center">
|
||||
<div class="flex h-14 w-14 items-center justify-center rounded-full bg-gray-100 text-gray-400">
|
||||
<Icon :name="icon" class="w-7 h-7" />
|
||||
</div>
|
||||
<p class="text-sm font-semibold text-gray-700">{{ title }}</p>
|
||||
<p v-if="description" class="text-sm text-gray-500 max-w-sm">{{ description }}</p>
|
||||
<div v-if="$slots.action" class="mt-1"><slot name="action" /></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ icon?: string; title: string; description?: string }>(), {
|
||||
icon: 'ph:tray',
|
||||
description: '',
|
||||
})
|
||||
</script>
|
||||
@@ -0,0 +1,86 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台图片字段:URL 输入 + 本地图片上传(调 /api/admin/upload)+ 预览。
|
||||
* v-model 绑定 URL 字符串。
|
||||
*/
|
||||
import { ref } from 'vue'
|
||||
|
||||
withDefaults(defineProps<{ modelValue?: string | null; label?: string }>(), {
|
||||
modelValue: '',
|
||||
label: '图片',
|
||||
})
|
||||
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: string] }>()
|
||||
|
||||
const fileInput = ref<HTMLInputElement | null>(null)
|
||||
const uploading = ref(false)
|
||||
const error = ref('')
|
||||
|
||||
const choose = () => fileInput.value?.click()
|
||||
|
||||
const onFileChange = async (e: Event) => {
|
||||
const input = e.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
uploading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
const res = await $fetch<{ ok: boolean; url: string }>('/api/admin/upload', {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
})
|
||||
emit('update:modelValue', res.url)
|
||||
} catch (err: any) {
|
||||
error.value = err?.data?.message || '上传失败'
|
||||
} finally {
|
||||
uploading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<label class="text-sm font-semibold text-gray-800">{{ label }}</label>
|
||||
<button
|
||||
v-if="modelValue"
|
||||
type="button"
|
||||
@click="emit('update:modelValue', '')"
|
||||
class="text-xs text-gray-400 hover:text-red-600 flex items-center gap-1 transition-colors"
|
||||
>
|
||||
<Icon name="ph:x-circle" class="w-3.5 h-3.5" /> 清除
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-3">
|
||||
<input
|
||||
:value="modelValue"
|
||||
type="text"
|
||||
placeholder="图片 URL(本地 /uploads/... 或 https://...)"
|
||||
@input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
|
||||
class="flex-1 min-w-0 px-3 py-2 rounded-lg border border-gray-200 bg-white text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/5"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="uploading"
|
||||
@click="choose"
|
||||
class="flex items-center gap-1.5 px-3 py-2 rounded-lg bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-colors disabled:opacity-60 flex-shrink-0"
|
||||
>
|
||||
<Icon v-if="uploading" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
<Icon v-else name="ph:upload-simple" class="w-4 h-4" />
|
||||
{{ uploading ? '上传中…' : '上传图片' }}
|
||||
</button>
|
||||
<input ref="fileInput" type="file" accept="image/*" class="hidden" @change="onFileChange" />
|
||||
</div>
|
||||
<div v-if="modelValue" class="mt-3">
|
||||
<img
|
||||
:src="modelValue"
|
||||
alt="图片预览"
|
||||
class="h-32 w-auto max-w-full rounded-lg border border-gray-100 object-cover"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="error" class="mt-1 text-xs text-red-600">{{ error }}</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<div>
|
||||
<label v-if="label" class="block text-sm font-semibold text-gray-800 mb-1.5">{{ label }}<span v-if="required" class="text-red-500 ml-0.5">*</span></label>
|
||||
<input
|
||||
:type="type"
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:required="required"
|
||||
class="w-full rounded-xl border bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:ring-2"
|
||||
:class="error ? 'border-red-300 focus:border-red-500 focus:ring-red-500/10' : 'border-gray-200 focus:border-black focus:ring-black/10'"
|
||||
@input="emit('update:modelValue', ($event.target as HTMLInputElement).value)"
|
||||
/>
|
||||
<p v-if="error" class="mt-1 text-xs text-red-600">{{ error }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
label?: string
|
||||
type?: string
|
||||
placeholder?: string
|
||||
error?: string
|
||||
disabled?: boolean
|
||||
required?: boolean
|
||||
}>(),
|
||||
{ label: '', type: 'text', placeholder: '', error: '', disabled: false, required: false },
|
||||
)
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: string] }>()
|
||||
</script>
|
||||
@@ -0,0 +1,55 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="modal">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-[150] flex items-end justify-center bg-black/40 p-0 sm:items-center sm:p-4"
|
||||
@click.self="emit('update:open', false)"
|
||||
>
|
||||
<!-- 移动端底部弹层;≥sm 居中 -->
|
||||
<div class="w-full max-w-lg rounded-t-2xl bg-white shadow-2xl sm:rounded-2xl sm:max-h-[85vh] sm:flex sm:flex-col max-h-[92vh] flex flex-col">
|
||||
<div class="flex items-center justify-between border-b border-gray-100 px-6 py-4">
|
||||
<h3 class="text-lg font-bold text-black">{{ title }}</h3>
|
||||
<button @click="emit('update:open', false)" class="text-gray-400 hover:text-gray-600" aria-label="close">
|
||||
<Icon name="ph:x" class="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="px-6 py-5 overflow-y-auto min-h-0"><slot /></div>
|
||||
<div v-if="$slots.footer" class="flex justify-end gap-2 border-t border-gray-100 px-6 py-4">
|
||||
<slot name="footer" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ open: boolean; title?: string }>(), { title: '' })
|
||||
const emit = defineEmits<{ 'update:open': [v: boolean] }>()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: opacity 0.22s ease;
|
||||
}
|
||||
.modal-enter-from,
|
||||
.modal-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
.modal-enter-active > div,
|
||||
.modal-leave-active > div {
|
||||
transition: transform 0.28s ease;
|
||||
}
|
||||
.modal-enter-from > div,
|
||||
.modal-leave-to > div {
|
||||
transform: translateY(24px);
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.modal-enter-from > div,
|
||||
.modal-leave-to > div {
|
||||
transform: scale(0.97) translateY(8px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 mb-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-black">{{ title }}</h1>
|
||||
<p v-if="subtitle" class="mt-1 text-sm text-gray-500">{{ subtitle }}</p>
|
||||
</div>
|
||||
<div v-if="$slots.actions" class="flex items-center gap-2"><slot name="actions" /></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ title: string; subtitle?: string }>(), { subtitle: '' })
|
||||
</script>
|
||||
@@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div v-if="total > 0" class="flex items-center justify-between gap-4 text-sm">
|
||||
<p class="text-gray-500">共 {{ total }} 条</p>
|
||||
<div class="flex items-center gap-2">
|
||||
<AdminButton variant="secondary" size="sm" :disabled="page <= 1" @click="emit('page', page - 1)">上一页</AdminButton>
|
||||
<span class="text-gray-600 px-1">{{ page }} / {{ totalPages }}</span>
|
||||
<AdminButton variant="secondary" size="sm" :disabled="page >= totalPages" @click="emit('page', page + 1)">下一页</AdminButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
const props = withDefaults(
|
||||
defineProps<{ total: number; page: number; pageSize?: number }>(),
|
||||
{ pageSize: 20 },
|
||||
)
|
||||
const emit = defineEmits<{ page: [p: number] }>()
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(props.total / props.pageSize)))
|
||||
</script>
|
||||
@@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<div>
|
||||
<label v-if="label" class="block text-sm font-semibold text-gray-800 mb-1.5">{{ label }}</label>
|
||||
<select
|
||||
:value="modelValue"
|
||||
:disabled="disabled"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10 disabled:opacity-50"
|
||||
@change="emit('update:modelValue', ($event.target as HTMLSelectElement).value)"
|
||||
>
|
||||
<option v-for="o in options" :key="o.value" :value="o.value">{{ o.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
interface Option {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
withDefaults(defineProps<{ modelValue: string; options: Option[]; label?: string; disabled?: boolean }>(), {
|
||||
label: '',
|
||||
disabled: false,
|
||||
})
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: string] }>()
|
||||
</script>
|
||||
@@ -0,0 +1,107 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台左侧导航栏:按「内容 / 数据 / 系统」分组,底部返回前台。
|
||||
* 高亮当前路由;点击任意导航项时向父级发出 navigate 事件(移动端关闭侧栏)。
|
||||
*/
|
||||
import { useRoute } from '#app'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
const route = useRoute()
|
||||
const emit = defineEmits<{ navigate: [] }>()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
interface SidebarItem {
|
||||
to: string
|
||||
label: string
|
||||
icon: string
|
||||
}
|
||||
|
||||
interface SidebarGroup {
|
||||
label: string
|
||||
items: SidebarItem[]
|
||||
}
|
||||
|
||||
const groups: SidebarGroup[] = [
|
||||
{
|
||||
label: '内容',
|
||||
items: [
|
||||
{ to: '/admin', label: 'Dashboard', icon: 'ph:gauge' },
|
||||
{ to: '/admin/news', label: '动态管理', icon: 'ph:newspaper' },
|
||||
{ to: '/admin/work', label: '作品管理', icon: 'ph:image-square' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '数据',
|
||||
items: [
|
||||
{ to: '/admin/users', label: '用户管理', icon: 'ph:users-three' },
|
||||
{ to: '/admin/comments', label: '评论管理', icon: 'ph:chat-circle-text' },
|
||||
{ to: '/admin/contacts', label: '联系留言', icon: 'ph:envelope-simple' },
|
||||
{ to: '/admin/subscribers', label: '订阅管理', icon: 'ph:paper-plane-tilt' },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: '系统',
|
||||
items: [
|
||||
{ to: '/admin/uploads', label: '图片管理', icon: 'ph:image' },
|
||||
{ to: '/admin/audit', label: '操作日志', icon: 'ph:list-checks' },
|
||||
{ to: '/admin/settings', label: '站点设置', icon: 'ph:gear-six' },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const isActive = (to: string) => route.path === to
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col h-full bg-black text-white">
|
||||
<NuxtLink
|
||||
to="/admin"
|
||||
class="flex items-center gap-3 px-5 h-16 border-b border-white/10 shrink-0"
|
||||
@click="emit('navigate')"
|
||||
>
|
||||
<div
|
||||
class="w-8 h-8 rounded-full bg-white text-black flex items-center justify-center font-bold text-sm"
|
||||
>
|
||||
A
|
||||
</div>
|
||||
<div class="leading-tight">
|
||||
<p class="text-sm font-bold">{{ settings?.site.brand }}</p>
|
||||
<p class="text-[11px] text-white/50">后台管理</p>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
|
||||
<nav class="flex-1 py-5 px-3 overflow-y-auto space-y-6">
|
||||
<div v-for="group in groups" :key="group.label">
|
||||
<p
|
||||
class="px-3 mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-white/40"
|
||||
>
|
||||
{{ group.label }}
|
||||
</p>
|
||||
<div class="space-y-1">
|
||||
<NuxtLink
|
||||
v-for="item in group.items"
|
||||
:key="item.to"
|
||||
:to="item.to"
|
||||
class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors"
|
||||
:class="isActive(item.to) ? 'bg-white text-black' : 'text-white/70 hover:bg-white/10 hover:text-white'"
|
||||
@click="emit('navigate')"
|
||||
>
|
||||
<Icon :name="item.icon" class="w-[18px] h-[18px]" />
|
||||
{{ item.label }}
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="p-3 border-t border-white/10 shrink-0">
|
||||
<NuxtLink
|
||||
to="/"
|
||||
class="flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium text-white/70 hover:bg-white/10 hover:text-white transition-colors"
|
||||
@click="emit('navigate')"
|
||||
>
|
||||
<Icon name="ph:arrow-left" class="w-[18px] h-[18px]" />
|
||||
返回前台
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<template>
|
||||
<div class="space-y-3 p-2">
|
||||
<div v-for="i in rows" :key="i" class="animate-pulse">
|
||||
<div class="h-3.5 rounded bg-gray-100" :style="{ width: `${40 + ((i * 13) % 50)}%` }" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(defineProps<{ rows?: number }>(), { rows: 5 })
|
||||
</script>
|
||||
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<div>
|
||||
<label v-if="label" class="block text-sm font-semibold text-gray-800 mb-1.5">{{ label }}<span v-if="required" class="text-red-500 ml-0.5">*</span></label>
|
||||
<textarea
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:disabled="disabled"
|
||||
:rows="rows"
|
||||
class="w-full rounded-xl border bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:ring-2 resize-y"
|
||||
:class="error ? 'border-red-300 focus:border-red-500 focus:ring-red-500/10' : 'border-gray-200 focus:border-black focus:ring-black/10'"
|
||||
@input="emit('update:modelValue', ($event.target as HTMLTextAreaElement).value)"
|
||||
/>
|
||||
<p v-if="error" class="mt-1 text-xs text-red-600">{{ error }}</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
label?: string
|
||||
placeholder?: string
|
||||
error?: string
|
||||
disabled?: boolean
|
||||
required?: boolean
|
||||
rows?: number
|
||||
}>(),
|
||||
{ label: '', placeholder: '', error: '', disabled: false, required: false, rows: 3 },
|
||||
)
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: string] }>()
|
||||
</script>
|
||||
@@ -0,0 +1,54 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div class="fixed top-4 right-4 z-[200] flex flex-col gap-2 w-80 max-w-[calc(100vw-2rem)]">
|
||||
<TransitionGroup name="toast">
|
||||
<div
|
||||
v-for="t in toast.toasts"
|
||||
:key="t.id"
|
||||
class="flex items-start gap-3 rounded-xl border bg-white px-4 py-3 shadow-lg"
|
||||
:class="borderClass(t.type)"
|
||||
>
|
||||
<Icon :name="iconFor(t.type)" class="w-5 h-5 mt-0.5" :class="iconClass(t.type)" />
|
||||
<p class="flex-1 text-sm text-gray-800 break-words">{{ t.message }}</p>
|
||||
<button @click="toast.remove(t.id)" class="text-gray-400 hover:text-gray-600" aria-label="close">
|
||||
<Icon name="ph:x" class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</TransitionGroup>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
const borderClass = (type: string) => {
|
||||
if (type === 'success') return 'border-green-200'
|
||||
if (type === 'error') return 'border-red-200'
|
||||
return 'border-gray-200'
|
||||
}
|
||||
const iconFor = (type: string) => {
|
||||
if (type === 'success') return 'ph:check-circle-fill'
|
||||
if (type === 'error') return 'ph:warning-circle-fill'
|
||||
return 'ph:info-fill'
|
||||
}
|
||||
const iconClass = (type: string) => {
|
||||
if (type === 'success') return 'text-green-600'
|
||||
if (type === 'error') return 'text-red-600'
|
||||
return 'text-gray-400'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.toast-enter-active,
|
||||
.toast-leave-active {
|
||||
transition: all 0.25s ease;
|
||||
}
|
||||
.toast-enter-from,
|
||||
.toast-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(16px);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<button
|
||||
type="button"
|
||||
class="relative inline-flex h-6 w-11 items-center rounded-full transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-black/10"
|
||||
:class="modelValue ? 'bg-black' : 'bg-gray-300'"
|
||||
@click="emit('update:modelValue', !modelValue)"
|
||||
>
|
||||
<span
|
||||
class="inline-block h-4 w-4 transform rounded-full bg-white shadow transition-transform duration-200"
|
||||
:class="modelValue ? 'translate-x-6' : 'translate-x-1'"
|
||||
/>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineProps<{ modelValue: boolean }>()
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: boolean] }>()
|
||||
</script>
|
||||
@@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<section class="mt-16">
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-8">{{ t('comments.title') }}</h2>
|
||||
|
||||
<!-- 登录提示 -->
|
||||
<div
|
||||
v-if="!userStore.isAuthenticated"
|
||||
class="p-6 rounded-2xl bg-gray-50 border border-gray-200 text-center"
|
||||
>
|
||||
<p class="text-gray-600 mb-4">{{ t('comments.loginToComment') }}</p>
|
||||
<button
|
||||
@click="authModal.openLogin()"
|
||||
class="px-6 py-2.5 rounded-full bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-colors"
|
||||
>
|
||||
{{ t('auth.login') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 评论表单(已登录) -->
|
||||
<form v-else @submit.prevent="handleSubmit" class="mb-10">
|
||||
<div class="flex items-start gap-4">
|
||||
<img
|
||||
:src="userStore.avatar"
|
||||
:alt="userStore.user?.username"
|
||||
class="w-10 h-10 rounded-full object-cover flex-shrink-0"
|
||||
/>
|
||||
<div class="flex-1">
|
||||
<textarea
|
||||
v-model="content"
|
||||
rows="3"
|
||||
maxlength="2000"
|
||||
:placeholder="t('comments.placeholder')"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 resize-none disabled:opacity-50"
|
||||
></textarea>
|
||||
<div class="flex items-center justify-between mt-3">
|
||||
<span v-if="errorMessage" class="text-sm text-red-600">{{ errorMessage }}</span>
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="isSubmitting || !content.trim()"
|
||||
class="ml-auto px-6 py-2.5 rounded-full bg-black text-white text-sm font-semibold flex items-center gap-2 transition-all"
|
||||
:class="isSubmitting || !content.trim() ? 'opacity-50 cursor-not-allowed' : 'hover:bg-gray-800'"
|
||||
>
|
||||
<Icon v-if="isSubmitting" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
{{ isSubmitting ? t('comments.submitting') : t('comments.submit') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- 评论列表 -->
|
||||
<div v-if="comments.length" class="space-y-6">
|
||||
<div
|
||||
v-for="comment in comments"
|
||||
:key="comment.id"
|
||||
class="flex items-start gap-4 p-5 rounded-2xl bg-gray-50 border border-gray-100"
|
||||
>
|
||||
<img
|
||||
:src="avatarUrl(comment.author.username)"
|
||||
:alt="comment.author.username"
|
||||
class="w-10 h-10 rounded-full object-cover flex-shrink-0"
|
||||
/>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center justify-between gap-3 mb-1">
|
||||
<p class="text-sm font-semibold text-black">{{ comment.author.username }}</p>
|
||||
<p class="text-xs text-gray-400 shrink-0">{{ formatDate(comment.createdAt) }}</p>
|
||||
</div>
|
||||
<p class="text-gray-700 text-sm md:text-base leading-relaxed break-words">{{ comment.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!loading && userStore.isAuthenticated" class="text-center text-gray-500 py-8">
|
||||
{{ t('comments.empty') }}
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
|
||||
const props = defineProps<{ newsSlug: string }>()
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const authModal = useAuthModalStore()
|
||||
|
||||
interface CommentItem {
|
||||
id: number
|
||||
content: string
|
||||
createdAt: string
|
||||
author: { username: string }
|
||||
}
|
||||
|
||||
const comments = ref<CommentItem[]>([])
|
||||
const content = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
const isLoading = ref(true)
|
||||
const errorMessage = ref('')
|
||||
|
||||
const avatarUrl = (name: string) =>
|
||||
`https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=000&color=fff&size=128`
|
||||
|
||||
const formatDate = (raw: string) => {
|
||||
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
return new Intl.DateTimeFormat(locale.value === 'zh' ? 'zh-CN' : 'en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(d)
|
||||
}
|
||||
|
||||
const fetchComments = async () => {
|
||||
isLoading.value = true
|
||||
try {
|
||||
const data = await $fetch<{ comments: CommentItem[] }>('/api/comments', {
|
||||
query: { newsSlug: props.newsSlug },
|
||||
})
|
||||
comments.value = data.comments
|
||||
} catch (err) {
|
||||
console.error('fetch comments error:', err)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (isSubmitting.value || !content.value.trim()) return
|
||||
isSubmitting.value = true
|
||||
errorMessage.value = ''
|
||||
try {
|
||||
await $fetch('/api/comments', {
|
||||
method: 'POST',
|
||||
body: { newsSlug: props.newsSlug, content: content.value.trim() },
|
||||
})
|
||||
content.value = ''
|
||||
await fetchComments()
|
||||
} catch (err) {
|
||||
console.error('post comment error:', err)
|
||||
errorMessage.value = t('comments.commentError')
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(fetchComments)
|
||||
watch(() => props.newsSlug, fetchComments)
|
||||
</script>
|
||||
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isLoading"
|
||||
@click="toggle"
|
||||
class="inline-flex w-full items-center justify-center gap-2 px-6 py-3.5 rounded-full font-semibold transition-all duration-300"
|
||||
:class="isFavorite
|
||||
? 'bg-gray-100 text-black hover:bg-gray-200'
|
||||
: 'bg-black text-white hover:bg-gray-800'"
|
||||
>
|
||||
<Icon v-if="isLoading" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
|
||||
<Icon v-else :name="isFavorite ? 'ph:bookmark-simple-fill' : 'ph:bookmark-simple'" class="w-5 h-5" />
|
||||
<span>{{ isFavorite ? t('favorites.remove') : t('favorites.add') }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
|
||||
const props = defineProps<{ workSlug: string }>()
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const authModal = useAuthModalStore()
|
||||
|
||||
const isFavorite = ref(false)
|
||||
const isLoading = ref(false)
|
||||
|
||||
// 已登录时同步收藏状态
|
||||
const refresh = async () => {
|
||||
if (!userStore.isAuthenticated) {
|
||||
isFavorite.value = false
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = await $fetch<{ slugs: string[] }>('/api/favorites')
|
||||
isFavorite.value = data.slugs.includes(props.workSlug)
|
||||
} catch {
|
||||
// 忽略,保持现状
|
||||
}
|
||||
}
|
||||
|
||||
const toggle = async () => {
|
||||
if (!userStore.isAuthenticated) {
|
||||
authModal.openLogin()
|
||||
return
|
||||
}
|
||||
if (isLoading.value) return
|
||||
isLoading.value = true
|
||||
try {
|
||||
if (isFavorite.value) {
|
||||
await $fetch('/api/favorites', { method: 'DELETE', body: { workSlug: props.workSlug } })
|
||||
isFavorite.value = false
|
||||
} else {
|
||||
await $fetch('/api/favorites', { method: 'POST', body: { workSlug: props.workSlug } })
|
||||
isFavorite.value = true
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('favorite toggle error:', err)
|
||||
} finally {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(refresh)
|
||||
watch(() => userStore.isAuthenticated, refresh)
|
||||
watch(() => props.workSlug, refresh)
|
||||
</script>
|
||||
@@ -2,7 +2,7 @@
|
||||
<Teleport to="body">
|
||||
<Transition name="modal">
|
||||
<div
|
||||
v-if="isOpen"
|
||||
v-if="authModal.isLoginOpen"
|
||||
class="fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm px-4"
|
||||
@click.self="closeModal"
|
||||
>
|
||||
@@ -35,7 +35,8 @@
|
||||
v-model="account"
|
||||
type="text"
|
||||
required
|
||||
:disabled="isLoggingIn"
|
||||
autocomplete="username"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.accountPlaceholder')"
|
||||
/>
|
||||
@@ -50,7 +51,8 @@
|
||||
v-model="password"
|
||||
type="password"
|
||||
required
|
||||
:disabled="isLoggingIn"
|
||||
autocomplete="current-password"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.passwordPlaceholder')"
|
||||
/>
|
||||
@@ -64,21 +66,21 @@
|
||||
<!-- 登录按钮 -->
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="isLoggingIn || !account || !password"
|
||||
:disabled="isSubmitting || !account || !password"
|
||||
class="w-full py-3 rounded-xl font-semibold text-white transition-all duration-300 flex items-center justify-center gap-2"
|
||||
:class="isLoggingIn || !account || !password
|
||||
:class="isSubmitting || !account || !password
|
||||
? 'bg-gray-400 cursor-not-allowed'
|
||||
: 'bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl'"
|
||||
>
|
||||
<Icon v-if="isLoggingIn" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
|
||||
<span>{{ isLoggingIn ? t('auth.loggingIn') : t('auth.loginButton') }}</span>
|
||||
<Icon v-if="isSubmitting" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
|
||||
<span>{{ isSubmitting ? t('auth.loggingIn') : t('auth.loginButton') }}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- 注册账号链接 -->
|
||||
<p class="mt-4 text-center text-sm text-gray-600">
|
||||
<p class="mt-6 text-center text-sm text-gray-600">
|
||||
{{ t('auth.noAccount') }}
|
||||
<button @click="switchToRegister" class="text-black font-semibold hover:underline">
|
||||
<button @click="authModal.switchToRegister()" class="text-black font-semibold hover:underline">
|
||||
{{ t('auth.createAccount') }}
|
||||
</button>
|
||||
</p>
|
||||
@@ -93,86 +95,60 @@
|
||||
import { ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
import { useApiError } from '~/composables/useApiError'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const authModal = useAuthModalStore()
|
||||
const apiError = useApiError()
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<{
|
||||
close: []
|
||||
switchToRegister: []
|
||||
}>()
|
||||
|
||||
const modalRef = ref<HTMLElement | null>(null)
|
||||
const account = ref('')
|
||||
const password = ref('')
|
||||
const isLoggingIn = ref(false)
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
|
||||
// 关闭模态框
|
||||
const closeModal = () => {
|
||||
if (!isLoggingIn.value) {
|
||||
emit('close')
|
||||
if (!isSubmitting.value) {
|
||||
authModal.closeAll()
|
||||
}
|
||||
}
|
||||
|
||||
// 切换到注册
|
||||
const switchToRegister = () => {
|
||||
emit('switchToRegister')
|
||||
}
|
||||
|
||||
// 处理登录
|
||||
const handleLogin = async () => {
|
||||
if (isLoggingIn.value) return
|
||||
|
||||
isLoggingIn.value = true
|
||||
errorMessage.value = ''
|
||||
|
||||
try {
|
||||
const result = await userStore.login(account.value, password.value)
|
||||
|
||||
if (result.success) {
|
||||
// 登录成功,关闭模态框
|
||||
// 打开时重置表单
|
||||
watch(
|
||||
() => authModal.isLoginOpen,
|
||||
(open) => {
|
||||
if (open) {
|
||||
account.value = ''
|
||||
password.value = ''
|
||||
closeModal()
|
||||
} else {
|
||||
errorMessage.value = t(result.error)
|
||||
errorMessage.value = ''
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Login error:', error)
|
||||
errorMessage.value = t('auth.loginError')
|
||||
} finally {
|
||||
isLoggingIn.value = false
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
// 监听打开状态,重置表单
|
||||
watch(() => props.isOpen, (isOpen) => {
|
||||
if (isOpen) {
|
||||
const handleLogin = async () => {
|
||||
if (isSubmitting.value) return
|
||||
isSubmitting.value = true
|
||||
errorMessage.value = ''
|
||||
|
||||
const result = await userStore.login(account.value, password.value)
|
||||
|
||||
if (result.success) {
|
||||
account.value = ''
|
||||
password.value = ''
|
||||
errorMessage.value = ''
|
||||
// 禁止背景滚动
|
||||
document.body.style.overflow = 'hidden'
|
||||
authModal.closeAll()
|
||||
} else {
|
||||
// 恢复滚动
|
||||
document.body.style.overflow = ''
|
||||
errorMessage.value = apiError({ data: { code: result.code } })
|
||||
}
|
||||
})
|
||||
isSubmitting.value = false
|
||||
}
|
||||
|
||||
// ESC 键关闭
|
||||
// ESC 关闭
|
||||
const handleKeydown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && props.isOpen) {
|
||||
if (e.key === 'Escape' && authModal.isLoginOpen) {
|
||||
closeModal()
|
||||
}
|
||||
}
|
||||
|
||||
// 添加键盘事件监听
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('keydown', handleKeydown)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<Teleport to="body">
|
||||
<Transition name="modal">
|
||||
<div
|
||||
v-if="isOpen"
|
||||
v-if="authModal.isRegisterOpen"
|
||||
class="fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm px-4"
|
||||
@click.self="closeModal"
|
||||
>
|
||||
@@ -35,7 +35,8 @@
|
||||
v-model="username"
|
||||
type="text"
|
||||
required
|
||||
:disabled="isRegistering"
|
||||
autocomplete="username"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.usernamePlaceholder')"
|
||||
/>
|
||||
@@ -50,7 +51,8 @@
|
||||
v-model="email"
|
||||
type="email"
|
||||
required
|
||||
:disabled="isRegistering"
|
||||
autocomplete="email"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.emailPlaceholder')"
|
||||
/>
|
||||
@@ -64,7 +66,8 @@
|
||||
id="reg-phone"
|
||||
v-model="phone"
|
||||
type="tel"
|
||||
:disabled="isRegistering"
|
||||
autocomplete="tel"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.phonePlaceholder')"
|
||||
/>
|
||||
@@ -79,7 +82,8 @@
|
||||
v-model="password"
|
||||
type="password"
|
||||
required
|
||||
:disabled="isRegistering"
|
||||
autocomplete="new-password"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.passwordPlaceholder')"
|
||||
/>
|
||||
@@ -94,7 +98,8 @@
|
||||
v-model="confirmPassword"
|
||||
type="password"
|
||||
required
|
||||
:disabled="isRegistering"
|
||||
autocomplete="new-password"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.confirmPasswordPlaceholder')"
|
||||
/>
|
||||
@@ -113,21 +118,21 @@
|
||||
<!-- 注册按钮 -->
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="isRegistering || !username || !email || !password || !confirmPassword"
|
||||
:disabled="isSubmitting || !username || !email || !password || !confirmPassword"
|
||||
class="w-full py-3 rounded-xl font-semibold text-white transition-all duration-300 flex items-center justify-center gap-2"
|
||||
:class="isRegistering || !username || !email || !password || !confirmPassword
|
||||
:class="isSubmitting || !username || !email || !password || !confirmPassword
|
||||
? 'bg-gray-400 cursor-not-allowed'
|
||||
: 'bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl'"
|
||||
>
|
||||
<Icon v-if="isRegistering" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
|
||||
<span>{{ isRegistering ? t('auth.registering') : t('auth.registerButton') }}</span>
|
||||
<Icon v-if="isSubmitting" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
|
||||
<span>{{ isSubmitting ? t('auth.registering') : t('auth.registerButton') }}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- 返回登录链接 -->
|
||||
<p class="mt-6 text-center text-sm text-gray-600">
|
||||
{{ t('auth.alreadyHaveAccount') }}
|
||||
<button @click="switchToLogin" class="text-black font-semibold hover:underline">
|
||||
<button @click="authModal.switchToLogin()" class="text-black font-semibold hover:underline">
|
||||
{{ t('auth.backToLogin') }}
|
||||
</button>
|
||||
</p>
|
||||
@@ -142,122 +147,89 @@
|
||||
import { ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
import { useApiError } from '~/composables/useApiError'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const authModal = useAuthModalStore()
|
||||
const apiError = useApiError()
|
||||
|
||||
interface Props {
|
||||
isOpen: boolean
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<{
|
||||
close: []
|
||||
switchToLogin: []
|
||||
}>()
|
||||
|
||||
const modalRef = ref<HTMLElement | null>(null)
|
||||
const username = ref('')
|
||||
const email = ref('')
|
||||
const phone = ref('')
|
||||
const password = ref('')
|
||||
const confirmPassword = ref('')
|
||||
const isRegistering = ref(false)
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const successMessage = ref('')
|
||||
|
||||
// 关闭模态框
|
||||
const closeModal = () => {
|
||||
if (!isRegistering.value) {
|
||||
emit('close')
|
||||
if (!isSubmitting.value) {
|
||||
authModal.closeAll()
|
||||
}
|
||||
}
|
||||
|
||||
// 切换到登录
|
||||
const switchToLogin = () => {
|
||||
emit('switchToLogin')
|
||||
}
|
||||
|
||||
// 处理注册
|
||||
const handleRegister = async () => {
|
||||
if (isRegistering.value) return
|
||||
|
||||
// 验证密码匹配
|
||||
if (password.value !== confirmPassword.value) {
|
||||
errorMessage.value = t('auth.passwordMismatch')
|
||||
return
|
||||
}
|
||||
|
||||
// 验证手机号格式(如果填写了)
|
||||
if (phone.value && !/^1[3-9]\d{9}$/.test(phone.value)) {
|
||||
errorMessage.value = t('auth.invalidPhone')
|
||||
return
|
||||
}
|
||||
|
||||
isRegistering.value = true
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
|
||||
try {
|
||||
const result = await userStore.register({
|
||||
username: username.value,
|
||||
email: email.value,
|
||||
phone: phone.value,
|
||||
password: password.value
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
// 注册成功
|
||||
successMessage.value = t('auth.registerSuccess')
|
||||
|
||||
// 清空表单
|
||||
// 打开时重置表单
|
||||
watch(
|
||||
() => authModal.isRegisterOpen,
|
||||
(open) => {
|
||||
if (open) {
|
||||
username.value = ''
|
||||
email.value = ''
|
||||
phone.value = ''
|
||||
password.value = ''
|
||||
confirmPassword.value = ''
|
||||
|
||||
// 2秒后关闭并自动登录
|
||||
setTimeout(() => {
|
||||
closeModal()
|
||||
}, 2000)
|
||||
} else {
|
||||
errorMessage.value = t(result.error)
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Register error:', error)
|
||||
errorMessage.value = t('auth.registerError')
|
||||
} finally {
|
||||
isRegistering.value = false
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
// 监听打开状态,重置表单
|
||||
watch(() => props.isOpen, (isOpen) => {
|
||||
if (isOpen) {
|
||||
const handleRegister = async () => {
|
||||
if (isSubmitting.value) return
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
|
||||
if (password.value !== confirmPassword.value) {
|
||||
errorMessage.value = t('auth.passwordMismatch')
|
||||
return
|
||||
}
|
||||
if (phone.value && !/^1[3-9]\d{9}$/.test(phone.value)) {
|
||||
errorMessage.value = t('auth.invalidPhone')
|
||||
return
|
||||
}
|
||||
|
||||
isSubmitting.value = true
|
||||
const result = await userStore.register({
|
||||
username: username.value,
|
||||
email: email.value,
|
||||
phone: phone.value,
|
||||
password: password.value,
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
successMessage.value = t('auth.registerSuccess')
|
||||
username.value = ''
|
||||
email.value = ''
|
||||
phone.value = ''
|
||||
password.value = ''
|
||||
confirmPassword.value = ''
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
// 禁止背景滚动
|
||||
document.body.style.overflow = 'hidden'
|
||||
setTimeout(() => {
|
||||
authModal.closeAll()
|
||||
}, 1500)
|
||||
} else {
|
||||
// 恢复滚动
|
||||
document.body.style.overflow = ''
|
||||
errorMessage.value = apiError({ data: { code: result.code } })
|
||||
}
|
||||
})
|
||||
isSubmitting.value = false
|
||||
}
|
||||
|
||||
// ESC 键关闭
|
||||
// ESC 关闭
|
||||
const handleKeydown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && props.isOpen) {
|
||||
if (e.key === 'Escape' && authModal.isRegisterOpen) {
|
||||
closeModal()
|
||||
}
|
||||
}
|
||||
|
||||
// 添加键盘事件监听
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('keydown', handleKeydown)
|
||||
}
|
||||
|
||||
@@ -1,19 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref, nextTick } from 'vue'
|
||||
import { onMounted, onUnmounted, ref, computed, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import gsap from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
interface WorkItem {
|
||||
slug: string
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
year: string
|
||||
image: string | null
|
||||
}
|
||||
|
||||
// 内容 API(仅已发布)
|
||||
const { data } = await useFetch<{ works: WorkItem[] }>('/api/work')
|
||||
const works = computed(() => data.value?.works ?? [])
|
||||
|
||||
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const workSectionRef = ref<HTMLElement | null>(null)
|
||||
const workPinRef = ref<HTMLElement | null>(null)
|
||||
|
||||
const cardRefs = ref<HTMLElement[]>([])
|
||||
|
||||
const partners = [
|
||||
{
|
||||
id: 'p1',
|
||||
@@ -49,139 +61,130 @@ const partners = [
|
||||
},
|
||||
]
|
||||
|
||||
const toImageUrl = (prompt: string, imageSize: string) => {
|
||||
const encoded = encodeURIComponent(prompt)
|
||||
return `https://coresg-normal.trae.ai/api/ide/v1/text_to_image?prompt=${encoded}&image_size=${imageSize}`
|
||||
}
|
||||
|
||||
const workItems = [
|
||||
{
|
||||
titleKey: 'home.work.items.forma',
|
||||
year: '26',
|
||||
image: toImageUrl(
|
||||
'high-end editorial product still life, minimal composition, matte ceramics and brushed aluminum on soft neutral background, studio lighting, shallow depth of field, premium, clean, realistic, 35mm photo',
|
||||
'landscape_16_9'
|
||||
),
|
||||
},
|
||||
{
|
||||
titleKey: 'home.work.items.oneStep',
|
||||
year: '24',
|
||||
image: toImageUrl(
|
||||
'architectural close-up, modern brutalist concrete facade with sharp shadows, minimal, cinematic lighting, high contrast, ultra realistic, 35mm photography, no people',
|
||||
'landscape_16_9'
|
||||
),
|
||||
},
|
||||
{
|
||||
titleKey: 'home.work.items.neroVision',
|
||||
year: '25',
|
||||
image: toImageUrl(
|
||||
'minimal graphic poster photographed in studio, black ink typography on off-white textured paper, premium editorial style, soft shadow, ultra realistic, no people',
|
||||
'landscape_16_9'
|
||||
),
|
||||
},
|
||||
{
|
||||
titleKey: 'home.work.items.boldMoves',
|
||||
year: '24',
|
||||
image: toImageUrl(
|
||||
'moody nighttime city street still life, neon reflection on wet asphalt, abstract bokeh, premium cinematic photography, no people, high detail',
|
||||
'landscape_16_9'
|
||||
),
|
||||
},
|
||||
] as const
|
||||
|
||||
let ctx: gsap.Context | null = null
|
||||
let st: ScrollTrigger | null = null
|
||||
let madeTweens: gsap.core.Animation[] = []
|
||||
let positionedCards: HTMLElement[] = []
|
||||
let initedOnce = false
|
||||
let retryTimer: ReturnType<typeof setTimeout> | null = null
|
||||
let stopRetry = false
|
||||
|
||||
const refresh = () => {
|
||||
ScrollTrigger.refresh()
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
if (!rootRef.value || !workSectionRef.value || !workPinRef.value) return
|
||||
// 全部用 DOM 选择器(仅客户端;SSR 无 document,返回空)
|
||||
const getWorkSection = () => (typeof document !== 'undefined' ? document.getElementById('work') : null)
|
||||
const getPinEl = () => (typeof document !== 'undefined' ? document.querySelector<HTMLElement>('#work [data-work-pin]') : null)
|
||||
const getCards = (): HTMLElement[] =>
|
||||
typeof document !== 'undefined'
|
||||
? Array.from(document.querySelectorAll<HTMLElement>('#work a[href^="/work/"]'))
|
||||
: []
|
||||
|
||||
await nextTick()
|
||||
const initScrollAnimation = (): boolean => {
|
||||
if (initedOnce) return true // 只初始化一次,绝不重初始化
|
||||
const section = getWorkSection()
|
||||
const pinEl = getPinEl()
|
||||
if (!section || !pinEl) return false
|
||||
const cards = getCards()
|
||||
const count = cards.length
|
||||
if (count < 2) return false
|
||||
initedOnce = true
|
||||
|
||||
// 延迟初始化 ScrollTrigger,避免阻塞首屏 Hero 动画
|
||||
// 等待 Hero 入场动画完成(约 3-4 秒)
|
||||
const initScrollAnimation = () => {
|
||||
ctx = gsap.context(() => {
|
||||
const cards = cardRefs.value
|
||||
const count = cards.length
|
||||
const enterOffset = 160
|
||||
const scaleTo = 0.92
|
||||
const depthOffsetY = -18
|
||||
|
||||
if (count < 2) return
|
||||
// 定位卡片为 absolute 堆叠(用原生样式,避免 gsap.set 被 pin 机制 revert)
|
||||
positionedCards = cards
|
||||
cards.forEach((card, i) => {
|
||||
card.style.position = 'absolute'
|
||||
card.style.top = '0'
|
||||
card.style.right = '0'
|
||||
card.style.bottom = '0'
|
||||
card.style.left = '0'
|
||||
card.style.zIndex = String(i + 1)
|
||||
card.style.borderRadius = '22px'
|
||||
card.style.overflow = 'hidden'
|
||||
card.style.boxShadow = '0 18px 40px rgba(0,0,0,0.12)'
|
||||
card.style.transform = i === 0 ? 'none' : `translateY(${window.innerHeight + enterOffset}px)`
|
||||
})
|
||||
|
||||
const enterOffset = 160
|
||||
const scaleTo = 0.92
|
||||
const depthOffsetY = -18
|
||||
|
||||
for (let i = 0; i < count; i += 1) {
|
||||
const card = cards[i]
|
||||
|
||||
gsap.set(card, {
|
||||
position: 'absolute',
|
||||
inset: 0,
|
||||
borderRadius: 22,
|
||||
overflow: 'hidden',
|
||||
transformOrigin: 'center center',
|
||||
force3D: true,
|
||||
zIndex: i + 1,
|
||||
boxShadow: '0 18px 40px rgba(0,0,0,0.12)',
|
||||
y: i === 0 ? 0 : window.innerHeight + enterOffset,
|
||||
scale: 1,
|
||||
})
|
||||
}
|
||||
|
||||
const tl = gsap.timeline()
|
||||
|
||||
for (let i = 1; i < count; i += 1) {
|
||||
const prev = cards[i - 1]
|
||||
const next = cards[i]
|
||||
const start = i - 1
|
||||
|
||||
tl.to(
|
||||
next,
|
||||
{ y: 0, duration: 1, ease: 'power2.out' },
|
||||
start
|
||||
)
|
||||
tl.to(
|
||||
prev,
|
||||
{ scale: scaleTo, y: depthOffsetY, duration: 0.6, ease: 'power2.out' },
|
||||
start + 0.35
|
||||
)
|
||||
tl.set(prev, { scale: scaleTo, y: depthOffsetY }, start + 1)
|
||||
}
|
||||
|
||||
ScrollTrigger.create({
|
||||
trigger: workSectionRef.value,
|
||||
start: 'top top',
|
||||
end: () => `+=${(count - 1) * window.innerHeight}`,
|
||||
pin: workPinRef.value,
|
||||
scrub: true,
|
||||
anticipatePin: 1,
|
||||
invalidateOnRefresh: true,
|
||||
animation: tl,
|
||||
})
|
||||
|
||||
ScrollTrigger.refresh()
|
||||
}, rootRef.value)
|
||||
const tl = gsap.timeline()
|
||||
for (let i = 1; i < count; i += 1) {
|
||||
const prev = cards[i - 1]
|
||||
const next = cards[i]
|
||||
const start = i - 1
|
||||
tl.to(next, { y: 0, duration: 1, ease: 'power2.out' }, start)
|
||||
tl.to(prev, { scale: scaleTo, y: depthOffsetY, duration: 0.6, ease: 'power2.out' }, start + 0.35)
|
||||
tl.set(prev, { scale: scaleTo, y: depthOffsetY }, start + 1)
|
||||
}
|
||||
madeTweens.push(tl)
|
||||
|
||||
// 监听 hero 动画完成事件
|
||||
st = ScrollTrigger.create({
|
||||
trigger: section,
|
||||
start: 'top top',
|
||||
end: () => `+=${(count - 1) * window.innerHeight}`,
|
||||
pin: pinEl,
|
||||
pinType: 'transform',
|
||||
scrub: true,
|
||||
anticipatePin: 1,
|
||||
invalidateOnRefresh: true,
|
||||
animation: tl,
|
||||
})
|
||||
|
||||
requestAnimationFrame(() => ScrollTrigger.refresh())
|
||||
return true
|
||||
}
|
||||
|
||||
// 自愈初始化:卡片尚未就绪时每 200ms 重试,直到成功(成功即停)
|
||||
const ensureInit = () => {
|
||||
if (stopRetry) return
|
||||
if (typeof window === 'undefined') return // SSR 不执行
|
||||
if (initScrollAnimation()) {
|
||||
if (retryTimer) {
|
||||
clearTimeout(retryTimer)
|
||||
retryTimer = null
|
||||
}
|
||||
return
|
||||
}
|
||||
retryTimer = setTimeout(ensureInit, 200)
|
||||
}
|
||||
|
||||
// 数据变化时触发(不在 setup 立即执行——hydration 前初始化会被 hydration 重置样式)
|
||||
watch(works, ensureInit)
|
||||
|
||||
onMounted(() => {
|
||||
ensureInit() // hydration 完成后初始化
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('hero-intro-done', initScrollAnimation, { once: true })
|
||||
|
||||
// 保底:3秒后必定初始化
|
||||
setTimeout(() => {
|
||||
window.removeEventListener('hero-intro-done', initScrollAnimation)
|
||||
if (!ctx) {
|
||||
initScrollAnimation()
|
||||
}
|
||||
}, 3000)
|
||||
window.addEventListener('hero-intro-done', ensureInit, { once: true })
|
||||
setTimeout(ensureInit, 3000)
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
ctx?.revert()
|
||||
ctx = null
|
||||
stopRetry = true
|
||||
if (retryTimer) clearTimeout(retryTimer)
|
||||
if (st) {
|
||||
st.kill()
|
||||
st = null
|
||||
}
|
||||
madeTweens.forEach((t) => t.revert())
|
||||
madeTweens = []
|
||||
// 复位卡片定位样式
|
||||
positionedCards.forEach((c) => {
|
||||
if (!c) return
|
||||
c.style.position = ''
|
||||
c.style.top = ''
|
||||
c.style.right = ''
|
||||
c.style.bottom = ''
|
||||
c.style.left = ''
|
||||
c.style.zIndex = ''
|
||||
c.style.borderRadius = ''
|
||||
c.style.overflow = ''
|
||||
c.style.boxShadow = ''
|
||||
c.style.transform = ''
|
||||
})
|
||||
positionedCards = []
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -210,7 +213,7 @@ onUnmounted(() => {
|
||||
<section id="work" ref="workSectionRef" class="bg-white">
|
||||
<div class="w-page-container max-w-[calc(100%-2rem)] mx-auto px-4 pb-28">
|
||||
<div
|
||||
ref="workPinRef"
|
||||
data-work-pin
|
||||
class="flex flex-col lg:flex-row gap-10 lg:gap-16 h-[100svh] items-stretch"
|
||||
>
|
||||
<div class="lg:w-[340px] flex flex-col gap-8 pt-8 md:pt-10">
|
||||
@@ -219,7 +222,7 @@ onUnmounted(() => {
|
||||
<h2 class="text-5xl md:text-6xl font-bold tracking-tighter leading-[0.92]">
|
||||
{{ t('home.work.title') }}
|
||||
<span class="text-black/40 text-base md:text-lg align-middle ml-2 font-semibold tracking-tight">
|
||||
({{ workItems.length }})
|
||||
({{ works.length }})
|
||||
</span>
|
||||
</h2>
|
||||
</div>
|
||||
@@ -235,29 +238,29 @@ onUnmounted(() => {
|
||||
<div class="relative flex-1 h-full flex items-center">
|
||||
<div class="relative w-full h-[78svh] md:h-[82svh] lg:h-[88svh] p-[clamp(14px,2.4vw,28px)]">
|
||||
<div class="relative h-full w-full">
|
||||
<article
|
||||
v-for="(item, idx) in workItems"
|
||||
:key="`${item.titleKey}-${idx}`"
|
||||
ref="cardRefs"
|
||||
class="will-change-transform relative"
|
||||
>
|
||||
<img
|
||||
class="h-full w-full object-cover"
|
||||
:src="item.image"
|
||||
:alt="t(item.titleKey)"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
@load="refresh"
|
||||
/>
|
||||
<div class="absolute left-6 top-6 flex items-baseline gap-3">
|
||||
<p class="text-white text-sm md:text-base font-semibold tracking-tight drop-shadow-[0_10px_18px_rgba(0,0,0,0.4)]">
|
||||
{{ t(item.titleKey) }}
|
||||
</p>
|
||||
<p class="text-white/80 text-xs md:text-sm font-semibold tracking-tight drop-shadow-[0_10px_18px_rgba(0,0,0,0.4)]">
|
||||
{{ item.year }} ©
|
||||
</p>
|
||||
</div>
|
||||
</article>
|
||||
<NuxtLink
|
||||
v-for="item in works"
|
||||
:key="item.slug"
|
||||
:to="`/work/${item.slug}`"
|
||||
class="will-change-transform relative block"
|
||||
>
|
||||
<img
|
||||
class="h-full w-full object-cover"
|
||||
:src="item.image || ''"
|
||||
:alt="locText(item.titleZh, item.titleEn)"
|
||||
loading="eager"
|
||||
decoding="async"
|
||||
@load="refresh"
|
||||
/>
|
||||
<div class="absolute left-6 top-6 flex items-baseline gap-3">
|
||||
<p class="text-white text-sm md:text-base font-semibold tracking-tight drop-shadow-[0_10px_18px_rgba(0,0,0,0.4)]">
|
||||
{{ locText(item.titleZh, item.titleEn) }}
|
||||
</p>
|
||||
<p class="text-white/80 text-xs md:text-sm font-semibold tracking-tight drop-shadow-[0_10px_18px_rgba(0,0,0,0.4)]">
|
||||
{{ item.year }} ©
|
||||
</p>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
v-for="(tech, index) in technologies"
|
||||
:key="tech.id"
|
||||
:ref="el => setTechRef(el, index)"
|
||||
class="tech-tag absolute flex items-center gap-3 px-5 py-3 bg-white rounded-full shadow-lg border-2 cursor-pointer hover:scale-110 transition-transform duration-300"
|
||||
class="tech-tag absolute flex items-center gap-3 px-5 py-3 bg-white rounded-full shadow-lg border-2 hover:scale-110 transition-transform duration-300"
|
||||
:class="tech.borderColor"
|
||||
:style="getTechStyle(index)"
|
||||
>
|
||||
|
||||
@@ -13,11 +13,12 @@
|
||||
|
||||
<!-- Bento 网格 -->
|
||||
<div class="grid grid-cols-12 gap-4 md:gap-6 auto-rows-[200px]">
|
||||
<div
|
||||
<NuxtLink
|
||||
v-for="(item, index) in updates"
|
||||
:key="item.id"
|
||||
:key="item.slug"
|
||||
:to="`/news/${item.slug}`"
|
||||
:ref="el => setCardRef(el, index)"
|
||||
class="update-card group relative overflow-hidden rounded-3xl cursor-pointer"
|
||||
class="update-card group relative overflow-hidden rounded-3xl cursor-pointer block"
|
||||
:class="item.gridClass"
|
||||
:style="{ opacity: 0 }"
|
||||
@mouseenter="() => handleCardHover(index, true)"
|
||||
@@ -31,27 +32,27 @@
|
||||
<div>
|
||||
<div class="inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-white/20 backdrop-blur-sm text-xs md:text-sm font-semibold mb-4">
|
||||
<Icon :name="item.categoryIcon" class="w-4 h-4" />
|
||||
{{ t(`home.updates.categories.${item.category}`) }}
|
||||
{{ t(`news.categories.${item.category}`) }}
|
||||
</div>
|
||||
|
||||
<h3 class="text-xl md:text-3xl font-bold mb-3 line-clamp-2">
|
||||
{{ t(`home.updates.items.${item.id}.title`) }}
|
||||
{{ locText(item.titleZh, item.titleEn) }}
|
||||
</h3>
|
||||
|
||||
<p v-if="item.showDescription" class="text-white/90 text-sm md:text-base line-clamp-3">
|
||||
{{ t(`home.updates.items.${item.id}.description`) }}
|
||||
{{ locText(item.excerptZh, item.excerptEn) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs md:text-sm text-white/80">{{ item.date }}</span>
|
||||
<span class="text-xs md:text-sm text-white/80">{{ formatNewsDate(item.date, locale) }}</span>
|
||||
<Icon name="ph:arrow-up-right" class="w-5 h-5 md:w-6 md:h-6 transition-transform duration-300 group-hover:translate-x-1 group-hover:-translate-y-1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 悬浮效果 -->
|
||||
<div class="absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors duration-300"></div>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 查看更多 -->
|
||||
@@ -69,14 +70,24 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
import { ref, onMounted, onUnmounted, nextTick, watch, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import gsap from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
interface ArticleItem {
|
||||
slug: string
|
||||
category: 'insights' | 'projects' | 'announcements'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
excerptZh: string
|
||||
excerptEn: string
|
||||
date: string | null
|
||||
}
|
||||
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const headerRef = ref<HTMLElement | null>(null)
|
||||
@@ -87,62 +98,40 @@ const setCardRef = (el: any, index: number) => {
|
||||
if (el) cardElements.value[index] = el
|
||||
}
|
||||
|
||||
const updates = [
|
||||
{
|
||||
id: 'project1',
|
||||
category: 'project',
|
||||
categoryIcon: 'ph:briefcase',
|
||||
gradient: 'bg-gradient-to-br from-blue-500 via-purple-500 to-pink-500',
|
||||
gridClass: 'col-span-12 md:col-span-6 md:row-span-2',
|
||||
showDescription: true,
|
||||
date: '2026-06-01'
|
||||
},
|
||||
{
|
||||
id: 'blog1',
|
||||
category: 'blog',
|
||||
categoryIcon: 'ph:article',
|
||||
gradient: 'bg-gradient-to-br from-orange-500 to-red-500',
|
||||
gridClass: 'col-span-12 md:col-span-3 md:row-span-1',
|
||||
showDescription: false,
|
||||
date: '2026-05-28'
|
||||
},
|
||||
{
|
||||
id: 'news1',
|
||||
category: 'news',
|
||||
categoryIcon: 'ph:newspaper',
|
||||
gradient: 'bg-gradient-to-br from-green-500 to-emerald-500',
|
||||
gridClass: 'col-span-12 md:col-span-3 md:row-span-1',
|
||||
showDescription: false,
|
||||
date: '2026-05-25'
|
||||
},
|
||||
{
|
||||
id: 'project2',
|
||||
category: 'project',
|
||||
categoryIcon: 'ph:briefcase',
|
||||
gradient: 'bg-gradient-to-br from-indigo-500 to-blue-500',
|
||||
gridClass: 'col-span-12 md:col-span-3 md:row-span-2',
|
||||
showDescription: true,
|
||||
date: '2026-05-20'
|
||||
},
|
||||
{
|
||||
id: 'blog2',
|
||||
category: 'blog',
|
||||
categoryIcon: 'ph:article',
|
||||
gradient: 'bg-gradient-to-br from-pink-500 to-rose-500',
|
||||
gridClass: 'col-span-12 md:col-span-6 md:row-span-1',
|
||||
showDescription: false,
|
||||
date: '2026-05-15'
|
||||
},
|
||||
{
|
||||
id: 'news2',
|
||||
category: 'news',
|
||||
categoryIcon: 'ph:newspaper',
|
||||
gradient: 'bg-gradient-to-br from-amber-500 to-orange-500',
|
||||
gridClass: 'col-span-12 md:col-span-3 md:row-span-1',
|
||||
showDescription: false,
|
||||
date: '2026-05-10'
|
||||
}
|
||||
]
|
||||
// 内容 API(仅已发布,date 降序)
|
||||
const { data } = await useFetch<{ articles: ArticleItem[] }>('/api/news')
|
||||
const articles = computed(() => data.value?.articles ?? [])
|
||||
|
||||
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
function formatNewsDate(date: string | null, loc: string): string {
|
||||
if (!date) return ''
|
||||
const d = new Date(`${date}T00:00:00`)
|
||||
if (Number.isNaN(d.getTime())) return date
|
||||
return new Intl.DateTimeFormat(loc === 'zh' ? 'zh-CN' : 'en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}).format(d)
|
||||
}
|
||||
|
||||
// Bento 布局(与动态数据一一对应;分类图标/渐变/跨度)
|
||||
const layout = [
|
||||
{ categoryIcon: 'ph:article', gradient: 'bg-gradient-to-br from-blue-500 via-purple-500 to-pink-500', gridClass: 'col-span-12 md:col-span-6 md:row-span-2', showDescription: true },
|
||||
{ categoryIcon: 'ph:briefcase', gradient: 'bg-gradient-to-br from-orange-500 to-red-500', gridClass: 'col-span-12 md:col-span-3 md:row-span-1', showDescription: false },
|
||||
{ categoryIcon: 'ph:newspaper', gradient: 'bg-gradient-to-br from-green-500 to-emerald-500', gridClass: 'col-span-12 md:col-span-3 md:row-span-1', showDescription: false },
|
||||
{ categoryIcon: 'ph:article', gradient: 'bg-gradient-to-br from-indigo-500 to-blue-500', gridClass: 'col-span-12 md:col-span-3 md:row-span-2', showDescription: true },
|
||||
{ categoryIcon: 'ph:briefcase', gradient: 'bg-gradient-to-br from-pink-500 to-rose-500', gridClass: 'col-span-12 md:col-span-6 md:row-span-1', showDescription: false },
|
||||
{ categoryIcon: 'ph:newspaper', gradient: 'bg-gradient-to-br from-amber-500 to-orange-500', gridClass: 'col-span-12 md:col-span-3 md:row-span-1', showDescription: false },
|
||||
] as const
|
||||
|
||||
// 取前 6 条动态,绑定布局
|
||||
const updates = computed(() =>
|
||||
articles.value.slice(0, 6).map((item, i) => ({
|
||||
...item,
|
||||
...layout[i],
|
||||
})),
|
||||
)
|
||||
|
||||
// 卡片悬浮效果
|
||||
const handleCardHover = (index: number, isHover: boolean) => {
|
||||
@@ -155,13 +144,14 @@ const handleCardHover = (index: number, isHover: boolean) => {
|
||||
? '0 25px 50px -12px rgba(0, 0, 0, 0.25)'
|
||||
: '0 10px 15px -3px rgba(0, 0, 0, 0.1)',
|
||||
duration: 0.3,
|
||||
ease: 'power2.out'
|
||||
ease: 'power2.out',
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const playIntro = async () => {
|
||||
if (!rootRef.value || !headerRef.value || cardElements.value.length === 0) return
|
||||
await nextTick()
|
||||
if (!rootRef.value || !headerRef.value) return
|
||||
if (ctx) ctx.revert()
|
||||
|
||||
ctx = gsap.context(() => {
|
||||
// 初始状态
|
||||
@@ -171,7 +161,7 @@ onMounted(async () => {
|
||||
gsap.set(card, { autoAlpha: 0, y: 60, scale: 0.9 })
|
||||
})
|
||||
|
||||
// 入场动画(无 pin):标题 + 卡片错开出现
|
||||
// 入场动画:标题 + 卡片错开出现
|
||||
const tl = gsap.timeline()
|
||||
|
||||
tl.to(headerRef.value, { autoAlpha: 1, y: 0, duration: 0.8, ease: 'power3.out' }, 0)
|
||||
@@ -191,8 +181,17 @@ onMounted(async () => {
|
||||
animation: tl,
|
||||
})
|
||||
}, rootRef.value)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
playIntro()
|
||||
})
|
||||
|
||||
// 若数据异步到达(纯客户端首帧),卡片渲染后补跑入场动画
|
||||
watch(updates, () => {
|
||||
if (!ctx) playIntro()
|
||||
}, { flush: 'post' })
|
||||
|
||||
onUnmounted(() => {
|
||||
ctx?.revert()
|
||||
})
|
||||
|
||||
@@ -5,15 +5,17 @@ import { gsap } from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
import FooterLogo from '~/components/common/FooterLogo.vue'
|
||||
import AnimatedButton from '~/components/common/AnimatedButton.vue'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { settings, loc } = useSiteSettings()
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const { t } = useI18n()
|
||||
const footerRef = ref<HTMLElement | null>(null)
|
||||
const newsletterEmail = ref('')
|
||||
const isSubscribing = ref(false)
|
||||
const subscribeStatus = ref<'idle' | 'success' | 'error'>('idle')
|
||||
const newsletterMessage = ref('')
|
||||
let ctx: gsap.Context
|
||||
|
||||
const pagesLinks = [
|
||||
@@ -34,45 +36,37 @@ const handleNewsletterSubmit = async () => {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||
if (!emailRegex.test(newsletterEmail.value)) {
|
||||
subscribeStatus.value = 'error'
|
||||
newsletterMessage.value = t('footer.newsletterInvalidEmail')
|
||||
setTimeout(() => {
|
||||
subscribeStatus.value = 'idle'
|
||||
newsletterMessage.value = ''
|
||||
}, 3000)
|
||||
return
|
||||
}
|
||||
|
||||
isSubscribing.value = true
|
||||
subscribeStatus.value = 'idle'
|
||||
newsletterMessage.value = ''
|
||||
|
||||
try {
|
||||
// 真实订阅:入库(PostgreSQL,邮箱唯一)+ 可选 SMTP 通知
|
||||
await $fetch('/api/newsletter/subscribe', {
|
||||
method: 'POST',
|
||||
body: { email: newsletterEmail.value },
|
||||
})
|
||||
// 真实订阅:落库 + 尽力发送欢迎邮件
|
||||
await $fetch('/api/newsletter', { method: 'POST', body: { email: newsletterEmail.value } })
|
||||
|
||||
subscribeStatus.value = 'success'
|
||||
newsletterMessage.value = t('footer.newsletterSuccess')
|
||||
newsletterEmail.value = ''
|
||||
|
||||
// 3秒后重置状态
|
||||
setTimeout(() => {
|
||||
subscribeStatus.value = 'idle'
|
||||
newsletterMessage.value = ''
|
||||
}, 3000)
|
||||
|
||||
} catch (error: any) {
|
||||
console.error('Newsletter subscription error:', error)
|
||||
subscribeStatus.value = 'error'
|
||||
// 服务端错误码(如已订阅 409)优先展示
|
||||
const code = error?.data?.statusMessage || error?.statusMessage || ''
|
||||
newsletterMessage.value = code && code !== 'Bad Request' ? t(code) : t('footer.newsletterError')
|
||||
} catch (error) {
|
||||
// 已在订阅列表视为成功(用户确实已订阅)
|
||||
if ((error as any)?.data?.code === 'ALREADY_SUBSCRIBED') {
|
||||
subscribeStatus.value = 'success'
|
||||
} else {
|
||||
subscribeStatus.value = 'error'
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
subscribeStatus.value = 'idle'
|
||||
newsletterMessage.value = ''
|
||||
}, 3000)
|
||||
} finally {
|
||||
isSubscribing.value = false
|
||||
@@ -129,7 +123,7 @@ onUnmounted(() => {
|
||||
<!-- Top Section -->
|
||||
<div class="flex flex-col md:flex-row justify-between items-start md:items-end gap-8 mb-16">
|
||||
<h2 class="animated-item text-3xl md:text-4xl lg:text-[44px] font-normal tracking-normal !leading-[1.4] max-w-none whitespace-pre-line">
|
||||
{{ t('footer.title') }}
|
||||
{{ loc(settings?.footer.title) }}
|
||||
</h2>
|
||||
<div class="animated-item inline-flex items-center shrink-0">
|
||||
<AnimatedButton
|
||||
@@ -151,7 +145,7 @@ onUnmounted(() => {
|
||||
<div>
|
||||
<FooterLogo class="mb-16 animated-item justify-start" />
|
||||
|
||||
<h3 class="text-2xl font-medium mb-6 animated-item">{{ t('footer.newsletterTitle') }}</h3>
|
||||
<h3 class="text-2xl font-medium mb-6 animated-item">{{ loc(settings?.footer.newsletterTitle) }}</h3>
|
||||
|
||||
<form @submit.prevent="handleNewsletterSubmit" class="relative w-full max-w-sm mb-4 animated-item">
|
||||
<input
|
||||
@@ -188,22 +182,13 @@ onUnmounted(() => {
|
||||
|
||||
<div class="text-xs text-white/40 flex items-center gap-2 animated-item">
|
||||
<span class="w-1.5 h-1.5 bg-white rounded-full inline-block shrink-0"></span>
|
||||
{{ t('footer.newsletterNote') }}
|
||||
{{ loc(settings?.footer.newsletterNote) }}
|
||||
</div>
|
||||
|
||||
<!-- 订阅状态消息 -->
|
||||
<p
|
||||
v-if="newsletterMessage"
|
||||
class="mt-3 text-xs animated-item"
|
||||
:class="subscribeStatus === 'success' ? 'text-green-400' : 'text-red-400'"
|
||||
>
|
||||
{{ newsletterMessage }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="mt-24 lg:mt-0 flex items-center gap-2 animated-item">
|
||||
<div class="text-[16px] font-bold text-white/30 font-sans">
|
||||
{{ t('footer.copyright') }}
|
||||
{{ loc(settings?.footer.copyright) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -243,10 +228,10 @@ onUnmounted(() => {
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-8">
|
||||
<ul class="space-y-3">
|
||||
<li class="animated-item">
|
||||
<a href="mailto:chenchun@virtheart.com" class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 hover:text-white transition-colors" style="justify-content: flex-start;">
|
||||
<a :href="`mailto:${settings?.contact.email}`" class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 hover:text-white transition-colors" style="justify-content: flex-start;">
|
||||
<div class="flex items-center transition-transform duration-300 group-hover:translate-x-0 -translate-x-[21px] pr-[21px]">
|
||||
<span class="mr-[10px] h-[11px] w-[11px] rounded-full bg-white shrink-0"></span>
|
||||
<span>chenchun@virtheart.com</span>
|
||||
<span>{{ settings?.contact.email }}</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
@@ -254,7 +239,7 @@ onUnmounted(() => {
|
||||
<span class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 transition-colors cursor-default" style="justify-content: flex-start;">
|
||||
<div class="flex items-center transition-transform duration-300 group-hover:translate-x-0 -translate-x-[21px] pr-[21px]">
|
||||
<span class="mr-[10px] h-[11px] w-[11px] rounded-full bg-white shrink-0"></span>
|
||||
<span>{{ t('footer.wechat') }}: LucskyNew</span>
|
||||
<span>{{ t('footer.wechat') }}: {{ settings?.contact.wechat }}</span>
|
||||
</div>
|
||||
</span>
|
||||
</li>
|
||||
@@ -262,10 +247,10 @@ onUnmounted(() => {
|
||||
|
||||
<ul class="space-y-3">
|
||||
<li class="animated-item">
|
||||
<a href="mailto:info@virtheart.com" class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 hover:text-white transition-colors" style="justify-content: flex-start;">
|
||||
<a :href="`mailto:${settings?.contact.infoEmail}`" class="group flex items-center overflow-hidden text-[16px] font-bold text-white/80 hover:text-white transition-colors" style="justify-content: flex-start;">
|
||||
<div class="flex items-center transition-transform duration-300 group-hover:translate-x-0 -translate-x-[21px] pr-[21px]">
|
||||
<span class="mr-[10px] h-[11px] w-[11px] rounded-full bg-white shrink-0"></span>
|
||||
<span>info@virtheart.com</span>
|
||||
<span>{{ settings?.contact.infoEmail }}</span>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
@@ -282,14 +267,16 @@ onUnmounted(() => {
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 animated-item">
|
||||
<a href="#" class="w-10 h-10 rounded-full bg-[#1f1f1f] hover:bg-[#2f2f2f] flex items-center justify-center transition-colors text-white">
|
||||
<Icon name="ph:instagram-logo" class="w-4 h-4" />
|
||||
</a>
|
||||
<a href="#" class="w-10 h-10 rounded-full bg-[#1f1f1f] hover:bg-[#2f2f2f] flex items-center justify-center transition-colors text-white">
|
||||
<Icon name="ph:x-logo" class="w-4 h-4" />
|
||||
</a>
|
||||
<a href="#" class="w-10 h-10 rounded-full bg-[#1f1f1f] hover:bg-[#2f2f2f] flex items-center justify-center transition-colors text-white">
|
||||
<Icon name="ph:diamond-fill" class="w-4 h-4" />
|
||||
<a
|
||||
v-for="social in settings?.socials ?? []"
|
||||
:key="social.name"
|
||||
:href="social.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="w-10 h-10 rounded-full bg-[#1f1f1f] hover:bg-[#2f2f2f] flex items-center justify-center transition-colors text-white"
|
||||
:aria-label="social.name"
|
||||
>
|
||||
<Icon :name="social.icon" class="w-4 h-4" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,16 +6,18 @@ import gsap from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
import { useAppStore } from '~/stores/app'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
import AppLogo from '~/components/common/AppLogo.vue'
|
||||
import LoginModal from '~/components/common/LoginModal.vue'
|
||||
import RegisterModal from '~/components/common/RegisterModal.vue'
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale, setLocale } = useI18n()
|
||||
const route = useRoute()
|
||||
const appStore = useAppStore()
|
||||
const userStore = useUserStore()
|
||||
const authModal = useAuthModalStore()
|
||||
|
||||
// 恢复用户状态
|
||||
onMounted(() => {
|
||||
@@ -36,46 +38,15 @@ const topHeaderRef = ref<HTMLElement | null>(null)
|
||||
const bottomHeaderRef = ref<HTMLElement | null>(null)
|
||||
const mobileMenuRef = ref<HTMLElement | null>(null)
|
||||
const isMobileMenuOpen = ref(false)
|
||||
const isLoginModalOpen = ref(false)
|
||||
const isRegisterModalOpen = ref(false)
|
||||
const isUserMenuOpen = ref(false)
|
||||
let topHeaderTween: gsap.core.Tween | null = null
|
||||
let bottomHeaderScrollTrigger: ReturnType<typeof ScrollTrigger.create> | null = null
|
||||
let isBottomHeaderVisible = false
|
||||
let fallbackTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
// 打开登录弹窗
|
||||
const openLoginModal = () => {
|
||||
isLoginModalOpen.value = true
|
||||
isRegisterModalOpen.value = false
|
||||
}
|
||||
|
||||
// 关闭登录弹窗
|
||||
const closeLoginModal = () => {
|
||||
isLoginModalOpen.value = false
|
||||
}
|
||||
|
||||
// 打开注册弹窗
|
||||
const openRegisterModal = () => {
|
||||
isRegisterModalOpen.value = true
|
||||
isLoginModalOpen.value = false
|
||||
}
|
||||
|
||||
// 关闭注册弹窗
|
||||
const closeRegisterModal = () => {
|
||||
isRegisterModalOpen.value = false
|
||||
}
|
||||
|
||||
// 从登录切换到注册
|
||||
const switchToRegister = () => {
|
||||
isLoginModalOpen.value = false
|
||||
isRegisterModalOpen.value = true
|
||||
}
|
||||
|
||||
// 从注册切换到登录
|
||||
const switchToLogin = () => {
|
||||
isRegisterModalOpen.value = false
|
||||
isLoginModalOpen.value = true
|
||||
// 语言切换
|
||||
const switchLocale = () => {
|
||||
setLocale(locale.value === 'zh' ? 'en' : 'zh')
|
||||
}
|
||||
|
||||
// 切换用户菜单
|
||||
@@ -368,12 +339,21 @@ if (typeof window !== 'undefined') {
|
||||
</NuxtLink>
|
||||
</nav>
|
||||
|
||||
<!-- 右侧:登录按钮 / 用户信息(桌面端) -->
|
||||
<!-- 右侧:登录按钮 / 用户信息 / 语言切换(桌面端) -->
|
||||
<div class="hidden md:flex items-center gap-4">
|
||||
<!-- 语言切换 -->
|
||||
<button
|
||||
@click="switchLocale"
|
||||
class="px-3 py-2 rounded-full border border-gray-200 text-sm font-semibold text-black hover:bg-gray-100 transition-all duration-300"
|
||||
:aria-label="locale === 'zh' ? t('lang.toEnglish') : t('lang.toChinese')"
|
||||
>
|
||||
{{ locale === 'zh' ? t('lang.toEnglish') : t('lang.toChinese') }}
|
||||
</button>
|
||||
|
||||
<!-- 未登录:显示登录按钮 -->
|
||||
<button
|
||||
v-if="!userStore.isAuthenticated"
|
||||
@click="openLoginModal"
|
||||
@click="authModal.openLogin()"
|
||||
class="px-5 py-2.5 rounded-full bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-all duration-300 shadow-md hover:shadow-lg"
|
||||
>
|
||||
{{ t('auth.login') }}
|
||||
@@ -386,7 +366,7 @@ if (typeof window !== 'undefined') {
|
||||
class="flex items-center gap-3 px-4 py-2 rounded-full hover:bg-gray-100 transition-all duration-300"
|
||||
>
|
||||
<img
|
||||
:src="userStore.avatar"
|
||||
:src="userStore.user?.avatar"
|
||||
:alt="userStore.user?.username"
|
||||
class="w-9 h-9 rounded-full object-cover border-2 border-gray-200"
|
||||
/>
|
||||
@@ -409,6 +389,14 @@ if (typeof window !== 'undefined') {
|
||||
<p class="text-sm font-semibold text-black">{{ userStore.user?.username }}</p>
|
||||
<p class="text-xs text-gray-500 truncate">{{ userStore.user?.email }}</p>
|
||||
</div>
|
||||
<NuxtLink
|
||||
to="/account"
|
||||
@click="closeUserMenu"
|
||||
class="w-full px-4 py-2.5 text-left text-sm font-medium text-gray-700 hover:bg-gray-100 transition-colors duration-200 flex items-center gap-2"
|
||||
>
|
||||
<Icon name="ph:user-circle" class="w-4 h-4" />
|
||||
{{ t('account.title') }}
|
||||
</NuxtLink>
|
||||
<button
|
||||
@click="handleLogout"
|
||||
class="w-full px-4 py-2.5 text-left text-sm font-medium text-red-600 hover:bg-red-50 transition-colors duration-200 flex items-center gap-2"
|
||||
@@ -458,10 +446,18 @@ if (typeof window !== 'undefined') {
|
||||
|
||||
<!-- 移动端登录/用户信息 -->
|
||||
<div class="mobile-menu-item mt-8 pt-8 border-t border-gray-200 w-full flex flex-col items-center gap-4">
|
||||
<!-- 语言切换 -->
|
||||
<button
|
||||
@click="switchLocale"
|
||||
class="px-8 py-3 rounded-full border-2 border-black text-black text-base font-semibold hover:bg-gray-100 transition-all duration-300"
|
||||
>
|
||||
{{ locale === 'zh' ? t('lang.toEnglish') : t('lang.toChinese') }}
|
||||
</button>
|
||||
|
||||
<!-- 未登录 -->
|
||||
<button
|
||||
v-if="!userStore.isAuthenticated"
|
||||
@click="openLoginModal"
|
||||
@click="authModal.openLogin()"
|
||||
class="px-8 py-3 rounded-full bg-black text-white text-base font-semibold hover:bg-gray-800 transition-all duration-300"
|
||||
>
|
||||
{{ t('auth.login') }}
|
||||
@@ -471,7 +467,7 @@ if (typeof window !== 'undefined') {
|
||||
<div v-else class="flex flex-col items-center gap-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<img
|
||||
:src="userStore.avatar"
|
||||
:src="userStore.user?.avatar"
|
||||
:alt="userStore.user?.username"
|
||||
class="w-12 h-12 rounded-full object-cover border-2 border-gray-200"
|
||||
/>
|
||||
@@ -492,19 +488,11 @@ if (typeof window !== 'undefined') {
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<!-- 登录弹窗 -->
|
||||
<LoginModal
|
||||
:is-open="isLoginModalOpen"
|
||||
@close="closeLoginModal"
|
||||
@switch-to-register="switchToRegister"
|
||||
/>
|
||||
<!-- 登录弹窗(由 authModal store 控制开关) -->
|
||||
<LoginModal />
|
||||
|
||||
<!-- 注册弹窗 -->
|
||||
<RegisterModal
|
||||
:is-open="isRegisterModalOpen"
|
||||
@close="closeRegisterModal"
|
||||
@switch-to-login="switchToLogin"
|
||||
/>
|
||||
<!-- 注册弹窗(由 authModal store 控制开关) -->
|
||||
<RegisterModal />
|
||||
|
||||
<header ref="bottomHeaderRef" class="site-header-bottom z-50 bg-white/80 backdrop-blur-md">
|
||||
<!-- 左侧菜单 (前两个菜单项) -->
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
/**
|
||||
* 把后端 API 错误码映射为已翻译的 i18n 文案。
|
||||
* 用法:`const apiError = useApiError()`;`apiError(err)` 返回中文/英文消息。
|
||||
*/
|
||||
export function useApiError() {
|
||||
const { t } = useI18n()
|
||||
|
||||
const codeKeyMap: Record<string, string> = {
|
||||
USERNAME_TAKEN: 'auth.usernameTaken',
|
||||
EMAIL_TAKEN: 'auth.emailTaken',
|
||||
INVALID_CREDENTIALS: 'auth.invalidCredentials',
|
||||
UNAUTHORIZED: 'auth.loginRequired',
|
||||
FORBIDDEN: 'auth.loginRequired',
|
||||
ALREADY_SUBSCRIBED: 'newsletter.alreadySubscribed',
|
||||
VALIDATION_ERROR: 'auth.serverError',
|
||||
}
|
||||
|
||||
return (err: any, fallbackKey = 'auth.serverError'): string => {
|
||||
const code = err?.data?.code
|
||||
if (code && codeKeyMap[code]) {
|
||||
return t(codeKeyMap[code])
|
||||
}
|
||||
// 后端若带具体 message 也如实展示
|
||||
if (typeof err?.data?.message === 'string' && err.data.message) {
|
||||
return err.data.message
|
||||
}
|
||||
return t(fallbackKey)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { computed } from 'vue'
|
||||
import { useFetch } from '#imports'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import type { SiteSettings, LocalizedText } from '~/config/site'
|
||||
|
||||
/**
|
||||
* 站点动态配置(SSR 友好)。
|
||||
* - settings:后端合并默认值后的站点配置(可在后台 /admin/settings 修改)
|
||||
* - loc(t):按当前语言取双语文本(locale 切换即时生效,无需重新请求)
|
||||
*/
|
||||
export function useSiteSettings() {
|
||||
const { locale } = useI18n()
|
||||
const { data, refresh, status } = useFetch<SiteSettings>('/api/settings')
|
||||
|
||||
const settings = computed(() => data.value)
|
||||
|
||||
const loc = (t?: LocalizedText) => (t ? (locale.value === 'zh' ? t.zh : t.en) : '')
|
||||
|
||||
return { settings, loc, refresh, status }
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* 站点配置:类型 + 默认值(单一事实源)。
|
||||
*
|
||||
* 业务配置可在后台 `/admin/settings` 动态修改(存于 DB settings 表),
|
||||
* 未修改时使用这里的默认值。`siteConfig` 为兼容旧引用的子集。
|
||||
*/
|
||||
|
||||
export interface LocalizedText {
|
||||
zh: string
|
||||
en: string
|
||||
}
|
||||
|
||||
export interface SocialLink {
|
||||
name: string
|
||||
icon: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export interface ToolItem {
|
||||
id: string
|
||||
name: string
|
||||
url: string
|
||||
icon: string
|
||||
color: string
|
||||
descZh: string
|
||||
descEn: string
|
||||
}
|
||||
|
||||
export interface SiteSettings {
|
||||
site: {
|
||||
name: string
|
||||
brand: string
|
||||
description: LocalizedText
|
||||
}
|
||||
contact: {
|
||||
email: string
|
||||
infoEmail: string
|
||||
wechat: string
|
||||
address: LocalizedText
|
||||
}
|
||||
socials: SocialLink[]
|
||||
tools: ToolItem[]
|
||||
footer: {
|
||||
title: LocalizedText
|
||||
newsletterTitle: LocalizedText
|
||||
newsletterNote: LocalizedText
|
||||
copyright: LocalizedText
|
||||
}
|
||||
seo: {
|
||||
description: LocalizedText
|
||||
keywords: LocalizedText
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultSettings: SiteSettings = {
|
||||
site: {
|
||||
name: 'ArcticNewOne',
|
||||
brand: '北极新一',
|
||||
description: {
|
||||
zh: '探索无限可能的现代化体验,欢迎来到 ArcticNewOne。',
|
||||
en: 'Explore infinite possibilities and modern experiences. Welcome to ArcticNewOne.',
|
||||
},
|
||||
},
|
||||
contact: {
|
||||
email: 'chenchun@virtheart.com',
|
||||
infoEmail: 'info@virtheart.com',
|
||||
wechat: 'LucskyNew',
|
||||
address: {
|
||||
zh: '贵州省毕节市七星关区\n滨河西路',
|
||||
en: 'Binhe West Road, Qixingguan District\nBijie City, Guizhou Province',
|
||||
},
|
||||
},
|
||||
socials: [
|
||||
{ name: 'X', icon: 'ph:x-logo', url: 'https://x.com/arcticnewone' },
|
||||
{ name: 'Instagram', icon: 'ph:instagram-logo', url: 'https://instagram.com/arcticnewone' },
|
||||
{ name: 'LinkedIn', icon: 'ph:linkedin-logo', url: 'https://www.linkedin.com/company/arcticnewone' },
|
||||
{ name: 'GitHub', icon: 'ph:github-logo', url: 'https://github.com/arcticnewone' },
|
||||
],
|
||||
tools: [
|
||||
{
|
||||
id: 'drawio',
|
||||
name: 'Drawio',
|
||||
url: 'https://drawio.virtheart.com',
|
||||
icon: 'ph:flow-arrow-duotone',
|
||||
color: 'from-orange-50/50 to-amber-100/50',
|
||||
descZh: '强大的在线图表绘制工具,支持流程图、UML、网络拓扑等。',
|
||||
descEn: 'Powerful online diagramming tool for flowcharts, UML, and network topologies.',
|
||||
},
|
||||
{
|
||||
id: 'excalidraw',
|
||||
name: 'Excalidraw',
|
||||
url: 'https://excalidraw.virtheart.com',
|
||||
icon: 'ph:pencil-circle-duotone',
|
||||
color: 'from-purple-50/50 to-indigo-100/50',
|
||||
descZh: '手绘风格的白板工具,轻松绘制草图和协作思考。',
|
||||
descEn: 'Hand-drawn style whiteboard tool for easy sketching and collaborative thinking.',
|
||||
},
|
||||
{
|
||||
id: 'itTools',
|
||||
name: 'IT-Tools',
|
||||
url: 'https://ittools.virtheart.com',
|
||||
icon: 'ph:wrench-duotone',
|
||||
color: 'from-blue-50/50 to-cyan-100/50',
|
||||
descZh: '为开发人员和IT从业者提供的一站式实用工具集合。',
|
||||
descEn: 'An all-in-one practical tool collection for developers and IT professionals.',
|
||||
},
|
||||
],
|
||||
footer: {
|
||||
title: {
|
||||
zh: '雕琢视觉,塑造故事。\n让我们共创卓越作品!',
|
||||
en: 'Crafting visuals. Shaping stories.\nLet\'s create great work together!',
|
||||
},
|
||||
newsletterTitle: { zh: '抢先获取最新资讯', en: 'Get the latest updates first' },
|
||||
newsletterNote: { zh: '无广告干扰。仅提供精选更新。', en: 'No spam. Only curated updates.' },
|
||||
copyright: { zh: '© 2026 北极新一工作室', en: '© 2026 ArcticNewOne Studio' },
|
||||
},
|
||||
seo: {
|
||||
description: {
|
||||
zh: '探索无限可能的现代化体验,欢迎来到 ArcticNewOne。',
|
||||
en: 'Explore infinite possibilities and modern experiences. Welcome to ArcticNewOne.',
|
||||
},
|
||||
keywords: { zh: '北极新一,ArcticNewOne,设计,开发,品牌', en: 'ArcticNewOne,design,development,branding' },
|
||||
},
|
||||
}
|
||||
|
||||
/** 兼容旧引用的站点元信息子集(新代码请用 useSiteSettings) */
|
||||
export const siteConfig = {
|
||||
brand: defaultSettings.site.name,
|
||||
brandZh: defaultSettings.site.brand,
|
||||
email: defaultSettings.contact.email,
|
||||
infoEmail: defaultSettings.contact.infoEmail,
|
||||
wechat: defaultSettings.contact.wechat,
|
||||
copyright: defaultSettings.footer.copyright.zh,
|
||||
socials: defaultSettings.socials,
|
||||
}
|
||||
+14
-13
@@ -1,30 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import type { NuxtError } from '#app'
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
const props = defineProps<{ error: NuxtError }>()
|
||||
const { t } = useI18n()
|
||||
|
||||
const statusText = computed(() => props.error.statusText || 'Something went wrong.')
|
||||
const statusText = computed(() => {
|
||||
if (props.error.statusCode === 404) return t('error.notFound')
|
||||
if (props.error.statusCode === 500) return t('error.serverError')
|
||||
return t('error.generic')
|
||||
})
|
||||
|
||||
const handleError = () => clearError({ redirect: '/' })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex min-h-screen flex-col items-center justify-center gap-4 bg-slate-950 px-6 text-center text-slate-50">
|
||||
<p class="text-sm font-medium uppercase tracking-[0.35em] text-cyan-300">
|
||||
Error occurred in this page
|
||||
</p>
|
||||
<h1 class="text-6xl font-semibold">
|
||||
{{ error.status }}
|
||||
</h1>
|
||||
<p class="max-w-xl text-slate-300">
|
||||
{{ statusText }}
|
||||
</p>
|
||||
<div class="flex min-h-screen flex-col items-center justify-center gap-6 bg-white px-6 text-center">
|
||||
<p class="text-sm font-semibold uppercase tracking-[0.35em] text-gray-400">{{ t('error.title') }}</p>
|
||||
<h1 class="text-7xl font-bold text-black">{{ error.statusCode }}</h1>
|
||||
<p class="max-w-xl text-gray-500">{{ statusText }}</p>
|
||||
<button
|
||||
class="rounded-md bg-cyan-300 px-5 py-3 text-sm font-semibold text-slate-950 transition hover:bg-cyan-200"
|
||||
class="rounded-full bg-black px-8 py-3 text-sm font-semibold text-white transition-colors hover:bg-gray-800"
|
||||
type="button"
|
||||
@click="handleError"
|
||||
>
|
||||
Go back home
|
||||
{{ t('error.backHome') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台管理布局:左侧固定深色侧边栏 + 右侧内容区。
|
||||
* - 挂载全局 <AdminToast />,供后台各页统一反馈
|
||||
* - 内容区统一内边距与最大宽度(居中)
|
||||
* - 不包含站点公共 Header/Footer;移动端侧栏收起为顶栏按钮
|
||||
* - 由各后台页面通过 definePageMeta({ layout: 'admin' }) 启用
|
||||
*/
|
||||
import { ref } from 'vue'
|
||||
|
||||
const sidebarOpen = ref(false)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-screen bg-gray-50">
|
||||
<!-- 全局 toast(Teleport 到 body) -->
|
||||
<AdminToast />
|
||||
|
||||
<!-- 移动端顶栏 -->
|
||||
<header
|
||||
class="lg:hidden fixed top-0 inset-x-0 z-50 h-14 bg-black text-white flex items-center justify-between px-4 shadow-lg"
|
||||
>
|
||||
<NuxtLink to="/admin" class="flex items-center gap-2" @click="sidebarOpen = false">
|
||||
<div
|
||||
class="w-7 h-7 rounded-full bg-white text-black flex items-center justify-center font-bold text-xs"
|
||||
>
|
||||
A
|
||||
</div>
|
||||
<span class="font-bold text-sm">北极新一 · 后台</span>
|
||||
</NuxtLink>
|
||||
<button
|
||||
type="button"
|
||||
class="w-10 h-10 rounded-lg hover:bg-white/10 flex items-center justify-center transition-colors"
|
||||
aria-label="切换菜单"
|
||||
:aria-expanded="sidebarOpen"
|
||||
@click="sidebarOpen = !sidebarOpen"
|
||||
>
|
||||
<Icon :name="sidebarOpen ? 'ph:x' : 'ph:list'" class="w-5 h-5" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<!-- 移动端遮罩 -->
|
||||
<Transition name="admin-fade">
|
||||
<div
|
||||
v-if="sidebarOpen"
|
||||
class="lg:hidden fixed inset-0 z-40 bg-black/50"
|
||||
@click="sidebarOpen = false"
|
||||
></div>
|
||||
</Transition>
|
||||
|
||||
<!-- 侧边栏 -->
|
||||
<aside
|
||||
class="fixed inset-y-0 left-0 z-50 w-64 shadow-2xl transition-transform duration-300 lg:translate-x-0"
|
||||
:class="sidebarOpen ? 'translate-x-0' : '-translate-x-full'"
|
||||
>
|
||||
<AdminSidebar @navigate="sidebarOpen = false" />
|
||||
</aside>
|
||||
|
||||
<!-- 内容区 -->
|
||||
<main class="lg:pl-64 pt-14 lg:pt-0 min-h-screen">
|
||||
<div class="mx-auto max-w-[1200px] px-4 sm:px-6 lg:px-10 py-6 lg:py-10">
|
||||
<slot />
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.admin-fade-enter-active,
|
||||
.admin-fade-leave-active {
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
.admin-fade-enter-from,
|
||||
.admin-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,23 @@
|
||||
import { defineNuxtRouteMiddleware, navigateTo } from '#app'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
|
||||
/**
|
||||
* 后台路由守卫(/admin/**):仅管理员可访问。
|
||||
* - SSR 不拦截(真实防护在 admin API 的 requireAdmin);
|
||||
* - 客户端依据已恢复的会话判定,未登录则弹出登录框并回退,非管理员回首页。
|
||||
*/
|
||||
export default defineNuxtRouteMiddleware(() => {
|
||||
if (import.meta.server) return
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
if (!userStore.isAuthenticated) {
|
||||
const authModal = useAuthModalStore()
|
||||
authModal.openLogin()
|
||||
return navigateTo('/account')
|
||||
}
|
||||
if (userStore.user?.role !== 'admin') {
|
||||
return navigateTo('/')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,533 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 个人中心(重新设计)—— 对齐站点黑白编辑风:极简、大排版、充足留白。
|
||||
* - 资料区:头像 + 大号姓名 + 邮箱 + 角色/加入时间 + 三项统计(细分隔线)
|
||||
* - 导航:下划线页签
|
||||
* - profile:资料编辑 / 修改密码 / 删除账号(克制危险区)
|
||||
* - favorites:作品封面网格;comments:评论列表
|
||||
*/
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useSeoMeta } from '#imports'
|
||||
import gsap from 'gsap'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
import { useApiError } from '~/composables/useApiError'
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const authModal = useAuthModalStore()
|
||||
const apiError = useApiError()
|
||||
|
||||
useSeoMeta({ title: () => t('account.title') })
|
||||
|
||||
const isAdmin = computed(() => userStore.user?.role === 'admin')
|
||||
|
||||
const formatDate = (raw?: string, monthOnly = false) => {
|
||||
if (!raw) return ''
|
||||
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
const loc = locale.value === 'zh' ? 'zh-CN' : 'en-US'
|
||||
return new Intl.DateTimeFormat(loc, monthOnly ? { year: 'numeric', month: 'short' } : { year: 'numeric', month: 'short', day: 'numeric' }).format(d)
|
||||
}
|
||||
|
||||
/* ---------- 页签 ---------- */
|
||||
const activeTab = ref('profile')
|
||||
const tabs = computed(() => [
|
||||
{ key: 'profile', label: t('account.profile'), count: null as number | null },
|
||||
{ key: 'favorites', label: t('account.favorites'), count: favorites.value.length },
|
||||
{ key: 'comments', label: t('account.comments'), count: myComments.value.length },
|
||||
])
|
||||
const switchTab = (key: string) => {
|
||||
if (key === activeTab.value) return
|
||||
activeTab.value = key
|
||||
if (key === 'favorites') loadFavorites()
|
||||
if (key === 'comments') loadComments()
|
||||
}
|
||||
|
||||
/* ---------- 资料编辑 ---------- */
|
||||
const profileForm = reactive({ username: '', phone: '' })
|
||||
const profileSaving = ref(false)
|
||||
const profileMsg = ref<{ ok: boolean; text: string } | null>(null)
|
||||
const initProfileForm = () => {
|
||||
profileForm.username = userStore.user?.username ?? ''
|
||||
profileForm.phone = userStore.user?.phone ?? ''
|
||||
}
|
||||
const saveProfile = async () => {
|
||||
profileSaving.value = true
|
||||
profileMsg.value = null
|
||||
const result = await userStore.updateProfile({ username: profileForm.username, phone: profileForm.phone })
|
||||
profileSaving.value = false
|
||||
profileMsg.value = result.success
|
||||
? { ok: true, text: t('account.saved') }
|
||||
: { ok: false, text: apiError({ data: { code: result.code } }) }
|
||||
}
|
||||
|
||||
/* ---------- 头像 ---------- */
|
||||
const avatarUpdating = ref(false)
|
||||
const avatarMsg = ref<{ ok: boolean; text: string } | null>(null)
|
||||
const onAvatarChange = async (e: Event) => {
|
||||
const input = e.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
if (!file) return
|
||||
if (!/^image\//.test(file.type) || file.size > 8 * 1024 * 1024) {
|
||||
avatarMsg.value = { ok: false, text: t('account.avatar.error') }
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
avatarUpdating.value = true
|
||||
avatarMsg.value = null
|
||||
const result = await userStore.updateAvatar(file)
|
||||
avatarUpdating.value = false
|
||||
input.value = ''
|
||||
avatarMsg.value = result.success
|
||||
? { ok: true, text: t('account.avatar.success') }
|
||||
: { ok: false, text: t('account.avatar.error') }
|
||||
}
|
||||
const removeAvatar = async () => {
|
||||
avatarUpdating.value = true
|
||||
avatarMsg.value = null
|
||||
const result = await userStore.updateAvatar(null)
|
||||
avatarUpdating.value = false
|
||||
avatarMsg.value = result.success
|
||||
? { ok: true, text: t('account.avatar.success') }
|
||||
: { ok: false, text: t('account.avatar.error') }
|
||||
}
|
||||
|
||||
/* ---------- 修改密码 ---------- */
|
||||
const pwForm = reactive({ currentPassword: '', newPassword: '', confirmPassword: '' })
|
||||
const pwSaving = ref(false)
|
||||
const pwError = ref('')
|
||||
const pwOk = ref(false)
|
||||
const changePassword = async () => {
|
||||
pwError.value = ''
|
||||
pwOk.value = false
|
||||
if (pwForm.newPassword.length < 8) { pwError.value = t('account.changePassword.tooShort'); return }
|
||||
if (pwForm.newPassword !== pwForm.confirmPassword) { pwError.value = t('account.changePassword.mismatch'); return }
|
||||
pwSaving.value = true
|
||||
try {
|
||||
await $fetch('/api/auth/password', { method: 'PATCH', body: { currentPassword: pwForm.currentPassword, newPassword: pwForm.newPassword } })
|
||||
pwForm.currentPassword = ''
|
||||
pwForm.newPassword = ''
|
||||
pwForm.confirmPassword = ''
|
||||
pwOk.value = true
|
||||
} catch (err) {
|
||||
pwError.value = (err as any)?.data?.code === 'WRONG_PASSWORD'
|
||||
? t('account.changePassword.wrongPassword')
|
||||
: apiError(err, 'account.changePassword.failed')
|
||||
} finally {
|
||||
pwSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 删除账号 ---------- */
|
||||
const deletePassword = ref('')
|
||||
const deleting = ref(false)
|
||||
const deleteError = ref('')
|
||||
const deleteConfirmOpen = ref(false)
|
||||
const askDeleteAccount = () => {
|
||||
deleteError.value = ''
|
||||
if (!deletePassword.value.trim()) { deleteError.value = t('account.deleteAccount.passwordPlaceholder'); return }
|
||||
deleteConfirmOpen.value = true
|
||||
}
|
||||
const doDeleteAccount = async () => {
|
||||
deleting.value = true
|
||||
try {
|
||||
await $fetch('/api/auth/me', { method: 'DELETE', body: { password: deletePassword.value } })
|
||||
deleteConfirmOpen.value = false
|
||||
await userStore.logout()
|
||||
await navigateTo('/')
|
||||
} catch (err) {
|
||||
deleteConfirmOpen.value = false
|
||||
deleteError.value = (err as any)?.data?.code === 'WRONG_PASSWORD'
|
||||
? t('account.deleteAccount.wrongPassword')
|
||||
: apiError(err)
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 收藏 ---------- */
|
||||
interface FavedWork { slug: string; titleZh: string; titleEn: string; image: string | null; year: string; category: string }
|
||||
const favorites = ref<FavedWork[]>([])
|
||||
const favLoading = ref(false)
|
||||
const favLoaded = ref(false)
|
||||
const favTitle = (w: FavedWork) => (locale.value === 'zh' ? w.titleZh : w.titleEn)
|
||||
const categoryLabel = (cat: string) => (['webDesign', 'branding', 'development'].includes(cat) ? t(`work.categories.${cat}`) : cat)
|
||||
const loadFavorites = async () => {
|
||||
if (favLoaded.value) return
|
||||
favLoading.value = true
|
||||
try {
|
||||
const [favRes, workRes] = await Promise.all([
|
||||
$fetch<{ slugs: string[] }>('/api/favorites'),
|
||||
$fetch<{ works: FavedWork[] }>('/api/work'),
|
||||
])
|
||||
const bySlug = new Map(workRes.works.map((w) => [w.slug, w]))
|
||||
favorites.value = favRes.slugs.map((s) => bySlug.get(s)).filter(Boolean) as FavedWork[]
|
||||
favLoaded.value = true
|
||||
} catch (err) { console.error('load favorites error:', err) } finally { favLoading.value = false }
|
||||
}
|
||||
const removeFavorite = async (slug: string) => {
|
||||
try {
|
||||
await $fetch('/api/favorites', { method: 'DELETE', body: { workSlug: slug } })
|
||||
favorites.value = favorites.value.filter((f) => f.slug !== slug)
|
||||
} catch (err) { console.error('remove favorite error:', err) }
|
||||
}
|
||||
|
||||
/* ---------- 我的评论 ---------- */
|
||||
interface MyComment { id: number; newsSlug: string; content: string; createdAt: string }
|
||||
const myComments = ref<MyComment[]>([])
|
||||
const commentLoading = ref(false)
|
||||
const commentsLoaded = ref(false)
|
||||
const loadComments = async () => {
|
||||
if (commentsLoaded.value) return
|
||||
commentLoading.value = true
|
||||
try {
|
||||
const data = await $fetch<{ comments: MyComment[] }>('/api/account/comments')
|
||||
myComments.value = data.comments
|
||||
commentsLoaded.value = true
|
||||
} catch (err) { console.error('load comments error:', err) } finally { commentLoading.value = false }
|
||||
}
|
||||
|
||||
/* ---------- 入场动画 ---------- */
|
||||
const mainRef = ref<HTMLElement | null>(null)
|
||||
let ctx: gsap.Context | null = null
|
||||
const runIntro = () => {
|
||||
ctx?.revert()
|
||||
if (!mainRef.value) return
|
||||
ctx = gsap.context(() => {
|
||||
const targets = gsap.utils.toArray<HTMLElement>('[data-animate]', mainRef.value)
|
||||
if (!targets.length) return
|
||||
gsap.set(targets, { autoAlpha: 0, y: 22 })
|
||||
gsap.to(targets, { autoAlpha: 1, y: 0, duration: 0.7, ease: 'power3.out', stagger: 0.08 })
|
||||
}, mainRef.value)
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await nextTick()
|
||||
initProfileForm()
|
||||
runIntro()
|
||||
if (userStore.isAuthenticated) await Promise.all([loadFavorites(), loadComments()])
|
||||
})
|
||||
onBeforeUnmount(() => ctx?.revert())
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main ref="mainRef" class="page-container min-h-screen pt-28 md:pt-36 pb-24 px-4 md:px-8 mx-auto max-w-[1000px]">
|
||||
<!-- 未登录 -->
|
||||
<section v-if="!userStore.isAuthenticated" data-animate class="max-w-sm mx-auto mt-10 md:mt-20 text-center">
|
||||
<div class="w-16 h-16 mx-auto rounded-full bg-gray-100 flex items-center justify-center mb-6">
|
||||
<Icon name="ph:user-duotone" class="w-8 h-8 text-gray-400" />
|
||||
</div>
|
||||
<h1 class="text-3xl md:text-4xl font-bold tracking-tight text-black mb-3">{{ t('account.title') }}</h1>
|
||||
<p class="text-gray-500 mb-8">{{ t('auth.loginRequired') }}</p>
|
||||
<button
|
||||
@click="authModal.openLogin()"
|
||||
class="px-8 py-3 rounded-full bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-colors"
|
||||
>
|
||||
{{ t('auth.login') }}
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<template v-else>
|
||||
<!-- 资料区(黑白极简) -->
|
||||
<header data-animate class="rounded-3xl border border-gray-100 bg-white shadow-sm">
|
||||
<div class="px-6 py-8 md:px-10 md:py-10">
|
||||
<div class="flex flex-col md:flex-row md:items-start gap-6 md:gap-8">
|
||||
<img
|
||||
:src="userStore.avatar"
|
||||
:alt="userStore.user?.username"
|
||||
class="w-20 h-20 md:w-24 md:h-24 rounded-2xl object-cover ring-1 ring-black/10 flex-shrink-0"
|
||||
/>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-3 flex-wrap">
|
||||
<h1 class="text-3xl md:text-4xl font-bold tracking-tight text-black">{{ userStore.user?.username }}</h1>
|
||||
<span
|
||||
class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold"
|
||||
:class="isAdmin ? 'bg-black text-white' : 'bg-gray-100 text-gray-600'"
|
||||
>
|
||||
<Icon :name="isAdmin ? 'ph:shield-check' : 'ph:user'" class="w-3 h-3" />
|
||||
{{ isAdmin ? t('account.roleAdmin') : t('account.roleUser') }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="mt-2 text-gray-500">{{ userStore.user?.email }}</p>
|
||||
<p class="mt-1 text-sm text-gray-400">
|
||||
{{ t('account.joinedAt') }} · {{ formatDate(userStore.user?.createdAt) }}
|
||||
</p>
|
||||
</div>
|
||||
<NuxtLink
|
||||
v-if="isAdmin"
|
||||
to="/admin"
|
||||
class="inline-flex items-center gap-1.5 text-sm font-semibold text-black underline underline-offset-4 hover:text-gray-500 transition-colors flex-shrink-0"
|
||||
>
|
||||
{{ t('account.adminEntry') }}
|
||||
<Icon name="ph:arrow-right" class="w-4 h-4" />
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 统计(细分隔线) -->
|
||||
<div class="mt-8 grid grid-cols-3 divide-x divide-gray-200 border-t border-gray-100 pt-6">
|
||||
<div class="text-center">
|
||||
<p class="text-2xl md:text-3xl font-bold text-black leading-none">{{ favorites.length }}</p>
|
||||
<p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statFavorites') }}</p>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p class="text-2xl md:text-3xl font-bold text-black leading-none">{{ myComments.length }}</p>
|
||||
<p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statComments') }}</p>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<p class="text-lg md:text-2xl font-bold text-black leading-none">{{ formatDate(userStore.user?.createdAt, true) }}</p>
|
||||
<p class="mt-1.5 text-[11px] uppercase tracking-wider text-gray-400">{{ t('account.statJoined') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- 页签(下划线) -->
|
||||
<nav data-animate class="mt-10 border-b border-gray-200">
|
||||
<div class="flex gap-8 overflow-x-auto">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:key="tab.key"
|
||||
type="button"
|
||||
@click="switchTab(tab.key)"
|
||||
class="flex items-center gap-2 py-3 text-sm font-semibold border-b-2 -mb-px whitespace-nowrap transition-colors"
|
||||
:class="activeTab === tab.key ? 'border-black text-black' : 'border-transparent text-gray-400 hover:text-black'"
|
||||
>
|
||||
{{ tab.label }}
|
||||
<span v-if="tab.count != null" class="text-xs text-gray-400">{{ tab.count }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- 内容 -->
|
||||
<div class="mt-8 md:mt-10">
|
||||
<Transition name="panel" mode="out-in">
|
||||
<!-- 个人资料(单一设置面板,内部分区) -->
|
||||
<section v-if="activeTab === 'profile'" key="profile" class="max-w-2xl mx-auto">
|
||||
<div class="rounded-3xl border border-gray-100 bg-white shadow-sm overflow-hidden divide-y divide-gray-100">
|
||||
<!-- 基本信息 -->
|
||||
<div class="px-6 md:px-8 py-7">
|
||||
<h3 class="text-lg font-bold text-black">{{ t('account.profile') }}</h3>
|
||||
<p class="text-sm text-gray-400 mt-0.5">个人基本信息与头像</p>
|
||||
|
||||
<div class="mt-6 flex items-center gap-6">
|
||||
<img :src="userStore.avatar" :alt="userStore.user?.username"
|
||||
class="w-20 h-20 rounded-2xl object-cover ring-1 ring-black/10 flex-shrink-0" />
|
||||
<div class="space-y-2.5">
|
||||
<label class="inline-flex cursor-pointer">
|
||||
<input type="file" accept="image/*" class="hidden" @change="onAvatarChange" />
|
||||
<span
|
||||
class="inline-flex items-center gap-1.5 px-4 py-2 rounded-full border border-gray-200 text-sm font-semibold text-gray-700 hover:border-black hover:text-black transition-colors"
|
||||
>
|
||||
<Icon v-if="avatarUpdating" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
<Icon v-else name="ph:camera" class="w-4 h-4" />
|
||||
{{ t('account.avatar.change') }}
|
||||
</span>
|
||||
</label>
|
||||
<button
|
||||
v-if="userStore.user?.avatar"
|
||||
@click="removeAvatar"
|
||||
:disabled="avatarUpdating"
|
||||
class="block text-sm text-gray-400 hover:text-red-600 transition-colors disabled:opacity-50"
|
||||
>
|
||||
{{ t('account.avatar.remove') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="avatarMsg" class="mt-3 text-sm" :class="avatarMsg.ok ? 'text-green-600' : 'text-red-600'">{{ avatarMsg.text }}</p>
|
||||
|
||||
<div class="mt-7 space-y-5">
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.username') }}</label>
|
||||
<input v-model="profileForm.username" type="text"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.phone') }}</label>
|
||||
<input v-model="profileForm.phone" type="tel"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.email') }}</label>
|
||||
<input :value="userStore.user?.email ?? ''" type="email" disabled
|
||||
class="w-full rounded-xl border border-gray-200 bg-gray-50 px-3.5 py-2.5 text-sm text-gray-500 cursor-not-allowed" />
|
||||
</div>
|
||||
<p v-if="profileMsg" class="text-sm" :class="profileMsg.ok ? 'text-green-600' : 'text-red-600'">{{ profileMsg.text }}</p>
|
||||
<div class="flex justify-end">
|
||||
<button @click="saveProfile" :disabled="profileSaving"
|
||||
class="inline-flex items-center gap-2 px-6 py-2.5 rounded-full bg-black text-white text-sm font-semibold hover:bg-gray-800 transition-colors disabled:opacity-50">
|
||||
<Icon v-if="profileSaving" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
{{ profileSaving ? t('account.saving') : t('account.save') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 安全设置 -->
|
||||
<div class="px-6 md:px-8 py-7">
|
||||
<h3 class="text-lg font-bold text-black">{{ t('account.changePassword.title') }}</h3>
|
||||
<p class="text-sm text-gray-400 mt-0.5">定期更换密码更安全</p>
|
||||
<form class="mt-6 space-y-5" @submit.prevent="changePassword">
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.changePassword.currentPassword') }}</label>
|
||||
<input v-model="pwForm.currentPassword" type="password" autocomplete="current-password" required
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.changePassword.newPassword') }}</label>
|
||||
<input v-model="pwForm.newPassword" type="password" autocomplete="new-password" required
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('account.changePassword.confirmPassword') }}</label>
|
||||
<input v-model="pwForm.confirmPassword" type="password" autocomplete="new-password" required
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10" />
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="pwError" class="text-sm text-red-600">{{ pwError }}</p>
|
||||
<p v-if="pwOk" class="text-sm text-green-600">{{ t('account.changePassword.success') }}</p>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" :disabled="pwSaving"
|
||||
class="inline-flex items-center gap-2 px-6 py-2.5 rounded-full border border-gray-200 text-gray-700 text-sm font-semibold hover:border-black hover:text-black transition-colors disabled:opacity-50">
|
||||
<Icon v-if="pwSaving" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
{{ pwSaving ? t('account.changePassword.saving') : t('account.changePassword.submit') }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- 危险操作 -->
|
||||
<div class="px-6 md:px-8 py-7 bg-red-50/40">
|
||||
<h3 class="text-lg font-bold text-red-600">{{ t('account.deleteAccount.title') }}</h3>
|
||||
<p class="text-sm text-red-400 mt-0.5">危险操作</p>
|
||||
<div class="mt-6 space-y-5">
|
||||
<p class="text-sm text-gray-600 leading-relaxed">{{ t('account.deleteAccount.hint') }}</p>
|
||||
<div>
|
||||
<label class="block text-sm font-semibold text-gray-800 mb-1.5">{{ t('auth.password') }}</label>
|
||||
<input v-model="deletePassword" type="password" autocomplete="current-password"
|
||||
:placeholder="t('account.deleteAccount.passwordPlaceholder')"
|
||||
@keydown.enter.prevent="askDeleteAccount"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-red-400 focus:ring-2 focus:ring-red-500/10" />
|
||||
</div>
|
||||
<p v-if="deleteError" class="text-sm text-red-600">{{ deleteError }}</p>
|
||||
<div class="flex justify-end">
|
||||
<button @click="askDeleteAccount" :disabled="deleting"
|
||||
class="inline-flex items-center gap-2 px-6 py-2.5 rounded-full bg-red-600 text-white text-sm font-semibold hover:bg-red-700 transition-colors disabled:opacity-50">
|
||||
<Icon v-if="deleting" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
{{ t('account.deleteAccount.confirmButton') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 我的收藏 -->
|
||||
<section v-else-if="activeTab === 'favorites'" key="favorites">
|
||||
<div v-if="favLoading" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
|
||||
<div v-for="i in 3" :key="i" class="rounded-2xl border border-gray-100 bg-white overflow-hidden animate-pulse">
|
||||
<div class="aspect-[4/3] bg-gray-100"></div>
|
||||
<div class="p-4 space-y-2"><div class="h-3.5 rounded bg-gray-100 w-2/3"></div><div class="h-3 rounded bg-gray-100 w-1/3"></div></div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!favorites.length" class="text-center py-20">
|
||||
<Icon name="ph:bookmark-simple" class="w-12 h-12 text-gray-200 mx-auto mb-4" />
|
||||
<p class="text-gray-500">{{ t('account.emptyFavorites') }}</p>
|
||||
</div>
|
||||
<div v-else class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
|
||||
<div v-for="fav in favorites" :key="fav.slug"
|
||||
class="group rounded-2xl overflow-hidden bg-white border border-gray-100 shadow-sm hover:shadow-xl transition-all duration-300 hover:-translate-y-1">
|
||||
<div class="relative aspect-[4/3] overflow-hidden bg-gray-50">
|
||||
<NuxtLink :to="`/work/${fav.slug}`" class="block w-full h-full" :aria-label="favTitle(fav)">
|
||||
<img v-if="fav.image" :src="fav.image" :alt="favTitle(fav)" loading="lazy"
|
||||
class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
<div v-else class="w-full h-full flex items-center justify-center"><Icon name="ph:image" class="w-8 h-8 text-gray-300" /></div>
|
||||
</NuxtLink>
|
||||
<span v-if="fav.year"
|
||||
class="absolute top-3 left-3 px-2.5 py-1 rounded-full bg-black/60 backdrop-blur-sm text-white text-xs font-semibold pointer-events-none">
|
||||
{{ fav.year }}
|
||||
</span>
|
||||
<button type="button" @click="removeFavorite(fav.slug)"
|
||||
class="absolute top-3 right-3 w-9 h-9 rounded-full bg-white/90 backdrop-blur-sm text-gray-600 hover:bg-red-500 hover:text-white flex items-center justify-center shadow transition-all duration-200"
|
||||
:aria-label="t('favorites.remove')">
|
||||
<Icon name="ph:bookmark-simple-fill" class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
<NuxtLink :to="`/work/${fav.slug}`" class="block font-bold text-black group-hover:text-gray-600 transition-colors truncate">
|
||||
{{ favTitle(fav) }}
|
||||
</NuxtLink>
|
||||
<span class="mt-1.5 inline-block px-2 py-0.5 rounded-full bg-gray-100 text-gray-500 text-xs font-medium">
|
||||
{{ categoryLabel(fav.category) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 我的评论 -->
|
||||
<section v-else key="comments" class="max-w-2xl mx-auto">
|
||||
<div v-if="commentLoading" class="space-y-4">
|
||||
<div v-for="i in 3" :key="i" class="rounded-2xl border border-gray-100 bg-white p-5 animate-pulse space-y-3">
|
||||
<div class="h-3.5 rounded bg-gray-100 w-1/4"></div><div class="h-3 rounded bg-gray-100 w-full"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="!myComments.length" class="text-center py-20">
|
||||
<Icon name="ph:chat-circle-text" class="w-12 h-12 text-gray-200 mx-auto mb-4" />
|
||||
<p class="text-gray-500">{{ t('account.emptyComments') }}</p>
|
||||
</div>
|
||||
<div v-else class="divide-y divide-gray-100 border border-gray-100 bg-white rounded-2xl shadow-sm">
|
||||
<div v-for="comment in myComments" :key="comment.id" class="p-5 md:p-6 flex gap-4">
|
||||
<div class="w-10 h-10 rounded-full bg-gray-100 text-gray-400 flex items-center justify-center flex-shrink-0">
|
||||
<Icon name="ph:chat-circle-dots" class="w-5 h-5" />
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center justify-between gap-3 flex-wrap">
|
||||
<NuxtLink :to="`/news/${comment.newsSlug}`"
|
||||
class="inline-flex items-center gap-1.5 text-sm font-semibold text-black hover:text-gray-600 transition-colors">
|
||||
<Icon name="ph:article" class="w-4 h-4 text-gray-400" />
|
||||
#{{ comment.newsSlug }}
|
||||
</NuxtLink>
|
||||
<span class="text-xs text-gray-400">{{ formatDate(comment.createdAt) }}</span>
|
||||
</div>
|
||||
<p class="mt-2 text-gray-700 text-sm leading-relaxed break-words">{{ comment.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 删除账号确认 -->
|
||||
<div v-if="deleteConfirmOpen" class="fixed inset-0 z-[150] flex items-center justify-center bg-black/40 p-4" @click.self="deleteConfirmOpen = false">
|
||||
<div class="w-full max-w-sm rounded-2xl bg-white shadow-2xl overflow-hidden">
|
||||
<div class="px-6 py-5 border-b border-gray-100 flex items-start gap-3">
|
||||
<div class="flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-red-50 text-red-600">
|
||||
<Icon name="ph:warning-fill" class="w-5 h-5" />
|
||||
</div>
|
||||
<p class="text-sm text-gray-700 leading-relaxed pt-1">{{ t('account.deleteAccount.confirmText') }}</p>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2 px-6 py-4">
|
||||
<button @click="deleteConfirmOpen = false" :disabled="deleting"
|
||||
class="px-4 py-2 rounded-full border border-gray-200 text-sm font-semibold text-gray-600 hover:border-gray-300 transition-colors disabled:opacity-50">
|
||||
{{ t('account.deleteAccount.cancelButton') }}
|
||||
</button>
|
||||
<button @click="doDeleteAccount" :disabled="deleting"
|
||||
class="inline-flex items-center gap-2 px-5 py-2 rounded-full bg-red-600 text-white text-sm font-semibold hover:bg-red-700 transition-colors disabled:opacity-50">
|
||||
<Icon v-if="deleting" name="ph:circle-notch" class="w-4 h-4 animate-spin" />
|
||||
{{ t('account.deleteAccount.confirmButton') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.panel-enter-active, .panel-leave-active { transition: opacity 0.25s ease, transform 0.25s ease; }
|
||||
.panel-enter-from { opacity: 0; transform: translateY(12px); }
|
||||
.panel-leave-to { opacity: 0; transform: translateY(-8px); }
|
||||
</style>
|
||||
@@ -0,0 +1,260 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台操作日志:后端分页 + 操作类型筛选 + 关键词检索(当前页过滤)+ 清空确认。
|
||||
* - GET /api/admin/audit?page=&pageSize= → { logs, total, page, pageSize };DELETE /api/admin/audit
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useHead({ title: '操作日志' })
|
||||
|
||||
interface AuditLog {
|
||||
id: number
|
||||
actor_name: string | null
|
||||
action: string
|
||||
target: string
|
||||
detail: string | null
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
const ACTION_META: Record<string, { label: string; tone: 'green' | 'amber' | 'red' | 'blue' | 'gray' }> = {
|
||||
create: { label: '新增', tone: 'green' },
|
||||
update: { label: '更新', tone: 'amber' },
|
||||
delete: { label: '删除', tone: 'red' },
|
||||
upload: { label: '上传', tone: 'blue' },
|
||||
clear: { label: '清空', tone: 'gray' },
|
||||
}
|
||||
const actionMeta = (action: string) =>
|
||||
ACTION_META[action] ?? { label: action, tone: 'gray' as const }
|
||||
|
||||
const ACTION_OPTIONS = [
|
||||
{ value: 'all', label: '全部操作' },
|
||||
{ value: 'create', label: '新增' },
|
||||
{ value: 'update', label: '更新' },
|
||||
{ value: 'delete', label: '删除' },
|
||||
{ value: 'upload', label: '上传' },
|
||||
{ value: 'clear', label: '清空' },
|
||||
]
|
||||
|
||||
/* ---------- 列表(后端分页) ---------- */
|
||||
const pageSize = 15
|
||||
const page = ref(1)
|
||||
const total = ref(0)
|
||||
const logs = ref<AuditLog[]>([])
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
|
||||
const loadLogs = async () => {
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const data = await $fetch<{ logs: AuditLog[]; total: number; page: number }>('/api/admin/audit', {
|
||||
query: { page: page.value, pageSize },
|
||||
})
|
||||
logs.value = data.logs
|
||||
total.value = data.total
|
||||
page.value = data.page
|
||||
} catch (err) {
|
||||
console.error('load audit error:', err)
|
||||
loadError.value = '加载失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadLogs)
|
||||
|
||||
const changePage = (p: number) => {
|
||||
if (p === page.value) return
|
||||
page.value = p
|
||||
loadLogs()
|
||||
}
|
||||
|
||||
/* ---------- 筛选 / 关键词(当前页过滤) ---------- */
|
||||
const actionFilter = ref('all')
|
||||
const keyword = ref('')
|
||||
|
||||
const filteredLogs = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return logs.value.filter((log) => {
|
||||
if (actionFilter.value !== 'all' && log.action !== actionFilter.value) return false
|
||||
if (!kw) return true
|
||||
return (
|
||||
(log.actor_name || '').toLowerCase().includes(kw) ||
|
||||
log.target.toLowerCase().includes(kw) ||
|
||||
(log.detail || '').toLowerCase().includes(kw)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
watch([actionFilter, keyword], () => {
|
||||
if (page.value !== 1) {
|
||||
page.value = 1
|
||||
loadLogs()
|
||||
}
|
||||
})
|
||||
|
||||
/* ---------- 清空 ---------- */
|
||||
const confirmClear = ref(false)
|
||||
const clearing = ref(false)
|
||||
|
||||
const clearLogs = async () => {
|
||||
clearing.value = true
|
||||
try {
|
||||
await $fetch('/api/admin/audit', { method: 'DELETE' })
|
||||
toast.success('日志已清空')
|
||||
confirmClear.value = false
|
||||
await loadLogs()
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '清空失败,请重试')
|
||||
} finally {
|
||||
clearing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (raw?: string) => {
|
||||
if (!raw) return ''
|
||||
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(d)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<AdminPageHeader title="操作日志" subtitle="后台管理员的关键操作审计记录。">
|
||||
<template #actions>
|
||||
<AdminButton variant="danger" size="sm" :disabled="!total || clearing" :loading="clearing" @click="confirmClear = true">
|
||||
<Icon name="ph:trash" class="w-4 h-4" /> 清空日志
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- 统计 + 工具栏 -->
|
||||
<div class="mb-4 flex flex-wrap items-center gap-x-4 gap-y-2">
|
||||
<span class="text-sm text-gray-500">共 {{ total }} 条日志</span>
|
||||
<span v-if="keyword" class="text-sm text-gray-400">· 当前页匹配 {{ filteredLogs.length }} 条</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 flex flex-col gap-3 md:flex-row">
|
||||
<div class="relative flex-1 md:max-w-xs">
|
||||
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索操作人 / 对象 / 详情…"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white py-2.5 pl-10 pr-9 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10"
|
||||
/>
|
||||
<button
|
||||
v-if="keyword"
|
||||
@click="keyword = ''"
|
||||
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
|
||||
aria-label="清空筛选"
|
||||
>
|
||||
<Icon name="ph:x" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<AdminSelect v-model="actionFilter" :options="ACTION_OPTIONS" class="w-full md:w-40" />
|
||||
</div>
|
||||
|
||||
<!-- 加载态 -->
|
||||
<AdminCard v-if="loading">
|
||||
<AdminSkeleton :rows="6" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 错误态 -->
|
||||
<AdminCard v-else-if="loadError">
|
||||
<div class="py-10 text-center">
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ loadError }}</p>
|
||||
<AdminButton size="sm" @click="loadLogs">重新加载</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState v-else-if="!logs.length" icon="ph:list-checks" title="暂无操作日志" description="后台管理操作会自动记录在这里。" />
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredLogs.length"
|
||||
icon="ph:magnifying-glass"
|
||||
title="当前页没有匹配的日志"
|
||||
description="换个关键词或筛选条件,或在其他页试试。"
|
||||
/>
|
||||
|
||||
<!-- 日志表格 -->
|
||||
<template v-else>
|
||||
<!-- 桌面表格(md+) -->
|
||||
<div class="hidden md:block rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap sticky left-0 bg-gray-50 z-10 border-r border-gray-100">时间</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">操作人</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">操作</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">对象</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">详情</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
<tr v-for="log in filteredLogs" :key="log.id" class="hover:bg-gray-50/60 transition-colors">
|
||||
<td class="px-5 py-4 text-gray-500 text-xs whitespace-nowrap sticky left-0 bg-white z-10 border-r border-gray-100">{{ formatDate(log.createdAt) }}</td>
|
||||
<td class="px-5 py-4 text-gray-700 whitespace-nowrap">{{ log.actor_name || 'system' }}</td>
|
||||
<td class="px-5 py-4 whitespace-nowrap">
|
||||
<AdminBadge :tone="actionMeta(log.action).tone">{{ actionMeta(log.action).label }}</AdminBadge>
|
||||
</td>
|
||||
<td class="px-5 py-4">
|
||||
<code class="text-xs text-gray-600 bg-gray-50 border border-gray-100 rounded px-2 py-1">{{ log.target }}</code>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-gray-600 max-w-[320px] md:max-w-md truncate" :title="log.detail || undefined">
|
||||
{{ log.detail || '—' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 移动端卡片(<md) -->
|
||||
<div class="md:hidden space-y-3">
|
||||
<div v-for="log in filteredLogs" :key="log.id" class="bg-white rounded-2xl border border-gray-100 shadow-sm p-4">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<AdminBadge :tone="actionMeta(log.action).tone">{{ actionMeta(log.action).label }}</AdminBadge>
|
||||
<span class="text-xs text-gray-400 flex-shrink-0">{{ formatDate(log.createdAt) }}</span>
|
||||
</div>
|
||||
<div class="mt-2 flex items-center gap-2 text-sm">
|
||||
<span class="text-gray-400 flex-shrink-0">操作人</span>
|
||||
<span class="text-gray-700 truncate">{{ log.actor_name || 'system' }}</span>
|
||||
</div>
|
||||
<div class="mt-1.5">
|
||||
<code class="inline-block max-w-full text-xs text-gray-600 bg-gray-50 border border-gray-100 rounded px-2 py-1 break-all">{{ log.target }}</code>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-600 break-words">{{ log.detail || '—' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<AdminPagination :total="total" :page="page" :page-size="pageSize" @page="changePage" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 清空确认 -->
|
||||
<AdminConfirm
|
||||
:open="confirmClear"
|
||||
:loading="clearing"
|
||||
danger
|
||||
message="确定清空全部操作日志吗?此操作不可恢复。"
|
||||
@update:open="confirmClear = false"
|
||||
@confirm="clearLogs"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,353 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台评论管理:后端分页 + 关键词检索(当前页过滤)+ 多选批量删除。
|
||||
* - GET /api/admin/comments?page=&pageSize= → { comments, total, page, pageSize };DELETE /api/admin/comments/[id]
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useHead({ title: '评论管理' })
|
||||
|
||||
interface AdminComment {
|
||||
id: number
|
||||
newsSlug: string
|
||||
content: string
|
||||
createdAt: string
|
||||
username: string
|
||||
}
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
/* ---------- 列表(后端分页) ---------- */
|
||||
const pageSize = 15
|
||||
const page = ref(1)
|
||||
const total = ref(0)
|
||||
const comments = ref<AdminComment[]>([])
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
|
||||
const loadComments = async () => {
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const data = await $fetch<{ comments: AdminComment[]; total: number; page: number }>('/api/admin/comments', {
|
||||
query: { page: page.value, pageSize },
|
||||
})
|
||||
comments.value = data.comments
|
||||
total.value = data.total
|
||||
page.value = data.page
|
||||
} catch (err) {
|
||||
console.error('load comments error:', err)
|
||||
loadError.value = '加载失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadComments)
|
||||
|
||||
const changePage = (p: number) => {
|
||||
if (p === page.value) return
|
||||
page.value = p
|
||||
loadComments()
|
||||
}
|
||||
|
||||
/* ---------- 关键词(当前页过滤) ---------- */
|
||||
const keyword = ref('')
|
||||
const filteredComments = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
if (!kw) return comments.value
|
||||
return comments.value.filter(
|
||||
(c) => c.newsSlug.toLowerCase().includes(kw) || c.content.toLowerCase().includes(kw) || c.username.toLowerCase().includes(kw),
|
||||
)
|
||||
})
|
||||
|
||||
watch(keyword, () => {
|
||||
if (page.value !== 1) {
|
||||
page.value = 1
|
||||
loadComments()
|
||||
}
|
||||
})
|
||||
|
||||
/* ---------- 多选 / 批量删除 ---------- */
|
||||
const selected = ref<Set<number>>(new Set())
|
||||
|
||||
const allChecked = computed(
|
||||
() => filteredComments.value.length > 0 && filteredComments.value.every((c) => selected.value.has(c.id)),
|
||||
)
|
||||
|
||||
const toggleAll = () => {
|
||||
if (allChecked.value) {
|
||||
for (const c of filteredComments.value) selected.value.delete(c.id)
|
||||
selected.value = new Set(selected.value)
|
||||
} else {
|
||||
const next = new Set(selected.value)
|
||||
for (const c of filteredComments.value) next.add(c.id)
|
||||
selected.value = next
|
||||
}
|
||||
}
|
||||
|
||||
const toggleOne = (id: number) => {
|
||||
const next = new Set(selected.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
selected.value = next
|
||||
}
|
||||
|
||||
const batchConfirmOpen = ref(false)
|
||||
const batchDeleting = ref(false)
|
||||
|
||||
const doBatchDelete = async () => {
|
||||
const ids = [...selected.value]
|
||||
if (!ids.length) return
|
||||
batchDeleting.value = true
|
||||
let failed = 0
|
||||
for (const id of ids) {
|
||||
try {
|
||||
await $fetch(`/api/admin/comments/${id}`, { method: 'DELETE' })
|
||||
} catch (err: any) {
|
||||
console.error('batch delete comment error:', err)
|
||||
failed++
|
||||
}
|
||||
}
|
||||
batchDeleting.value = false
|
||||
batchConfirmOpen.value = false
|
||||
selected.value = new Set()
|
||||
if (failed === 0) {
|
||||
toast.success(`已删除 ${ids.length} 条评论`)
|
||||
} else {
|
||||
toast.error(`删除 ${ids.length - failed} 条成功,${failed} 条失败`)
|
||||
}
|
||||
await loadComments()
|
||||
}
|
||||
|
||||
/* ---------- 单条删除 ---------- */
|
||||
const confirmDelete = ref<AdminComment | null>(null)
|
||||
const deleting = ref(false)
|
||||
|
||||
const askDelete = (c: AdminComment) => {
|
||||
confirmDelete.value = c
|
||||
}
|
||||
|
||||
const doDelete = async () => {
|
||||
const c = confirmDelete.value
|
||||
if (!c) return
|
||||
deleting.value = true
|
||||
try {
|
||||
await $fetch(`/api/admin/comments/${c.id}`, { method: 'DELETE' })
|
||||
toast.success('评论已删除')
|
||||
confirmDelete.value = null
|
||||
selected.value.delete(c.id)
|
||||
await loadComments()
|
||||
} catch (err: any) {
|
||||
toast.error((err as any)?.data?.message || '删除失败,请重试')
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (raw?: string) => {
|
||||
if (!raw) return ''
|
||||
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(d)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<AdminPageHeader title="评论管理" subtitle="查看全站文章评论,按文章或内容关键词检索。">
|
||||
<template #actions>
|
||||
<AdminButton variant="secondary" size="sm" @click="loadComments">
|
||||
<Icon name="ph:arrows-clockwise" class="w-4 h-4" /> 刷新
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- 统计 + 工具栏 -->
|
||||
<div class="mb-4 flex flex-wrap items-center gap-x-4 gap-y-2">
|
||||
<span class="text-sm text-gray-500">共 {{ total }} 条评论</span>
|
||||
<span v-if="keyword" class="text-sm text-gray-400">· 当前页匹配 {{ filteredComments.length }} 条</span>
|
||||
<span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 flex flex-col gap-3 md:flex-row md:items-center">
|
||||
<div class="relative flex-1 md:max-w-xs">
|
||||
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="按文章或内容关键词筛选…"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white py-2.5 pl-10 pr-9 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10"
|
||||
/>
|
||||
<button
|
||||
v-if="keyword"
|
||||
@click="keyword = ''"
|
||||
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
|
||||
aria-label="清空筛选"
|
||||
>
|
||||
<Icon name="ph:x" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<AdminButton variant="danger" size="sm" class="w-full md:w-auto" :disabled="!selected.size" @click="batchConfirmOpen = true">
|
||||
<Icon name="ph:trash" class="w-4 h-4" /> 批量删除
|
||||
</AdminButton>
|
||||
</div>
|
||||
|
||||
<!-- 加载态 -->
|
||||
<AdminCard v-if="loading">
|
||||
<AdminSkeleton :rows="6" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 错误态 -->
|
||||
<AdminCard v-else-if="loadError">
|
||||
<div class="py-10 text-center">
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ loadError }}</p>
|
||||
<AdminButton size="sm" @click="loadComments">重新加载</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState v-else-if="!comments.length" icon="ph:chat-circle-text" title="暂无评论" description="还没有人发表评论。" />
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredComments.length"
|
||||
icon="ph:magnifying-glass"
|
||||
title="当前页没有匹配的评论"
|
||||
description="换个关键词,或在其他页试试。"
|
||||
/>
|
||||
|
||||
<!-- 评论表格 -->
|
||||
<template v-else>
|
||||
<!-- 桌面表格(md+) -->
|
||||
<div class="hidden md:block rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
|
||||
<th class="px-5 py-4 w-10 sticky left-0 bg-gray-50 z-10 border-r border-gray-100">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allChecked"
|
||||
class="w-4 h-4 rounded border-gray-300 accent-black cursor-pointer"
|
||||
@change="toggleAll"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">文章</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">作者</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">内容</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">评论时间</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
<tr
|
||||
v-for="c in filteredComments"
|
||||
:key="c.id"
|
||||
class="hover:bg-gray-50/60 transition-colors"
|
||||
:class="selected.has(c.id) ? 'bg-gray-50/70' : ''"
|
||||
>
|
||||
<td class="px-5 py-4 sticky left-0 bg-white z-10 border-r border-gray-100">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selected.has(c.id)"
|
||||
class="w-4 h-4 rounded border-gray-300 accent-black cursor-pointer"
|
||||
@change="toggleOne(c.id)"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-5 py-4 whitespace-nowrap">
|
||||
<NuxtLink
|
||||
:to="`/news/${c.newsSlug}`"
|
||||
class="inline-flex items-center gap-1.5 font-semibold text-black hover:text-gray-600 transition-colors"
|
||||
>
|
||||
<Icon name="ph:article" class="w-4 h-4 text-gray-400" />
|
||||
#{{ c.newsSlug }}
|
||||
</NuxtLink>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-gray-600 whitespace-nowrap">{{ c.username }}</td>
|
||||
<td class="px-5 py-4">
|
||||
<p class="text-gray-700 max-w-[300px] md:max-w-md truncate" :title="c.content">{{ c.content }}</p>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-gray-500 text-xs whitespace-nowrap">{{ formatDate(c.createdAt) }}</td>
|
||||
<td class="px-5 py-4">
|
||||
<div class="flex items-center justify-end">
|
||||
<AdminButton size="sm" variant="ghost" @click="askDelete(c)">
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</AdminButton>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 移动端卡片(<md) -->
|
||||
<div class="md:hidden space-y-3">
|
||||
<div
|
||||
v-for="c in filteredComments"
|
||||
:key="c.id"
|
||||
class="bg-white rounded-2xl border border-gray-100 shadow-sm p-4"
|
||||
:class="selected.has(c.id) ? 'ring-2 ring-black/5 border-black/10' : ''"
|
||||
>
|
||||
<div class="flex items-start gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selected.has(c.id)"
|
||||
class="w-5 h-5 mt-0.5 rounded border-gray-300 accent-black cursor-pointer flex-shrink-0"
|
||||
@change="toggleOne(c.id)"
|
||||
/>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<NuxtLink
|
||||
:to="`/news/${c.newsSlug}`"
|
||||
class="inline-flex items-center gap-1.5 font-semibold text-black min-w-0"
|
||||
>
|
||||
<Icon name="ph:article" class="w-4 h-4 text-gray-400 flex-shrink-0" />
|
||||
<span class="truncate">#{{ c.newsSlug }}</span>
|
||||
</NuxtLink>
|
||||
<AdminButton size="sm" variant="ghost" class="min-h-10 shrink-0 -my-1" @click="askDelete(c)">
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</AdminButton>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-gray-400">作者:{{ c.username }} · {{ formatDate(c.createdAt) }}</p>
|
||||
<p class="mt-2 text-sm text-gray-700 break-words line-clamp-3">{{ c.content }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<AdminPagination :total="total" :page="page" :page-size="pageSize" @page="changePage" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 批量删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="batchConfirmOpen"
|
||||
:loading="batchDeleting"
|
||||
danger
|
||||
:message="`确定删除已选的 ${selected.size} 条评论吗?此操作不可恢复。`"
|
||||
@update:open="batchConfirmOpen = false"
|
||||
@confirm="doBatchDelete"
|
||||
/>
|
||||
|
||||
<!-- 单条删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="!!confirmDelete"
|
||||
:loading="deleting"
|
||||
danger
|
||||
:message="'确定删除这条评论吗?此操作不可恢复。'"
|
||||
@update:open="confirmDelete = null"
|
||||
@confirm="doDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,359 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台联系留言:列表 + 已读/未读筛选 + 已读切换 + 多选批量删除 + 前端分页。
|
||||
* - GET /api/admin/contacts;PATCH /api/admin/contacts/[id] body { read: 0|1 };DELETE /api/admin/contacts/[id]
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useHead({ title: '联系留言' })
|
||||
|
||||
interface AdminContact {
|
||||
id: number
|
||||
name: string
|
||||
email: string
|
||||
subject: string
|
||||
message: string
|
||||
delivered: number
|
||||
read: number
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
/* ---------- 列表 ---------- */
|
||||
const contacts = ref<AdminContact[]>([])
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
|
||||
const loadContacts = async () => {
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const data = await $fetch<{ contacts: AdminContact[] }>('/api/admin/contacts')
|
||||
contacts.value = data.contacts
|
||||
} catch (err) {
|
||||
console.error('load contacts error:', err)
|
||||
loadError.value = '加载失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadContacts)
|
||||
|
||||
const deliveredCount = computed(() => contacts.value.filter((c) => Number(c.delivered) === 1).length)
|
||||
const unreadCount = computed(() => contacts.value.filter((c) => Number(c.read) !== 1).length)
|
||||
|
||||
/* ---------- 筛选 / 搜索 / 分页 ---------- */
|
||||
const readFilter = ref<'all' | 'read' | 'unread'>('all')
|
||||
const keyword = ref('')
|
||||
|
||||
const filteredContacts = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return contacts.value.filter((c) => {
|
||||
if (readFilter.value === 'read' && Number(c.read) !== 1) return false
|
||||
if (readFilter.value === 'unread' && Number(c.read) === 1) return false
|
||||
if (!kw) return true
|
||||
return (
|
||||
c.name.toLowerCase().includes(kw) ||
|
||||
c.email.toLowerCase().includes(kw) ||
|
||||
c.subject.toLowerCase().includes(kw) ||
|
||||
c.message.toLowerCase().includes(kw)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
const pageSize = 10
|
||||
const page = ref(1)
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(filteredContacts.value.length / pageSize)))
|
||||
|
||||
const pagedContacts = computed(() => {
|
||||
const p = Math.min(page.value, totalPages.value)
|
||||
const start = (p - 1) * pageSize
|
||||
return filteredContacts.value.slice(start, start + pageSize)
|
||||
})
|
||||
|
||||
watch([readFilter, keyword], () => {
|
||||
page.value = 1
|
||||
})
|
||||
|
||||
const changePage = (p: number) => {
|
||||
page.value = Math.min(Math.max(1, p), totalPages.value)
|
||||
}
|
||||
|
||||
/* ---------- 已读切换 ---------- */
|
||||
const togglingId = ref<number | null>(null)
|
||||
const toggleRead = async (c: AdminContact) => {
|
||||
const next = Number(c.read) === 1 ? 0 : 1
|
||||
togglingId.value = c.id
|
||||
try {
|
||||
await $fetch(`/api/admin/contacts/${c.id}`, { method: 'PATCH', body: { read: next } })
|
||||
c.read = next
|
||||
toast.success(next === 1 ? '已标记为已读' : '已标记为未读')
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '操作失败,请重试')
|
||||
} finally {
|
||||
togglingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 多选 / 批量删除 ---------- */
|
||||
const selected = ref<Set<number>>(new Set())
|
||||
|
||||
const allChecked = computed(
|
||||
() => pagedContacts.value.length > 0 && pagedContacts.value.every((c) => selected.value.has(c.id)),
|
||||
)
|
||||
|
||||
const toggleAll = () => {
|
||||
if (allChecked.value) {
|
||||
for (const c of pagedContacts.value) selected.value.delete(c.id)
|
||||
selected.value = new Set(selected.value)
|
||||
} else {
|
||||
const next = new Set(selected.value)
|
||||
for (const c of pagedContacts.value) next.add(c.id)
|
||||
selected.value = next
|
||||
}
|
||||
}
|
||||
|
||||
const toggleOne = (id: number) => {
|
||||
const next = new Set(selected.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
selected.value = next
|
||||
}
|
||||
|
||||
const batchConfirmOpen = ref(false)
|
||||
const batchDeleting = ref(false)
|
||||
|
||||
const doBatchDelete = async () => {
|
||||
const ids = [...selected.value]
|
||||
if (!ids.length) return
|
||||
batchDeleting.value = true
|
||||
let failed = 0
|
||||
for (const id of ids) {
|
||||
try {
|
||||
await $fetch(`/api/admin/contacts/${id}`, { method: 'DELETE' })
|
||||
} catch (err: any) {
|
||||
console.error('batch delete contact error:', err)
|
||||
failed++
|
||||
}
|
||||
}
|
||||
batchDeleting.value = false
|
||||
batchConfirmOpen.value = false
|
||||
selected.value = new Set()
|
||||
if (failed === 0) {
|
||||
toast.success(`已删除 ${ids.length} 条留言`)
|
||||
} else {
|
||||
toast.error(`删除 ${ids.length - failed} 条成功,${failed} 条失败`)
|
||||
}
|
||||
await loadContacts()
|
||||
}
|
||||
|
||||
/* ---------- 单条删除 ---------- */
|
||||
const confirmDelete = ref<AdminContact | null>(null)
|
||||
const deleting = ref(false)
|
||||
|
||||
const askDelete = (c: AdminContact) => {
|
||||
confirmDelete.value = c
|
||||
}
|
||||
|
||||
const doDelete = async () => {
|
||||
const c = confirmDelete.value
|
||||
if (!c) return
|
||||
deleting.value = true
|
||||
try {
|
||||
await $fetch(`/api/admin/contacts/${c.id}`, { method: 'DELETE' })
|
||||
contacts.value = contacts.value.filter((x) => x.id !== c.id)
|
||||
selected.value.delete(c.id)
|
||||
toast.success('留言已删除')
|
||||
confirmDelete.value = null
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '删除失败,请重试')
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (raw?: string) => {
|
||||
if (!raw) return ''
|
||||
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(d)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<AdminPageHeader title="联系留言" subtitle="访客通过联系表单提交的留言,关注送达状态。">
|
||||
<template #actions>
|
||||
<AdminButton variant="secondary" size="sm" @click="loadContacts">
|
||||
<Icon name="ph:arrows-clockwise" class="w-4 h-4" /> 刷新
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- 统计 + 工具栏 -->
|
||||
<div class="mb-4 flex flex-wrap items-center gap-x-4 gap-y-2">
|
||||
<span class="text-sm text-gray-500">共 {{ contacts.length }} 条消息</span>
|
||||
<span class="text-sm text-gray-400">· 已送达 {{ deliveredCount }} 条</span>
|
||||
<span class="text-sm text-gray-400">· 未读 {{ unreadCount }} 条</span>
|
||||
<span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 flex flex-col gap-3 md:flex-row md:items-center">
|
||||
<div class="relative flex-1 md:max-w-xs">
|
||||
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索姓名 / 邮箱 / 主题 / 内容…"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white py-2.5 pl-10 pr-9 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10"
|
||||
/>
|
||||
<button
|
||||
v-if="keyword"
|
||||
@click="keyword = ''"
|
||||
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
|
||||
aria-label="清空筛选"
|
||||
>
|
||||
<Icon name="ph:x" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<AdminSelect
|
||||
v-model="readFilter"
|
||||
:options="[
|
||||
{ value: 'all', label: '全部状态' },
|
||||
{ value: 'unread', label: '未读' },
|
||||
{ value: 'read', label: '已读' },
|
||||
]"
|
||||
class="w-full md:w-36"
|
||||
/>
|
||||
<AdminButton variant="danger" size="sm" class="w-full md:w-auto" :disabled="!selected.size" @click="batchConfirmOpen = true">
|
||||
<Icon name="ph:trash" class="w-4 h-4" /> 批量删除
|
||||
</AdminButton>
|
||||
</div>
|
||||
|
||||
<!-- 加载态 -->
|
||||
<AdminCard v-if="loading">
|
||||
<AdminSkeleton :rows="6" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 错误态 -->
|
||||
<AdminCard v-else-if="loadError">
|
||||
<div class="py-10 text-center">
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ loadError }}</p>
|
||||
<AdminButton size="sm" @click="loadContacts">重新加载</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState
|
||||
v-else-if="!contacts.length"
|
||||
icon="ph:envelope-simple-open"
|
||||
title="暂无联系消息"
|
||||
description="访客通过联系表单提交的留言会出现在这里。"
|
||||
/>
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredContacts.length"
|
||||
icon="ph:magnifying-glass"
|
||||
title="没有匹配的消息"
|
||||
description="换个关键词或筛选条件试试。"
|
||||
/>
|
||||
|
||||
<!-- 消息卡片列表 -->
|
||||
<div v-else class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-3">
|
||||
<div
|
||||
v-for="c in pagedContacts"
|
||||
:key="c.id"
|
||||
class="bg-white rounded-2xl border border-gray-100 shadow-sm p-5 flex flex-col gap-3 transition-shadow"
|
||||
:class="[selected.has(c.id) ? 'ring-2 ring-black/5 border-black/10' : 'hover:shadow-md']"
|
||||
>
|
||||
<div class="flex items-start gap-3 min-w-0">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selected.has(c.id)"
|
||||
class="w-5 h-5 rounded border-gray-300 accent-black cursor-pointer flex-shrink-0 mt-0.5"
|
||||
@change="toggleOne(c.id)"
|
||||
/>
|
||||
<div class="w-10 h-10 rounded-full bg-black text-white flex items-center justify-center font-bold flex-shrink-0">
|
||||
{{ (c.name || '?').charAt(0) }}
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex flex-wrap items-center gap-x-2">
|
||||
<h3 class="font-bold text-black">{{ c.name }}</h3>
|
||||
<a :href="`mailto:${c.email}`" class="text-sm text-gray-500 hover:text-black transition-colors break-all">
|
||||
{{ c.email }}
|
||||
</a>
|
||||
</div>
|
||||
<p class="text-xs text-gray-400 mt-1">{{ formatDate(c.createdAt) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<AdminBadge :tone="Number(c.delivered) === 1 ? 'green' : 'amber'">
|
||||
<Icon :name="Number(c.delivered) === 1 ? 'ph:check' : 'ph:clock'" class="w-3.5 h-3.5" />
|
||||
{{ Number(c.delivered) === 1 ? '已送达' : '未送达' }}
|
||||
</AdminBadge>
|
||||
<AdminBadge :tone="Number(c.read) === 1 ? 'gray' : 'black'">
|
||||
<Icon :name="Number(c.read) === 1 ? 'ph:envelope-open' : 'ph:envelope-simple'" class="w-3.5 h-3.5" />
|
||||
{{ Number(c.read) === 1 ? '已读' : '未读' }}
|
||||
</AdminBadge>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 border-t border-gray-100 pt-3">
|
||||
<p class="text-sm font-semibold text-gray-800">{{ c.subject }}</p>
|
||||
<p class="mt-1.5 text-sm text-gray-600 whitespace-pre-line break-words">{{ c.message }}</p>
|
||||
</div>
|
||||
|
||||
<div class="mt-auto pt-3 border-t border-gray-100 flex flex-wrap items-center gap-2">
|
||||
<AdminButton
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
class="flex-1 min-w-0 min-h-10"
|
||||
:loading="togglingId === c.id"
|
||||
@click="toggleRead(c)"
|
||||
>
|
||||
<Icon :name="Number(c.read) === 1 ? 'ph:envelope-open' : 'ph:envelope-simple'" class="w-3.5 h-3.5" />
|
||||
{{ Number(c.read) === 1 ? '标为未读' : '标为已读' }}
|
||||
</AdminButton>
|
||||
<AdminButton size="sm" variant="ghost" class="min-h-10 shrink-0" @click="askDelete(c)">
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</AdminButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="md:col-span-2 lg:col-span-3">
|
||||
<AdminPagination :total="filteredContacts.length" :page="page" :page-size="pageSize" @page="changePage" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 批量删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="batchConfirmOpen"
|
||||
:loading="batchDeleting"
|
||||
danger
|
||||
:message="`确定删除已选的 ${selected.size} 条留言吗?此操作不可恢复。`"
|
||||
@update:open="batchConfirmOpen = false"
|
||||
@confirm="doBatchDelete"
|
||||
/>
|
||||
|
||||
<!-- 单条删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="!!confirmDelete"
|
||||
:loading="deleting"
|
||||
danger
|
||||
:message="`确定删除「${confirmDelete?.name}」的这条消息吗?此操作不可恢复。`"
|
||||
@update:open="confirmDelete = null"
|
||||
@confirm="doDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,321 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台 Dashboard:统计卡片 + 最近联系/评论 + 快捷入口 + 存储用量。
|
||||
* 数据在 onMounted 客户端拉取(/api/admin/stats、/contacts、/comments、/uploads)。
|
||||
*/
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useSeoMeta({ title: 'Dashboard' })
|
||||
|
||||
interface Stats {
|
||||
articles: number
|
||||
works: number
|
||||
publishedArticles: number
|
||||
publishedWorks: number
|
||||
users: number
|
||||
comments: number
|
||||
contacts: number
|
||||
subscribers: number
|
||||
favorites: number
|
||||
}
|
||||
|
||||
interface AdminContact {
|
||||
id: number
|
||||
name: string
|
||||
email: string
|
||||
subject: string
|
||||
message: string
|
||||
delivered: number
|
||||
read: number
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
interface AdminComment {
|
||||
id: number
|
||||
newsSlug: string
|
||||
content: string
|
||||
username: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
interface UploadFile {
|
||||
name: string
|
||||
size: number
|
||||
modified: string
|
||||
url: string
|
||||
}
|
||||
|
||||
const stats = ref<Stats | null>(null)
|
||||
const contacts = ref<AdminContact[]>([])
|
||||
const comments = ref<AdminComment[]>([])
|
||||
|
||||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
|
||||
const files = ref<UploadFile[]>([])
|
||||
const storageType = ref('')
|
||||
const storageLoading = ref(true)
|
||||
const storageError = ref('')
|
||||
|
||||
const loadDashboard = async () => {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const [s, c, cm] = await Promise.all([
|
||||
$fetch<Stats>('/api/admin/stats'),
|
||||
$fetch<{ contacts: AdminContact[] }>('/api/admin/contacts'),
|
||||
$fetch<{ comments: AdminComment[] }>('/api/admin/comments?page=1&pageSize=5'),
|
||||
])
|
||||
stats.value = s
|
||||
contacts.value = (c.contacts || []).slice(0, 5)
|
||||
comments.value = (cm.comments || []).slice(0, 5)
|
||||
} catch (err: any) {
|
||||
error.value = err?.data?.message || '数据加载失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const loadStorage = async () => {
|
||||
storageLoading.value = true
|
||||
storageError.value = ''
|
||||
try {
|
||||
const data = await $fetch<{ files: UploadFile[]; storage: string }>('/api/admin/uploads')
|
||||
files.value = data.files || []
|
||||
storageType.value = data.storage || ''
|
||||
} catch {
|
||||
storageError.value = '存储信息加载失败'
|
||||
} finally {
|
||||
storageLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const refreshing = ref(false)
|
||||
const refreshAll = async () => {
|
||||
refreshing.value = true
|
||||
try {
|
||||
await Promise.all([loadDashboard(), loadStorage()])
|
||||
} finally {
|
||||
refreshing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadDashboard()
|
||||
loadStorage()
|
||||
})
|
||||
|
||||
const cards = computed(() => {
|
||||
const s = stats.value
|
||||
return [
|
||||
{
|
||||
label: '动态文章',
|
||||
value: s?.articles ?? 0,
|
||||
sub: `已发布 ${s?.publishedArticles ?? 0}`,
|
||||
icon: 'ph:newspaper',
|
||||
to: '/admin/news',
|
||||
},
|
||||
{
|
||||
label: '作品',
|
||||
value: s?.works ?? 0,
|
||||
sub: `已发布 ${s?.publishedWorks ?? 0}`,
|
||||
icon: 'ph:image-square',
|
||||
to: '/admin/work',
|
||||
},
|
||||
{ label: '注册用户', value: s?.users ?? 0, sub: '全部用户', icon: 'ph:users-three', to: '/admin/users' },
|
||||
{ label: '评论', value: s?.comments ?? 0, sub: '全部评论', icon: 'ph:chat-circle-text', to: '/admin/comments' },
|
||||
{ label: '联系留言', value: s?.contacts ?? 0, sub: '表单留言', icon: 'ph:envelope-simple', to: '/admin/contacts' },
|
||||
{ label: '订阅邮箱', value: s?.subscribers ?? 0, sub: 'Newsletter', icon: 'ph:paper-plane-tilt', to: '/admin/subscribers' },
|
||||
{ label: '作品收藏', value: s?.favorites ?? 0, sub: '收藏数', icon: 'ph:bookmark-simple', to: '/admin/work' },
|
||||
]
|
||||
})
|
||||
|
||||
const storageTotalBytes = computed(() => files.value.reduce((sum, f) => sum + (Number(f.size) || 0), 0))
|
||||
|
||||
const formatSize = (bytes: number) => {
|
||||
if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(2)} MB`
|
||||
if (bytes >= 1024) return `${Math.round(bytes / 1024)} KB`
|
||||
return `${bytes} B`
|
||||
}
|
||||
|
||||
const formatDate = (raw?: string) => {
|
||||
if (!raw) return ''
|
||||
// 兼容 "YYYY-MM-DD HH:MM:SS"(UTC)与 ISO 两种格式
|
||||
const iso = String(raw).includes('T') ? String(raw) : String(raw).replace(' ', 'T') + 'Z'
|
||||
const d = new Date(iso)
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
return new Intl.DateTimeFormat('zh-CN', { month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' }).format(d)
|
||||
}
|
||||
|
||||
const initial = (name?: string) => (name || '?').charAt(0).toUpperCase()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<AdminPageHeader title="Dashboard" subtitle="站点内容与数据概览">
|
||||
<template #actions>
|
||||
<AdminButton variant="secondary" :loading="refreshing" @click="refreshAll">
|
||||
<Icon name="ph:arrows-clockwise" class="w-4 h-4" /> 刷新数据
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- 统计卡片 -->
|
||||
<div
|
||||
v-if="loading"
|
||||
class="mt-8 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5"
|
||||
>
|
||||
<div
|
||||
v-for="i in 8"
|
||||
:key="i"
|
||||
class="rounded-2xl bg-white border border-gray-100 shadow-sm p-6 h-32 animate-pulse"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="error" class="mt-8">
|
||||
<AdminCard>
|
||||
<AdminEmptyState icon="ph:warning-circle" title="数据加载失败" :description="error">
|
||||
<template #action>
|
||||
<AdminButton variant="secondary" @click="loadDashboard">重新加载</AdminButton>
|
||||
</template>
|
||||
</AdminEmptyState>
|
||||
</AdminCard>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-else
|
||||
class="mt-8 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-5"
|
||||
>
|
||||
<NuxtLink
|
||||
v-for="card in cards"
|
||||
:key="card.label"
|
||||
:to="card.to"
|
||||
class="group block h-full"
|
||||
>
|
||||
<AdminCard class="h-full transition-all duration-300 hover:-translate-y-0.5 hover:shadow-md">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="text-2xl sm:text-3xl font-bold text-black leading-none tabular-nums">{{ card.value }}</p>
|
||||
<p class="mt-2 text-sm font-semibold text-gray-800">{{ card.label }}</p>
|
||||
<p class="mt-1 text-xs text-gray-400">{{ card.sub }}</p>
|
||||
</div>
|
||||
<div
|
||||
class="w-10 h-10 rounded-xl bg-gray-100 text-gray-600 flex items-center justify-center group-hover:bg-black group-hover:text-white transition-colors duration-300"
|
||||
>
|
||||
<Icon :name="card.icon" class="w-5 h-5" />
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 最近动态 + 侧栏 -->
|
||||
<div class="mt-8 grid grid-cols-1 xl:grid-cols-3 gap-5">
|
||||
<div class="xl:col-span-2 grid grid-cols-1 sm:grid-cols-2 gap-5">
|
||||
<!-- 最近联系 -->
|
||||
<AdminCard title="最近联系" subtitle="最新 5 条留言">
|
||||
<template #actions>
|
||||
<NuxtLink to="/admin/contacts" class="text-xs font-semibold text-gray-500 hover:text-black transition-colors">
|
||||
查看全部
|
||||
</NuxtLink>
|
||||
</template>
|
||||
<AdminSkeleton v-if="loading" :rows="4" />
|
||||
<AdminEmptyState v-else-if="!contacts.length" icon="ph:envelope-simple-open" title="暂无留言" />
|
||||
<ul v-else class="divide-y divide-gray-100 -my-1">
|
||||
<li v-for="c in contacts" :key="c.id" class="flex items-center gap-3 py-2.5">
|
||||
<div
|
||||
class="w-8 h-8 rounded-full bg-black text-white flex items-center justify-center text-xs font-bold flex-shrink-0"
|
||||
>
|
||||
{{ initial(c.name) }}
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<p class="text-sm font-semibold text-gray-800 truncate">{{ c.name }}</p>
|
||||
<span
|
||||
v-if="Number(c.read) !== 1"
|
||||
class="w-1.5 h-1.5 rounded-full bg-red-500 flex-shrink-0"
|
||||
title="未读"
|
||||
></span>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500 truncate">{{ c.subject }}</p>
|
||||
</div>
|
||||
<span class="text-[11px] text-gray-400 flex-shrink-0">{{ formatDate(c.createdAt) }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 最近评论 -->
|
||||
<AdminCard title="最近评论" subtitle="最新 5 条评论">
|
||||
<template #actions>
|
||||
<NuxtLink to="/admin/comments" class="text-xs font-semibold text-gray-500 hover:text-black transition-colors">
|
||||
查看全部
|
||||
</NuxtLink>
|
||||
</template>
|
||||
<AdminSkeleton v-if="loading" :rows="4" />
|
||||
<AdminEmptyState v-else-if="!comments.length" icon="ph:chat-circle-text" title="暂无评论" />
|
||||
<ul v-else class="divide-y divide-gray-100 -my-1">
|
||||
<li v-for="cm in comments" :key="cm.id" class="py-2.5">
|
||||
<div class="flex items-center gap-2">
|
||||
<p class="text-sm font-semibold text-gray-800 truncate">{{ cm.username }}</p>
|
||||
<span class="text-[11px] text-gray-400 flex-shrink-0">{{ formatDate(cm.createdAt) }}</span>
|
||||
</div>
|
||||
<p class="mt-0.5 text-xs text-gray-500 truncate">{{ cm.content }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</AdminCard>
|
||||
</div>
|
||||
|
||||
<div class="space-y-5">
|
||||
<!-- 快捷入口 -->
|
||||
<AdminCard title="快捷入口" subtitle="常用操作">
|
||||
<div class="grid grid-cols-1 gap-2">
|
||||
<NuxtLink
|
||||
to="/admin/news"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-black text-white text-sm font-semibold px-4 py-2.5 hover:bg-gray-800 transition-colors shadow-sm"
|
||||
>
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 新建动态
|
||||
</NuxtLink>
|
||||
<NuxtLink
|
||||
to="/admin/uploads"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-gray-100 text-gray-800 text-sm font-semibold px-4 py-2.5 hover:bg-gray-200 transition-colors"
|
||||
>
|
||||
<Icon name="ph:cloud-arrow-up" class="w-4 h-4" /> 上传图片
|
||||
</NuxtLink>
|
||||
<NuxtLink
|
||||
to="/admin/settings"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-gray-100 text-gray-800 text-sm font-semibold px-4 py-2.5 hover:bg-gray-200 transition-colors"
|
||||
>
|
||||
<Icon name="ph:gear-six" class="w-4 h-4" /> 站点设置
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 存储用量 -->
|
||||
<AdminCard title="存储用量" subtitle="上传文件占用">
|
||||
<AdminSkeleton v-if="storageLoading" :rows="3" />
|
||||
<div v-else-if="storageError" class="py-4 text-center">
|
||||
<p class="text-sm text-gray-500 mb-3">{{ storageError }}</p>
|
||||
<AdminButton variant="secondary" size="sm" @click="loadStorage">重试</AdminButton>
|
||||
</div>
|
||||
<div v-else class="flex items-center gap-4">
|
||||
<div class="flex-1">
|
||||
<p class="text-2xl font-bold text-black leading-none tabular-nums">{{ files.length }}</p>
|
||||
<p class="mt-1 text-xs text-gray-500">图片文件</p>
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<p class="text-2xl font-bold text-black leading-none tabular-nums">{{ formatSize(storageTotalBytes) }}</p>
|
||||
<p class="mt-1 text-xs text-gray-500">总大小</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="storageType" class="mt-4 pt-4 border-t border-gray-100 flex items-center gap-2">
|
||||
<AdminBadge :tone="storageType === 'oss' ? 'blue' : 'gray'">
|
||||
{{ storageType === 'oss' ? '对象存储 OSS' : '本地存储' }}
|
||||
</AdminBadge>
|
||||
<span class="text-xs text-gray-400">约 {{ (storageTotalBytes / (1024 * 1024)).toFixed(1) }} MB</span>
|
||||
</div>
|
||||
</AdminCard>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,482 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台动态管理:列表(搜索/分类/状态筛选 + 前端分页)+ 新建/编辑表单。
|
||||
* - 列表来自 /api/admin/articles(含未发布)
|
||||
* - 新建 POST /api/admin/articles;编辑 PATCH /api/admin/articles/[id];删除 DELETE /api/admin/articles/[id]
|
||||
* - 正文为内容块编辑器(中英各一组)
|
||||
*/
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useHead({ title: '动态管理' })
|
||||
|
||||
interface Block {
|
||||
type: string
|
||||
text: string
|
||||
}
|
||||
|
||||
interface Article {
|
||||
id?: number
|
||||
slug: string
|
||||
category: 'insights' | 'projects' | 'announcements'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
excerptZh: string
|
||||
excerptEn: string
|
||||
contentZh: Block[]
|
||||
contentEn: Block[]
|
||||
image: string | null
|
||||
date: string | null
|
||||
readTime: number
|
||||
author: string
|
||||
published: number
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
const CATEGORIES = [
|
||||
{ value: 'insights', label: '行业洞察' },
|
||||
{ value: 'projects', label: '项目动态' },
|
||||
{ value: 'announcements', label: '公告通知' },
|
||||
]
|
||||
const catLabel = (c: string) => CATEGORIES.find((x) => x.value === c)?.label ?? c
|
||||
|
||||
/* ---------- 列表 ---------- */
|
||||
const articles = ref<Article[]>([])
|
||||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
|
||||
const loadArticles = async () => {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const res = await $fetch<{ articles: Article[] }>('/api/admin/articles')
|
||||
articles.value = res.articles
|
||||
} catch (err: any) {
|
||||
error.value = err?.data?.message || '加载失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadArticles)
|
||||
|
||||
/* ---------- 搜索 / 筛选 / 分页 ---------- */
|
||||
const keyword = ref('')
|
||||
const categoryFilter = ref<'all' | Article['category']>('all')
|
||||
const statusFilter = ref<'all' | 'published' | 'draft'>('all')
|
||||
|
||||
const filteredArticles = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return articles.value.filter((a) => {
|
||||
if (categoryFilter.value !== 'all' && a.category !== categoryFilter.value) return false
|
||||
if (statusFilter.value === 'published' && !a.published) return false
|
||||
if (statusFilter.value === 'draft' && a.published) return false
|
||||
if (!kw) return true
|
||||
return (
|
||||
a.titleZh.toLowerCase().includes(kw) ||
|
||||
a.titleEn.toLowerCase().includes(kw) ||
|
||||
a.slug.toLowerCase().includes(kw) ||
|
||||
a.author.toLowerCase().includes(kw)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
const pageSize = 10
|
||||
const page = ref(1)
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(filteredArticles.value.length / pageSize)))
|
||||
|
||||
const pagedArticles = computed(() => {
|
||||
const p = Math.min(page.value, totalPages.value)
|
||||
const start = (p - 1) * pageSize
|
||||
return filteredArticles.value.slice(start, start + pageSize)
|
||||
})
|
||||
|
||||
watch([keyword, categoryFilter, statusFilter], () => {
|
||||
page.value = 1
|
||||
})
|
||||
|
||||
const changePage = (p: number) => {
|
||||
page.value = Math.min(Math.max(1, p), totalPages.value)
|
||||
}
|
||||
|
||||
const headerSubtitle = computed(() => {
|
||||
if (view.value === 'form') return editingId.value != null ? '编辑动态' : '新建动态'
|
||||
return `共 ${articles.value.length} 篇动态`
|
||||
})
|
||||
|
||||
/* ---------- 表单 ---------- */
|
||||
const view = ref<'list' | 'form'>('list')
|
||||
const editingId = ref<number | null>(null)
|
||||
const saving = ref(false)
|
||||
const formError = ref('')
|
||||
|
||||
const emptyForm = () => ({
|
||||
slug: '',
|
||||
category: 'insights' as Article['category'],
|
||||
titleZh: '',
|
||||
titleEn: '',
|
||||
excerptZh: '',
|
||||
excerptEn: '',
|
||||
contentZh: [] as Block[],
|
||||
contentEn: [] as Block[],
|
||||
image: '',
|
||||
date: '',
|
||||
readTime: 5,
|
||||
author: 'ArcticNewOne',
|
||||
published: true,
|
||||
})
|
||||
const form = reactive(emptyForm())
|
||||
|
||||
const openCreate = () => {
|
||||
Object.assign(form, emptyForm())
|
||||
editingId.value = null
|
||||
formError.value = ''
|
||||
view.value = 'form'
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
const openEdit = (a: Article) => {
|
||||
if (a.id == null) {
|
||||
toast.error('该条目缺少 id 字段,暂时无法编辑(后端待补)')
|
||||
return
|
||||
}
|
||||
editingId.value = a.id
|
||||
Object.assign(form, {
|
||||
slug: a.slug,
|
||||
category: a.category,
|
||||
titleZh: a.titleZh,
|
||||
titleEn: a.titleEn,
|
||||
excerptZh: a.excerptZh,
|
||||
excerptEn: a.excerptEn,
|
||||
contentZh: a.contentZh.map((b) => ({ ...b })),
|
||||
contentEn: a.contentEn.map((b) => ({ ...b })),
|
||||
image: a.image ?? '',
|
||||
date: a.date ?? '',
|
||||
readTime: a.readTime,
|
||||
author: a.author,
|
||||
published: !!a.published,
|
||||
})
|
||||
formError.value = ''
|
||||
view.value = 'form'
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
const backToList = () => {
|
||||
view.value = 'list'
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
formError.value = ''
|
||||
if (!/^[a-z0-9-]{2,64}$/.test(form.slug)) {
|
||||
formError.value = 'slug 需为 2-64 位小写字母/数字/中划线'
|
||||
return
|
||||
}
|
||||
if (!form.titleZh.trim() || !form.titleEn.trim()) {
|
||||
formError.value = '中英文标题均为必填'
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const payload = {
|
||||
slug: form.slug,
|
||||
category: form.category,
|
||||
titleZh: form.titleZh,
|
||||
titleEn: form.titleEn,
|
||||
excerptZh: form.excerptZh,
|
||||
excerptEn: form.excerptEn,
|
||||
contentZh: form.contentZh,
|
||||
contentEn: form.contentEn,
|
||||
image: form.image || null,
|
||||
date: form.date || null,
|
||||
readTime: Number(form.readTime) || 5,
|
||||
author: form.author.trim() || 'ArcticNewOne',
|
||||
published: form.published,
|
||||
}
|
||||
if (editingId.value != null) {
|
||||
await $fetch(`/api/admin/articles/${editingId.value}`, { method: 'PATCH', body: payload })
|
||||
toast.success('动态已更新')
|
||||
} else {
|
||||
await $fetch('/api/admin/articles', { method: 'POST', body: payload })
|
||||
toast.success('动态已创建')
|
||||
}
|
||||
await loadArticles()
|
||||
view.value = 'list'
|
||||
} catch (err: any) {
|
||||
formError.value = err?.data?.message || '保存失败'
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 删除 ---------- */
|
||||
const confirmDelete = ref<Article | null>(null)
|
||||
const deleting = ref(false)
|
||||
|
||||
const askDelete = (a: Article) => {
|
||||
if (a.id == null) {
|
||||
toast.error('该条目缺少 id 字段,暂时无法删除(后端待补)')
|
||||
return
|
||||
}
|
||||
confirmDelete.value = a
|
||||
}
|
||||
|
||||
const doDelete = async () => {
|
||||
const a = confirmDelete.value
|
||||
if (!a || a.id == null) return
|
||||
deleting.value = true
|
||||
try {
|
||||
await $fetch(`/api/admin/articles/${a.id}`, { method: 'DELETE' })
|
||||
toast.success(`已删除「${a.titleZh}」`)
|
||||
confirmDelete.value = null
|
||||
await loadArticles()
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '删除失败')
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- 页头 -->
|
||||
<AdminPageHeader title="动态管理" :subtitle="headerSubtitle">
|
||||
<template #actions>
|
||||
<AdminButton v-if="view === 'list'" size="sm" @click="openCreate">
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 新建动态
|
||||
</AdminButton>
|
||||
<AdminButton v-else size="sm" variant="secondary" @click="backToList">
|
||||
<Icon name="ph:arrow-left" class="w-4 h-4" /> 返回列表
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- ==================== 列表视图 ==================== -->
|
||||
<template v-if="view === 'list'">
|
||||
<!-- 工具栏 -->
|
||||
<div class="mb-5 flex flex-col sm:flex-row gap-3">
|
||||
<div class="relative flex-1 sm:max-w-xs">
|
||||
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索标题 / slug / 作者…"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white py-2.5 pl-10 pr-9 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10"
|
||||
/>
|
||||
<button
|
||||
v-if="keyword"
|
||||
@click="keyword = ''"
|
||||
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-6 h-6 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
|
||||
aria-label="清空筛选"
|
||||
>
|
||||
<Icon name="ph:x" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<AdminSelect
|
||||
v-model="categoryFilter"
|
||||
:options="[
|
||||
{ value: 'all', label: '全部分类' },
|
||||
...CATEGORIES,
|
||||
]"
|
||||
class="w-full sm:w-40"
|
||||
/>
|
||||
<AdminSelect
|
||||
v-model="statusFilter"
|
||||
:options="[
|
||||
{ value: 'all', label: '全部状态' },
|
||||
{ value: 'published', label: '已发布' },
|
||||
{ value: 'draft', label: '草稿' },
|
||||
]"
|
||||
class="w-full sm:w-36"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 加载态 -->
|
||||
<AdminCard v-if="loading">
|
||||
<AdminSkeleton :rows="6" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 错误态 -->
|
||||
<AdminCard v-else-if="error">
|
||||
<div class="py-10 text-center">
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ error }}</p>
|
||||
<AdminButton size="sm" @click="loadArticles">重新加载</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState
|
||||
v-else-if="!articles.length"
|
||||
icon="ph:newspaper"
|
||||
title="还没有动态"
|
||||
description="点击右上角「新建动态」创建第一篇。"
|
||||
/>
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredArticles.length"
|
||||
icon="ph:magnifying-glass"
|
||||
title="没有匹配的动态"
|
||||
description="换个关键词或筛选条件试试。"
|
||||
/>
|
||||
|
||||
<!-- 列表 -->
|
||||
<template v-else>
|
||||
<div class="rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">标题</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">分类</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">发布日期</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">时长</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">状态</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
<tr
|
||||
v-for="a in pagedArticles"
|
||||
:key="a.slug"
|
||||
class="hover:bg-gray-50/60 transition-colors"
|
||||
>
|
||||
<td class="px-5 py-4">
|
||||
<p class="font-semibold text-black">{{ a.titleZh }}</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5 font-mono">{{ a.slug }}</p>
|
||||
</td>
|
||||
<td class="px-5 py-4">
|
||||
<AdminBadge tone="gray">{{ catLabel(a.category) }}</AdminBadge>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-gray-600 whitespace-nowrap">{{ a.date || '-' }}</td>
|
||||
<td class="px-5 py-4 text-gray-600 whitespace-nowrap">{{ a.readTime }} 分钟</td>
|
||||
<td class="px-5 py-4">
|
||||
<AdminBadge :tone="a.published ? 'green' : 'amber'">
|
||||
<span
|
||||
class="w-1.5 h-1.5 rounded-full inline-block"
|
||||
:class="a.published ? 'bg-green-500' : 'bg-amber-500'"
|
||||
></span>
|
||||
{{ a.published ? '已发布' : '草稿' }}
|
||||
</AdminBadge>
|
||||
</td>
|
||||
<td class="px-5 py-4">
|
||||
<div class="flex items-center justify-end gap-2">
|
||||
<AdminButton size="sm" variant="secondary" class="min-h-10" @click="openEdit(a)">
|
||||
<Icon name="ph:pencil-simple" class="w-3.5 h-3.5" /> 编辑
|
||||
</AdminButton>
|
||||
<AdminButton size="sm" variant="danger" class="min-h-10" @click="askDelete(a)">
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
|
||||
</AdminButton>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<AdminPagination :total="filteredArticles.length" :page="page" :page-size="pageSize" @page="changePage" />
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- ==================== 表单视图 ==================== -->
|
||||
<template v-else>
|
||||
<div class="space-y-6 max-w-4xl">
|
||||
<!-- 基本信息 -->
|
||||
<AdminCard title="基本信息">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<div>
|
||||
<AdminInput
|
||||
v-model="form.slug"
|
||||
label="slug"
|
||||
required
|
||||
placeholder="如 design-trends-2026"
|
||||
:error="formError && !/^[a-z0-9-]{2,64}$/.test(form.slug) ? 'slug 需为 2-64 位小写字母/数字/中划线' : ''"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-gray-400">2-64 位小写字母 / 数字 / 中划线,用于前台链接</p>
|
||||
</div>
|
||||
<AdminSelect
|
||||
v-model="form.category"
|
||||
label="分类"
|
||||
:options="CATEGORIES"
|
||||
/>
|
||||
<AdminInput v-model="form.date" type="date" label="发布日期" />
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5">
|
||||
<AdminInput
|
||||
:model-value="String(form.readTime)"
|
||||
type="number"
|
||||
label="阅读时长(分钟)"
|
||||
@update:model-value="form.readTime = Number($event) || 1"
|
||||
/>
|
||||
<AdminInput v-model="form.author" label="作者" />
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<p class="block text-sm font-semibold text-gray-800 mb-1.5">发布状态</p>
|
||||
<div class="flex items-center gap-3">
|
||||
<AdminToggle v-model="form.published" />
|
||||
<span class="text-sm" :class="form.published ? 'text-green-700 font-semibold' : 'text-gray-500'">
|
||||
{{ form.published ? '已发布(前台可见)' : '草稿(前台隐藏)' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 标题与摘要 -->
|
||||
<AdminCard title="标题与摘要">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<div class="space-y-4">
|
||||
<AdminInput v-model="form.titleZh" label="中文标题" required />
|
||||
<AdminTextarea v-model="form.excerptZh" label="中文摘要" :rows="3" />
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
<AdminInput v-model="form.titleEn" label="English Title" required />
|
||||
<AdminTextarea v-model="form.excerptEn" label="English Excerpt" :rows="3" />
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 正文内容 -->
|
||||
<AdminCard title="正文内容(中英各一组)">
|
||||
<div class="space-y-6">
|
||||
<AdminBlockEditor v-model="form.contentZh" label="中文正文" />
|
||||
<AdminBlockEditor v-model="form.contentEn" label="English Content" />
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 封面图 -->
|
||||
<AdminCard title="封面图">
|
||||
<AdminImageUpload v-model="form.image" label="封面图" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 提交 -->
|
||||
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-end gap-3">
|
||||
<p v-if="formError" class="text-sm text-red-600 sm:mr-auto">{{ formError }}</p>
|
||||
<div class="flex items-center gap-3 w-full sm:w-auto sm:justify-end">
|
||||
<AdminButton class="flex-1 sm:flex-none" variant="secondary" @click="backToList">取消</AdminButton>
|
||||
<AdminButton class="flex-1 sm:flex-none" :loading="saving" @click="save">
|
||||
{{ saving ? '保存中…' : editingId != null ? '保存修改' : '创建动态' }}
|
||||
</AdminButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="!!confirmDelete"
|
||||
:loading="deleting"
|
||||
danger
|
||||
:message="`确定要删除「${confirmDelete?.titleZh}」吗?该动态下的所有评论将一并删除,此操作不可撤销。`"
|
||||
@update:open="confirmDelete = null"
|
||||
@confirm="doDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,260 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台站点设置:分组表单,管理站点全局信息。
|
||||
* - 加载 GET /api/admin/settings(返回合并默认值后的完整 SiteSettings)
|
||||
* - 保存 PATCH /api/admin/settings,body { settings: <整体表单> }(按叶节点写库,未提供项不变)
|
||||
* - 保存后前台 /api/settings 即时生效
|
||||
*/
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { defaultSettings, type SiteSettings } from '~/config/site'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
|
||||
useHead({ title: '站点设置' })
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
const clone = <T>(v: T): T => JSON.parse(JSON.stringify(v))
|
||||
|
||||
/* ---------- 表单数据 ---------- */
|
||||
// 先以默认值初始化,加载成功后整体覆盖为后端配置
|
||||
const form = reactive<SiteSettings>(clone(defaultSettings))
|
||||
|
||||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
const saving = ref(false)
|
||||
|
||||
const loadSettings = async () => {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const data = await $fetch<SiteSettings>('/api/admin/settings')
|
||||
Object.assign(form, clone(data))
|
||||
} catch (err: any) {
|
||||
error.value = err?.data?.message || '配置加载失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadSettings)
|
||||
|
||||
/* ---------- 保存 ---------- */
|
||||
const saveAll = async () => {
|
||||
saving.value = true
|
||||
try {
|
||||
await $fetch('/api/admin/settings', {
|
||||
method: 'PATCH',
|
||||
body: { settings: clone(form) },
|
||||
})
|
||||
toast.success('已保存,前台即时生效')
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '保存失败,请重试')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 社交链接 ---------- */
|
||||
const SOCIAL_ICONS = [
|
||||
{ label: 'X (Twitter)', value: 'ph:x-logo' },
|
||||
{ label: 'Instagram', value: 'ph:instagram-logo' },
|
||||
{ label: 'LinkedIn', value: 'ph:linkedin-logo' },
|
||||
{ label: 'GitHub', value: 'ph:github-logo' },
|
||||
{ label: 'YouTube', value: 'ph:youtube-logo' },
|
||||
{ label: 'Facebook', value: 'ph:facebook-logo' },
|
||||
{ label: '微信', value: 'ph:wechat-logo' },
|
||||
{ label: '邮箱', value: 'ph:envelope-simple' },
|
||||
{ label: '链接', value: 'ph:link-simple' },
|
||||
{ label: '地球', value: 'ph:globe-simple' },
|
||||
]
|
||||
|
||||
const addSocial = () => form.socials.push({ name: '', icon: 'ph:link-simple', url: '' })
|
||||
const removeSocial = (i: number) => form.socials.splice(i, 1)
|
||||
|
||||
/* ---------- 工具箱 ---------- */
|
||||
const TOOL_COLORS = [
|
||||
{ label: '橙 · 琥珀', value: 'from-orange-50/50 to-amber-100/50' },
|
||||
{ label: '紫 · 靛蓝', value: 'from-purple-50/50 to-indigo-100/50' },
|
||||
{ label: '蓝 · 青', value: 'from-blue-50/50 to-cyan-100/50' },
|
||||
{ label: '绿 · 翠', value: 'from-emerald-50/50 to-teal-100/50' },
|
||||
{ label: '粉 · 玫', value: 'from-pink-50/50 to-rose-100/50' },
|
||||
{ label: '灰 · 石板', value: 'from-gray-50/50 to-slate-100/50' },
|
||||
]
|
||||
|
||||
const addTool = () =>
|
||||
form.tools.push({
|
||||
id: '',
|
||||
name: '',
|
||||
url: '',
|
||||
icon: 'ph:wrench-duotone',
|
||||
color: TOOL_COLORS[0].value,
|
||||
descZh: '',
|
||||
descEn: '',
|
||||
})
|
||||
const removeTool = (i: number) => form.tools.splice(i, 1)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- 页头 -->
|
||||
<AdminPageHeader title="站点设置" subtitle="管理站点全局信息,保存后前台即时生效">
|
||||
<template #actions>
|
||||
<AdminButton :loading="saving" :disabled="loading || !!error" @click="saveAll">
|
||||
<Icon v-if="!saving" name="ph:floppy-disk" class="w-4 h-4" />
|
||||
{{ saving ? '保存中…' : '保存全部' }}
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- 加载骨架 -->
|
||||
<div v-if="loading" class="space-y-6 max-w-5xl">
|
||||
<AdminCard v-for="i in 4" :key="i" title="">
|
||||
<AdminSkeleton :rows="5" />
|
||||
</AdminCard>
|
||||
</div>
|
||||
|
||||
<!-- 加载失败 -->
|
||||
<div
|
||||
v-else-if="error"
|
||||
class="max-w-5xl rounded-2xl bg-white border border-gray-100 shadow-sm p-10 text-center"
|
||||
>
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ error }}</p>
|
||||
<AdminButton variant="secondary" @click="loadSettings">
|
||||
<Icon name="ph:arrow-clockwise" class="w-4 h-4" /> 重新加载
|
||||
</AdminButton>
|
||||
</div>
|
||||
|
||||
<!-- 表单 -->
|
||||
<div v-else class="space-y-6 max-w-5xl">
|
||||
<!-- 1. 站点信息 -->
|
||||
<AdminCard title="站点信息" subtitle="品牌标识与浏览器标题等基础信息">
|
||||
<template #actions><Icon name="ph:info" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<AdminInput v-model="form.site.name" label="站点名称" placeholder="ArcticNewOne" />
|
||||
<AdminInput v-model="form.site.brand" label="品牌名" placeholder="北极新一" />
|
||||
<AdminTextarea v-model="form.site.description.zh" label="站点简介(中文)" :rows="3" />
|
||||
<AdminTextarea v-model="form.site.description.en" label="Description (EN)" :rows="3" />
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 2. 联系方式 -->
|
||||
<AdminCard title="联系方式" subtitle="前台「联系我们」展示的联系信息">
|
||||
<template #actions><Icon name="ph:envelope-simple" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<AdminInput v-model="form.contact.email" label="联系邮箱" type="email" placeholder="hello@..." />
|
||||
<AdminInput v-model="form.contact.infoEmail" label="信息邮箱" type="email" placeholder="info@..." />
|
||||
<AdminInput v-model="form.contact.wechat" label="微信号" placeholder="LucskyNew" />
|
||||
<AdminTextarea v-model="form.contact.address.zh" label="地址(中文)" :rows="2" />
|
||||
<AdminTextarea v-model="form.contact.address.en" label="Address (EN)" :rows="2" />
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 3. 社交链接 -->
|
||||
<AdminCard title="社交链接" subtitle="前台页脚与联系页展示的社交入口">
|
||||
<template #actions><Icon name="ph:share-network" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="(s, i) in form.socials"
|
||||
:key="i"
|
||||
class="rounded-xl border border-gray-100 bg-gray-50/50 p-4"
|
||||
>
|
||||
<div class="grid grid-cols-1 md:grid-cols-[120px_200px_1fr_auto] gap-3 items-end">
|
||||
<AdminInput v-model="s.name" label="名称" placeholder="X" />
|
||||
<AdminSelect v-model="s.icon" :options="SOCIAL_ICONS" label="图标" />
|
||||
<AdminInput v-model="s.url" label="链接" type="url" placeholder="https://..." />
|
||||
<button
|
||||
type="button"
|
||||
class="mb-1 w-9 h-9 rounded-lg text-gray-400 hover:text-red-600 hover:bg-red-50 flex items-center justify-center transition-colors"
|
||||
:aria-label="`删除社交链接 ${s.name}`"
|
||||
@click="removeSocial(i)"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<AdminButton variant="secondary" size="sm" @click="addSocial">
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 添加社交链接
|
||||
</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 4. 工具箱 -->
|
||||
<AdminCard title="工具箱" subtitle="前台「工具箱」页展示的在线工具">
|
||||
<template #actions><Icon name="ph:wrench" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="(tool, i) in form.tools"
|
||||
:key="i"
|
||||
class="rounded-xl border border-gray-100 bg-gray-50/50 p-4 space-y-3"
|
||||
>
|
||||
<div class="flex items-center justify-between">
|
||||
<span class="text-xs font-semibold text-gray-400">工具 #{{ i + 1 }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 px-2.5 py-1.5 rounded-lg text-xs font-semibold text-gray-400 hover:text-red-600 hover:bg-red-50 transition-colors"
|
||||
@click="removeTool(i)"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
|
||||
</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<AdminInput v-model="tool.id" label="ID" placeholder="drawio" />
|
||||
<AdminInput v-model="tool.name" label="名称" placeholder="Drawio" />
|
||||
<AdminInput v-model="tool.url" label="链接" type="url" placeholder="https://..." />
|
||||
<AdminInput v-model="tool.icon" label="图标名" placeholder="ph:flow-arrow-duotone" />
|
||||
<AdminSelect v-model="tool.color" :options="TOOL_COLORS" label="主题色" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<AdminTextarea v-model="tool.descZh" label="中文简介" :rows="2" />
|
||||
<AdminTextarea v-model="tool.descEn" label="Description (EN)" :rows="2" />
|
||||
</div>
|
||||
</div>
|
||||
<AdminButton variant="secondary" size="sm" @click="addTool">
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 添加工具
|
||||
</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 5. 页脚文案 -->
|
||||
<AdminCard title="页脚文案" subtitle="前台页脚与订阅区的文案">
|
||||
<template #actions><Icon name="ph:paragraph" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-5">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<AdminTextarea v-model="form.footer.title.zh" label="主标题(中文)" :rows="3" />
|
||||
<AdminTextarea v-model="form.footer.title.en" label="Headline (EN)" :rows="3" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<AdminInput v-model="form.footer.newsletterTitle.zh" label="订阅标题(中文)" />
|
||||
<AdminInput v-model="form.footer.newsletterTitle.en" label="Newsletter Title (EN)" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<AdminInput v-model="form.footer.newsletterNote.zh" label="订阅说明(中文)" />
|
||||
<AdminInput v-model="form.footer.newsletterNote.en" label="Newsletter Note (EN)" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<AdminInput v-model="form.footer.copyright.zh" label="版权(中文)" />
|
||||
<AdminInput v-model="form.footer.copyright.en" label="Copyright (EN)" />
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 6. SEO -->
|
||||
<AdminCard title="SEO" subtitle="搜索引擎描述与关键词">
|
||||
<template #actions><Icon name="ph:magnifying-glass" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-5">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<AdminTextarea v-model="form.seo.description.zh" label="描述(中文)" :rows="3" />
|
||||
<AdminTextarea v-model="form.seo.description.en" label="Description (EN)" :rows="3" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<AdminTextarea v-model="form.seo.keywords.zh" label="关键词(中文,逗号分隔)" :rows="2" />
|
||||
<AdminTextarea v-model="form.seo.keywords.en" label="Keywords (EN, comma-separated)" :rows="2" />
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,338 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台订阅管理:列表 + 搜索 + 多选批量删除 + 导出 CSV + 前端分页。
|
||||
* - GET/DELETE /api/admin/subscribers[/id];导出 GET /api/admin/subscribers/export
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useHead({ title: '订阅管理' })
|
||||
|
||||
interface AdminSubscriber {
|
||||
id: number
|
||||
email: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
/* ---------- 列表 ---------- */
|
||||
const subscribers = ref<AdminSubscriber[]>([])
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
|
||||
const loadSubscribers = async () => {
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const data = await $fetch<{ subscribers: AdminSubscriber[] }>('/api/admin/subscribers')
|
||||
subscribers.value = data.subscribers
|
||||
} catch (err) {
|
||||
console.error('load subscribers error:', err)
|
||||
loadError.value = '加载失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadSubscribers)
|
||||
|
||||
/* ---------- 搜索 / 分页 ---------- */
|
||||
const keyword = ref('')
|
||||
const filteredSubscribers = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
if (!kw) return subscribers.value
|
||||
return subscribers.value.filter((s) => s.email.toLowerCase().includes(kw))
|
||||
})
|
||||
|
||||
const pageSize = 15
|
||||
const page = ref(1)
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(filteredSubscribers.value.length / pageSize)))
|
||||
|
||||
const pagedSubscribers = computed(() => {
|
||||
const p = Math.min(page.value, totalPages.value)
|
||||
const start = (p - 1) * pageSize
|
||||
return filteredSubscribers.value.slice(start, start + pageSize)
|
||||
})
|
||||
|
||||
watch(keyword, () => {
|
||||
page.value = 1
|
||||
})
|
||||
|
||||
const changePage = (p: number) => {
|
||||
page.value = Math.min(Math.max(1, p), totalPages.value)
|
||||
}
|
||||
|
||||
/* ---------- 多选 / 批量删除 ---------- */
|
||||
const selected = ref<Set<number>>(new Set())
|
||||
|
||||
const allChecked = computed(
|
||||
() => pagedSubscribers.value.length > 0 && pagedSubscribers.value.every((s) => selected.value.has(s.id)),
|
||||
)
|
||||
|
||||
const toggleAll = () => {
|
||||
if (allChecked.value) {
|
||||
for (const s of pagedSubscribers.value) selected.value.delete(s.id)
|
||||
selected.value = new Set(selected.value)
|
||||
} else {
|
||||
const next = new Set(selected.value)
|
||||
for (const s of pagedSubscribers.value) next.add(s.id)
|
||||
selected.value = next
|
||||
}
|
||||
}
|
||||
|
||||
const toggleOne = (id: number) => {
|
||||
const next = new Set(selected.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
else next.add(id)
|
||||
selected.value = next
|
||||
}
|
||||
|
||||
const batchConfirmOpen = ref(false)
|
||||
const batchDeleting = ref(false)
|
||||
|
||||
const doBatchDelete = async () => {
|
||||
const ids = [...selected.value]
|
||||
if (!ids.length) return
|
||||
batchDeleting.value = true
|
||||
let failed = 0
|
||||
for (const id of ids) {
|
||||
try {
|
||||
await $fetch(`/api/admin/subscribers/${id}`, { method: 'DELETE' })
|
||||
} catch (err: any) {
|
||||
console.error('batch delete subscriber error:', err)
|
||||
failed++
|
||||
}
|
||||
}
|
||||
batchDeleting.value = false
|
||||
batchConfirmOpen.value = false
|
||||
selected.value = new Set()
|
||||
if (failed === 0) {
|
||||
toast.success(`已取消订阅 ${ids.length} 个邮箱`)
|
||||
} else {
|
||||
toast.error(`删除 ${ids.length - failed} 个成功,${failed} 个失败`)
|
||||
}
|
||||
await loadSubscribers()
|
||||
}
|
||||
|
||||
/* ---------- 单条删除 ---------- */
|
||||
const confirmDelete = ref<AdminSubscriber | null>(null)
|
||||
const deleting = ref(false)
|
||||
|
||||
const askDelete = (s: AdminSubscriber) => {
|
||||
confirmDelete.value = s
|
||||
}
|
||||
|
||||
const doDelete = async () => {
|
||||
const s = confirmDelete.value
|
||||
if (!s) return
|
||||
deleting.value = true
|
||||
try {
|
||||
await $fetch(`/api/admin/subscribers/${s.id}`, { method: 'DELETE' })
|
||||
subscribers.value = subscribers.value.filter((x) => x.id !== s.id)
|
||||
selected.value.delete(s.id)
|
||||
toast.success(`已取消订阅「${s.email}」`)
|
||||
confirmDelete.value = null
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '删除失败,请重试')
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (raw?: string) => {
|
||||
if (!raw) return ''
|
||||
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(d)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<AdminPageHeader title="订阅管理" subtitle="订阅了站内更新的邮箱列表,可导出 CSV。">
|
||||
<template #actions>
|
||||
<a
|
||||
:href="'/api/admin/subscribers/export'"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl bg-black px-4 py-2 text-sm font-semibold text-white shadow-sm transition-all duration-200 hover:bg-gray-800"
|
||||
title="导出全部订阅邮箱"
|
||||
>
|
||||
<Icon name="ph:download-simple" class="w-4 h-4" /> 导出 CSV
|
||||
</a>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- 统计 + 工具栏 -->
|
||||
<div class="mb-4 flex flex-wrap items-center gap-x-4 gap-y-2">
|
||||
<span class="text-sm text-gray-500">共 {{ subscribers.length }} 个订阅</span>
|
||||
<span v-if="selected.size" class="text-sm text-gray-400">· 已选 {{ selected.size }} 项</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 flex flex-col gap-3 md:flex-row md:items-center">
|
||||
<div class="relative flex-1 md:max-w-xs">
|
||||
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索邮箱…"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white py-2.5 pl-10 pr-9 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10"
|
||||
/>
|
||||
<button
|
||||
v-if="keyword"
|
||||
@click="keyword = ''"
|
||||
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
|
||||
aria-label="清空筛选"
|
||||
>
|
||||
<Icon name="ph:x" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<AdminButton variant="danger" size="sm" class="w-full md:w-auto" :disabled="!selected.size" @click="batchConfirmOpen = true">
|
||||
<Icon name="ph:trash" class="w-4 h-4" /> 批量删除
|
||||
</AdminButton>
|
||||
</div>
|
||||
|
||||
<!-- 加载态 -->
|
||||
<AdminCard v-if="loading">
|
||||
<AdminSkeleton :rows="6" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 错误态 -->
|
||||
<AdminCard v-else-if="loadError">
|
||||
<div class="py-10 text-center">
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ loadError }}</p>
|
||||
<AdminButton size="sm" @click="loadSubscribers">重新加载</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState v-else-if="!subscribers.length" icon="ph:envelope" title="暂无订阅" description="还没有人订阅站内更新。" />
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredSubscribers.length"
|
||||
icon="ph:magnifying-glass"
|
||||
title="没有匹配的订阅"
|
||||
description="换个邮箱关键词试试。"
|
||||
/>
|
||||
|
||||
<!-- 订阅表格 -->
|
||||
<template v-else>
|
||||
<!-- 桌面表格(md+) -->
|
||||
<div class="hidden md:block rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
|
||||
<th class="px-5 py-4 w-10 sticky left-0 bg-gray-50 z-10 border-r border-gray-100">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allChecked"
|
||||
class="w-4 h-4 rounded border-gray-300 accent-black cursor-pointer"
|
||||
@change="toggleAll"
|
||||
/>
|
||||
</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">邮箱</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">订阅时间</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
<tr
|
||||
v-for="s in pagedSubscribers"
|
||||
:key="s.id"
|
||||
class="hover:bg-gray-50/60 transition-colors"
|
||||
:class="selected.has(s.id) ? 'bg-gray-50/70' : ''"
|
||||
>
|
||||
<td class="px-5 py-4 sticky left-0 bg-white z-10 border-r border-gray-100">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selected.has(s.id)"
|
||||
class="w-4 h-4 rounded border-gray-300 accent-black cursor-pointer"
|
||||
@change="toggleOne(s.id)"
|
||||
/>
|
||||
</td>
|
||||
<td class="px-5 py-4">
|
||||
<a
|
||||
:href="`mailto:${s.email}`"
|
||||
class="inline-flex items-center gap-2 font-semibold text-black hover:text-gray-600 transition-colors"
|
||||
>
|
||||
<Icon name="ph:envelope-simple" class="w-4 h-4 text-gray-400" />
|
||||
{{ s.email }}
|
||||
</a>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-gray-500 text-xs whitespace-nowrap">{{ formatDate(s.createdAt) }}</td>
|
||||
<td class="px-5 py-4">
|
||||
<div class="flex items-center justify-end">
|
||||
<AdminButton size="sm" variant="ghost" @click="askDelete(s)">
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</AdminButton>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 移动端卡片(<md) -->
|
||||
<div class="md:hidden space-y-3">
|
||||
<div
|
||||
v-for="s in pagedSubscribers"
|
||||
:key="s.id"
|
||||
class="bg-white rounded-2xl border border-gray-100 shadow-sm p-4"
|
||||
:class="selected.has(s.id) ? 'ring-2 ring-black/5 border-black/10' : ''"
|
||||
>
|
||||
<div class="flex items-start gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selected.has(s.id)"
|
||||
class="w-5 h-5 mt-0.5 rounded border-gray-300 accent-black cursor-pointer flex-shrink-0"
|
||||
@change="toggleOne(s.id)"
|
||||
/>
|
||||
<div class="min-w-0 flex-1">
|
||||
<a :href="`mailto:${s.email}`" class="inline-flex items-center gap-2 font-semibold text-black break-all">
|
||||
<Icon name="ph:envelope-simple" class="w-4 h-4 text-gray-400 flex-shrink-0" />
|
||||
{{ s.email }}
|
||||
</a>
|
||||
<p class="mt-1 text-xs text-gray-400">{{ formatDate(s.createdAt) }}</p>
|
||||
</div>
|
||||
<AdminButton size="sm" variant="ghost" class="min-h-10 shrink-0 -my-1" @click="askDelete(s)">
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</AdminButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<AdminPagination :total="filteredSubscribers.length" :page="page" :page-size="pageSize" @page="changePage" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 批量删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="batchConfirmOpen"
|
||||
:loading="batchDeleting"
|
||||
danger
|
||||
:message="`确定删除已选的 ${selected.size} 个订阅邮箱吗?此操作不可恢复。`"
|
||||
@update:open="batchConfirmOpen = false"
|
||||
@confirm="doBatchDelete"
|
||||
/>
|
||||
|
||||
<!-- 单条删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="!!confirmDelete"
|
||||
:loading="deleting"
|
||||
danger
|
||||
:message="`确定取消订阅「${confirmDelete?.email}」吗?此操作不可恢复。`"
|
||||
@update:open="confirmDelete = null"
|
||||
@confirm="doDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,225 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台图片管理:网格 + 搜索 + 存储模式标识 + 删除确认 + 前端分页。
|
||||
* - GET /api/admin/uploads → { files, storage };DELETE /api/admin/uploads?name=<key>
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useHead({ title: '图片管理' })
|
||||
|
||||
interface UploadFile {
|
||||
name: string
|
||||
size: number
|
||||
modified: string
|
||||
url: string
|
||||
}
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
/* ---------- 列表 ---------- */
|
||||
const files = ref<UploadFile[]>([])
|
||||
const storage = ref<'local' | 'oss' | ''>('')
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
|
||||
const loadFiles = async () => {
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const data = await $fetch<{ files: UploadFile[]; storage: 'local' | 'oss' }>('/api/admin/uploads')
|
||||
files.value = data.files
|
||||
storage.value = data.storage
|
||||
} catch (err) {
|
||||
console.error('load uploads error:', err)
|
||||
loadError.value = '加载失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadFiles)
|
||||
|
||||
/* ---------- 搜索 / 分页 ---------- */
|
||||
const keyword = ref('')
|
||||
const filteredFiles = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
if (!kw) return files.value
|
||||
return files.value.filter((f) => f.name.toLowerCase().includes(kw))
|
||||
})
|
||||
|
||||
const pageSize = 12
|
||||
const page = ref(1)
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(filteredFiles.value.length / pageSize)))
|
||||
|
||||
const pagedFiles = computed(() => {
|
||||
const p = Math.min(page.value, totalPages.value)
|
||||
const start = (p - 1) * pageSize
|
||||
return filteredFiles.value.slice(start, start + pageSize)
|
||||
})
|
||||
|
||||
watch(keyword, () => {
|
||||
page.value = 1
|
||||
})
|
||||
|
||||
const changePage = (p: number) => {
|
||||
page.value = Math.min(Math.max(1, p), totalPages.value)
|
||||
}
|
||||
|
||||
const totalSize = computed(() => files.value.reduce((sum, f) => sum + f.size, 0))
|
||||
|
||||
/* ---------- 删除 ---------- */
|
||||
const confirmDelete = ref<UploadFile | null>(null)
|
||||
const deleting = ref(false)
|
||||
|
||||
const askDelete = (f: UploadFile) => {
|
||||
confirmDelete.value = f
|
||||
}
|
||||
|
||||
const doDelete = async () => {
|
||||
const f = confirmDelete.value
|
||||
if (!f) return
|
||||
deleting.value = true
|
||||
try {
|
||||
await $fetch('/api/admin/uploads', { method: 'DELETE', query: { name: f.name } })
|
||||
files.value = files.value.filter((x) => x.name !== f.name)
|
||||
toast.success('已删除;如被内容引用请同步更新')
|
||||
confirmDelete.value = null
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '删除失败,请重试')
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const formatSize = (bytes: number) => {
|
||||
if (!bytes && bytes !== 0) return ''
|
||||
if (bytes >= 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
|
||||
return `${Math.max(1, Math.round(bytes / 1024))} KB`
|
||||
}
|
||||
|
||||
const formatDate = (raw?: string) => {
|
||||
if (!raw) return ''
|
||||
// 兼容 "YYYY-MM-DD HH:MM:SS"(UTC)与 ISO 两种格式
|
||||
const iso = String(raw).includes('T') ? String(raw) : String(raw).replace(' ', 'T') + 'Z'
|
||||
const d = new Date(iso)
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(d)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<AdminPageHeader title="图片管理" subtitle="站点上传的图片文件,删除前请确认未被动态/作品引用。">
|
||||
<template #actions>
|
||||
<AdminButton variant="secondary" size="sm" @click="loadFiles">
|
||||
<Icon name="ph:arrows-clockwise" class="w-4 h-4" /> 刷新
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- 统计 + 工具栏 -->
|
||||
<div class="mb-4 flex flex-wrap items-center gap-x-4 gap-y-2">
|
||||
<span class="text-sm text-gray-500">共 {{ files.length }} 张图片</span>
|
||||
<span class="text-sm text-gray-400">· 共 {{ formatSize(totalSize) }}</span>
|
||||
<AdminBadge :tone="storage === 'oss' ? 'blue' : 'gray'">
|
||||
<Icon :name="storage === 'oss' ? 'ph:cloud' : 'ph:hard-drives'" class="w-3.5 h-3.5" />
|
||||
{{ storage === 'oss' ? 'OSS 存储' : '本地存储' }}
|
||||
</AdminBadge>
|
||||
</div>
|
||||
|
||||
<div class="mb-5">
|
||||
<div class="relative flex-1 md:max-w-xs">
|
||||
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索文件名…"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white py-2.5 pl-10 pr-9 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10"
|
||||
/>
|
||||
<button
|
||||
v-if="keyword"
|
||||
@click="keyword = ''"
|
||||
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
|
||||
aria-label="清空筛选"
|
||||
>
|
||||
<Icon name="ph:x" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 加载态 -->
|
||||
<AdminCard v-if="loading">
|
||||
<AdminSkeleton :rows="6" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 错误态 -->
|
||||
<AdminCard v-else-if="loadError">
|
||||
<div class="py-10 text-center">
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ loadError }}</p>
|
||||
<AdminButton size="sm" @click="loadFiles">重新加载</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState v-else-if="!files.length" icon="ph:image" title="暂无图片" description="通过动态/作品的图片上传功能产生的文件会出现在这里。" />
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredFiles.length"
|
||||
icon="ph:magnifying-glass"
|
||||
title="没有匹配的图片"
|
||||
description="换个文件名关键词试试。"
|
||||
/>
|
||||
|
||||
<!-- 图片网格 -->
|
||||
<template v-else>
|
||||
<div class="grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4">
|
||||
<div
|
||||
v-for="f in pagedFiles"
|
||||
:key="f.name"
|
||||
class="bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden group"
|
||||
>
|
||||
<div class="relative aspect-square bg-gray-50">
|
||||
<img :src="f.url" :alt="f.name" loading="lazy" class="w-full h-full object-cover" />
|
||||
<button
|
||||
@click="askDelete(f)"
|
||||
class="absolute top-2 right-2 w-10 h-10 lg:w-8 lg:h-8 rounded-full bg-black/60 text-white flex items-center justify-center opacity-100 lg:opacity-0 lg:group-hover:opacity-100 transition-opacity hover:bg-red-600"
|
||||
title="删除图片"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="p-3">
|
||||
<p class="text-xs font-semibold text-gray-800 truncate" :title="f.name">{{ f.name }}</p>
|
||||
<div class="mt-1 flex items-center justify-between gap-2 text-[11px] text-gray-400">
|
||||
<span class="flex-shrink-0">{{ formatSize(f.size) }}</span>
|
||||
<span class="truncate">{{ formatDate(f.modified) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<AdminPagination :total="filteredFiles.length" :page="page" :page-size="pageSize" @page="changePage" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="!!confirmDelete"
|
||||
:loading="deleting"
|
||||
danger
|
||||
:message="`确定删除图片「${confirmDelete?.name}」吗?此操作不可恢复。`"
|
||||
@update:open="confirmDelete = null"
|
||||
@confirm="doDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,335 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台用户管理:列表 + 搜索/角色筛选 + 角色切换 + 删除确认 + 前端分页。
|
||||
* - GET /api/admin/users;PATCH /api/admin/users/[id](角色切换,不能操作自己);DELETE /api/admin/users/[id]
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useHead({ title: '用户管理' })
|
||||
|
||||
interface AdminUser {
|
||||
id: number
|
||||
username: string
|
||||
email: string | null
|
||||
phone: string | null
|
||||
role: 'user' | 'admin'
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
const toast = useToastStore()
|
||||
const userStore = useUserStore()
|
||||
const meId = computed(() => userStore.user?.id)
|
||||
|
||||
/* ---------- 列表 ---------- */
|
||||
const users = ref<AdminUser[]>([])
|
||||
const loading = ref(true)
|
||||
const loadError = ref('')
|
||||
|
||||
const loadUsers = async () => {
|
||||
loading.value = true
|
||||
loadError.value = ''
|
||||
try {
|
||||
const data = await $fetch<{ users: AdminUser[] }>('/api/admin/users')
|
||||
users.value = data.users
|
||||
} catch (err) {
|
||||
console.error('load users error:', err)
|
||||
loadError.value = '加载失败,请重试'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadUsers)
|
||||
|
||||
/* ---------- 搜索 / 筛选 ---------- */
|
||||
const keyword = ref('')
|
||||
const roleFilter = ref<'all' | 'admin' | 'user'>('all')
|
||||
|
||||
const filteredUsers = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return users.value.filter((u) => {
|
||||
if (roleFilter.value !== 'all' && u.role !== roleFilter.value) return false
|
||||
if (!kw) return true
|
||||
return (
|
||||
u.username.toLowerCase().includes(kw) ||
|
||||
(u.email || '').toLowerCase().includes(kw) ||
|
||||
(u.phone || '').toLowerCase().includes(kw)
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
const adminCount = computed(() => users.value.filter((u) => u.role === 'admin').length)
|
||||
|
||||
/* ---------- 前端分页 ---------- */
|
||||
const pageSize = 15
|
||||
const page = ref(1)
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(filteredUsers.value.length / pageSize)))
|
||||
|
||||
const pagedUsers = computed(() => {
|
||||
const p = Math.min(page.value, totalPages.value)
|
||||
const start = (p - 1) * pageSize
|
||||
return filteredUsers.value.slice(start, start + pageSize)
|
||||
})
|
||||
|
||||
watch([keyword, roleFilter], () => {
|
||||
page.value = 1
|
||||
})
|
||||
|
||||
const changePage = (p: number) => {
|
||||
page.value = Math.min(Math.max(1, p), totalPages.value)
|
||||
}
|
||||
|
||||
/* ---------- 角色切换 ---------- */
|
||||
const togglingId = ref<number | null>(null)
|
||||
const toggleRole = async (u: AdminUser) => {
|
||||
const next: AdminUser['role'] = u.role === 'admin' ? 'user' : 'admin'
|
||||
togglingId.value = u.id
|
||||
try {
|
||||
await $fetch(`/api/admin/users/${u.id}`, { method: 'PATCH', body: { role: next } })
|
||||
u.role = next
|
||||
toast.success(`已将「${u.username}」设为${next === 'admin' ? '管理员' : '普通用户'}`)
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '操作失败,请重试')
|
||||
} finally {
|
||||
togglingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 删除 ---------- */
|
||||
const confirmDelete = ref<AdminUser | null>(null)
|
||||
const deleting = ref(false)
|
||||
|
||||
const askDelete = (u: AdminUser) => {
|
||||
confirmDelete.value = u
|
||||
}
|
||||
|
||||
const doDelete = async () => {
|
||||
const u = confirmDelete.value
|
||||
if (!u) return
|
||||
deleting.value = true
|
||||
try {
|
||||
await $fetch(`/api/admin/users/${u.id}`, { method: 'DELETE' })
|
||||
users.value = users.value.filter((x) => x.id !== u.id)
|
||||
toast.success(`已删除用户「${u.username}」`)
|
||||
confirmDelete.value = null
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '删除失败,请重试')
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const formatDate = (raw?: string) => {
|
||||
if (!raw) return ''
|
||||
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
|
||||
if (Number.isNaN(d.getTime())) return raw
|
||||
return new Intl.DateTimeFormat('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(d)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<AdminPageHeader title="用户管理" subtitle="管理站点注册用户,调整角色或删除账号。">
|
||||
<template #actions>
|
||||
<AdminButton variant="secondary" size="sm" @click="loadUsers">
|
||||
<Icon name="ph:arrows-clockwise" class="w-4 h-4" /> 刷新
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- 统计 + 工具栏 -->
|
||||
<div class="mb-4 flex flex-wrap items-center gap-x-4 gap-y-2">
|
||||
<span class="text-sm text-gray-500">共 {{ users.length }} 个用户</span>
|
||||
<span class="text-sm text-gray-400">· 管理员 {{ adminCount }} · 普通用户 {{ users.length - adminCount }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 flex flex-col gap-3 md:flex-row">
|
||||
<div class="relative flex-1 md:max-w-xs">
|
||||
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索用户名 / 邮箱 / 手机号"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white py-2.5 pl-10 pr-9 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10"
|
||||
/>
|
||||
<button
|
||||
v-if="keyword"
|
||||
@click="keyword = ''"
|
||||
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-5 h-5 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
|
||||
aria-label="清空筛选"
|
||||
>
|
||||
<Icon name="ph:x" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<AdminSelect
|
||||
v-model="roleFilter"
|
||||
:options="[
|
||||
{ value: 'all', label: '全部角色' },
|
||||
{ value: 'admin', label: '管理员' },
|
||||
{ value: 'user', label: '普通用户' },
|
||||
]"
|
||||
class="w-full md:w-40"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 加载态 -->
|
||||
<AdminCard v-if="loading">
|
||||
<AdminSkeleton :rows="6" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 错误态 -->
|
||||
<AdminCard v-else-if="loadError">
|
||||
<div class="py-10 text-center">
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ loadError }}</p>
|
||||
<AdminButton size="sm" @click="loadUsers">重新加载</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState v-else-if="!users.length" icon="ph:users-three" title="暂无用户" description="还没有注册用户。" />
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredUsers.length"
|
||||
icon="ph:magnifying-glass"
|
||||
title="没有匹配的用户"
|
||||
description="换个关键词或筛选条件试试。"
|
||||
/>
|
||||
|
||||
<!-- 用户表格 -->
|
||||
<template v-else>
|
||||
<!-- 桌面表格(md+) -->
|
||||
<div class="hidden md:block rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap sticky left-0 bg-gray-50 z-10 border-r border-gray-100">ID</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">用户名</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">邮箱</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">手机号</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">角色</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider whitespace-nowrap">注册时间</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
<tr v-for="u in pagedUsers" :key="u.id" class="hover:bg-gray-50/60 transition-colors">
|
||||
<td class="px-5 py-4 text-gray-400 font-mono text-xs whitespace-nowrap sticky left-0 bg-white z-10 border-r border-gray-100">#{{ u.id }}</td>
|
||||
<td class="px-5 py-4 font-semibold text-black whitespace-nowrap">{{ u.username }}</td>
|
||||
<td class="px-5 py-4 text-gray-600">{{ u.email || '—' }}</td>
|
||||
<td class="px-5 py-4 text-gray-600 whitespace-nowrap">{{ u.phone || '—' }}</td>
|
||||
<td class="px-5 py-4 whitespace-nowrap">
|
||||
<AdminBadge :tone="u.role === 'admin' ? 'black' : 'gray'">
|
||||
<Icon v-if="u.role === 'admin'" name="ph:crown-simple" class="w-3 h-3" />
|
||||
{{ u.role === 'admin' ? '管理员' : '用户' }}
|
||||
</AdminBadge>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-gray-500 text-xs whitespace-nowrap">{{ formatDate(u.createdAt) }}</td>
|
||||
<td class="px-5 py-4">
|
||||
<div class="flex items-center justify-end gap-2">
|
||||
<template v-if="u.id !== meId">
|
||||
<AdminButton
|
||||
size="sm"
|
||||
:variant="u.role === 'admin' ? 'secondary' : 'primary'"
|
||||
:loading="togglingId === u.id"
|
||||
@click="toggleRole(u)"
|
||||
>
|
||||
{{ u.role === 'admin' ? '设为用户' : '设为管理员' }}
|
||||
</AdminButton>
|
||||
<AdminButton size="sm" variant="danger" @click="askDelete(u)">
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
|
||||
</AdminButton>
|
||||
</template>
|
||||
<AdminBadge v-else tone="gray">当前账号</AdminBadge>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 移动端卡片(<md) -->
|
||||
<div class="md:hidden space-y-3">
|
||||
<div
|
||||
v-for="u in pagedUsers"
|
||||
:key="u.id"
|
||||
class="bg-white rounded-2xl border border-gray-100 shadow-sm p-4"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-3 min-w-0">
|
||||
<div
|
||||
class="w-10 h-10 rounded-full bg-black text-white flex items-center justify-center font-bold flex-shrink-0"
|
||||
>
|
||||
{{ (u.username || '?').charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<p class="font-semibold text-black truncate">{{ u.username }}</p>
|
||||
<p class="text-xs text-gray-400 font-mono">#{{ u.id }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<AdminBadge :tone="u.role === 'admin' ? 'black' : 'gray'" class="flex-shrink-0">
|
||||
<Icon v-if="u.role === 'admin'" name="ph:crown-simple" class="w-3 h-3" />
|
||||
{{ u.role === 'admin' ? '管理员' : '用户' }}
|
||||
</AdminBadge>
|
||||
</div>
|
||||
<dl class="mt-3 space-y-1.5 text-sm">
|
||||
<div class="flex justify-between gap-3">
|
||||
<dt class="text-gray-400 flex-shrink-0">邮箱</dt>
|
||||
<dd class="text-gray-700 text-right break-all">{{ u.email || '—' }}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between gap-3">
|
||||
<dt class="text-gray-400 flex-shrink-0">手机号</dt>
|
||||
<dd class="text-gray-700 text-right">{{ u.phone || '—' }}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between gap-3">
|
||||
<dt class="text-gray-400 flex-shrink-0">注册时间</dt>
|
||||
<dd class="text-gray-700 text-right">{{ formatDate(u.createdAt) }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div class="mt-4 flex flex-wrap items-center gap-2">
|
||||
<template v-if="u.id !== meId">
|
||||
<AdminButton
|
||||
size="sm"
|
||||
class="flex-1 min-h-10"
|
||||
:variant="u.role === 'admin' ? 'secondary' : 'primary'"
|
||||
:loading="togglingId === u.id"
|
||||
@click="toggleRole(u)"
|
||||
>
|
||||
{{ u.role === 'admin' ? '设为用户' : '设为管理员' }}
|
||||
</AdminButton>
|
||||
<AdminButton size="sm" variant="danger" class="min-h-10" @click="askDelete(u)">
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
|
||||
</AdminButton>
|
||||
</template>
|
||||
<AdminBadge v-else tone="gray">当前账号</AdminBadge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<AdminPagination :total="filteredUsers.length" :page="page" :page-size="pageSize" @page="changePage" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="!!confirmDelete"
|
||||
:loading="deleting"
|
||||
danger
|
||||
:message="`确定删除用户「${confirmDelete?.username}」吗?此操作不可恢复。`"
|
||||
@update:open="confirmDelete = null"
|
||||
@confirm="doDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,640 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台作品管理:列表(搜索/分类/状态筛选 + 前端分页)+ 新建/编辑表单。
|
||||
* - 列表来自 /api/admin/works(含未发布)
|
||||
* - 新建 POST /api/admin/works;编辑 PATCH /api/admin/works/[id];删除 DELETE /api/admin/works/[id]
|
||||
* - tags 逗号分隔输入;gallery 多 URL 行(每行可上传)
|
||||
*/
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useToastStore } from '~/stores/toast'
|
||||
|
||||
definePageMeta({ middleware: 'admin', layout: 'admin' })
|
||||
useHead({ title: '作品管理' })
|
||||
|
||||
interface Work {
|
||||
id?: number
|
||||
slug: string
|
||||
category: 'webDesign' | 'branding' | 'development'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
descriptionZh: string
|
||||
descriptionEn: string
|
||||
overviewZh: string
|
||||
overviewEn: string
|
||||
challengeZh: string
|
||||
challengeEn: string
|
||||
solutionZh: string
|
||||
solutionEn: string
|
||||
clientZh: string
|
||||
clientEn: string
|
||||
durationZh: string
|
||||
durationEn: string
|
||||
year: string
|
||||
tags: string[]
|
||||
image: string | null
|
||||
gallery: string[]
|
||||
url: string | null
|
||||
published: number
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
const toast = useToastStore()
|
||||
|
||||
const CATEGORIES = [
|
||||
{ value: 'webDesign', label: '网页设计' },
|
||||
{ value: 'branding', label: '品牌设计' },
|
||||
{ value: 'development', label: '程序开发' },
|
||||
]
|
||||
const catLabel = (c: string) => CATEGORIES.find((x) => x.value === c)?.label ?? c
|
||||
|
||||
/* ---------- 列表 ---------- */
|
||||
const works = ref<Work[]>([])
|
||||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
|
||||
const loadWorks = async () => {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const res = await $fetch<{ works: Work[] }>('/api/admin/works')
|
||||
works.value = res.works
|
||||
} catch (err: any) {
|
||||
error.value = err?.data?.message || '加载失败'
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadWorks)
|
||||
|
||||
/* ---------- 搜索 / 筛选 / 分页 ---------- */
|
||||
const keyword = ref('')
|
||||
const categoryFilter = ref<'all' | Work['category']>('all')
|
||||
const statusFilter = ref<'all' | 'published' | 'draft'>('all')
|
||||
|
||||
const filteredWorks = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return works.value.filter((w) => {
|
||||
if (categoryFilter.value !== 'all' && w.category !== categoryFilter.value) return false
|
||||
if (statusFilter.value === 'published' && !w.published) return false
|
||||
if (statusFilter.value === 'draft' && w.published) return false
|
||||
if (!kw) return true
|
||||
return (
|
||||
w.titleZh.toLowerCase().includes(kw) ||
|
||||
w.titleEn.toLowerCase().includes(kw) ||
|
||||
w.slug.toLowerCase().includes(kw) ||
|
||||
w.tags.some((t) => t.toLowerCase().includes(kw))
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
const pageSize = 10
|
||||
const page = ref(1)
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(filteredWorks.value.length / pageSize)))
|
||||
|
||||
const pagedWorks = computed(() => {
|
||||
const p = Math.min(page.value, totalPages.value)
|
||||
const start = (p - 1) * pageSize
|
||||
return filteredWorks.value.slice(start, start + pageSize)
|
||||
})
|
||||
|
||||
watch([keyword, categoryFilter, statusFilter], () => {
|
||||
page.value = 1
|
||||
})
|
||||
|
||||
const changePage = (p: number) => {
|
||||
page.value = Math.min(Math.max(1, p), totalPages.value)
|
||||
}
|
||||
|
||||
const headerSubtitle = computed(() => {
|
||||
if (view.value === 'form') return editingId.value != null ? '编辑作品' : '新建作品'
|
||||
return `共 ${works.value.length} 个作品`
|
||||
})
|
||||
|
||||
/* ---------- 表单 ---------- */
|
||||
const view = ref<'list' | 'form'>('list')
|
||||
const editingId = ref<number | null>(null)
|
||||
const saving = ref(false)
|
||||
const formError = ref('')
|
||||
|
||||
const emptyForm = () => ({
|
||||
slug: '',
|
||||
category: 'webDesign' as Work['category'],
|
||||
titleZh: '',
|
||||
titleEn: '',
|
||||
descriptionZh: '',
|
||||
descriptionEn: '',
|
||||
overviewZh: '',
|
||||
overviewEn: '',
|
||||
challengeZh: '',
|
||||
challengeEn: '',
|
||||
solutionZh: '',
|
||||
solutionEn: '',
|
||||
clientZh: '',
|
||||
clientEn: '',
|
||||
durationZh: '',
|
||||
durationEn: '',
|
||||
year: String(new Date().getFullYear()),
|
||||
image: '',
|
||||
gallery: [''] as string[],
|
||||
url: '',
|
||||
published: true,
|
||||
})
|
||||
const form = reactive(emptyForm())
|
||||
const tagsText = ref('')
|
||||
|
||||
const openCreate = () => {
|
||||
Object.assign(form, emptyForm())
|
||||
tagsText.value = ''
|
||||
editingId.value = null
|
||||
formError.value = ''
|
||||
view.value = 'form'
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
const openEdit = (w: Work) => {
|
||||
if (w.id == null) {
|
||||
toast.error('该条目缺少 id 字段,暂时无法编辑(后端待补)')
|
||||
return
|
||||
}
|
||||
editingId.value = w.id
|
||||
Object.assign(form, {
|
||||
slug: w.slug,
|
||||
category: w.category,
|
||||
titleZh: w.titleZh,
|
||||
titleEn: w.titleEn,
|
||||
descriptionZh: w.descriptionZh,
|
||||
descriptionEn: w.descriptionEn,
|
||||
overviewZh: w.overviewZh,
|
||||
overviewEn: w.overviewEn,
|
||||
challengeZh: w.challengeZh,
|
||||
challengeEn: w.challengeEn,
|
||||
solutionZh: w.solutionZh,
|
||||
solutionEn: w.solutionEn,
|
||||
clientZh: w.clientZh,
|
||||
clientEn: w.clientEn,
|
||||
durationZh: w.durationZh,
|
||||
durationEn: w.durationEn,
|
||||
year: w.year,
|
||||
image: w.image ?? '',
|
||||
gallery: w.gallery.length ? [...w.gallery] : [''],
|
||||
url: w.url ?? '',
|
||||
published: !!w.published,
|
||||
})
|
||||
tagsText.value = w.tags.join(', ')
|
||||
formError.value = ''
|
||||
view.value = 'form'
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
const backToList = () => {
|
||||
view.value = 'list'
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
formError.value = ''
|
||||
if (!/^[a-z0-9-]{2,64}$/.test(form.slug)) {
|
||||
formError.value = 'slug 需为 2-64 位小写字母/数字/中划线'
|
||||
return
|
||||
}
|
||||
if (!form.titleZh.trim() || !form.titleEn.trim()) {
|
||||
formError.value = '中英文标题均为必填'
|
||||
return
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const payload = {
|
||||
slug: form.slug,
|
||||
category: form.category,
|
||||
titleZh: form.titleZh,
|
||||
titleEn: form.titleEn,
|
||||
descriptionZh: form.descriptionZh,
|
||||
descriptionEn: form.descriptionEn,
|
||||
overviewZh: form.overviewZh,
|
||||
overviewEn: form.overviewEn,
|
||||
challengeZh: form.challengeZh,
|
||||
challengeEn: form.challengeEn,
|
||||
solutionZh: form.solutionZh,
|
||||
solutionEn: form.solutionEn,
|
||||
clientZh: form.clientZh,
|
||||
clientEn: form.clientEn,
|
||||
durationZh: form.durationZh,
|
||||
durationEn: form.durationEn,
|
||||
year: form.year,
|
||||
tags: tagsText.value.split(',').map((t) => t.trim()).filter(Boolean),
|
||||
image: form.image || null,
|
||||
gallery: form.gallery.filter((u) => u.trim()),
|
||||
url: form.url.trim() || null,
|
||||
published: form.published,
|
||||
}
|
||||
if (editingId.value != null) {
|
||||
await $fetch(`/api/admin/works/${editingId.value}`, { method: 'PATCH', body: payload })
|
||||
toast.success('作品已更新')
|
||||
} else {
|
||||
await $fetch('/api/admin/works', { method: 'POST', body: payload })
|
||||
toast.success('作品已创建')
|
||||
}
|
||||
await loadWorks()
|
||||
view.value = 'list'
|
||||
} catch (err: any) {
|
||||
formError.value = err?.data?.message || '保存失败'
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 删除 ---------- */
|
||||
const confirmDelete = ref<Work | null>(null)
|
||||
const deleting = ref(false)
|
||||
|
||||
const askDelete = (w: Work) => {
|
||||
if (w.id == null) {
|
||||
toast.error('该条目缺少 id 字段,暂时无法删除(后端待补)')
|
||||
return
|
||||
}
|
||||
confirmDelete.value = w
|
||||
}
|
||||
|
||||
const doDelete = async () => {
|
||||
const w = confirmDelete.value
|
||||
if (!w || w.id == null) return
|
||||
deleting.value = true
|
||||
try {
|
||||
await $fetch(`/api/admin/works/${w.id}`, { method: 'DELETE' })
|
||||
toast.success(`已删除「${w.titleZh}」`)
|
||||
confirmDelete.value = null
|
||||
await loadWorks()
|
||||
} catch (err: any) {
|
||||
toast.error(err?.data?.message || '删除失败')
|
||||
} finally {
|
||||
deleting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- 图集(gallery)上传 ---------- */
|
||||
const galleryFileInput = ref<HTMLInputElement | null>(null)
|
||||
const uploadingIndex = ref<number | null>(null)
|
||||
const galleryUploading = ref(false)
|
||||
const galleryError = ref('')
|
||||
|
||||
const pickGalleryFile = (i: number) => {
|
||||
uploadingIndex.value = i
|
||||
galleryFileInput.value?.click()
|
||||
}
|
||||
|
||||
const onGalleryFile = async (e: Event) => {
|
||||
const input = e.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
input.value = ''
|
||||
if (!file || uploadingIndex.value == null) return
|
||||
galleryUploading.value = true
|
||||
galleryError.value = ''
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
const res = await $fetch<{ ok: boolean; url: string }>('/api/admin/upload', {
|
||||
method: 'POST',
|
||||
body: fd,
|
||||
})
|
||||
form.gallery[uploadingIndex.value] = res.url
|
||||
} catch (err: any) {
|
||||
galleryError.value = err?.data?.message || '上传失败'
|
||||
} finally {
|
||||
galleryUploading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const addGalleryRow = () => form.gallery.push('')
|
||||
const removeGalleryRow = (i: number) => form.gallery.splice(i, 1)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<!-- 页头 -->
|
||||
<AdminPageHeader title="作品管理" :subtitle="headerSubtitle">
|
||||
<template #actions>
|
||||
<AdminButton v-if="view === 'list'" size="sm" @click="openCreate">
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 新建作品
|
||||
</AdminButton>
|
||||
<AdminButton v-else size="sm" variant="secondary" @click="backToList">
|
||||
<Icon name="ph:arrow-left" class="w-4 h-4" /> 返回列表
|
||||
</AdminButton>
|
||||
</template>
|
||||
</AdminPageHeader>
|
||||
|
||||
<!-- ==================== 列表视图 ==================== -->
|
||||
<template v-if="view === 'list'">
|
||||
<!-- 工具栏 -->
|
||||
<div class="mb-5 flex flex-col sm:flex-row gap-3">
|
||||
<div class="relative flex-1 sm:max-w-xs">
|
||||
<Icon name="ph:magnifying-glass" class="w-4 h-4 text-gray-400 absolute left-3.5 top-1/2 -translate-y-1/2 pointer-events-none" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索标题 / slug / 标签…"
|
||||
class="w-full rounded-xl border border-gray-200 bg-white py-2.5 pl-10 pr-9 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10"
|
||||
/>
|
||||
<button
|
||||
v-if="keyword"
|
||||
@click="keyword = ''"
|
||||
class="absolute right-2.5 top-1/2 -translate-y-1/2 w-6 h-6 rounded-full text-gray-400 hover:text-gray-600 hover:bg-gray-100 flex items-center justify-center"
|
||||
aria-label="清空筛选"
|
||||
>
|
||||
<Icon name="ph:x" class="w-3.5 h-3.5" />
|
||||
</button>
|
||||
</div>
|
||||
<AdminSelect
|
||||
v-model="categoryFilter"
|
||||
:options="[
|
||||
{ value: 'all', label: '全部分类' },
|
||||
...CATEGORIES,
|
||||
]"
|
||||
class="w-full sm:w-40"
|
||||
/>
|
||||
<AdminSelect
|
||||
v-model="statusFilter"
|
||||
:options="[
|
||||
{ value: 'all', label: '全部状态' },
|
||||
{ value: 'published', label: '已发布' },
|
||||
{ value: 'draft', label: '草稿' },
|
||||
]"
|
||||
class="w-full sm:w-36"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 加载态 -->
|
||||
<AdminCard v-if="loading">
|
||||
<AdminSkeleton :rows="6" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 错误态 -->
|
||||
<AdminCard v-else-if="error">
|
||||
<div class="py-10 text-center">
|
||||
<Icon name="ph:warning-circle" class="w-10 h-10 text-gray-300 mx-auto mb-4" />
|
||||
<p class="text-gray-500 mb-4">{{ error }}</p>
|
||||
<AdminButton size="sm" @click="loadWorks">重新加载</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState
|
||||
v-else-if="!works.length"
|
||||
icon="ph:image-square"
|
||||
title="还没有作品"
|
||||
description="点击右上角「新建作品」创建第一个。"
|
||||
/>
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredWorks.length"
|
||||
icon="ph:magnifying-glass"
|
||||
title="没有匹配的作品"
|
||||
description="换个关键词或筛选条件试试。"
|
||||
/>
|
||||
|
||||
<!-- 列表 -->
|
||||
<template v-else>
|
||||
<div class="rounded-2xl border border-gray-100 bg-white shadow-sm overflow-hidden">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="text-left text-gray-400 border-b border-gray-100 bg-gray-50">
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">标题</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">分类</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">年份</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">标签</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider">状态</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
<tr
|
||||
v-for="w in pagedWorks"
|
||||
:key="w.slug"
|
||||
class="hover:bg-gray-50/60 transition-colors"
|
||||
>
|
||||
<td class="px-5 py-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<img
|
||||
v-if="w.image"
|
||||
:src="w.image"
|
||||
:alt="w.titleZh"
|
||||
class="w-10 h-10 rounded-lg object-cover border border-gray-100 flex-shrink-0"
|
||||
/>
|
||||
<div v-else class="w-10 h-10 rounded-lg bg-gray-100 flex items-center justify-center flex-shrink-0">
|
||||
<Icon name="ph:image" class="w-4 h-4 text-gray-400" />
|
||||
</div>
|
||||
<div class="min-w-0">
|
||||
<p class="font-semibold text-black truncate">{{ w.titleZh }}</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5 font-mono truncate">{{ w.slug }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-4">
|
||||
<AdminBadge tone="gray">{{ catLabel(w.category) }}</AdminBadge>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-gray-600 whitespace-nowrap">{{ w.year || '-' }}</td>
|
||||
<td class="px-5 py-4">
|
||||
<div class="flex flex-wrap gap-1.5 max-w-[220px]">
|
||||
<span
|
||||
v-for="tag in w.tags.slice(0, 3)"
|
||||
:key="tag"
|
||||
class="px-2 py-0.5 rounded-full bg-gray-50 text-gray-500 text-xs"
|
||||
>
|
||||
{{ tag }}
|
||||
</span>
|
||||
<span v-if="w.tags.length > 3" class="text-xs text-gray-400">+{{ w.tags.length - 3 }}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-4">
|
||||
<AdminBadge :tone="w.published ? 'green' : 'amber'">
|
||||
<span
|
||||
class="w-1.5 h-1.5 rounded-full inline-block"
|
||||
:class="w.published ? 'bg-green-500' : 'bg-amber-500'"
|
||||
></span>
|
||||
{{ w.published ? '已发布' : '草稿' }}
|
||||
</AdminBadge>
|
||||
</td>
|
||||
<td class="px-5 py-4">
|
||||
<div class="flex items-center justify-end gap-2">
|
||||
<AdminButton size="sm" variant="secondary" class="min-h-10" @click="openEdit(w)">
|
||||
<Icon name="ph:pencil-simple" class="w-3.5 h-3.5" /> 编辑
|
||||
</AdminButton>
|
||||
<AdminButton size="sm" variant="danger" class="min-h-10" @click="askDelete(w)">
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
|
||||
</AdminButton>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4">
|
||||
<AdminPagination :total="filteredWorks.length" :page="page" :page-size="pageSize" @page="changePage" />
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<!-- ==================== 表单视图 ==================== -->
|
||||
<template v-else>
|
||||
<div class="space-y-6 max-w-4xl">
|
||||
<!-- 基本信息 -->
|
||||
<AdminCard title="基本信息">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<div>
|
||||
<AdminInput
|
||||
v-model="form.slug"
|
||||
label="slug"
|
||||
required
|
||||
placeholder="如 forma-digital"
|
||||
:error="formError && !/^[a-z0-9-]{2,64}$/.test(form.slug) ? 'slug 需为 2-64 位小写字母/数字/中划线' : ''"
|
||||
/>
|
||||
<p class="mt-1 text-xs text-gray-400">2-64 位小写字母 / 数字 / 中划线,用于前台链接</p>
|
||||
</div>
|
||||
<AdminSelect
|
||||
v-model="form.category"
|
||||
label="分类"
|
||||
:options="CATEGORIES"
|
||||
/>
|
||||
<AdminInput v-model="form.year" label="年份" placeholder="如 2026" />
|
||||
<AdminInput v-model="tagsText" label="标签" placeholder="Web Design, React, E-commerce" />
|
||||
<div>
|
||||
<AdminInput v-model="form.url" label="外部链接(可选)" placeholder="https://… 留空则前台不显示访问按钮" />
|
||||
</div>
|
||||
<div>
|
||||
<p class="block text-sm font-semibold text-gray-800 mb-1.5">发布状态</p>
|
||||
<div class="flex items-center gap-3 mt-1">
|
||||
<AdminToggle v-model="form.published" />
|
||||
<span class="text-sm" :class="form.published ? 'text-green-700 font-semibold' : 'text-gray-500'">
|
||||
{{ form.published ? '已发布(前台可见)' : '草稿(前台隐藏)' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 标题与简介 -->
|
||||
<AdminCard title="标题与简介">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<div class="space-y-4">
|
||||
<AdminInput v-model="form.titleZh" label="中文标题" required />
|
||||
<AdminTextarea v-model="form.descriptionZh" label="中文简介" :rows="3" />
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
<AdminInput v-model="form.titleEn" label="English Title" required />
|
||||
<AdminTextarea v-model="form.descriptionEn" label="English Description" :rows="3" />
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 项目详情(中英) -->
|
||||
<AdminCard title="项目详情(中英各一组)">
|
||||
<div class="space-y-6">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<div class="space-y-4">
|
||||
<AdminTextarea v-model="form.overviewZh" label="中文概述(Overview)" :rows="4" />
|
||||
<AdminTextarea v-model="form.challengeZh" label="中文挑战(Challenge)" :rows="3" />
|
||||
<AdminTextarea v-model="form.solutionZh" label="中文方案(Solution)" :rows="3" />
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
<AdminTextarea v-model="form.overviewEn" label="English Overview" :rows="4" />
|
||||
<AdminTextarea v-model="form.challengeEn" label="English Challenge" :rows="3" />
|
||||
<AdminTextarea v-model="form.solutionEn" label="English Solution" :rows="3" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
||||
<AdminInput v-model="form.clientZh" label="中文客户(Client)" />
|
||||
<AdminInput v-model="form.clientEn" label="English Client" />
|
||||
<AdminInput v-model="form.durationZh" label="中文周期(Duration)" placeholder="如 3 个月" />
|
||||
<AdminInput v-model="form.durationEn" label="English Duration" placeholder="如 3 months" />
|
||||
</div>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 封面图 -->
|
||||
<AdminCard title="封面图">
|
||||
<AdminImageUpload v-model="form.image" label="封面图" />
|
||||
</AdminCard>
|
||||
|
||||
<!-- 作品图集 -->
|
||||
<AdminCard>
|
||||
<template #actions>
|
||||
<AdminButton size="sm" variant="secondary" @click="addGalleryRow">
|
||||
<Icon name="ph:plus" class="w-3.5 h-3.5" /> 添加图片
|
||||
</AdminButton>
|
||||
</template>
|
||||
<template #default>
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
v-for="(url, i) in form.gallery"
|
||||
:key="i"
|
||||
class="flex flex-col sm:flex-row sm:items-center gap-3 border border-gray-200 rounded-xl bg-white p-3"
|
||||
>
|
||||
<div class="flex-1 min-w-0">
|
||||
<input
|
||||
v-model="form.gallery[i]"
|
||||
type="text"
|
||||
placeholder="图片 URL(本地 /uploads/... 或 https://...)"
|
||||
class="w-full px-3 py-2.5 rounded-lg border border-gray-200 bg-gray-50 text-sm outline-none transition-all focus:border-black focus:bg-white"
|
||||
/>
|
||||
<div v-if="url" class="mt-2">
|
||||
<img :src="url" alt="图集预览" class="h-24 w-auto max-w-full rounded-lg border border-gray-100 object-cover" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 sm:flex-shrink-0">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="galleryUploading && uploadingIndex === i"
|
||||
@click="pickGalleryFile(i)"
|
||||
class="flex-1 sm:flex-none flex items-center justify-center gap-1.5 px-3 py-2.5 min-h-10 rounded-lg bg-black text-white text-xs font-semibold hover:bg-gray-800 transition-colors disabled:opacity-60"
|
||||
>
|
||||
<Icon
|
||||
:name="galleryUploading && uploadingIndex === i ? 'ph:circle-notch' : 'ph:upload-simple'"
|
||||
:class="galleryUploading && uploadingIndex === i ? 'w-3.5 h-3.5 animate-spin' : 'w-3.5 h-3.5'"
|
||||
/>
|
||||
{{ galleryUploading && uploadingIndex === i ? '上传中…' : '上传' }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="removeGalleryRow(i)"
|
||||
class="w-10 h-10 rounded-lg hover:bg-red-50 text-gray-400 hover:text-red-600 flex items-center justify-center transition-colors flex-shrink-0"
|
||||
aria-label="删除该图"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="galleryError" class="text-xs text-red-600">{{ galleryError }}</p>
|
||||
</div>
|
||||
<input ref="galleryFileInput" type="file" accept="image/*" class="hidden" @change="onGalleryFile" />
|
||||
</template>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 提交 -->
|
||||
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-end gap-3">
|
||||
<p v-if="formError" class="text-sm text-red-600 sm:mr-auto">{{ formError }}</p>
|
||||
<div class="flex items-center gap-3 w-full sm:w-auto sm:justify-end">
|
||||
<AdminButton class="flex-1 sm:flex-none" variant="secondary" @click="backToList">取消</AdminButton>
|
||||
<AdminButton class="flex-1 sm:flex-none" :loading="saving" @click="save">
|
||||
{{ saving ? '保存中…' : editingId != null ? '保存修改' : '创建作品' }}
|
||||
</AdminButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 删除确认 -->
|
||||
<AdminConfirm
|
||||
:open="!!confirmDelete"
|
||||
:loading="deleting"
|
||||
danger
|
||||
:message="`确定要删除「${confirmDelete?.titleZh}」吗?该作品下的所有收藏将一并删除,此操作不可撤销。`"
|
||||
@update:open="confirmDelete = null"
|
||||
@confirm="doDelete"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
+14
-42
@@ -139,7 +139,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="text-base md:text-lg font-bold text-gray-900 mb-2">Email</h3>
|
||||
<a href="mailto:chenchun@virtheart.com" class="text-sm md:text-base text-gray-600 hover:text-black transition-colors duration-300">
|
||||
<a :href="`mailto:${settings?.contact.email}`" class="text-sm md:text-base text-gray-600 hover:text-black transition-colors duration-300">
|
||||
{{ t('contact.info.email') }}
|
||||
</a>
|
||||
</div>
|
||||
@@ -193,14 +193,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, reactive } from 'vue'
|
||||
import { nextTick, onBeforeUnmount, onMounted, ref, reactive, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useSeoMeta } from '#imports'
|
||||
import gsap from 'gsap'
|
||||
import { useAppStore } from '~/stores/app'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
const { t } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
const headerWrapRef = ref<HTMLElement | null>(null)
|
||||
const titleRef = ref<HTMLElement | null>(null)
|
||||
@@ -234,32 +236,28 @@ const handleSubmit = async () => {
|
||||
statusMessage.value = ''
|
||||
|
||||
try {
|
||||
// 真实提交:入库(PostgreSQL)+ 可选 SMTP 邮件通知
|
||||
await $fetch('/api/contact', {
|
||||
method: 'POST',
|
||||
body: { ...form },
|
||||
})
|
||||
// 真实提交到后端(落库 + 尽力发送邮件)
|
||||
await $fetch('/api/contact', { method: 'POST', body: { ...form } })
|
||||
|
||||
submitStatus.value = 'success'
|
||||
statusMessage.value = t('contact.form.successMessage')
|
||||
statusMessage.value = t('contact.form.successMessage') || 'Message sent successfully! We will get back to you soon.'
|
||||
|
||||
// 清空表单
|
||||
Object.keys(form).forEach(key => {
|
||||
form[key as keyof typeof form] = ''
|
||||
})
|
||||
|
||||
// 3秒后重置状态
|
||||
// 4秒后重置状态
|
||||
setTimeout(() => {
|
||||
submitStatus.value = 'idle'
|
||||
statusMessage.value = ''
|
||||
}, 3000)
|
||||
}, 4000)
|
||||
|
||||
} catch (error: any) {
|
||||
} catch (error) {
|
||||
console.error('Form submission error:', error)
|
||||
submitStatus.value = 'error'
|
||||
// 优先显示服务端返回的具体错误码(i18n key),否则显示通用错误
|
||||
const code = error?.data?.statusMessage || error?.statusMessage || ''
|
||||
statusMessage.value = code && code !== 'Bad Request' ? t(code) : t('contact.form.errorMessage')
|
||||
// 如实展示后端错误
|
||||
statusMessage.value = (error as any)?.data?.message || t('contact.form.errorMessage') || 'Failed to send message. Please try again or contact us directly.'
|
||||
} finally {
|
||||
isSubmitting.value = false
|
||||
}
|
||||
@@ -353,34 +351,8 @@ onBeforeUnmount(() => {
|
||||
contactCtx?.revert()
|
||||
})
|
||||
|
||||
interface SocialLink {
|
||||
name: string
|
||||
icon: string
|
||||
url: string
|
||||
}
|
||||
|
||||
const socials: SocialLink[] = [
|
||||
{
|
||||
name: 'Twitter',
|
||||
icon: 'ph:x-logo',
|
||||
url: 'https://twitter.com'
|
||||
},
|
||||
{
|
||||
name: 'Instagram',
|
||||
icon: 'ph:instagram-logo',
|
||||
url: 'https://instagram.com'
|
||||
},
|
||||
{
|
||||
name: 'LinkedIn',
|
||||
icon: 'ph:linkedin-logo',
|
||||
url: 'https://linkedin.com'
|
||||
},
|
||||
{
|
||||
name: 'GitHub',
|
||||
icon: 'ph:github-logo',
|
||||
url: 'https://github.com'
|
||||
}
|
||||
]
|
||||
// 社交链接统一取自站点动态配置(后台可改)
|
||||
const socials = computed(() => settings?.socials ?? [])
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
+174
-133
@@ -14,8 +14,8 @@
|
||||
<!-- 文章 Hero -->
|
||||
<section class="relative h-[50vh] md:h-[60vh] overflow-hidden">
|
||||
<img
|
||||
:src="article.image"
|
||||
:alt="article.title"
|
||||
:src="article.image || ''"
|
||||
:alt="title"
|
||||
class="w-full h-full object-cover"
|
||||
/>
|
||||
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"></div>
|
||||
@@ -23,21 +23,21 @@
|
||||
<div class="max-w-[800px] mx-auto">
|
||||
<span
|
||||
class="inline-block px-3 py-1.5 text-xs md:text-sm font-semibold rounded-full mb-4"
|
||||
:class="article.badge"
|
||||
:class="categoryBadge[article.category]"
|
||||
>
|
||||
{{ article.category }}
|
||||
{{ t(`news.categories.${article.category}`) }}
|
||||
</span>
|
||||
<h1 class="text-3xl md:text-5xl lg:text-6xl font-bold text-white mb-4 tracking-tight">
|
||||
{{ article.title }}
|
||||
{{ title }}
|
||||
</h1>
|
||||
<div class="flex items-center gap-4 text-white/80 text-sm md:text-base">
|
||||
<span class="flex items-center gap-1.5">
|
||||
<Icon name="ph:calendar-blank" class="w-4 h-4" />
|
||||
{{ article.date }}
|
||||
{{ formatNewsDate(article.date, locale) }}
|
||||
</span>
|
||||
<span class="flex items-center gap-1.5">
|
||||
<Icon name="ph:clock" class="w-4 h-4" />
|
||||
{{ article.readTime }}
|
||||
{{ article.readTime }} {{ t('news.minutes') }}
|
||||
</span>
|
||||
<span class="flex items-center gap-1.5">
|
||||
<Icon name="ph:user" class="w-4 h-4" />
|
||||
@@ -48,62 +48,76 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 文章内容 -->
|
||||
<!-- 文章内容(内容块:paragraph / heading / quote / image) -->
|
||||
<section class="max-w-[800px] mx-auto px-6 md:px-10 py-16 md:py-24">
|
||||
<article class="prose prose-lg max-w-none">
|
||||
<p class="text-gray-700 text-lg leading-relaxed mb-8">
|
||||
{{ t(`news.detail.items.${slug}.content`) }}
|
||||
</p>
|
||||
<template v-for="(block, index) in blocks" :key="index">
|
||||
<p
|
||||
v-if="block.type === 'paragraph'"
|
||||
class="text-gray-700 text-lg leading-relaxed mb-8"
|
||||
>
|
||||
{{ block.text }}
|
||||
</p>
|
||||
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6 mt-12">
|
||||
{{ t(`news.detail.items.${slug}.section1Title`) }}
|
||||
</h2>
|
||||
<p class="text-gray-700 text-lg leading-relaxed mb-8">
|
||||
{{ t(`news.detail.items.${slug}.section1Content`) }}
|
||||
</p>
|
||||
<h2
|
||||
v-else-if="block.type === 'heading'"
|
||||
class="text-2xl md:text-3xl font-bold text-black mb-6 mt-12"
|
||||
>
|
||||
{{ block.text }}
|
||||
</h2>
|
||||
|
||||
<!-- 引用 -->
|
||||
<blockquote class="border-l-4 border-black pl-6 my-10 italic text-gray-600 text-lg">
|
||||
"{{ t(`news.detail.items.${slug}.quote`) }}"
|
||||
</blockquote>
|
||||
<blockquote
|
||||
v-else-if="block.type === 'quote'"
|
||||
class="border-l-4 border-black pl-6 my-10 italic text-gray-600 text-lg"
|
||||
>
|
||||
"{{ block.text }}"
|
||||
</blockquote>
|
||||
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6 mt-12">
|
||||
{{ t(`news.detail.items.${slug}.section2Title`) }}
|
||||
</h2>
|
||||
<p class="text-gray-700 text-lg leading-relaxed mb-8">
|
||||
{{ t(`news.detail.items.${slug}.section2Content`) }}
|
||||
</p>
|
||||
|
||||
<!-- 文章内图片 -->
|
||||
<div class="my-10 rounded-2xl overflow-hidden">
|
||||
<img :src="article.image" :alt="article.title" class="w-full h-auto" />
|
||||
</div>
|
||||
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6 mt-12">
|
||||
{{ t(`news.detail.items.${slug}.section3Title`) }}
|
||||
</h2>
|
||||
<p class="text-gray-700 text-lg leading-relaxed mb-8">
|
||||
{{ t(`news.detail.items.${slug}.section3Content`) }}
|
||||
</p>
|
||||
<img
|
||||
v-else-if="block.type === 'image'"
|
||||
:src="block.text"
|
||||
:alt="title"
|
||||
class="my-10 rounded-2xl w-full h-auto"
|
||||
/>
|
||||
</template>
|
||||
</article>
|
||||
|
||||
<!-- 分享按钮 -->
|
||||
<!-- 分享按钮(真实动作) -->
|
||||
<div class="mt-16 pt-8 border-t border-gray-200">
|
||||
<div class="flex items-center justify-between">
|
||||
<p class="text-sm text-gray-500">{{ t('news.detail.shareArticle') }}</p>
|
||||
<div class="flex items-center justify-between flex-wrap gap-4">
|
||||
<p class="text-sm text-gray-500">{{ t('share.article') }}</p>
|
||||
<div class="flex gap-3">
|
||||
<button class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300">
|
||||
<button
|
||||
@click="shareToX"
|
||||
class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300"
|
||||
:title="'X'"
|
||||
aria-label="Share on X"
|
||||
>
|
||||
<Icon name="ph:x-logo" class="w-5 h-5" />
|
||||
</button>
|
||||
<button class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300">
|
||||
<button
|
||||
@click="shareToLinkedIn"
|
||||
class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300"
|
||||
:title="'LinkedIn'"
|
||||
aria-label="Share on LinkedIn"
|
||||
>
|
||||
<Icon name="ph:linkedin-logo" class="w-5 h-5" />
|
||||
</button>
|
||||
<button class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300">
|
||||
<button
|
||||
@click="copyLink"
|
||||
class="w-10 h-10 rounded-full bg-gray-100 hover:bg-black hover:text-white flex items-center justify-center transition-all duration-300"
|
||||
:title="t('share.copy')"
|
||||
aria-label="Copy link"
|
||||
>
|
||||
<Icon name="ph:link" class="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="copyFeedback" class="text-sm mt-3 text-green-600">{{ copyFeedback }}</p>
|
||||
</div>
|
||||
|
||||
<!-- 评论区 -->
|
||||
<CommentSection :news-slug="slug" />
|
||||
</section>
|
||||
|
||||
<!-- 相关文章 -->
|
||||
@@ -113,17 +127,17 @@
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<NuxtLink
|
||||
v-for="related in relatedArticles"
|
||||
:key="related.id"
|
||||
:to="`/news/${related.id}`"
|
||||
:key="related.slug"
|
||||
:to="`/news/${related.slug}`"
|
||||
class="group block rounded-2xl overflow-hidden bg-white shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1"
|
||||
>
|
||||
<div class="relative aspect-[16/10] overflow-hidden">
|
||||
<img :src="related.image" :alt="related.title" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
<img :src="related.image || ''" :alt="locText(related.titleZh, related.titleEn)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
</div>
|
||||
<div class="p-5">
|
||||
<span class="text-xs text-gray-500">{{ related.date }}</span>
|
||||
<span class="text-xs text-gray-500">{{ formatNewsDate(related.date, locale) }}</span>
|
||||
<h3 class="text-lg font-bold text-black group-hover:text-gray-600 transition-colors mt-1 line-clamp-2">
|
||||
{{ related.title }}
|
||||
{{ locText(related.titleZh, related.titleEn) }}
|
||||
</h3>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
@@ -134,103 +148,130 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useSeoMeta, createError } from '#imports'
|
||||
import { useSeoMeta, useHead, useRuntimeConfig, createError } from '#imports'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const route = useRoute()
|
||||
const slug = route.params.slug as string
|
||||
|
||||
interface NewsItem {
|
||||
id: string
|
||||
title: string
|
||||
image: string
|
||||
category: string
|
||||
badge: string
|
||||
date: string
|
||||
readTime: string
|
||||
interface Block {
|
||||
type: 'paragraph' | 'heading' | 'quote' | 'image'
|
||||
text: string
|
||||
}
|
||||
|
||||
interface ArticleItem {
|
||||
slug: string
|
||||
category: 'insights' | 'projects' | 'announcements'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
excerptZh: string
|
||||
excerptEn: string
|
||||
contentZh: Block[]
|
||||
contentEn: Block[]
|
||||
image: string | null
|
||||
date: string | null
|
||||
readTime: number
|
||||
author: string
|
||||
}
|
||||
|
||||
const newsData: Record<string, NewsItem> = {
|
||||
'design-trends-2026': {
|
||||
id: 'design-trends-2026',
|
||||
title: 'Design Trends Shaping 2026',
|
||||
image: 'https://picsum.photos/id/1/1200/800',
|
||||
category: 'Insights',
|
||||
badge: 'bg-purple-100 text-purple-700',
|
||||
date: 'May 28, 2026',
|
||||
readTime: '5 min',
|
||||
author: 'ArcticNewOne Team'
|
||||
},
|
||||
'forma-digital-launch': {
|
||||
id: 'forma-digital-launch',
|
||||
title: 'Forma Digital Platform Launch',
|
||||
image: 'https://picsum.photos/id/201/1200/800',
|
||||
category: 'Projects',
|
||||
badge: 'bg-blue-100 text-blue-700',
|
||||
date: 'May 15, 2026',
|
||||
readTime: '3 min',
|
||||
author: 'ArcticNewOne Team'
|
||||
},
|
||||
'studio-expansion': {
|
||||
id: 'studio-expansion',
|
||||
title: 'Studio Expansion Announcement',
|
||||
image: 'https://picsum.photos/id/164/1200/800',
|
||||
category: 'Announcements',
|
||||
badge: 'bg-green-100 text-green-700',
|
||||
date: 'May 10, 2026',
|
||||
readTime: '2 min',
|
||||
author: 'ArcticNewOne Team'
|
||||
},
|
||||
'ux-research-methods': {
|
||||
id: 'ux-research-methods',
|
||||
title: 'Modern UX Research Methods',
|
||||
image: 'https://picsum.photos/id/180/1200/800',
|
||||
category: 'Insights',
|
||||
badge: 'bg-purple-100 text-purple-700',
|
||||
date: 'Apr 28, 2026',
|
||||
readTime: '7 min',
|
||||
author: 'ArcticNewOne Team'
|
||||
},
|
||||
'bold-moves-case-study': {
|
||||
id: 'bold-moves-case-study',
|
||||
title: 'Bold Moves: A Case Study',
|
||||
image: 'https://picsum.photos/id/119/1200/800',
|
||||
category: 'Projects',
|
||||
badge: 'bg-blue-100 text-blue-700',
|
||||
date: 'Apr 20, 2026',
|
||||
readTime: '6 min',
|
||||
author: 'ArcticNewOne Team'
|
||||
},
|
||||
'new-tools-integration': {
|
||||
id: 'new-tools-integration',
|
||||
title: 'New Tools Added to Our Platform',
|
||||
image: 'https://picsum.photos/id/326/1200/800',
|
||||
category: 'Announcements',
|
||||
badge: 'bg-green-100 text-green-700',
|
||||
date: 'Apr 12, 2026',
|
||||
readTime: '4 min',
|
||||
author: 'ArcticNewOne Team'
|
||||
}
|
||||
}
|
||||
const [{ data, error }, { data: listData }] = await Promise.all([
|
||||
useFetch<{ article: ArticleItem }>(`/api/news/${slug}`),
|
||||
useFetch<{ articles: ArticleItem[] }>('/api/news'),
|
||||
])
|
||||
|
||||
const article = newsData[slug]
|
||||
|
||||
if (!article) {
|
||||
// 未发布 / 不存在 → 404
|
||||
if (error.value || !data.value?.article) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Article not found' })
|
||||
}
|
||||
|
||||
const relatedArticles = computed(() => {
|
||||
return Object.values(newsData)
|
||||
.filter(a => a.id !== slug)
|
||||
.slice(0, 3)
|
||||
})
|
||||
const article = computed<ArticleItem>(() => data.value!.article)
|
||||
|
||||
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
function formatNewsDate(date: string | null, loc: string): string {
|
||||
if (!date) return ''
|
||||
const d = new Date(`${date}T00:00:00`)
|
||||
if (Number.isNaN(d.getTime())) return date
|
||||
return new Intl.DateTimeFormat(loc === 'zh' ? 'zh-CN' : 'en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}).format(d)
|
||||
}
|
||||
|
||||
const categoryBadge: Record<string, string> = {
|
||||
insights: 'bg-purple-100 text-purple-700',
|
||||
projects: 'bg-blue-100 text-blue-700',
|
||||
announcements: 'bg-green-100 text-green-700',
|
||||
}
|
||||
|
||||
const title = computed(() => locText(article.value.titleZh, article.value.titleEn))
|
||||
|
||||
// 正文内容块(按当前语言选择 contentZh / contentEn)
|
||||
const blocks = computed(() =>
|
||||
locale.value === 'zh' ? article.value.contentZh : article.value.contentEn,
|
||||
)
|
||||
|
||||
const relatedArticles = computed(() =>
|
||||
(listData.value?.articles ?? []).filter((a) => a.slug !== slug).slice(0, 3),
|
||||
)
|
||||
|
||||
useSeoMeta({
|
||||
title: () => `${article.title} - ${t('news.title')}`,
|
||||
description: () => article.title,
|
||||
title: () => `${title.value} - ${t('news.title')}`,
|
||||
description: () => locText(article.value.excerptZh, article.value.excerptEn),
|
||||
})
|
||||
|
||||
// 文章 JSON-LD(Article schema,利于搜索引擎富摘要)
|
||||
const { public: publicCfg } = useRuntimeConfig()
|
||||
const siteBase = String(publicCfg.siteUrl || '').replace(/\/$/, '')
|
||||
useHead({
|
||||
script: [
|
||||
{
|
||||
type: 'application/ld+json',
|
||||
innerHTML: JSON.stringify({
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'Article',
|
||||
headline: title.value,
|
||||
description: locText(article.value.excerptZh, article.value.excerptEn),
|
||||
image: article.value.image || undefined,
|
||||
datePublished: article.value.date || undefined,
|
||||
author: { '@type': 'Organization', name: 'ArcticNewOne' },
|
||||
mainEntityOfPage: {
|
||||
'@type': 'WebPage',
|
||||
'@id': siteBase ? `${siteBase}/news/${slug}` : undefined,
|
||||
},
|
||||
}),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
// ---- 分享(真实动作) ----
|
||||
const copyFeedback = ref('')
|
||||
|
||||
const shareUrl = () => (typeof window !== 'undefined' ? window.location.href : '')
|
||||
const shareText = () => title.value
|
||||
|
||||
const shareToX = () => {
|
||||
const url = `https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl())}&text=${encodeURIComponent(shareText())}`
|
||||
window.open(url, '_blank', 'noopener,noreferrer,width=600,height=480')
|
||||
}
|
||||
|
||||
const shareToLinkedIn = () => {
|
||||
const url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl())}`
|
||||
window.open(url, '_blank', 'noopener,noreferrer,width=600,height=480')
|
||||
}
|
||||
|
||||
const copyLink = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(shareUrl())
|
||||
copyFeedback.value = t('share.copied')
|
||||
} catch {
|
||||
// 剪贴板不可用时回退到 prompt 复制
|
||||
window.prompt(t('share.copyFailed'), shareUrl())
|
||||
}
|
||||
setTimeout(() => (copyFeedback.value = ''), 3000)
|
||||
}
|
||||
</script>
|
||||
|
||||
+118
-97
@@ -8,6 +8,20 @@
|
||||
<p ref="descRef" class="text-base md:text-lg text-gray-600 max-w-2xl">{{ t('news.description') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<div ref="searchWrapRef" class="flex justify-center mb-8">
|
||||
<div class="relative w-full max-w-md">
|
||||
<Icon name="ph:magnifying-glass" class="w-5 h-5 text-gray-400 absolute left-4 top-1/2 -translate-y-1/2" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
:placeholder="t('search.placeholder')"
|
||||
class="w-full pl-12 pr-4 py-3 rounded-full border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 text-sm md:text-base"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分类筛选 -->
|
||||
<div
|
||||
ref="filterWrapRef"
|
||||
class="flex justify-center gap-3 md:gap-4 mb-10 md:mb-14 flex-wrap"
|
||||
@@ -15,7 +29,7 @@
|
||||
<button
|
||||
v-for="category in categories"
|
||||
:key="category"
|
||||
@click="activeCategory = category"
|
||||
@click="setCategory(category)"
|
||||
class="px-5 md:px-6 py-2 md:py-2.5 rounded-full text-sm md:text-base font-semibold transition-all duration-300"
|
||||
:class="activeCategory === category
|
||||
? 'bg-black text-white shadow-lg'
|
||||
@@ -25,28 +39,36 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 空结果 -->
|
||||
<p v-if="!visibleNews.length" class="text-center text-gray-500 py-16">
|
||||
{{ t('search.empty') }}
|
||||
</p>
|
||||
|
||||
<!-- 文章列表 -->
|
||||
<div
|
||||
v-else
|
||||
ref="articlesWrapRef"
|
||||
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-8"
|
||||
>
|
||||
<NuxtLink
|
||||
v-for="article in filteredNewsData"
|
||||
:key="article.id"
|
||||
:to="`/news/${article.id}`"
|
||||
v-for="article in visibleNews"
|
||||
:key="article.slug"
|
||||
:to="`/news/${article.slug}`"
|
||||
class="news-card group relative flex flex-col rounded-2xl md:rounded-3xl overflow-hidden bg-white border border-gray-100 hover:shadow-xl transition-all duration-500 cursor-pointer hover:-translate-y-2"
|
||||
>
|
||||
<div class="relative aspect-[16/10] overflow-hidden bg-gray-100">
|
||||
<img
|
||||
:src="article.image"
|
||||
:alt="article.title"
|
||||
:src="article.image || ''"
|
||||
:alt="locText(article.titleZh, article.titleEn)"
|
||||
:loading="'lazy'"
|
||||
class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
|
||||
/>
|
||||
<div class="absolute top-4 left-4">
|
||||
<span
|
||||
class="px-3 py-1.5 text-xs md:text-sm font-semibold rounded-full shadow-sm"
|
||||
:class="article.badge"
|
||||
:class="categoryBadge[article.category]"
|
||||
>
|
||||
{{ article.category }}
|
||||
{{ t(`news.categories.${article.category}`) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -55,20 +77,20 @@
|
||||
<div class="flex items-center gap-3 text-xs md:text-sm text-gray-500 mb-3">
|
||||
<span class="flex items-center gap-1.5">
|
||||
<Icon name="ph:calendar-blank" class="w-4 h-4" />
|
||||
{{ article.date }}
|
||||
{{ formatNewsDate(article.date, locale) }}
|
||||
</span>
|
||||
<span class="flex items-center gap-1.5">
|
||||
<Icon name="ph:clock" class="w-4 h-4" />
|
||||
{{ article.readTime }}
|
||||
{{ article.readTime }} {{ t('news.minutes') }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h3 class="text-lg md:text-xl font-bold text-black mb-3 group-hover:text-gray-700 transition-colors duration-300 line-clamp-2">
|
||||
{{ article.title }}
|
||||
{{ locText(article.titleZh, article.titleEn) }}
|
||||
</h3>
|
||||
|
||||
<p class="text-sm md:text-base text-gray-600 mb-4 flex-grow line-clamp-3">
|
||||
{{ article.excerpt }}
|
||||
{{ locText(article.excerptZh, article.excerptEn) }}
|
||||
</p>
|
||||
|
||||
<div class="flex items-center justify-between pt-3 border-t border-gray-100">
|
||||
@@ -82,6 +104,20 @@
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<div v-if="hasMore" class="flex justify-center mt-12">
|
||||
<button
|
||||
@click="loadMore"
|
||||
class="px-8 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-all duration-300 flex items-center gap-2"
|
||||
>
|
||||
<Icon name="ph:plus" class="w-5 h-5" />
|
||||
{{ t('pagination.loadMore') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-else-if="filteredNews.length > PAGE_SIZE" class="text-center text-gray-400 text-sm mt-8">
|
||||
{{ t('pagination.noMore') }}
|
||||
</p>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
@@ -92,25 +128,85 @@ import { useSeoMeta } from '#imports'
|
||||
import gsap from 'gsap'
|
||||
import { useAppStore } from '~/stores/app'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
|
||||
interface ArticleItem {
|
||||
slug: string
|
||||
category: 'insights' | 'projects' | 'announcements'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
excerptZh: string
|
||||
excerptEn: string
|
||||
image: string | null
|
||||
date: string | null
|
||||
readTime: number
|
||||
author: string
|
||||
}
|
||||
|
||||
// 内容 API(仅已发布,date 降序)
|
||||
const { data } = await useFetch<{ articles: ArticleItem[] }>('/api/news')
|
||||
const articles = computed(() => data.value?.articles ?? [])
|
||||
|
||||
// 双语选择:切换语言即时生效(内容双字段已在 API 返回,无需重新请求)
|
||||
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
function formatNewsDate(date: string | null, loc: string): string {
|
||||
if (!date) return ''
|
||||
const d = new Date(`${date}T00:00:00`)
|
||||
if (Number.isNaN(d.getTime())) return date
|
||||
return new Intl.DateTimeFormat(loc === 'zh' ? 'zh-CN' : 'en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
}).format(d)
|
||||
}
|
||||
|
||||
// 分类徽章样式(insights=紫、projects=蓝、announcements=绿)
|
||||
const categoryBadge: Record<string, string> = {
|
||||
insights: 'bg-purple-100 text-purple-700',
|
||||
projects: 'bg-blue-100 text-blue-700',
|
||||
announcements: 'bg-green-100 text-green-700',
|
||||
}
|
||||
|
||||
const headerWrapRef = ref<HTMLElement | null>(null)
|
||||
const titleRef = ref<HTMLElement | null>(null)
|
||||
const descRef = ref<HTMLElement | null>(null)
|
||||
const searchWrapRef = ref<HTMLElement | null>(null)
|
||||
const filterWrapRef = ref<HTMLElement | null>(null)
|
||||
const articlesWrapRef = ref<HTMLElement | null>(null)
|
||||
const activeCategory = ref('all')
|
||||
const keyword = ref('')
|
||||
const visibleCount = ref(0)
|
||||
|
||||
const PAGE_SIZE = 6
|
||||
|
||||
const categories = ['all', 'insights', 'projects', 'announcements']
|
||||
|
||||
const filteredNewsData = computed(() => {
|
||||
if (activeCategory.value === 'all') {
|
||||
return newsData
|
||||
}
|
||||
return newsData.filter(item => item.category.toLowerCase() === activeCategory.value.toLowerCase())
|
||||
// 分类 + 搜索过滤(标题/摘要按当前语言文案匹配)
|
||||
const filteredNews = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return articles.value.filter((item) => {
|
||||
if (activeCategory.value !== 'all' && item.category !== activeCategory.value) return false
|
||||
if (!kw) return true
|
||||
const title = locText(item.titleZh, item.titleEn).toLowerCase()
|
||||
const excerpt = locText(item.excerptZh, item.excerptEn).toLowerCase()
|
||||
return title.includes(kw) || excerpt.includes(kw)
|
||||
})
|
||||
})
|
||||
|
||||
const visibleNews = computed(() => filteredNews.value.slice(0, visibleCount.value))
|
||||
const hasMore = computed(() => visibleCount.value < filteredNews.value.length)
|
||||
|
||||
const setCategory = (category: string) => {
|
||||
activeCategory.value = category
|
||||
visibleCount.value = PAGE_SIZE
|
||||
}
|
||||
|
||||
const loadMore = () => {
|
||||
visibleCount.value = Math.min(visibleCount.value + PAGE_SIZE, filteredNews.value.length)
|
||||
}
|
||||
|
||||
useSeoMeta({
|
||||
title: () => t('news.title'),
|
||||
description: () => t('news.description'),
|
||||
@@ -123,101 +219,26 @@ const playPageIntro = async () => {
|
||||
const filterButtons = gsap.utils.toArray<HTMLElement>('button', filterWrapRef.value!)
|
||||
const newsCards = gsap.utils.toArray<HTMLElement>('.news-card', articlesWrapRef.value!)
|
||||
|
||||
// 先设置初始状态,防止闪现
|
||||
gsap.set([titleRef.value, descRef.value, ...filterButtons, ...newsCards], {
|
||||
autoAlpha: 0, y: 30
|
||||
gsap.set([titleRef.value, descRef.value, searchWrapRef.value, ...filterButtons, ...newsCards], {
|
||||
autoAlpha: 0, y: 30,
|
||||
})
|
||||
|
||||
// 然后播放动画
|
||||
const tl = gsap.timeline({ defaults: { ease: 'power2.out' } })
|
||||
|
||||
tl.to(titleRef.value, { autoAlpha: 1, y: 0, duration: 0.5 })
|
||||
tl.to(descRef.value, { autoAlpha: 1, y: 0, duration: 0.4 }, '-=0.3')
|
||||
tl.to(searchWrapRef.value, { autoAlpha: 1, y: 0, duration: 0.4 }, '-=0.2')
|
||||
tl.to(filterButtons, { autoAlpha: 1, y: 0, duration: 0.4, stagger: 0.05 }, '-=0.2')
|
||||
tl.to(newsCards, { autoAlpha: 1, y: 0, duration: 0.5, stagger: 0.08 }, '-=0.2')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
visibleCount.value = PAGE_SIZE
|
||||
if (!appStore.isAppLoading) {
|
||||
playPageIntro()
|
||||
} else {
|
||||
window.addEventListener('app-loading-done', playPageIntro, { once: true })
|
||||
}
|
||||
})
|
||||
|
||||
interface NewsItem {
|
||||
id: string
|
||||
title: string
|
||||
excerpt: string
|
||||
image: string
|
||||
category: string
|
||||
badge: string
|
||||
date: string
|
||||
readTime: string
|
||||
}
|
||||
|
||||
const newsData: NewsItem[] = [
|
||||
{
|
||||
id: 'design-trends-2026',
|
||||
title: 'Design Trends Shaping 2026',
|
||||
excerpt: 'Explore the emerging design trends that are defining digital experiences this year, from minimalism to bold typography.',
|
||||
image: 'https://picsum.photos/id/1/800/500',
|
||||
category: 'Insights',
|
||||
badge: 'bg-purple-100 text-purple-700',
|
||||
date: 'May 28, 2026',
|
||||
readTime: '5 min'
|
||||
},
|
||||
{
|
||||
id: 'forma-digital-launch',
|
||||
title: 'Forma Digital Platform Launch',
|
||||
excerpt: 'We are excited to announce the successful launch of Forma Digital, a revolutionary e-commerce experience.',
|
||||
image: 'https://picsum.photos/id/201/800/500',
|
||||
category: 'Projects',
|
||||
badge: 'bg-blue-100 text-blue-700',
|
||||
date: 'May 15, 2026',
|
||||
readTime: '3 min'
|
||||
},
|
||||
{
|
||||
id: 'studio-expansion',
|
||||
title: 'Studio Expansion Announcement',
|
||||
excerpt: 'ArcticNewOne is growing! We are expanding our team and capabilities to serve you better.',
|
||||
image: 'https://picsum.photos/id/164/800/500',
|
||||
category: 'Announcements',
|
||||
badge: 'bg-green-100 text-green-700',
|
||||
date: 'May 10, 2026',
|
||||
readTime: '2 min'
|
||||
},
|
||||
{
|
||||
id: 'ux-research-methods',
|
||||
title: 'Modern UX Research Methods',
|
||||
excerpt: 'Dive into the latest user experience research methodologies that inform our design decisions.',
|
||||
image: 'https://picsum.photos/id/180/800/500',
|
||||
category: 'Insights',
|
||||
badge: 'bg-purple-100 text-purple-700',
|
||||
date: 'Apr 28, 2026',
|
||||
readTime: '7 min'
|
||||
},
|
||||
{
|
||||
id: 'bold-moves-case-study',
|
||||
title: 'Bold Moves: A Case Study',
|
||||
excerpt: 'Behind the scenes of our award-winning architectural visualization project featuring cutting-edge 3D technology.',
|
||||
image: 'https://picsum.photos/id/119/800/500',
|
||||
category: 'Projects',
|
||||
badge: 'bg-blue-100 text-blue-700',
|
||||
date: 'Apr 20, 2026',
|
||||
readTime: '6 min'
|
||||
},
|
||||
{
|
||||
id: 'new-tools-integration',
|
||||
title: 'New Tools Added to Our Platform',
|
||||
excerpt: 'Check out the latest additions to our toolbox, designed to streamline your workflow and boost productivity.',
|
||||
image: 'https://picsum.photos/id/326/800/500',
|
||||
category: 'Announcements',
|
||||
badge: 'bg-green-100 text-green-700',
|
||||
date: 'Apr 12, 2026',
|
||||
readTime: '4 min'
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
+4
-35
@@ -15,7 +15,7 @@
|
||||
style="opacity: 0; visibility: hidden;"
|
||||
>
|
||||
<a
|
||||
v-for="tool in toolsData"
|
||||
v-for="tool in settings?.tools ?? []"
|
||||
:key="tool.id"
|
||||
:href="tool.url"
|
||||
target="_blank"
|
||||
@@ -38,7 +38,7 @@
|
||||
</div>
|
||||
|
||||
<h3 class="text-lg md:text-2xl font-bold mb-2 md:mb-3 text-black">{{ tool.name }}</h3>
|
||||
<p class="text-sm md:text-base text-gray-600 leading-snug md:leading-relaxed flex-grow">{{ t(`tools.items.${tool.id}`) }}</p>
|
||||
<p class="text-sm md:text-base text-gray-600 leading-snug md:leading-relaxed flex-grow">{{ locale === 'zh' ? tool.descZh : tool.descEn }}</p>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
@@ -52,8 +52,9 @@ import { useSeoMeta } from '#imports'
|
||||
import gsap from 'gsap'
|
||||
import { useAppStore } from '~/stores/app'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
const headerWrapRef = ref<HTMLElement | null>(null)
|
||||
const titleRef = ref<HTMLElement | null>(null)
|
||||
@@ -123,38 +124,6 @@ onMounted(() => {
|
||||
onBeforeUnmount(() => {
|
||||
cardsCtx?.revert()
|
||||
})
|
||||
|
||||
interface ToolItem {
|
||||
id: string
|
||||
name: string
|
||||
url: string
|
||||
icon: string
|
||||
color: string
|
||||
}
|
||||
|
||||
const toolsData: ToolItem[] = [
|
||||
{
|
||||
id: 'drawio',
|
||||
name: 'Drawio',
|
||||
url: 'https://drawio.virtheart.com',
|
||||
icon: 'ph:flow-arrow-duotone',
|
||||
color: 'from-orange-50/50 to-amber-100/50'
|
||||
},
|
||||
{
|
||||
id: 'excalidraw',
|
||||
name: 'Excalidraw',
|
||||
url: 'https://excalidraw.virtheart.com',
|
||||
icon: 'ph:pencil-circle-duotone',
|
||||
color: 'from-purple-50/50 to-indigo-100/50'
|
||||
},
|
||||
{
|
||||
id: 'itTools',
|
||||
name: 'IT-Tools',
|
||||
url: 'https://ittools.virtheart.com',
|
||||
icon: 'ph:wrench-duotone',
|
||||
color: 'from-blue-50/50 to-cyan-100/50'
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<main class="min-h-screen flex items-center justify-center px-4 py-32">
|
||||
<div ref="cardRef" class="w-full max-w-md mx-auto p-10 rounded-3xl bg-white border border-gray-100 shadow-xl text-center">
|
||||
<div class="w-16 h-16 mx-auto rounded-full bg-gray-100 flex items-center justify-center mb-6">
|
||||
<Icon name="ph:envelope-simple-duotone" class="w-8 h-8 text-gray-400" />
|
||||
</div>
|
||||
<h1 class="text-2xl font-bold text-black mb-3">{{ t('unsubscribe.title') }}</h1>
|
||||
<p class="text-gray-500 mb-8">{{ t('unsubscribe.description') }}</p>
|
||||
|
||||
<!-- 处理中 -->
|
||||
<p v-if="status === 'processing'" class="text-gray-500 flex items-center justify-center gap-2">
|
||||
<Icon name="ph:circle-notch" class="w-5 h-5 animate-spin" />
|
||||
{{ t('unsubscribe.unsubscribe') }}
|
||||
</p>
|
||||
|
||||
<!-- 结果 -->
|
||||
<div v-else class="space-y-8">
|
||||
<p
|
||||
class="text-lg font-semibold"
|
||||
:class="status === 'unsubscribed' ? 'text-green-600' : 'text-gray-700'"
|
||||
>
|
||||
{{ resultText }}
|
||||
</p>
|
||||
<NuxtLink
|
||||
to="/"
|
||||
class="inline-block px-8 py-3 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-colors"
|
||||
>
|
||||
{{ t('unsubscribe.backHome') }}
|
||||
</NuxtLink>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useSeoMeta } from '#imports'
|
||||
import gsap from 'gsap'
|
||||
|
||||
const { t } = useI18n()
|
||||
const route = useRoute()
|
||||
|
||||
useSeoMeta({
|
||||
title: () => t('unsubscribe.title'),
|
||||
})
|
||||
|
||||
const status = ref<'processing' | 'unsubscribed' | 'already' | 'invalid'>('processing')
|
||||
|
||||
const resultText = computed(() => {
|
||||
if (status.value === 'unsubscribed') return t('unsubscribe.unsubscribed')
|
||||
if (status.value === 'already') return t('unsubscribe.already')
|
||||
return t('unsubscribe.invalid')
|
||||
})
|
||||
|
||||
const cardRef = ref<HTMLElement | null>(null)
|
||||
|
||||
onMounted(async () => {
|
||||
// 入场淡入(与其他公开页一致的轻量 GSAP 动画)
|
||||
if (cardRef.value) {
|
||||
gsap.fromTo(cardRef.value, { autoAlpha: 0, y: 24 }, { autoAlpha: 1, y: 0, duration: 0.6, ease: 'power3.out' })
|
||||
}
|
||||
|
||||
const token = route.query.token
|
||||
if (!token || Array.isArray(token)) {
|
||||
status.value = 'invalid'
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await $fetch<{ ok: boolean; unsubscribed: boolean }>('/api/newsletter/unsubscribe', {
|
||||
method: 'POST',
|
||||
body: { token },
|
||||
})
|
||||
status.value = data.unsubscribed ? 'unsubscribed' : 'already'
|
||||
} catch (err) {
|
||||
console.error('unsubscribe error:', err)
|
||||
status.value = 'invalid'
|
||||
}
|
||||
})
|
||||
</script>
|
||||
+130
-139
@@ -14,8 +14,8 @@
|
||||
<!-- Hero 大图 -->
|
||||
<section class="relative h-[60vh] md:h-[70vh] overflow-hidden">
|
||||
<img
|
||||
:src="project.image"
|
||||
:alt="project.title"
|
||||
:src="project.image || ''"
|
||||
:alt="title"
|
||||
class="w-full h-full object-cover"
|
||||
/>
|
||||
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"></div>
|
||||
@@ -31,10 +31,10 @@
|
||||
</span>
|
||||
</div>
|
||||
<h1 class="text-4xl md:text-6xl lg:text-7xl font-bold text-white mb-4 tracking-tight">
|
||||
{{ project.title }}
|
||||
{{ title }}
|
||||
</h1>
|
||||
<p class="text-lg md:text-xl text-white/80 max-w-2xl">
|
||||
{{ project.description }}
|
||||
{{ description }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -48,26 +48,26 @@
|
||||
<div>
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.overview') }}</h2>
|
||||
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
|
||||
{{ t(`work.detail.items.${slug}.overview`) }}
|
||||
{{ locText(project.overviewZh, project.overviewEn) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.challenge') }}</h2>
|
||||
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
|
||||
{{ t(`work.detail.items.${slug}.challenge`) }}
|
||||
{{ locText(project.challengeZh, project.challengeEn) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.solution') }}</h2>
|
||||
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
|
||||
{{ t(`work.detail.items.${slug}.solution`) }}
|
||||
{{ locText(project.solutionZh, project.solutionEn) }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- 项目截图 -->
|
||||
<div class="space-y-6">
|
||||
<div v-if="project.gallery.length" class="space-y-6">
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black">{{ t('work.detail.gallery') }}</h2>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||
<div
|
||||
@@ -75,7 +75,7 @@
|
||||
:key="index"
|
||||
class="rounded-2xl overflow-hidden shadow-lg hover:shadow-2xl transition-shadow duration-300"
|
||||
>
|
||||
<img :src="img" :alt="`${project.title} screenshot ${index + 1}`" class="w-full h-auto" />
|
||||
<img :src="img" :alt="`${title} screenshot ${index + 1}`" class="w-full h-auto" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -89,7 +89,7 @@
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.client') }}</p>
|
||||
<p class="text-base font-semibold text-black">{{ t(`work.detail.items.${slug}.client`) }}</p>
|
||||
<p class="text-base font-semibold text-black">{{ locText(project.clientZh, project.clientEn) }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.year') }}</p>
|
||||
@@ -97,7 +97,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.duration') }}</p>
|
||||
<p class="text-base font-semibold text-black">{{ t(`work.detail.items.${slug}.duration`) }}</p>
|
||||
<p class="text-base font-semibold text-black">{{ locText(project.durationZh, project.durationEn) }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.services') }}</p>
|
||||
@@ -113,17 +113,54 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 访问项目按钮 -->
|
||||
<a
|
||||
v-if="project.url"
|
||||
:href="project.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="mt-8 w-full inline-flex items-center justify-center gap-2 px-6 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-colors duration-300"
|
||||
>
|
||||
{{ t('work.detail.visitProject') }}
|
||||
<Icon name="ph:arrow-up-right" class="w-5 h-5" />
|
||||
</a>
|
||||
<div class="mt-8 space-y-3">
|
||||
<!-- 访问项目(仅存在真实地址时渲染) -->
|
||||
<a
|
||||
v-if="project.url"
|
||||
:href="project.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="w-full inline-flex items-center justify-center gap-2 px-6 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-colors duration-300"
|
||||
>
|
||||
{{ t('work.detail.visitProject') }}
|
||||
<Icon name="ph:arrow-up-right" class="w-5 h-5" />
|
||||
</a>
|
||||
|
||||
<!-- 收藏 -->
|
||||
<FavoriteButton :work-slug="slug" />
|
||||
</div>
|
||||
|
||||
<!-- 分享 -->
|
||||
<div class="mt-8 pt-6 border-t border-gray-200">
|
||||
<p class="text-sm text-gray-500 mb-3">{{ t('share.article') }}</p>
|
||||
<div class="flex gap-3">
|
||||
<button
|
||||
@click="shareToX"
|
||||
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black flex items-center justify-center transition-all duration-300"
|
||||
:title="'X'"
|
||||
aria-label="Share on X"
|
||||
>
|
||||
<Icon name="ph:x-logo" class="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
@click="shareToLinkedIn"
|
||||
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black flex items-center justify-center transition-all duration-300"
|
||||
:title="'LinkedIn'"
|
||||
aria-label="Share on LinkedIn"
|
||||
>
|
||||
<Icon name="ph:linkedin-logo" class="w-5 h-5" />
|
||||
</button>
|
||||
<button
|
||||
@click="copyLink"
|
||||
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black flex items-center justify-center transition-all duration-300"
|
||||
:title="t('share.copy')"
|
||||
aria-label="Copy link"
|
||||
>
|
||||
<Icon name="ph:link" class="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="copyFeedback" class="text-sm mt-3 text-green-600">{{ copyFeedback }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -136,16 +173,16 @@
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
<NuxtLink
|
||||
v-for="related in relatedProjects"
|
||||
:key="related.id"
|
||||
:to="`/work/${related.id}`"
|
||||
:key="related.slug"
|
||||
:to="`/work/${related.slug}`"
|
||||
class="group block rounded-2xl overflow-hidden bg-white shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1"
|
||||
>
|
||||
<div class="relative aspect-[4/3] overflow-hidden">
|
||||
<img :src="related.image" :alt="related.title" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
<img :src="related.image || ''" :alt="locText(related.titleZh, related.titleEn)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
</div>
|
||||
<div class="p-5">
|
||||
<h3 class="text-lg font-bold text-black group-hover:text-gray-600 transition-colors">{{ related.title }}</h3>
|
||||
<p class="text-sm text-gray-500 mt-1">{{ related.tags[0] }}</p>
|
||||
<h3 class="text-lg font-bold text-black group-hover:text-gray-600 transition-colors">{{ locText(related.titleZh, related.titleEn) }}</h3>
|
||||
<p class="text-sm text-gray-500 mt-1">{{ related.tags?.[0] }}</p>
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
@@ -155,135 +192,89 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useSeoMeta, createError } from '#imports'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const route = useRoute()
|
||||
const slug = route.params.slug as string
|
||||
|
||||
interface WorkItem {
|
||||
id: string
|
||||
title: string
|
||||
description: string
|
||||
image: string
|
||||
tags: string[]
|
||||
category: string
|
||||
slug: string
|
||||
category: 'webDesign' | 'branding' | 'development'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
descriptionZh: string
|
||||
descriptionEn: string
|
||||
overviewZh: string
|
||||
overviewEn: string
|
||||
challengeZh: string
|
||||
challengeEn: string
|
||||
solutionZh: string
|
||||
solutionEn: string
|
||||
clientZh: string
|
||||
clientEn: string
|
||||
durationZh: string
|
||||
durationEn: string
|
||||
year: string
|
||||
url?: string
|
||||
tags: string[]
|
||||
image: string | null
|
||||
gallery: string[]
|
||||
url: string | null
|
||||
}
|
||||
|
||||
const workData: Record<string, WorkItem> = {
|
||||
'forma-digital': {
|
||||
id: 'forma-digital',
|
||||
title: 'Forma Digital',
|
||||
description: 'A modern e-commerce platform with seamless user experience and dynamic product showcases.',
|
||||
image: 'https://picsum.photos/id/201/1200/800',
|
||||
tags: ['Web Design', 'E-commerce', 'React'],
|
||||
category: 'webDesign',
|
||||
year: '2026',
|
||||
url: '#',
|
||||
gallery: [
|
||||
'https://picsum.photos/id/201/800/600',
|
||||
'https://picsum.photos/id/202/800/600',
|
||||
'https://picsum.photos/id/203/800/600',
|
||||
'https://picsum.photos/id/204/800/600',
|
||||
]
|
||||
},
|
||||
'one-step': {
|
||||
id: 'one-step',
|
||||
title: 'One Step',
|
||||
description: 'Brand identity and marketing campaign for a fitness app focused on sustainable habits.',
|
||||
image: 'https://picsum.photos/id/180/1200/800',
|
||||
tags: ['Branding', 'Marketing', 'UI/UX'],
|
||||
category: 'branding',
|
||||
year: '2024',
|
||||
gallery: [
|
||||
'https://picsum.photos/id/180/800/600',
|
||||
'https://picsum.photos/id/181/800/600',
|
||||
'https://picsum.photos/id/182/800/600',
|
||||
'https://picsum.photos/id/183/800/600',
|
||||
]
|
||||
},
|
||||
'nero-vision': {
|
||||
id: 'nero-vision',
|
||||
title: 'Nero Vision',
|
||||
description: 'Full-stack web application for creative professionals to manage their portfolios.',
|
||||
image: 'https://picsum.photos/id/119/1200/800',
|
||||
tags: ['Development', 'Vue.js', 'Node.js'],
|
||||
category: 'development',
|
||||
year: '2025',
|
||||
gallery: [
|
||||
'https://picsum.photos/id/119/800/600',
|
||||
'https://picsum.photos/id/120/800/600',
|
||||
'https://picsum.photos/id/121/800/600',
|
||||
'https://picsum.photos/id/122/800/600',
|
||||
]
|
||||
},
|
||||
'bold-moves': {
|
||||
id: 'bold-moves',
|
||||
title: 'Bold Moves',
|
||||
description: 'Interactive website showcasing innovative architectural designs with 3D visualizations.',
|
||||
image: 'https://picsum.photos/id/164/1200/800',
|
||||
tags: ['Web Design', '3D', 'Three.js'],
|
||||
category: 'webDesign',
|
||||
year: '2024',
|
||||
gallery: [
|
||||
'https://picsum.photos/id/164/800/600',
|
||||
'https://picsum.photos/id/165/800/600',
|
||||
'https://picsum.photos/id/166/800/600',
|
||||
'https://picsum.photos/id/167/800/600',
|
||||
]
|
||||
},
|
||||
'echo-labs': {
|
||||
id: 'echo-labs',
|
||||
title: 'Echo Labs',
|
||||
description: 'Corporate branding and visual identity for a tech startup in the AI space.',
|
||||
image: 'https://picsum.photos/id/101/1200/800',
|
||||
tags: ['Branding', 'Visual Identity', 'Corporate'],
|
||||
category: 'branding',
|
||||
year: '2025',
|
||||
gallery: [
|
||||
'https://picsum.photos/id/101/800/600',
|
||||
'https://picsum.photos/id/102/800/600',
|
||||
'https://picsum.photos/id/103/800/600',
|
||||
'https://picsum.photos/id/104/800/600',
|
||||
]
|
||||
},
|
||||
'flux-api': {
|
||||
id: 'flux-api',
|
||||
title: 'Flux API',
|
||||
description: 'Scalable REST API with comprehensive documentation and developer tools.',
|
||||
image: 'https://picsum.photos/id/326/1200/800',
|
||||
tags: ['Development', 'API', 'Python'],
|
||||
category: 'development',
|
||||
year: '2025',
|
||||
gallery: [
|
||||
'https://picsum.photos/id/326/800/600',
|
||||
'https://picsum.photos/id/327/800/600',
|
||||
'https://picsum.photos/id/328/800/600',
|
||||
'https://picsum.photos/id/329/800/600',
|
||||
]
|
||||
}
|
||||
}
|
||||
const [{ data, error }, { data: listData }] = await Promise.all([
|
||||
useFetch<{ work: WorkItem }>(`/api/work/${slug}`),
|
||||
useFetch<{ works: WorkItem[] }>('/api/work'),
|
||||
])
|
||||
|
||||
const project = workData[slug]
|
||||
|
||||
if (!project) {
|
||||
// 未发布 / 不存在 → 404
|
||||
if (error.value || !data.value?.work) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Project not found' })
|
||||
}
|
||||
|
||||
const relatedProjects = computed(() => {
|
||||
return Object.values(workData)
|
||||
.filter(p => p.id !== slug)
|
||||
.slice(0, 3)
|
||||
})
|
||||
const project = computed<WorkItem>(() => data.value!.work)
|
||||
|
||||
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
const title = computed(() => locText(project.value.titleZh, project.value.titleEn))
|
||||
const description = computed(() => locText(project.value.descriptionZh, project.value.descriptionEn))
|
||||
|
||||
const relatedProjects = computed(() =>
|
||||
(listData.value?.works ?? []).filter((p) => p.slug !== slug).slice(0, 3),
|
||||
)
|
||||
|
||||
useSeoMeta({
|
||||
title: () => `${project.title} - ${t('work.title')}`,
|
||||
description: () => project.description,
|
||||
title: () => `${title.value} - ${t('work.title')}`,
|
||||
description: () => description.value,
|
||||
})
|
||||
|
||||
// ---- 分享(真实动作) ----
|
||||
const copyFeedback = ref('')
|
||||
|
||||
const shareUrl = () => (typeof window !== 'undefined' ? window.location.href : '')
|
||||
const shareText = () => title.value
|
||||
|
||||
const shareToX = () => {
|
||||
const url = `https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl())}&text=${encodeURIComponent(shareText())}`
|
||||
window.open(url, '_blank', 'noopener,noreferrer,width=600,height=480')
|
||||
}
|
||||
|
||||
const shareToLinkedIn = () => {
|
||||
const url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl())}`
|
||||
window.open(url, '_blank', 'noopener,noreferrer,width=600,height=480')
|
||||
}
|
||||
|
||||
const copyLink = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(shareUrl())
|
||||
copyFeedback.value = t('share.copied')
|
||||
} catch {
|
||||
// 剪贴板不可用时回退到 prompt 复制
|
||||
window.prompt(t('share.copyFailed'), shareUrl())
|
||||
}
|
||||
setTimeout(() => (copyFeedback.value = ''), 3000)
|
||||
}
|
||||
</script>
|
||||
|
||||
+97
-79
@@ -8,6 +8,20 @@
|
||||
<p ref="descRef" class="text-base md:text-lg text-gray-600 max-w-2xl">{{ t('work.description') }}</p>
|
||||
</div>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<div ref="searchWrapRef" class="flex justify-center mb-8">
|
||||
<div class="relative w-full max-w-md">
|
||||
<Icon name="ph:magnifying-glass" class="w-5 h-5 text-gray-400 absolute left-4 top-1/2 -translate-y-1/2" />
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
:placeholder="t('search.placeholder')"
|
||||
class="w-full pl-12 pr-4 py-3 rounded-full border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 text-sm md:text-base"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 分类筛选 -->
|
||||
<div
|
||||
ref="filterWrapRef"
|
||||
class="flex justify-center gap-3 md:gap-4 mb-10 md:mb-14 flex-wrap"
|
||||
@@ -15,7 +29,7 @@
|
||||
<button
|
||||
v-for="category in categories"
|
||||
:key="category"
|
||||
@click="activeCategory = category"
|
||||
@click="setCategory(category)"
|
||||
class="px-5 md:px-6 py-2 md:py-2.5 rounded-full text-sm md:text-base font-semibold transition-all duration-300"
|
||||
:class="activeCategory === category
|
||||
? 'bg-black text-white shadow-lg'
|
||||
@@ -25,20 +39,28 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 空结果 -->
|
||||
<p v-if="!visibleWork.length" class="text-center text-gray-500 py-16">
|
||||
{{ t('search.empty') }}
|
||||
</p>
|
||||
|
||||
<!-- 作品列表 -->
|
||||
<div
|
||||
v-else
|
||||
ref="projectsWrapRef"
|
||||
class="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8"
|
||||
>
|
||||
<NuxtLink
|
||||
v-for="project in filteredWorkData"
|
||||
:key="project.id"
|
||||
:to="`/work/${project.id}`"
|
||||
v-for="project in visibleWork"
|
||||
:key="project.slug"
|
||||
:to="`/work/${project.slug}`"
|
||||
class="work-card group relative block rounded-2xl md:rounded-3xl overflow-hidden cursor-pointer hover:shadow-2xl transition-all duration-500"
|
||||
>
|
||||
<div class="relative aspect-[4/3] overflow-hidden bg-gray-100">
|
||||
<img
|
||||
:src="project.image"
|
||||
:alt="project.title"
|
||||
:src="project.image || ''"
|
||||
:alt="locText(project.titleZh, project.titleEn)"
|
||||
:loading="'lazy'"
|
||||
class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
|
||||
/>
|
||||
<div class="absolute inset-0 bg-gradient-to-t from-black/60 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500"></div>
|
||||
@@ -46,12 +68,14 @@
|
||||
|
||||
<div class="p-6 md:p-8 bg-white">
|
||||
<div class="flex items-start justify-between mb-3">
|
||||
<h3 class="text-xl md:text-2xl font-bold text-black group-hover:text-gray-700 transition-colors duration-300">{{ project.title }}</h3>
|
||||
<h3 class="text-xl md:text-2xl font-bold text-black group-hover:text-gray-700 transition-colors duration-300">
|
||||
{{ locText(project.titleZh, project.titleEn) }}
|
||||
</h3>
|
||||
<div class="w-9 h-9 md:w-10 md:h-10 rounded-full flex items-center justify-center bg-gray-50 text-gray-400 group-hover:bg-black group-hover:text-white transition-all duration-300 flex-shrink-0 ml-3">
|
||||
<Icon name="ph:arrow-up-right" class="w-4 h-4 md:w-5 md:h-5" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-sm md:text-base text-gray-600 mb-4">{{ project.description }}</p>
|
||||
<p class="text-sm md:text-base text-gray-600 mb-4">{{ locText(project.descriptionZh, project.descriptionEn) }}</p>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="tag in project.tags"
|
||||
@@ -64,6 +88,20 @@
|
||||
</div>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
<div v-if="hasMore" class="flex justify-center mt-12">
|
||||
<button
|
||||
@click="loadMore"
|
||||
class="px-8 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-all duration-300 flex items-center gap-2"
|
||||
>
|
||||
<Icon name="ph:plus" class="w-5 h-5" />
|
||||
{{ t('pagination.loadMore') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-else-if="filteredWork.length > PAGE_SIZE" class="text-center text-gray-400 text-sm mt-8">
|
||||
{{ t('pagination.noMore') }}
|
||||
</p>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
@@ -74,25 +112,66 @@ import { useSeoMeta } from '#imports'
|
||||
import gsap from 'gsap'
|
||||
import { useAppStore } from '~/stores/app'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
|
||||
interface WorkItem {
|
||||
slug: string
|
||||
category: 'webDesign' | 'branding' | 'development'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
descriptionZh: string
|
||||
descriptionEn: string
|
||||
year: string
|
||||
tags: string[]
|
||||
image: string | null
|
||||
}
|
||||
|
||||
// 内容 API(仅已发布)
|
||||
const { data } = await useFetch<{ works: WorkItem[] }>('/api/work')
|
||||
const works = computed(() => data.value?.works ?? [])
|
||||
|
||||
// 双语选择:切换语言即时生效
|
||||
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
const headerWrapRef = ref<HTMLElement | null>(null)
|
||||
const titleRef = ref<HTMLElement | null>(null)
|
||||
const descRef = ref<HTMLElement | null>(null)
|
||||
const searchWrapRef = ref<HTMLElement | null>(null)
|
||||
const filterWrapRef = ref<HTMLElement | null>(null)
|
||||
const projectsWrapRef = ref<HTMLElement | null>(null)
|
||||
const activeCategory = ref('all')
|
||||
const keyword = ref('')
|
||||
const visibleCount = ref(0)
|
||||
|
||||
const PAGE_SIZE = 4
|
||||
|
||||
const categories = ['all', 'webDesign', 'branding', 'development']
|
||||
|
||||
const filteredWorkData = computed(() => {
|
||||
if (activeCategory.value === 'all') {
|
||||
return workData
|
||||
}
|
||||
return workData.filter(item => item.category === activeCategory.value)
|
||||
// 分类 + 搜索过滤(标题/描述按当前语言文案匹配)
|
||||
const filteredWork = computed(() => {
|
||||
const kw = keyword.value.trim().toLowerCase()
|
||||
return works.value.filter((item) => {
|
||||
if (activeCategory.value !== 'all' && item.category !== activeCategory.value) return false
|
||||
if (!kw) return true
|
||||
const title = locText(item.titleZh, item.titleEn).toLowerCase()
|
||||
const desc = locText(item.descriptionZh, item.descriptionEn).toLowerCase()
|
||||
return title.includes(kw) || desc.includes(kw)
|
||||
})
|
||||
})
|
||||
|
||||
const visibleWork = computed(() => filteredWork.value.slice(0, visibleCount.value))
|
||||
const hasMore = computed(() => visibleCount.value < filteredWork.value.length)
|
||||
|
||||
const setCategory = (category: string) => {
|
||||
activeCategory.value = category
|
||||
visibleCount.value = PAGE_SIZE
|
||||
}
|
||||
|
||||
const loadMore = () => {
|
||||
visibleCount.value = Math.min(visibleCount.value + PAGE_SIZE, filteredWork.value.length)
|
||||
}
|
||||
|
||||
useSeoMeta({
|
||||
title: () => t('work.title'),
|
||||
description: () => t('work.description'),
|
||||
@@ -105,87 +184,26 @@ const playPageIntro = async () => {
|
||||
const filterButtons = gsap.utils.toArray<HTMLElement>('button', filterWrapRef.value!)
|
||||
const projectCards = gsap.utils.toArray<HTMLElement>('.work-card', projectsWrapRef.value!)
|
||||
|
||||
// 先设置初始状态,防止闪现
|
||||
gsap.set([titleRef.value, descRef.value, ...filterButtons, ...projectCards], {
|
||||
autoAlpha: 0, y: 30
|
||||
gsap.set([titleRef.value, descRef.value, searchWrapRef.value, ...filterButtons, ...projectCards], {
|
||||
autoAlpha: 0, y: 30,
|
||||
})
|
||||
|
||||
// 然后播放动画
|
||||
const tl = gsap.timeline({ defaults: { ease: 'power2.out' } })
|
||||
|
||||
tl.to(titleRef.value, { autoAlpha: 1, y: 0, duration: 0.5 })
|
||||
tl.to(descRef.value, { autoAlpha: 1, y: 0, duration: 0.4 }, '-=0.3')
|
||||
tl.to(searchWrapRef.value, { autoAlpha: 1, y: 0, duration: 0.4 }, '-=0.2')
|
||||
tl.to(filterButtons, { autoAlpha: 1, y: 0, duration: 0.4, stagger: 0.05 }, '-=0.2')
|
||||
tl.to(projectCards, { autoAlpha: 1, y: 0, duration: 0.5, stagger: 0.08 }, '-=0.2')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
visibleCount.value = PAGE_SIZE
|
||||
if (!appStore.isAppLoading) {
|
||||
playPageIntro()
|
||||
} else {
|
||||
window.addEventListener('app-loading-done', playPageIntro, { once: true })
|
||||
}
|
||||
})
|
||||
|
||||
interface WorkItem {
|
||||
id: string
|
||||
title: string
|
||||
description: string
|
||||
image: string
|
||||
tags: string[]
|
||||
category: string
|
||||
}
|
||||
|
||||
const workData: WorkItem[] = [
|
||||
{
|
||||
id: 'forma-digital',
|
||||
title: 'Forma Digital',
|
||||
description: 'A modern e-commerce platform with seamless user experience and dynamic product showcases.',
|
||||
image: 'https://picsum.photos/id/201/800/600',
|
||||
tags: ['Web Design', 'E-commerce', 'React'],
|
||||
category: 'webDesign'
|
||||
},
|
||||
{
|
||||
id: 'one-step',
|
||||
title: 'One Step',
|
||||
description: 'Brand identity and marketing campaign for a fitness app focused on sustainable habits.',
|
||||
image: 'https://picsum.photos/id/180/800/600',
|
||||
tags: ['Branding', 'Marketing', 'UI/UX'],
|
||||
category: 'branding'
|
||||
},
|
||||
{
|
||||
id: 'nero-vision',
|
||||
title: 'Nero Vision',
|
||||
description: 'Full-stack web application for creative professionals to manage their portfolios.',
|
||||
image: 'https://picsum.photos/id/119/800/600',
|
||||
tags: ['Development', 'Vue.js', 'Node.js'],
|
||||
category: 'development'
|
||||
},
|
||||
{
|
||||
id: 'bold-moves',
|
||||
title: 'Bold Moves',
|
||||
description: 'Interactive website showcasing innovative architectural designs with 3D visualizations.',
|
||||
image: 'https://picsum.photos/id/164/800/600',
|
||||
tags: ['Web Design', '3D', 'Three.js'],
|
||||
category: 'webDesign'
|
||||
},
|
||||
{
|
||||
id: 'echo-labs',
|
||||
title: 'Echo Labs',
|
||||
description: 'Corporate branding and visual identity for a tech startup in the AI space.',
|
||||
image: 'https://picsum.photos/id/101/800/600',
|
||||
tags: ['Branding', 'Visual Identity', 'Corporate'],
|
||||
category: 'branding'
|
||||
},
|
||||
{
|
||||
id: 'flux-api',
|
||||
title: 'Flux API',
|
||||
description: 'Scalable REST API with comprehensive documentation and developer tools.',
|
||||
image: 'https://picsum.photos/id/326/800/600',
|
||||
tags: ['Development', 'API', 'Python'],
|
||||
category: 'development'
|
||||
}
|
||||
]
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defineNuxtPlugin } from '#app'
|
||||
|
||||
/**
|
||||
* 客户端启动时从服务端会话恢复登录状态(在路由守卫前完成,
|
||||
* 保证 admin 中间件与 /account 页能立即拿到真实用户)。
|
||||
*/
|
||||
export default defineNuxtPlugin(async () => {
|
||||
const userStore = useUserStore()
|
||||
await userStore.restoreUser()
|
||||
})
|
||||
@@ -0,0 +1,56 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
/**
|
||||
* 登录/注册弹窗全局状态。
|
||||
* Header、个人中心、收藏/评论组件等都可直接 openLogin() 唤起登录弹窗,
|
||||
* 避免层层 prop/事件传递。
|
||||
*/
|
||||
export const useAuthModalStore = defineStore('authModal', () => {
|
||||
const isLoginOpen = ref(false)
|
||||
const isRegisterOpen = ref(false)
|
||||
|
||||
// 任一弹窗打开时锁定背景滚动
|
||||
watch(
|
||||
() => [isLoginOpen.value, isRegisterOpen.value],
|
||||
([login, register]) => {
|
||||
if (typeof document === 'undefined') return
|
||||
document.body.style.overflow = login || register ? 'hidden' : ''
|
||||
},
|
||||
)
|
||||
|
||||
const openLogin = () => {
|
||||
isRegisterOpen.value = false
|
||||
isLoginOpen.value = true
|
||||
}
|
||||
|
||||
const openRegister = () => {
|
||||
isLoginOpen.value = false
|
||||
isRegisterOpen.value = true
|
||||
}
|
||||
|
||||
const closeAll = () => {
|
||||
isLoginOpen.value = false
|
||||
isRegisterOpen.value = false
|
||||
}
|
||||
|
||||
const switchToRegister = () => {
|
||||
isLoginOpen.value = false
|
||||
isRegisterOpen.value = true
|
||||
}
|
||||
|
||||
const switchToLogin = () => {
|
||||
isRegisterOpen.value = false
|
||||
isLoginOpen.value = true
|
||||
}
|
||||
|
||||
return {
|
||||
isLoginOpen,
|
||||
isRegisterOpen,
|
||||
openLogin,
|
||||
openRegister,
|
||||
closeAll,
|
||||
switchToRegister,
|
||||
switchToLogin,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,31 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
|
||||
export interface ToastItem {
|
||||
id: number
|
||||
type: 'success' | 'error' | 'info'
|
||||
message: string
|
||||
}
|
||||
|
||||
/** 全局 toast 通知(后台各页统一反馈) */
|
||||
export const useToastStore = defineStore('toast', () => {
|
||||
const toasts = ref<ToastItem[]>([])
|
||||
let seq = 0
|
||||
|
||||
const remove = (id: number) => {
|
||||
toasts.value = toasts.value.filter((t) => t.id !== id)
|
||||
}
|
||||
|
||||
const show = (type: ToastItem['type'], message: string) => {
|
||||
const id = ++seq
|
||||
toasts.value.push({ id, type, message })
|
||||
setTimeout(() => remove(id), 3200)
|
||||
return id
|
||||
}
|
||||
|
||||
const success = (message: string) => show('success', message)
|
||||
const error = (message: string) => show('error', message)
|
||||
const info = (message: string) => show('info', message)
|
||||
|
||||
return { toasts, show, success, error, info, remove }
|
||||
})
|
||||
+72
-32
@@ -5,76 +5,114 @@ export interface User {
|
||||
id: number
|
||||
username: string
|
||||
email: string
|
||||
phone?: string
|
||||
avatarUrl?: string
|
||||
phone: string | null
|
||||
avatar: string | null
|
||||
role: 'user' | 'admin'
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export interface ApiResult {
|
||||
success: boolean
|
||||
/** 后端错误码(供 useApiError 翻译),成功时为 null */
|
||||
code?: string | null
|
||||
}
|
||||
|
||||
const AVATAR_URL = (name: string) =>
|
||||
`https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=000&color=fff&size=128`
|
||||
|
||||
/**
|
||||
* 从服务端错误响应中提取 i18n 错误码(如 'auth.emailTaken')
|
||||
* 用户会话状态(真实后端:httpOnly Cookie 会话)。
|
||||
*/
|
||||
function extractErrorCode(err: any): string {
|
||||
return err?.data?.statusMessage || err?.statusMessage || ''
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const user = ref<User | null>(null)
|
||||
const isAuthenticated = computed(() => user.value !== null)
|
||||
|
||||
// 登录(服务端校验账号密码,成功后写入 httpOnly Cookie)
|
||||
const login = async (account: string, password: string) => {
|
||||
// 登录
|
||||
const login = async (account: string, password: string): Promise<ApiResult> => {
|
||||
try {
|
||||
const data = await $fetch<{ success: true; user: User }>('/api/auth/login', {
|
||||
const data = await $fetch<{ user: User }>('/api/auth/login', {
|
||||
method: 'POST',
|
||||
body: { account, password },
|
||||
})
|
||||
user.value = data.user
|
||||
return { success: true as const }
|
||||
return { success: true }
|
||||
} catch (err) {
|
||||
const code = extractErrorCode(err)
|
||||
return { success: false as const, error: code || 'auth.loginError' }
|
||||
return { success: false, code: (err as any)?.data?.code || 'SERVER_ERROR' }
|
||||
}
|
||||
}
|
||||
|
||||
// 注册(成功后自动登录)
|
||||
const register = async (data: { username: string; email: string; phone?: string; password: string }) => {
|
||||
// 注册(成功即自动登录)
|
||||
const register = async (data: {
|
||||
username: string
|
||||
email: string
|
||||
phone?: string
|
||||
password: string
|
||||
}): Promise<ApiResult> => {
|
||||
try {
|
||||
const res = await $fetch<{ success: true; user: User }>('/api/auth/register', {
|
||||
const res = await $fetch<{ user: User }>('/api/auth/register', {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
})
|
||||
user.value = res.user
|
||||
return { success: true as const }
|
||||
return { success: true }
|
||||
} catch (err) {
|
||||
const code = extractErrorCode(err)
|
||||
return { success: false as const, error: code || 'auth.registerError' }
|
||||
return { success: false, code: (err as any)?.data?.code || 'SERVER_ERROR' }
|
||||
}
|
||||
}
|
||||
|
||||
// 登出(清除服务端 Cookie)
|
||||
const logout = async () => {
|
||||
// 登出
|
||||
const logout = async (): Promise<void> => {
|
||||
try {
|
||||
await $fetch('/api/auth/logout', { method: 'POST' })
|
||||
} catch {
|
||||
// 忽略登出接口异常,本地状态照常清理
|
||||
} catch (err) {
|
||||
console.error('logout error:', err)
|
||||
}
|
||||
user.value = null
|
||||
}
|
||||
|
||||
// 从 httpOnly Cookie 恢复登录状态(替代旧的 localStorage 假恢复)
|
||||
const restoreUser = async () => {
|
||||
// 从服务端会话恢复用户(应用启动时调用)
|
||||
const restoreUser = async (): Promise<void> => {
|
||||
try {
|
||||
const data = await $fetch<{ user: User | null }>('/api/auth/me')
|
||||
const data = await $fetch<{ user: User }>('/api/auth/me')
|
||||
user.value = data.user
|
||||
} catch {
|
||||
} catch (err) {
|
||||
user.value = null
|
||||
}
|
||||
}
|
||||
|
||||
// 头像兜底:无自定义头像时用 ui-avatars 生成(保持与旧版一致的视觉)
|
||||
// 更新资料
|
||||
const updateProfile = async (patch: { username?: string; phone?: string }): Promise<ApiResult> => {
|
||||
try {
|
||||
const data = await $fetch<{ user: User }>('/api/auth/me', { method: 'PATCH', body: patch })
|
||||
user.value = data.user
|
||||
return { success: true }
|
||||
} catch (err) {
|
||||
return { success: false, code: (err as any)?.data?.code || 'SERVER_ERROR' }
|
||||
}
|
||||
}
|
||||
|
||||
// 更新头像(上传后由接口返回新 user,直接替换)
|
||||
const updateAvatar = async (file: File | null): Promise<ApiResult> => {
|
||||
try {
|
||||
if (file) {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
const data = await $fetch<{ user: User }>('/api/auth/avatar', { method: 'POST', body: fd })
|
||||
user.value = data.user
|
||||
} else {
|
||||
const data = await $fetch<{ user: User }>('/api/auth/avatar', { method: 'POST', body: { clear: true } })
|
||||
user.value = data.user
|
||||
}
|
||||
return { success: true }
|
||||
} catch (err) {
|
||||
return { success: false, code: (err as any)?.data?.code || 'SERVER_ERROR' }
|
||||
}
|
||||
}
|
||||
|
||||
// 头像:用户自定义优先,否则按用户名生成
|
||||
const avatar = computed(() => {
|
||||
if (user.value?.avatarUrl) return user.value.avatarUrl
|
||||
const name = user.value?.username || 'U'
|
||||
return `https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=000&color=fff&size=128`
|
||||
if (!user.value) return ''
|
||||
return user.value.avatar || AVATAR_URL(user.value.username)
|
||||
})
|
||||
|
||||
return {
|
||||
@@ -82,8 +120,10 @@ export const useUserStore = defineStore('user', () => {
|
||||
isAuthenticated,
|
||||
avatar,
|
||||
login,
|
||||
logout,
|
||||
register,
|
||||
logout,
|
||||
restoreUser,
|
||||
updateProfile,
|
||||
updateAvatar,
|
||||
}
|
||||
})
|
||||
|
||||
+67
-25
@@ -1,12 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# =========================================================
|
||||
# Arcticnewone 镜像构建与推送脚本(本地 / 部署服务器手动执行)
|
||||
# Arcticnewone 镜像构建与推送脚本(版本化)
|
||||
#
|
||||
# 遵循团队部署规范:
|
||||
# - 镜像推送到华为云 SWR,tag 固定为 latest
|
||||
# - 多架构(linux/amd64 + linux/arm64)一步构建推送
|
||||
# - oci-mediatypes=false:使用 Docker V2 manifest 格式(SWR 兼容的关键)
|
||||
# - --provenance=false --sbom=false:禁用 SLSA/SBOM 证明,避免额外 manifest
|
||||
# 用法:
|
||||
# ./build-and-push.sh # 版本取最新 git tag(无 tag 时取短 commit)
|
||||
# ./build-and-push.sh 0.0.1-dev # 显式指定版本
|
||||
#
|
||||
# 版本与镜像 tag 对应:
|
||||
# git tag = 0.0.1-dev => 推送 arcticnewone:0.0.1-dev(amd64 单 manifest)
|
||||
# 同时更新 arcticnewone:latest(amd64 单 manifest)
|
||||
#
|
||||
# SWR 兼容性说明:
|
||||
# - SWR 无法解析 Docker manifest list(报 "Invalid image, fail to parse manifest.json"),
|
||||
# 因此版本 tag 与 latest 采用 **amd64 单架构 manifest**(生产集群为 amd64);
|
||||
# - 同时仍分架构推送 <tag>-amd64 / <tag>-arm64 与 latest-amd64 / latest-arm64,
|
||||
# 便于 arm64 环境按需使用。
|
||||
# - 登录凭据一律从环境变量读取,绝不写入仓库
|
||||
#
|
||||
# 使用前先设置环境变量(示例):
|
||||
@@ -14,8 +22,6 @@
|
||||
# export SWR_NAMESPACE="virtheart"
|
||||
# export SWR_USERNAME="<SWR 用户名>"
|
||||
# export SWR_PASSWORD="<SWR 密码>"
|
||||
# 然后执行:
|
||||
# ./build-and-push.sh
|
||||
# =========================================================
|
||||
set -euo pipefail
|
||||
|
||||
@@ -26,10 +32,32 @@ set -euo pipefail
|
||||
: "${SWR_PASSWORD:?请先设置环境变量 SWR_PASSWORD(SWR 登录密码)}"
|
||||
|
||||
IMAGE_NAME="arcticnewone"
|
||||
IMAGE_TAG="${IMAGE_TAG:-latest}"
|
||||
FULL_IMAGE="${SWR_REGISTRY}/${SWR_NAMESPACE}/${IMAGE_NAME}:${IMAGE_TAG}"
|
||||
PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}"
|
||||
ARCHS="amd64 arm64"
|
||||
BUILDER_NAME="multiarch-builder"
|
||||
# 生产集群架构(作为版本 tag / latest 的单架构 manifest)
|
||||
PRIMARY_ARCH="amd64"
|
||||
|
||||
# ---------- 版本解析 ----------
|
||||
# 优先级: 命令行参数 > 最新 git tag > 短 commit
|
||||
VERSION="${1:-}"
|
||||
if [ -z "${VERSION}" ]; then
|
||||
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || true)"
|
||||
fi
|
||||
if [ -z "${VERSION}" ]; then
|
||||
VERSION="$(git rev-parse --short HEAD)"
|
||||
fi
|
||||
# 合法化 docker tag 字符集 [A-Za-z0-9_.-]
|
||||
VERSION="${VERSION//[^A-Za-z0-9_.-]/-}"
|
||||
|
||||
FULL_IMAGE="${SWR_REGISTRY}/${SWR_NAMESPACE}/${IMAGE_NAME}"
|
||||
VERSION_IMAGE="${FULL_IMAGE}:${VERSION}"
|
||||
LATEST_IMAGE="${FULL_IMAGE}:latest"
|
||||
|
||||
echo "=========================================================="
|
||||
echo " 版本: ${VERSION}"
|
||||
echo " 目标: ${VERSION_IMAGE} (latest 同步更新为 ${LATEST_IMAGE})"
|
||||
echo " 架构: 分架构 ${ARCHS// /, };版本/latest 以 ${PRIMARY_ARCH} 单 manifest 输出(SWR 兼容)"
|
||||
echo "=========================================================="
|
||||
|
||||
# 前置检查:docker / buildx
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
@@ -42,23 +70,37 @@ if ! docker buildx version >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
# 1. 登录 SWR(凭据来自环境变量,不写入仓库)
|
||||
echo ">>> [1/3] 登录 SWR: ${SWR_REGISTRY}"
|
||||
echo ">>> [1/5] 登录 SWR: ${SWR_REGISTRY}"
|
||||
echo "${SWR_PASSWORD}" | docker login "${SWR_REGISTRY}" -u "${SWR_USERNAME}" --password-stdin
|
||||
|
||||
# 2. 准备支持多架构的 builder(docker-container 驱动)
|
||||
echo ">>> [2/3] 准备多架构 builder: ${BUILDER_NAME}"
|
||||
# 2. 确保支持多架构的 builder 存在
|
||||
echo ">>> [2/5] 准备多架构 builder: ${BUILDER_NAME}"
|
||||
if ! docker buildx inspect "${BUILDER_NAME}" >/dev/null 2>&1; then
|
||||
docker buildx create --name "${BUILDER_NAME}"
|
||||
fi
|
||||
|
||||
# 3. 多架构一步构建并推送(Docker V2 manifest list,SWR 可正常解析)
|
||||
echo ">>> [3/3] 构建并推送: ${FULL_IMAGE} (${PLATFORMS})"
|
||||
docker buildx build \
|
||||
--builder "${BUILDER_NAME}" \
|
||||
--platform "${PLATFORMS}" \
|
||||
--provenance=false \
|
||||
--sbom=false \
|
||||
-o "type=image,push=true,oci-mediatypes=false" \
|
||||
-t "${FULL_IMAGE}" \
|
||||
.
|
||||
echo ">>> 推送完成: ${FULL_IMAGE}"
|
||||
# 3. 分别构建并推送各架构镜像(禁用 provenance,产物为单一 manifest)
|
||||
for ARCH in ${ARCHS}; do
|
||||
echo ">>> [3/5] 构建并推送 linux/${ARCH}: ${VERSION_IMAGE}-${ARCH} 与 ${LATEST_IMAGE}-${ARCH}"
|
||||
docker buildx build \
|
||||
--builder "${BUILDER_NAME}" \
|
||||
--platform "linux/${ARCH}" \
|
||||
--provenance=false \
|
||||
--push \
|
||||
-t "${VERSION_IMAGE}-${ARCH}" \
|
||||
-t "${LATEST_IMAGE}-${ARCH}" \
|
||||
.
|
||||
done
|
||||
|
||||
# 4. 将主架构(amd64)单 manifest 推送为版本 tag 与 latest(SWR 兼容)
|
||||
echo ">>> [4/5] 以 ${PRIMARY_ARCH} 单 manifest 推送版本 tag 与 latest(SWR 兼容)"
|
||||
docker pull "${VERSION_IMAGE}-${PRIMARY_ARCH}"
|
||||
docker tag "${VERSION_IMAGE}-${PRIMARY_ARCH}" "${VERSION_IMAGE}"
|
||||
docker push "${VERSION_IMAGE}"
|
||||
docker tag "${VERSION_IMAGE}-${PRIMARY_ARCH}" "${LATEST_IMAGE}"
|
||||
docker push "${LATEST_IMAGE}"
|
||||
|
||||
# 5. 完成
|
||||
echo ">>> [5/5] 推送完成: ${VERSION_IMAGE}(${PRIMARY_ARCH})"
|
||||
echo ">>> 同步更新: ${LATEST_IMAGE}(${PRIMARY_ARCH})"
|
||||
echo ">>> 分架构可用: ${VERSION_IMAGE}-{amd64,arm64} 与 ${LATEST_IMAGE}-{amd64,arm64}"
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env bash
|
||||
# =========================================================
|
||||
# Arcticnewone 一条命令部署 / 升级脚本
|
||||
#
|
||||
# 用法:
|
||||
# ./deploy.sh # 版本取最新 git tag(无 tag 时取短 commit)
|
||||
# ./deploy.sh 0.0.1-dev # 显式指定版本(须与镜像 tag 一致)
|
||||
# SKIP_BUILD=1 ./deploy.sh ... # 跳过构建推送,仅更新集群(镜像须已存在)
|
||||
#
|
||||
# 流程: 构建并推送镜像(版本化) -> 注入 Secret/ConfigMap -> kubectl apply
|
||||
# -> 等待滚动更新 -> 健康检查。全程一条命令完成部署与升级。
|
||||
#
|
||||
# 必填环境变量(与 build-and-push.sh 一致):
|
||||
# SWR_REGISTRY / SWR_NAMESPACE / SWR_USERNAME / SWR_PASSWORD
|
||||
# 可选(不设则取默认/自动生成):
|
||||
# SESSION_SECRET 会话密钥(缺省复用已有或自动生成)
|
||||
# SMTP_HOST/PORT/USER/PASS/FROM 邮件
|
||||
# CONTACT_TO 联系表单收件邮箱
|
||||
# ADMIN_EMAILS 管理员邮箱(逗号分隔)
|
||||
# ADMIN_INITIAL_PASSWORD 预置管理员初始密码(缺省自动生成并打印)
|
||||
# SITE_URL 站点公开地址(默认 https://personal.virtheart.com)
|
||||
# =========================================================
|
||||
set -euo pipefail
|
||||
|
||||
NAMESPACE="arcticnewone"
|
||||
REGISTRY="${SWR_REGISTRY:?请先设置环境变量 SWR_REGISTRY}"
|
||||
REPO_NAMESPACE="${SWR_NAMESPACE:?请先设置环境变量 SWR_NAMESPACE}"
|
||||
IMAGE_NAME="arcticnewone"
|
||||
|
||||
# ---------- 版本解析 ----------
|
||||
VERSION="${1:-}"
|
||||
if [ -z "${VERSION}" ]; then
|
||||
VERSION="$(git describe --tags --abbrev=0 2>/dev/null || true)"
|
||||
fi
|
||||
if [ -z "${VERSION}" ]; then
|
||||
VERSION="$(git rev-parse --short HEAD)"
|
||||
fi
|
||||
VERSION="${VERSION//[^A-Za-z0-9_.-]/-}"
|
||||
IMAGE="${REGISTRY}/${REPO_NAMESPACE}/${IMAGE_NAME}:${VERSION}"
|
||||
|
||||
echo "=========================================================="
|
||||
echo " 目标版本: ${VERSION}"
|
||||
echo " 镜像: ${IMAGE}"
|
||||
echo " 命名空间: ${NAMESPACE}"
|
||||
echo "=========================================================="
|
||||
|
||||
# ---------- 1. 构建并推送镜像(可跳过) ----------
|
||||
if [ "${SKIP_BUILD:-0}" != "1" ]; then
|
||||
echo ">>> [1/6] 构建并推送镜像(${VERSION} + latest)"
|
||||
./build-and-push.sh "${VERSION}"
|
||||
else
|
||||
echo ">>> [1/6] SKIP_BUILD=1,跳过构建推送(要求 ${IMAGE} 已存在)"
|
||||
fi
|
||||
|
||||
# ---------- 2. 镜像拉取 Secret(SWR 凭据,不写入仓库) ----------
|
||||
echo ">>> [2/6] 确保镜像拉取 Secret: huawei-swr-secret"
|
||||
kubectl create secret docker-registry huawei-swr-secret -n "${NAMESPACE}" \
|
||||
--docker-server="${REGISTRY}" \
|
||||
--docker-username="${SWR_USERNAME:?请先设置环境变量 SWR_USERNAME}" \
|
||||
--docker-password="${SWR_PASSWORD:?请先设置环境变量 SWR_PASSWORD}" \
|
||||
--dry-run=client -o yaml | kubectl apply -f - >/dev/null
|
||||
|
||||
# ---------- 3. 应用 Secret / ConfigMap ----------
|
||||
echo ">>> [3/6] 注入 Secret: app-secrets / ConfigMap: app-config"
|
||||
|
||||
SESSION_SECRET="${SESSION_SECRET:-}"
|
||||
if [ -z "${SESSION_SECRET}" ]; then
|
||||
SESSION_SECRET="$(kubectl get secret app-secrets -n "${NAMESPACE}" -o jsonpath='{.data.NUXT_SESSION_SECRET}' 2>/dev/null | base64 -d 2>/dev/null || true)"
|
||||
fi
|
||||
if [ -z "${SESSION_SECRET}" ]; then
|
||||
SESSION_SECRET="$(node -e "console.log(require('crypto').randomBytes(48).toString('hex'))")"
|
||||
echo " (未设置 SESSION_SECRET,已自动生成;如需固定请设置环境变量)"
|
||||
fi
|
||||
|
||||
# 注意:Nuxt runtimeConfig 的环境变量一律使用 NUXT_ 前缀
|
||||
# 预置管理员密码(首次部署生成,用于 DB 初始化时创建 admin 账号)
|
||||
ADMIN_INITIAL_PASSWORD="${ADMIN_INITIAL_PASSWORD:-}"
|
||||
if [ -z "${ADMIN_INITIAL_PASSWORD}" ]; then
|
||||
ADMIN_INITIAL_PASSWORD="$(openssl rand -base64 18 2>/dev/null | tr -d '/+=' | cut -c1-16)"
|
||||
echo " (已自动生成预置管理员密码,请保存: ${ADMIN_INITIAL_PASSWORD})"
|
||||
fi
|
||||
|
||||
kubectl create secret generic app-secrets -n "${NAMESPACE}" \
|
||||
--from-literal="NUXT_SESSION_SECRET=${SESSION_SECRET}" \
|
||||
--from-literal="NUXT_SMTP_HOST=${SMTP_HOST:-}" \
|
||||
--from-literal="NUXT_SMTP_PORT=${SMTP_PORT:-587}" \
|
||||
--from-literal="NUXT_SMTP_USER=${SMTP_USER:-}" \
|
||||
--from-literal="NUXT_SMTP_PASS=${SMTP_PASS:-}" \
|
||||
--from-literal="NUXT_SMTP_FROM=${SMTP_FROM:-}" \
|
||||
--from-literal="NUXT_CONTACT_TO=${CONTACT_TO:-}" \
|
||||
--from-literal="NUXT_ADMIN_EMAILS=${ADMIN_EMAILS:-}" \
|
||||
--from-literal="NUXT_ADMIN_INITIAL_PASSWORD=${ADMIN_INITIAL_PASSWORD}" \
|
||||
--from-literal="NUXT_OSS_ENDPOINT=${OSS_ENDPOINT:-}" \
|
||||
--from-literal="NUXT_OSS_ACCESS_KEY=${OSS_ACCESS_KEY:-}" \
|
||||
--from-literal="NUXT_OSS_SECRET_KEY=${OSS_SECRET_KEY:-}" \
|
||||
--from-literal="NUXT_OSS_BUCKET=${OSS_BUCKET:-}" \
|
||||
--from-literal="NUXT_OSS_REGION=${OSS_REGION:-us-east-1}" \
|
||||
--from-literal="NUXT_OSS_PUBLIC_BASE=${OSS_PUBLIC_BASE:-}" \
|
||||
--dry-run=client -o yaml | kubectl apply -f - >/dev/null
|
||||
|
||||
kubectl create configmap app-config -n "${NAMESPACE}" \
|
||||
--from-literal="NUXT_PUBLIC_SITE_URL=${SITE_URL:-https://personal.virtheart.com}" \
|
||||
--from-literal="NUXT_DB_PATH=/data/arcticnewone.db" \
|
||||
--dry-run=client -o yaml | kubectl apply -f - >/dev/null
|
||||
|
||||
# ---------- 4. 应用全部资源 ----------
|
||||
echo ">>> [4/6] 应用 K8s 资源(namespace/pvc/deployment/service/ingress)"
|
||||
kubectl apply -f deploy/namespace.yaml >/dev/null
|
||||
sed "s|__IMAGE__|${IMAGE}|g" deploy/deployment.yaml | kubectl apply -f -
|
||||
kubectl apply -f deploy/pvc.yaml
|
||||
kubectl apply -f deploy/service.yaml
|
||||
kubectl apply -f deploy/ingress.yaml
|
||||
|
||||
# ---------- 5. 等待滚动更新 ----------
|
||||
echo ">>> [5/6] 等待滚动更新完成..."
|
||||
kubectl rollout status deployment/arcticnewone -n "${NAMESPACE}" --timeout=300s
|
||||
|
||||
# ---------- 6. 健康检查 ----------
|
||||
echo ">>> [6/6] 部署完成,当前状态:"
|
||||
kubectl get pods -n "${NAMESPACE}" -l app=arcticnewone
|
||||
echo
|
||||
echo "部署成功: ${IMAGE}"
|
||||
echo "访问: ${SITE_URL:-https://personal.virtheart.com}"
|
||||
+43
-73
@@ -7,16 +7,14 @@
|
||||
| 文件 | 说明 |
|
||||
| --- | --- |
|
||||
| `namespace.yaml` | Namespace:项目专属命名空间 `arcticnewone` |
|
||||
| `deployment.yaml` | Deployment:SWR 镜像、副本数 1、私有镜像拉取 secrets、数据库/SMTP 环境变量 |
|
||||
| `deployment.yaml` | Deployment:镜像占位 `__IMAGE__`(由 deploy.sh 渲染为版本化地址)、副本数 1、PVC 持久化、Secret/ConfigMap 注入 |
|
||||
| `pvc.yaml` | PersistentVolumeClaim:SQLite 数据持久化(挂载 `/data`,Pod 升级不丢数据) |
|
||||
| `service.yaml` | Service:ClusterIP,80 端口转发到容器 3000 端口 |
|
||||
| `ingress.yaml` | Ingress:域名 `personal.virtheart.com`,Traefik + cert-manager 自动签发证书 |
|
||||
| `postgres.yaml` | (可选)集群内 PostgreSQL StatefulSet + PVC,仅在没有外部数据库时使用 |
|
||||
|
||||
`namespace.yaml` 负责创建 `arcticnewone` 命名空间;deployment/service/ingress 三个 YAML 的 `metadata` 均已指定 `namespace: arcticnewone`。
|
||||
> 不建议手工 apply 上述清单;请使用项目根目录的 `./deploy.sh` 一条命令完成构建/推送/更新/升级(详见下方「一条命令部署」)。
|
||||
|
||||
## 镜像构建与推送
|
||||
|
||||
镜像由项目根目录的 `build-and-push.sh` 构建并推送到华为云 SWR(多架构 `linux/amd64,linux/arm64`,tag 统一为 `latest`):
|
||||
## 一条命令部署 / 升级(推荐)
|
||||
|
||||
```bash
|
||||
# 1. 设置环境变量(凭据绝不写入仓库)
|
||||
@@ -24,95 +22,67 @@ export SWR_REGISTRY="swr.cn-north-4.myhuaweicloud.com"
|
||||
export SWR_NAMESPACE="virtheart"
|
||||
export SWR_USERNAME="<用户名>"
|
||||
export SWR_PASSWORD="<密码>"
|
||||
# 可选:SESSION_SECRET / SMTP_* / CONTACT_TO / ADMIN_EMAILS / SITE_URL
|
||||
|
||||
# 2. 执行构建与推送
|
||||
./build-and-push.sh
|
||||
# 2. 打版本标签(版本号即镜像 tag)
|
||||
git tag 0.0.1-dev
|
||||
|
||||
# 3. 一条命令:构建镜像 -> 推送 SWR -> 注入 Secret/ConfigMap -> kubectl apply -> 滚动升级
|
||||
./deploy.sh 0.0.1-dev
|
||||
# 或
|
||||
./deploy.sh # 自动取最新 git tag
|
||||
```
|
||||
|
||||
推送完成后镜像地址:`swr.cn-north-4.myhuaweicloud.com/virtheart/arcticnewone:latest`。
|
||||
`deploy.sh` 依次完成:
|
||||
1. 调用 `build-and-push.sh` 构建并推送版本化镜像(`:0.0.1-dev` + `:latest`)
|
||||
2. 创建/更新镜像拉取 Secret(`huawei-swr-secret`)
|
||||
3. 创建/更新 `app-secrets`(SESSION_SECRET/SMTP/CONTACT_TO/ADMIN_EMAILS)与 `app-config`(站点地址/DB 路径)
|
||||
4. `kubectl apply`:namespace / pvc / deployment(镜像渲染为版本化地址)/ service / ingress
|
||||
5. `kubectl rollout status` 等待滚动更新
|
||||
6. 输出 Pod 状态与访问地址
|
||||
|
||||
说明:脚本通过 `--output "type=image,push=true,oci-mediatypes=false"` 一步完成多架构构建推送,使用 Docker V2 manifest 格式(而非 OCI 格式,这是 SWR 兼容的关键),并禁用 provenance/SBOM(`--provenance=false --sbom=false`),保证 SWR 可正常解析。
|
||||
|
||||
## 数据库(PostgreSQL)
|
||||
|
||||
应用依赖 PostgreSQL 16+ 存储用户、联系留言与订阅数据。两种方式二选一:
|
||||
|
||||
### 方式 A:使用云托管数据库(推荐)
|
||||
|
||||
使用华为云 RDS for PostgreSQL 等托管服务(自带备份与高可用),创建数据库 `arcticnewone`,连接串格式:
|
||||
`postgres://<用户>:<密码>@<主机>:<端口>/arcticnewone`
|
||||
|
||||
### 方式 B:集群内部署(deploy/postgres.yaml)
|
||||
## 仅构建镜像
|
||||
|
||||
```bash
|
||||
kubectl apply -f deploy/postgres.yaml
|
||||
./build-and-push.sh # 版本取最新 git tag
|
||||
./build-and-push.sh 0.0.1-dev # 显式指定版本
|
||||
```
|
||||
|
||||
会创建一个 StatefulSet + PVC(8Gi),数据库地址为 `arcticnewone-postgres.arcticnewone.svc.cluster.local:5432`。
|
||||
仅建议在测试/低负载场景使用;数据持久化依赖集群存储类。
|
||||
分架构构建(`linux/amd64,linux/arm64`)并推送 `-amd64` / `-arm64` 标签;
|
||||
版本 tag 与 `latest` 以 **amd64 单架构 manifest** 输出(华为云 SWR 无法解析 Docker manifest list,多架构合并会报 `Invalid image`;生产集群为 amd64),并禁用 provenance(`--provenance=false`)。
|
||||
|
||||
## 部署前置条件
|
||||
|
||||
1. 镜像已构建并推送到华为云 SWR(通过项目根目录 `./build-and-push.sh` 执行,见上方「镜像构建与推送」)
|
||||
2. 集群已安装 Traefik Ingress 与 cert-manager(ClusterIssuer 名称为 `lets-encrypt`)
|
||||
3. 域名 `personal.virtheart.com` 的 DNS 已解析到集群入口
|
||||
4. 创建私有镜像拉取 Secret(凭据从环境变量读取,绝不写入仓库;命名空间由 `namespace.yaml` 创建):
|
||||
1. 集群已安装 Traefik Ingress 与 cert-manager(ClusterIssuer 名称为 `lets-encrypt`)
|
||||
2. 域名 `personal.virtheart.com` 的 DNS 已解析到集群入口
|
||||
3. 具备 `arcticnewone` 命名空间的 kubectl 权限(`./deploy.sh` 会自动创建命名空间与全部资源)
|
||||
|
||||
```bash
|
||||
kubectl create secret docker-registry huawei-swr-secret -n arcticnewone \
|
||||
--docker-server="$SWR_REGISTRY" \
|
||||
--docker-username="$SWR_USERNAME" \
|
||||
--docker-password="$SWR_PASSWORD" \
|
||||
--dry-run=client -o yaml | kubectl apply -f -
|
||||
```
|
||||
|
||||
5. 创建应用配置 Secret `arcticnewone-secrets`(`database-url` 与 `jwt-secret` 必填;SMTP 项可选,不配置时联系表单/订阅仅入库不发邮件):
|
||||
|
||||
```bash
|
||||
kubectl create secret generic arcticnewone-secrets -n arcticnewone \
|
||||
--from-literal=database-url='postgres://arcticnewone:<密码>@<数据库地址>:5432/arcticnewone' \
|
||||
--from-literal=jwt-secret='<随机长字符串,建议 openssl rand -hex 32>' \
|
||||
--from-literal=postgres-password='<集群内数据库密码,仅方式 B 需要>' \
|
||||
--from-literal=smtp-host='smtp.example.com' \
|
||||
--from-literal=smtp-port='465' \
|
||||
--from-literal=smtp-user='<SMTP 用户名>' \
|
||||
--from-literal=smtp-pass='<SMTP 密码>' \
|
||||
--from-literal=smtp-from='北极新一 <noreply@virtheart.com>' \
|
||||
--from-literal=smtp-contact-to='chenchun@virtheart.com' \
|
||||
--dry-run=client -o yaml | kubectl apply -f -
|
||||
```
|
||||
|
||||
## 部署步骤
|
||||
## 部署后验证
|
||||
|
||||
```bash
|
||||
kubectl apply -f deploy/namespace.yaml
|
||||
kubectl apply -f deploy/deployment.yaml
|
||||
kubectl apply -f deploy/service.yaml
|
||||
kubectl apply -f deploy/ingress.yaml
|
||||
```
|
||||
|
||||
`namespace.yaml` 需最先应用;其余三个 YAML 自带 `namespace: arcticnewone`,`kubectl apply` 时无需额外指定。
|
||||
若使用集群内数据库,还需先应用 `deploy/postgres.yaml`。
|
||||
|
||||
部署后验证:
|
||||
|
||||
```bash
|
||||
kubectl get deploy,svc,ingress -n arcticnewone
|
||||
kubectl get deploy,svc,pvc,ingress -n arcticnewone
|
||||
kubectl rollout status deployment/arcticnewone -n arcticnewone
|
||||
kubectl logs deploy/arcticnewone -n arcticnewone | grep '\[db\]' # 确认数据库连接成功
|
||||
curl -I https://personal.virtheart.com
|
||||
curl https://personal.virtheart.com/sitemap.xml
|
||||
curl https://personal.virtheart.com/robots.txt
|
||||
```
|
||||
|
||||
## 回滚方案
|
||||
|
||||
镜像 tag 固定为 `latest`,回滚前先确认 SWR 上 `latest` 对应可回滚的版本(或先推送目标版本镜像),再执行:
|
||||
镜像使用版本化 tag,回滚即切回上一版本镜像:
|
||||
|
||||
```bash
|
||||
# 回滚到上一版本镜像
|
||||
# 方式一:回滚到 Deployment 上一版本
|
||||
kubectl rollout undo deployment/arcticnewone -n arcticnewone
|
||||
|
||||
# 或整体移除本次部署的资源
|
||||
kubectl delete -f deploy/ingress.yaml -n arcticnewone
|
||||
kubectl delete -f deploy/service.yaml -n arcticnewone
|
||||
kubectl delete -f deploy/deployment.yaml -n arcticnewone
|
||||
# 方式二:显式部署旧版本镜像(旧镜像需已在 SWR)
|
||||
IMAGE="swr.cn-north-4.myhuaweicloud.com/virtheart/arcticnewone:<旧版本>"
|
||||
sed "s|__IMAGE__|${IMAGE}|g" deploy/deployment.yaml | kubectl apply -f - && \
|
||||
kubectl rollout status deployment/arcticnewone -n arcticnewone
|
||||
```
|
||||
|
||||
## 数据持久化
|
||||
|
||||
- SQLite 数据库位于容器 `/data/arcticnewone.db`,由 PVC `arcticnewone-data`(RWO,1Gi)持久化
|
||||
- Pod 升级、重启、回滚均不丢失用户/留言/订阅/收藏/评论数据
|
||||
- 备份:对 PVC 挂载目录执行 `sqlite3 arcticnewone.db ".backup 'backup.db'"` 或整卷快照
|
||||
|
||||
+22
-60
@@ -1,17 +1,13 @@
|
||||
# =========================================================
|
||||
# Arcticnewone 生产部署 - Deployment
|
||||
#
|
||||
# 镜像: 华为云 SWR swr.cn-north-4.myhuaweicloud.com/virtheart/arcticnewone:latest
|
||||
# 镜像: 由 deploy.sh 渲染,占位 __IMAGE__ 替换为
|
||||
# swr.cn-north-4.myhuaweicloud.com/virtheart/arcticnewone:<版本号>
|
||||
# 副本数: 1(团队规范)
|
||||
#
|
||||
# 私有镜像拉取说明:
|
||||
# 集群中需预先创建 docker-registry 类型的 Secret(凭据从环境变量读取,不写入仓库):
|
||||
# kubectl create secret docker-registry huawei-swr-secret \
|
||||
# --docker-server="$SWR_REGISTRY" \
|
||||
# --docker-username="$SWR_USERNAME" \
|
||||
# --docker-password="$SWR_PASSWORD" \
|
||||
# --dry-run=client -o yaml | kubectl apply -f -
|
||||
# 详见 deploy/README.md
|
||||
# 敏感配置(SESSION_SECRET / SMTP_* / CONTACT_TO / ADMIN_EMAILS)
|
||||
# 由 deploy.sh 以 Secret `app-secrets` 注入;公开配置(站点地址/DB 路径)
|
||||
# 以 ConfigMap `app-config` 注入。数据库持久化到 PVC `arcticnewone-data`(/data)。
|
||||
# =========================================================
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
@@ -21,6 +17,9 @@ metadata:
|
||||
labels:
|
||||
app: arcticnewone
|
||||
spec:
|
||||
# RWO PVC 单副本场景:Recreate 策略避免滚动更新时新旧 Pod 争用卷导致死锁
|
||||
strategy:
|
||||
type: Recreate
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
@@ -34,8 +33,8 @@ spec:
|
||||
- name: huawei-swr-secret
|
||||
containers:
|
||||
- name: arcticnewone
|
||||
image: swr.cn-north-4.myhuaweicloud.com/virtheart/arcticnewone:latest
|
||||
imagePullPolicy: Always
|
||||
image: __IMAGE__
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 3000
|
||||
@@ -46,55 +45,14 @@ spec:
|
||||
value: "0.0.0.0"
|
||||
- name: PORT
|
||||
value: "3000"
|
||||
# 数据库连接(必填)
|
||||
- name: NUXT_DATABASE_URL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: database-url
|
||||
# JWT 签名密钥(必填)
|
||||
- name: NUXT_JWT_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: jwt-secret
|
||||
# SMTP 邮件通知(可选;不配置时表单/订阅仅入库)
|
||||
- name: NUXT_SMTP_HOST
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: smtp-host
|
||||
optional: true
|
||||
- name: NUXT_SMTP_PORT
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: smtp-port
|
||||
optional: true
|
||||
- name: NUXT_SMTP_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: smtp-user
|
||||
optional: true
|
||||
- name: NUXT_SMTP_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: smtp-pass
|
||||
optional: true
|
||||
- name: NUXT_SMTP_FROM
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: smtp-from
|
||||
optional: true
|
||||
- name: NUXT_SMTP_CONTACT_TO
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: smtp-contact-to
|
||||
optional: true
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: app-config
|
||||
- secretRef:
|
||||
name: app-secrets
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
@@ -118,3 +76,7 @@ spec:
|
||||
periodSeconds: 20
|
||||
timeoutSeconds: 3
|
||||
failureThreshold: 3
|
||||
volumes:
|
||||
- name: data
|
||||
persistentVolumeClaim:
|
||||
claimName: arcticnewone-data
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
# =========================================================
|
||||
# Arcticnewone 可选生产数据库 - PostgreSQL StatefulSet
|
||||
#
|
||||
# 说明:
|
||||
# - 仅当生产环境没有可用的 PostgreSQL(如华为云 RDS)时才使用本文件
|
||||
# - 建议优先使用云托管数据库(RDS),自带备份/高可用,运维成本更低
|
||||
# - 数据保存在 PVC(8Gi 本地存储类),如需扩容请先调整 storage
|
||||
# - 部署后创建 Secret 提供连接信息(见 deploy/README.md)
|
||||
# =========================================================
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: arcticnewone-postgres
|
||||
namespace: arcticnewone
|
||||
labels:
|
||||
app: arcticnewone-postgres
|
||||
spec:
|
||||
clusterIP: None
|
||||
ports:
|
||||
- name: postgres
|
||||
port: 5432
|
||||
targetPort: 5432
|
||||
selector:
|
||||
app: arcticnewone-postgres
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: arcticnewone-postgres
|
||||
namespace: arcticnewone
|
||||
labels:
|
||||
app: arcticnewone-postgres
|
||||
spec:
|
||||
serviceName: arcticnewone-postgres
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: arcticnewone-postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: arcticnewone-postgres
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
image: docker.m.daocloud.io/library/postgres:16-alpine
|
||||
ports:
|
||||
- name: postgres
|
||||
containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_DB
|
||||
value: "arcticnewone"
|
||||
- name: POSTGRES_USER
|
||||
value: "arcticnewone"
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: arcticnewone-secrets
|
||||
key: postgres-password
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 1Gi
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: ["pg_isready", "-U", "arcticnewone", "-d", "arcticnewone"]
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
exec:
|
||||
command: ["pg_isready", "-U", "arcticnewone", "-d", "arcticnewone"]
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes: ["ReadWriteOnce"]
|
||||
resources:
|
||||
requests:
|
||||
storage: 8Gi
|
||||
@@ -0,0 +1,19 @@
|
||||
# =========================================================
|
||||
# Arcticnewone 生产部署 - 持久化卷
|
||||
#
|
||||
# SQLite 数据(/data/arcticnewone.db)持久化,Pod 重启/升级不丢数据。
|
||||
# microk8s 默认提供 hostpath 存储类;生产可按需替换为云盘存储类。
|
||||
# =========================================================
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: arcticnewone-data
|
||||
namespace: arcticnewone
|
||||
labels:
|
||||
app: arcticnewone
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
@@ -1,24 +1,4 @@
|
||||
services:
|
||||
postgres:
|
||||
# 国内可访问的 DaoCloud 镜像源(与 Dockerfile 一致)
|
||||
image: docker.m.daocloud.io/library/postgres:16-alpine
|
||||
container_name: arcticnewone-postgres
|
||||
environment:
|
||||
POSTGRES_DB: arcticnewone
|
||||
POSTGRES_USER: arcticnewone
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-arcticnewone_dev_password}
|
||||
ports:
|
||||
# 宿主机 5433,避免与本机已有 PostgreSQL(5432/15432) 冲突
|
||||
- "5433:5432"
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U arcticnewone -d arcticnewone"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
restart: unless-stopped
|
||||
|
||||
app:
|
||||
# 生产与本地使用同一 SWR 镜像(团队规范)
|
||||
image: swr.cn-north-4.myhuaweicloud.com/virtheart/arcticnewone:latest
|
||||
@@ -29,21 +9,4 @@ services:
|
||||
- NODE_ENV=production
|
||||
- HOST=0.0.0.0
|
||||
- PORT=3000
|
||||
# 数据库连接(compose 内通过服务名 postgres 访问)
|
||||
- NUXT_DATABASE_URL=postgres://arcticnewone:${POSTGRES_PASSWORD:-arcticnewone_dev_password}@postgres:5432/arcticnewone
|
||||
# JWT 签名密钥(生产必须覆盖)
|
||||
- NUXT_JWT_SECRET=${JWT_SECRET:-dev-only-secret-change-in-production}
|
||||
# SMTP 邮件通知(可选;不配置时表单/订阅仅入库)
|
||||
- NUXT_SMTP_HOST=${SMTP_HOST:-}
|
||||
- NUXT_SMTP_PORT=${SMTP_PORT:-465}
|
||||
- NUXT_SMTP_USER=${SMTP_USER:-}
|
||||
- NUXT_SMTP_PASS=${SMTP_PASS:-}
|
||||
- NUXT_SMTP_FROM=${SMTP_FROM:-}
|
||||
- NUXT_SMTP_CONTACT_TO=${SMTP_CONTACT_TO:-}
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
+136
-159
@@ -32,13 +32,7 @@
|
||||
"work": {
|
||||
"label": "Portfolio 26©",
|
||||
"title": "Work",
|
||||
"viewAll": "View all work",
|
||||
"items": {
|
||||
"forma": "Forma Digital",
|
||||
"oneStep": "One Step",
|
||||
"neroVision": "Nero Vision",
|
||||
"boldMoves": "Bold Moves"
|
||||
}
|
||||
"viewAll": "View all work"
|
||||
},
|
||||
"services": {
|
||||
"title": "Our Services",
|
||||
@@ -239,34 +233,7 @@
|
||||
"updates": {
|
||||
"title": "Latest Updates",
|
||||
"subtitle": "Explore our latest projects, blog posts, and industry insights",
|
||||
"viewAll": "View All Updates",
|
||||
"categories": {
|
||||
"project": "Project",
|
||||
"blog": "Blog",
|
||||
"news": "News"
|
||||
},
|
||||
"items": {
|
||||
"project1": {
|
||||
"title": "Brand Redesign: Modern E-commerce Platform",
|
||||
"description": "Created a new brand identity and user experience for a leading e-commerce platform, boosting conversion by 45%."
|
||||
},
|
||||
"blog1": {
|
||||
"title": "Web Design Trends in 2026"
|
||||
},
|
||||
"news1": {
|
||||
"title": "Awarded Best Design Studio"
|
||||
},
|
||||
"project2": {
|
||||
"title": "AI-Powered Recommendation System",
|
||||
"description": "Developed an innovative AI recommendation engine for personalized experiences."
|
||||
},
|
||||
"blog2": {
|
||||
"title": "How to Boost Website Performance"
|
||||
},
|
||||
"news2": {
|
||||
"title": "Team Expands to 50 Members"
|
||||
}
|
||||
}
|
||||
"viewAll": "View All Updates"
|
||||
},
|
||||
"cta": {
|
||||
"titleLine1": "Ready to Start",
|
||||
@@ -297,11 +264,7 @@
|
||||
"newsletterNote": "No noise. Just curated updates.",
|
||||
"copyright": "© 2026 ArcticNewOne Studio",
|
||||
"address": "Binhe West Road, Qixingguan District, Bijie City, Guizhou Province",
|
||||
"wechat": "WeChat",
|
||||
"newsletterSuccess": "Subscribed! Thank you for your support.",
|
||||
"newsletterError": "Subscription failed. Please try again later.",
|
||||
"newsletterAlreadySubscribed": "This email is already subscribed.",
|
||||
"newsletterInvalidEmail": "Please enter a valid email address"
|
||||
"wechat": "WeChat"
|
||||
},
|
||||
"work": {
|
||||
"title": "Our Work",
|
||||
@@ -325,51 +288,7 @@
|
||||
"duration": "Duration",
|
||||
"services": "Services",
|
||||
"visitProject": "Visit Project",
|
||||
"relatedProjects": "Related Projects",
|
||||
"items": {
|
||||
"forma-digital": {
|
||||
"overview": "Forma Digital is a modern e-commerce platform designed to provide a seamless shopping experience. We redesigned the entire user interface with a minimalist design approach, focusing on product showcase and conversion optimization.",
|
||||
"challenge": "The client needed a platform that could both showcase premium products and deliver a smooth shopping experience. The existing website was slow, had poor mobile experience, and low conversion rates.",
|
||||
"solution": "We built the platform with React + Next.js, implementing server-side rendering and static generation for blazing fast load times. The product pages feature immersive large-format imagery with smooth animation transitions.",
|
||||
"client": "Forma Digital Inc.",
|
||||
"duration": "3 months"
|
||||
},
|
||||
"one-step": {
|
||||
"overview": "One Step is a fitness app focused on building healthy habits. We created a complete brand visual identity system including logo design, UI interface, and marketing materials.",
|
||||
"challenge": "In the competitive fitness app market, how to stand out through brand design and establish unique brand recognition.",
|
||||
"solution": "With the core concept of 'one step at a time', we designed a clean and powerful brand identity. Using gradient colors and rounded graphic language to convey health, positivity, and progress.",
|
||||
"client": "One Step Fitness",
|
||||
"duration": "2 months"
|
||||
},
|
||||
"nero-vision": {
|
||||
"overview": "Nero Vision is a portfolio management platform for creative professionals, helping designers and artists showcase and manage their work.",
|
||||
"challenge": "Creative professionals need a platform that can perfectly showcase work while being easy to manage. Existing solutions are either too complex or have poor display quality.",
|
||||
"solution": "We developed a full-stack application with Vue.js + Node.js, designing an intuitive drag-and-drop portfolio management interface with beautiful display templates.",
|
||||
"client": "Nero Studio",
|
||||
"duration": "4 months"
|
||||
},
|
||||
"bold-moves": {
|
||||
"overview": "Bold Moves is an interactive website showcasing innovative architectural designs through 3D visualization technology, letting users experience architecture immersively.",
|
||||
"challenge": "How to present complex architectural designs in an intuitive and engaging way to general users while maintaining professionalism.",
|
||||
"solution": "We used Three.js for high-quality 3D rendering with smooth interactive design, allowing users to appreciate architectural details from any angle, with lighting effects and material displays.",
|
||||
"client": "Bold Moves Architecture",
|
||||
"duration": "5 months"
|
||||
},
|
||||
"echo-labs": {
|
||||
"overview": "Echo Labs is an AI tech startup. We created a complete brand visual identity system and corporate website for them.",
|
||||
"challenge": "AI brands need to convey both technology and humanity, avoiding being too cold or technical.",
|
||||
"solution": "With the concept of 'echo', we designed a dynamic brand identity. Using dark themes with gradient colors for a tech feel, while rounded graphic language adds approachability.",
|
||||
"client": "Echo Labs AI",
|
||||
"duration": "3 months"
|
||||
},
|
||||
"flux-api": {
|
||||
"overview": "Flux API is a scalable REST API service platform with comprehensive documentation and developer tools to help developers integrate quickly.",
|
||||
"challenge": "API documentation and developer experience are core competitive advantages. How to make complex APIs easy to understand and use.",
|
||||
"solution": "We designed interactive API documentation with online testing and code generation. Multi-language SDKs and detailed tutorials significantly reduce the learning curve for developers.",
|
||||
"client": "Flux Technologies",
|
||||
"duration": "6 months"
|
||||
}
|
||||
}
|
||||
"relatedProjects": "Related Projects"
|
||||
}
|
||||
},
|
||||
"studio": {
|
||||
@@ -408,11 +327,7 @@
|
||||
"sent": "Sent!",
|
||||
"retry": "Try Again",
|
||||
"successMessage": "Message sent successfully! We will get back to you soon.",
|
||||
"errorMessage": "Failed to send message. Please try again or contact us directly.",
|
||||
"invalidName": "Please enter your name",
|
||||
"invalidEmail": "Invalid email format",
|
||||
"invalidSubject": "Subject is too long (max 255 characters)",
|
||||
"invalidMessage": "Message must be at least 10 characters"
|
||||
"errorMessage": "Failed to send message. Please try again or contact us directly."
|
||||
},
|
||||
"info": {
|
||||
"email": "chenchun{'@'}virtheart.com",
|
||||
@@ -433,71 +348,10 @@
|
||||
"projects": "Projects",
|
||||
"announcements": "Announcements"
|
||||
},
|
||||
"minutes": "min",
|
||||
"detail": {
|
||||
"shareArticle": "Share Article",
|
||||
"relatedArticles": "Related Articles",
|
||||
"items": {
|
||||
"design-trends-2026": {
|
||||
"content": "In 2026, the design industry is undergoing a profound transformation. From the return of minimalism to the rise of bold typography, from the普及 of 3D elements to the maturity of AI-assisted design, these trends are redefining the boundaries of digital experiences.",
|
||||
"section1Title": "The Return of Minimalism",
|
||||
"section1Content": "In an age of information overload, users increasingly渴望 clean, clear interfaces. 2026's minimalism isn't just 'less is more' — it's about delivering more value in limited space through careful information architecture and visual hierarchy.",
|
||||
"quote": "Good design isn't about adding more, it's about removing the unnecessary. In 2026, this matters more than ever.",
|
||||
"section2Title": "Bold Typography & Dynamic Text",
|
||||
"section2Content": "Typography is moving from supporting actor to leading role. Large, high-contrast font designs are becoming important brand expression tools. Dynamic text effects are making typography a living, interactive element rather than static decoration.",
|
||||
"section3Title": "Maturity of AI-Assisted Design",
|
||||
"section3Content": "AI tools are shifting from 'replacing designers' to 'empowering designers.' Smart layout suggestions, automated color schemes, and real-time design feedback let designers focus on creativity and strategy rather than repetitive execution."
|
||||
},
|
||||
"forma-digital-launch": {
|
||||
"content": "After three months of careful crafting, we're excited to announce the official launch of the Forma Digital e-commerce platform! This project is one of our team's most challenging works to date.",
|
||||
"section1Title": "Project Background",
|
||||
"section1Content": "Forma Digital is an e-commerce brand focusing on premium home goods. They needed a platform that could perfectly showcase product quality while delivering a smooth shopping experience.",
|
||||
"quote": "The ArcticNewOne team not only understood our needs but exceeded our expectations. After the new platform launched, our conversion rate increased by 45%.",
|
||||
"section2Title": "Technical Highlights",
|
||||
"section2Content": "We used React + Next.js for server-side rendering and static generation. Through lazy loading, code splitting, and CDN acceleration, we reduced first load time from 4.5s to 1.2s.",
|
||||
"section3Title": "Results",
|
||||
"section3Content": "After launch, user停留 time increased by 60%, bounce rate decreased by 35%, and conversion rate improved by 45%."
|
||||
},
|
||||
"studio-expansion": {
|
||||
"content": "With continued business growth and increasing client demand, we're excited to announce the official expansion of ArcticNewOne Studio!",
|
||||
"section1Title": "Team Growth",
|
||||
"section1Content": "We're adding 5 senior designers and 3 senior developers covering frontend, backend, UI/UX, and more. All new members have extensive industry experience.",
|
||||
"quote": "Talent is our most valuable asset. By expanding our team, we can take on more projects while maintaining consistent high-quality delivery.",
|
||||
"section2Title": "Service Upgrade",
|
||||
"section2Content": "In addition to existing services, we're adding data visualization, AI application development, AR/VR experience design, and other cutting-edge services.",
|
||||
"section3Title": "Looking Ahead",
|
||||
"section3Content": "We plan to complete 50+ projects and serve 30+ new clients in the coming year while continuing to explore new possibilities."
|
||||
},
|
||||
"ux-research-methods": {
|
||||
"content": "UX research is the foundation of design decisions. In 2026, as technology evolves and user behaviors change, UX research methods continue to advance.",
|
||||
"section1Title": "Remote User Testing",
|
||||
"section1Content": "Remote user testing has become mainstream. Through professional platforms, we can recruit test users globally and gather broader feedback in less time.",
|
||||
"quote": "Remote testing not only reduces costs but more importantly lets us access more authentic user scenarios.",
|
||||
"section2Title": "Behavioral Data Analysis",
|
||||
"section2Content": "Through heatmaps, scroll depth, click streams, and other behavioral data, we can objectively understand how users interact with products.",
|
||||
"section3Title": "AI-Assisted Analysis",
|
||||
"section3Content": "AI tools help us analyze user feedback more efficiently. Sentiment analysis, topic clustering, and trend prediction help extract valuable insights from massive data."
|
||||
},
|
||||
"bold-moves-case-study": {
|
||||
"content": "Bold Moves is an interactive website showcasing innovative architectural designs. This article provides an in-depth look at the design思路, technical implementation, and final results.",
|
||||
"section1Title": "Design Philosophy",
|
||||
"section1Content": "Bold Moves wanted to showcase architectural beauty digitally. We decided to use 3D visualization to let users appreciate architectural details from any angle.",
|
||||
"quote": "We didn't just want a showcase website — we wanted a digital space where users could 'walk into' the architecture.",
|
||||
"section2Title": "Technical Challenges",
|
||||
"section2Content": "High-quality 3D rendering requires significant computing power, but web performance is limited. We achieved smooth interactions through model optimization, LOD techniques, and WebGL rendering.",
|
||||
"section3Title": "Final Results",
|
||||
"section3Content": "The project received widespread acclaim and won multiple design awards. Average user停留 time exceeded 5 minutes, well above industry average."
|
||||
},
|
||||
"new-tools-integration": {
|
||||
"content": "To better serve our clients, we continuously expand and improve our toolbox. Recently, we've added several practical tools covering design, development, collaboration, and more.",
|
||||
"section1Title": "Design Tool Upgrades",
|
||||
"section1Content": "We've引入 the latest design collaboration platform supporting real-time multi-person editing, version management, and design system integration.",
|
||||
"quote": "Good tools significantly boost team efficiency. The right toolchain is key to delivering quality work.",
|
||||
"section2Title": "Development Tool Enhancements",
|
||||
"section2Content": "Added automated testing frameworks, performance monitoring tools, and code quality checks to help identify and resolve issues during development.",
|
||||
"section3Title": "Collaboration Tool Optimization",
|
||||
"section3Content": "We upgraded our project management platform with new Kanban views, time tracking, and resource allocation features for better project oversight."
|
||||
}
|
||||
}
|
||||
"relatedArticles": "Related Articles"
|
||||
}
|
||||
},
|
||||
"auth": {
|
||||
@@ -511,6 +365,7 @@
|
||||
"loginButton": "Login",
|
||||
"loggingIn": "Logging in...",
|
||||
"loginError": "Login failed. Please check your credentials.",
|
||||
"demoHint": "Demo: Use any account and password to login",
|
||||
"noAccount": "Don't have an account?",
|
||||
"createAccount": "Sign Up",
|
||||
"register": "Sign Up",
|
||||
@@ -531,12 +386,134 @@
|
||||
"invalidPhone": "Invalid phone number format",
|
||||
"alreadyHaveAccount": "Already have an account?",
|
||||
"backToLogin": "Back to Login",
|
||||
"invalidUsername": "Username must be 2-50 characters (letters, numbers, underscore)",
|
||||
"invalidEmail": "Invalid email format",
|
||||
"passwordTooShort": "Password must be at least 6 characters",
|
||||
"usernameTaken": "This username is already taken",
|
||||
"usernameTaken": "Username is already taken",
|
||||
"emailTaken": "This email is already registered",
|
||||
"phoneTaken": "This phone number is already registered",
|
||||
"invalidCredentials": "Incorrect account or password"
|
||||
"invalidCredentials": "Incorrect account or password",
|
||||
"passwordTooShort": "Password must be at least 8 characters",
|
||||
"invalidUsername": "Username must be 2-20 characters (letters, digits, underscores, Chinese)",
|
||||
"invalidEmail": "Invalid email address",
|
||||
"loginRequired": "Please sign in first",
|
||||
"serverError": "Server error. Please try again later."
|
||||
},
|
||||
"account": {
|
||||
"title": "My Account",
|
||||
"profile": "Profile",
|
||||
"favorites": "Favorites",
|
||||
"comments": "My Comments",
|
||||
"adminTitle": "Admin",
|
||||
"username": "Username",
|
||||
"email": "Email",
|
||||
"phone": "Phone",
|
||||
"joinedAt": "Joined",
|
||||
"role": "Role",
|
||||
"roleAdmin": "Admin",
|
||||
"roleUser": "User",
|
||||
"save": "Save Changes",
|
||||
"saving": "Saving...",
|
||||
"saved": "Saved",
|
||||
"saveFailed": "Failed to save. Please try again.",
|
||||
"emptyFavorites": "No favorites yet. Go to the Work page to explore.",
|
||||
"emptyComments": "No comments posted yet",
|
||||
"admin": {
|
||||
"contacts": "Contact Messages",
|
||||
"subscribers": "Newsletter Subscribers",
|
||||
"emptyContacts": "No contact messages",
|
||||
"emptySubscribers": "No subscribers yet",
|
||||
"name": "Name",
|
||||
"email": "Email",
|
||||
"subject": "Subject",
|
||||
"message": "Message",
|
||||
"date": "Date",
|
||||
"delivered": "Delivered to inbox",
|
||||
"notDelivered": "Not delivered (SMTP not configured)"
|
||||
},
|
||||
"adminEntry": "Admin Panel",
|
||||
"changePassword": {
|
||||
"title": "Change Password",
|
||||
"currentPassword": "Current Password",
|
||||
"newPassword": "New Password",
|
||||
"confirmPassword": "Confirm New Password",
|
||||
"submit": "Update Password",
|
||||
"saving": "Updating...",
|
||||
"success": "Password updated",
|
||||
"failed": "Failed to update password",
|
||||
"wrongPassword": "Current password is incorrect",
|
||||
"tooShort": "New password must be at least 8 characters",
|
||||
"mismatch": "Passwords do not match"
|
||||
},
|
||||
"deleteAccount": {
|
||||
"title": "Delete Account",
|
||||
"hint": "This cannot be undone. Your comments and favorites will be removed.",
|
||||
"passwordPlaceholder": "Enter your password to confirm",
|
||||
"confirmButton": "Delete",
|
||||
"cancelButton": "Cancel",
|
||||
"success": "Account deleted",
|
||||
"wrongPassword": "Incorrect password",
|
||||
"confirmText": "Delete your account permanently? This cannot be undone."
|
||||
},
|
||||
"statFavorites": "Favorites",
|
||||
"statComments": "Comments",
|
||||
"statJoined": "Joined",
|
||||
"avatar": {
|
||||
"change": "Change Avatar",
|
||||
"uploading": "Uploading...",
|
||||
"remove": "Remove Avatar",
|
||||
"error": "Failed to update avatar",
|
||||
"success": "Avatar updated"
|
||||
}
|
||||
},
|
||||
"comments": {
|
||||
"title": "Comments",
|
||||
"placeholder": "Share your thoughts...",
|
||||
"submit": "Post Comment",
|
||||
"submitting": "Posting...",
|
||||
"empty": "No comments yet. Be the first to comment.",
|
||||
"loginToComment": "Sign in to join the discussion",
|
||||
"commentError": "Failed to post comment. Please try again."
|
||||
},
|
||||
"favorites": {
|
||||
"add": "Favorite",
|
||||
"remove": "Unfavorite",
|
||||
"added": "Favorited",
|
||||
"loginToFavorite": "Sign in to favorite this project"
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "Search...",
|
||||
"empty": "No matching results"
|
||||
},
|
||||
"pagination": {
|
||||
"loadMore": "Load More",
|
||||
"noMore": "All loaded"
|
||||
},
|
||||
"share": {
|
||||
"article": "Share this article",
|
||||
"copy": "Copy link",
|
||||
"copied": "Link copied",
|
||||
"copyFailed": "Copy failed. Please copy the URL from the address bar."
|
||||
},
|
||||
"lang": {
|
||||
"toEnglish": "English",
|
||||
"toChinese": "中文"
|
||||
},
|
||||
"newsletter": {
|
||||
"subscribed": "Subscribed! Thank you for joining.",
|
||||
"alreadySubscribed": "You are already subscribed",
|
||||
"error": "Subscription failed. Please try again."
|
||||
},
|
||||
"error": {
|
||||
"title": "Something went wrong",
|
||||
"notFound": "Page not found",
|
||||
"serverError": "Server error",
|
||||
"generic": "An error occurred",
|
||||
"backHome": "Back to Home"
|
||||
},
|
||||
"unsubscribe": {
|
||||
"title": "Unsubscribe",
|
||||
"description": "Unsubscribe from ArcticNewOne newsletter:",
|
||||
"unsubscribe": "Unsubscribe",
|
||||
"unsubscribed": "You've been unsubscribed. Thanks for following along!",
|
||||
"already": "This address is no longer subscribed.",
|
||||
"invalid": "The unsubscribe link is invalid or has expired.",
|
||||
"backHome": "Back to Home"
|
||||
}
|
||||
}
|
||||
|
||||
+136
-159
@@ -32,13 +32,7 @@
|
||||
"work": {
|
||||
"label": "作品集 26©",
|
||||
"title": "Work",
|
||||
"viewAll": "查看全部作品",
|
||||
"items": {
|
||||
"forma": "Forma Digital",
|
||||
"oneStep": "One Step",
|
||||
"neroVision": "Nero Vision",
|
||||
"boldMoves": "Bold Moves"
|
||||
}
|
||||
"viewAll": "查看全部作品"
|
||||
},
|
||||
"services": {
|
||||
"title": "我们的服务",
|
||||
@@ -239,34 +233,7 @@
|
||||
"updates": {
|
||||
"title": "最新动态",
|
||||
"subtitle": "探索我们最新的项目、博客文章和行业洞察",
|
||||
"viewAll": "查看全部动态",
|
||||
"categories": {
|
||||
"project": "项目",
|
||||
"blog": "博客",
|
||||
"news": "新闻"
|
||||
},
|
||||
"items": {
|
||||
"project1": {
|
||||
"title": "品牌重塑:现代电商平台设计",
|
||||
"description": "为领先的电商平台打造全新品牌形象和用户体验,提升转化率 45%。"
|
||||
},
|
||||
"blog1": {
|
||||
"title": "2026 年 Web 设计趋势"
|
||||
},
|
||||
"news1": {
|
||||
"title": "公司荣获最佳设计奖"
|
||||
},
|
||||
"project2": {
|
||||
"title": "AI 驱动的智能推荐系统",
|
||||
"description": "开发创新的 AI 推荐引擎,个性化用户体验。"
|
||||
},
|
||||
"blog2": {
|
||||
"title": "如何提升网站性能"
|
||||
},
|
||||
"news2": {
|
||||
"title": "团队规模扩大至 50 人"
|
||||
}
|
||||
}
|
||||
"viewAll": "查看全部动态"
|
||||
},
|
||||
"cta": {
|
||||
"titleLine1": "准备好开始",
|
||||
@@ -297,11 +264,7 @@
|
||||
"newsletterNote": "无广告干扰。仅提供精选更新。",
|
||||
"copyright": "© 2026 北极新一工作室",
|
||||
"address": "贵州省毕节市七星关区滨河西路",
|
||||
"wechat": "微信",
|
||||
"newsletterSuccess": "订阅成功!感谢您的关注。",
|
||||
"newsletterError": "订阅失败,请稍后重试。",
|
||||
"newsletterAlreadySubscribed": "该邮箱已订阅过啦。",
|
||||
"newsletterInvalidEmail": "请输入有效的邮箱地址"
|
||||
"wechat": "微信"
|
||||
},
|
||||
"work": {
|
||||
"title": "我们的作品",
|
||||
@@ -325,51 +288,7 @@
|
||||
"duration": "周期",
|
||||
"services": "服务内容",
|
||||
"visitProject": "访问项目",
|
||||
"relatedProjects": "相关项目",
|
||||
"items": {
|
||||
"forma-digital": {
|
||||
"overview": "Forma Digital 是一个现代化的电商平台,致力于为用户提供无缝的购物体验。我们重新设计了整个用户界面,采用极简主义设计风格,突出产品展示,提升转化率。",
|
||||
"challenge": "客户需要一个既能展示高端产品,又能提供流畅购物体验的平台。原有的网站加载缓慢,用户体验差,转化率低下。",
|
||||
"solution": "我们采用了 React + Next.js 技术栈,实现了服务端渲染和静态生成,大幅提升加载速度。同时重新设计了产品展示页面,采用沉浸式大图展示,配合流畅的动画过渡。",
|
||||
"client": "Forma Digital Inc.",
|
||||
"duration": "3 个月"
|
||||
},
|
||||
"one-step": {
|
||||
"overview": "One Step 是一款专注于健康习惯养成的健身应用。我们为其打造了完整的品牌视觉识别系统,包括 Logo 设计、UI 界面和营销物料。",
|
||||
"challenge": "在竞争激烈的健身应用市场中,如何通过品牌设计脱颖而出,建立独特的品牌认知。",
|
||||
"solution": "我们以「一步一个脚印」为核心理念,设计了简洁有力的品牌标识。采用渐变色彩和圆润的图形语言,传达健康、积极、向上的品牌调性。",
|
||||
"client": "One Step Fitness",
|
||||
"duration": "2 个月"
|
||||
},
|
||||
"nero-vision": {
|
||||
"overview": "Nero Vision 是一个面向创意专业人士的作品集管理平台,帮助设计师和艺术家展示和管理他们的创作。",
|
||||
"challenge": "创意人士需要一个既能完美展示作品,又能方便管理的平台。现有解决方案要么太复杂,要么展示效果不佳。",
|
||||
"solution": "我们采用 Vue.js + Node.js 全栈开发,设计了直观的拖拽式作品管理界面,配合精美的展示模板,让创意人士轻松打造个人品牌。",
|
||||
"client": "Nero Studio",
|
||||
"duration": "4 个月"
|
||||
},
|
||||
"bold-moves": {
|
||||
"overview": "Bold Moves 是一个展示创新建筑设计的交互式网站,通过 3D 可视化技术,让用户身临其境地体验建筑之美。",
|
||||
"challenge": "如何将复杂的建筑设计以直观、吸引人的方式展示给普通用户,同时保持专业性。",
|
||||
"solution": "我们使用 Three.js 实现了高质量的 3D 渲染,配合流畅的交互设计,用户可以从任意角度欣赏建筑细节。同时加入了光影效果和材质展示,提升视觉冲击力。",
|
||||
"client": "Bold Moves Architecture",
|
||||
"duration": "5 个月"
|
||||
},
|
||||
"echo-labs": {
|
||||
"overview": "Echo Labs 是一家 AI 领域的科技创业公司,我们为其打造了完整的品牌视觉识别系统和企业官网。",
|
||||
"challenge": "AI 领域的品牌需要既体现科技感,又要有人文温度,避免过于冷冰冰的技术感。",
|
||||
"solution": "我们以「回声」为概念,设计了富有动感的品牌标识。采用深色主题配合渐变色彩,营造科技感的同时,通过圆润的图形语言增添亲和力。",
|
||||
"client": "Echo Labs AI",
|
||||
"duration": "3 个月"
|
||||
},
|
||||
"flux-api": {
|
||||
"overview": "Flux API 是一个可扩展的 REST API 服务平台,提供全面的文档和开发者工具,帮助开发者快速集成。",
|
||||
"challenge": "API 文档和开发者体验是技术产品的核心竞争力,如何让复杂的 API 变得易于理解和使用。",
|
||||
"solution": "我们设计了交互式 API 文档,支持在线测试和代码生成。同时提供了多语言 SDK 和详细的教程,大幅降低开发者的学习成本。",
|
||||
"client": "Flux Technologies",
|
||||
"duration": "6 个月"
|
||||
}
|
||||
}
|
||||
"relatedProjects": "相关项目"
|
||||
}
|
||||
},
|
||||
"studio": {
|
||||
@@ -408,11 +327,7 @@
|
||||
"sent": "已发送!",
|
||||
"retry": "重试",
|
||||
"successMessage": "消息发送成功!我们会尽快回复您。",
|
||||
"errorMessage": "发送失败,请重试或直接联系我们。",
|
||||
"invalidName": "请填写您的姓名",
|
||||
"invalidEmail": "邮箱格式不正确",
|
||||
"invalidSubject": "主题过长(最多 255 个字符)",
|
||||
"invalidMessage": "留言内容至少 10 个字符"
|
||||
"errorMessage": "发送失败,请重试或直接联系我们。"
|
||||
},
|
||||
"info": {
|
||||
"email": "chenchun{'@'}virtheart.com",
|
||||
@@ -433,71 +348,10 @@
|
||||
"projects": "项目动态",
|
||||
"announcements": "公告通知"
|
||||
},
|
||||
"minutes": "分钟",
|
||||
"detail": {
|
||||
"shareArticle": "分享文章",
|
||||
"relatedArticles": "相关文章",
|
||||
"items": {
|
||||
"design-trends-2026": {
|
||||
"content": "2026 年,设计行业正在经历一场深刻的变革。从极简主义的回归到大胆排版的兴起,从 3D 元素的普及到 AI 辅助设计的成熟,这些趋势正在重新定义数字体验的边界。作为设计从业者,我们需要紧跟这些变化,才能为客户创造更具竞争力的作品。",
|
||||
"section1Title": "极简主义的回归",
|
||||
"section1Content": "在信息过载的时代,用户越来越渴望简洁、清晰的界面。2026 年的极简主义不再是简单的「少即是多」,而是通过精心的信息架构和视觉层次,在有限的空间内传达更多价值。留白不再是空白,而是一种有意为之的设计语言。",
|
||||
"quote": "好的设计不是添加更多,而是去除不必要的。在 2026 年,这一点比以往任何时候都更加重要。",
|
||||
"section2Title": "大胆排版与动态文字",
|
||||
"section2Content": "排版正在从配角变成主角。大尺寸、高对比度的字体设计正在成为品牌表达的重要手段。动态文字效果的普及,让排版不再是静态的装饰,而是能够与用户互动的活元素。",
|
||||
"section3Title": "AI 辅助设计的成熟",
|
||||
"section3Content": "AI 工具正在从「替代设计师」转向「增强设计师」。智能布局建议、自动化配色方案、实时设计反馈等功能,让设计师能够专注于创意和策略,而非重复性的执行工作。"
|
||||
},
|
||||
"forma-digital-launch": {
|
||||
"content": "经过三个月的精心打造,我们很高兴地宣布 Forma Digital 电商平台正式上线!这个项目是我们团队迄今为止最具挑战性的作品之一,也是我们技术实力和设计能力的集中体现。",
|
||||
"section1Title": "项目背景",
|
||||
"section1Content": "Forma Digital 是一家专注于高端家居用品的电商品牌。他们需要一个能够完美展示产品质感、提供流畅购物体验的平台。原有的网站存在加载缓慢、移动端体验差、转化率低等问题。",
|
||||
"quote": "北极新一团队不仅理解我们的需求,更超越了我们的期望。新平台上线后,我们的转化率提升了 45%。",
|
||||
"section2Title": "技术亮点",
|
||||
"section2Content": "我们采用了 React + Next.js 技术栈,实现了服务端渲染和静态生成。通过图片懒加载、代码分割、CDN 加速等技术手段,将首屏加载时间从 4.5 秒降低到 1.2 秒。",
|
||||
"section3Title": "成果展示",
|
||||
"section3Content": "新平台上线后,用户停留时间增加了 60%,跳出率降低了 35%,转化率提升了 45%。客户对新平台的设计和性能都非常满意。"
|
||||
},
|
||||
"studio-expansion": {
|
||||
"content": "随着业务的持续增长和客户需求的不断增加,我们很高兴地宣布 ArcticNewOne 工作室正式扩展!我们将增加新的团队成员,拓展服务能力,为客户提供更优质的数字化解决方案。",
|
||||
"section1Title": "团队扩展",
|
||||
"section1Content": "我们将新增 5 名资深设计师和 3 名高级开发工程师,覆盖前端、后端、UI/UX 等多个领域。这些新成员都拥有丰富的行业经验,曾服务于多家知名企业。",
|
||||
"quote": "人才是我们最宝贵的资产。通过扩展团队,我们能够承接更多项目,同时保持一贯的高品质交付。",
|
||||
"section2Title": "服务升级",
|
||||
"section2Content": "除了现有的网页设计、品牌设计、程序开发等服务,我们还将新增数据可视化、AI 应用开发、AR/VR 体验设计等前沿服务。",
|
||||
"section3Title": "展望未来",
|
||||
"section3Content": "我们计划在未来一年内完成 50+ 项目,服务 30+ 新客户。同时,我们将继续深耕技术创新,探索更多可能性,为客户创造更大价值。"
|
||||
},
|
||||
"ux-research-methods": {
|
||||
"content": "用户体验研究是设计决策的基础。在 2026 年,随着技术的发展和用户行为的变化,UX 研究方法也在不断演进。本文将介绍几种最有效的现代 UX 研究方法。",
|
||||
"section1Title": "远程用户测试",
|
||||
"section1Content": "远程用户测试已经成为 UX 研究的主流方法。通过专业的远程测试平台,我们可以在短时间内招募到全球各地的测试用户,获取更广泛的反馈。",
|
||||
"quote": "远程测试不仅降低了成本,更重要的是让我们能够接触到更真实的用户场景。",
|
||||
"section2Title": "行为数据分析",
|
||||
"section2Content": "通过热力图、滚动深度、点击流等行为数据,我们可以客观地了解用户如何与产品互动。这些数据弥补了传统访谈和问卷的不足,提供了更真实的用户行为洞察。",
|
||||
"section3Title": "AI 辅助分析",
|
||||
"section3Content": "AI 工具正在帮助我们更高效地分析用户反馈。情感分析、主题聚类、趋势预测等功能,让我们能够从海量数据中快速提取有价值的洞察。"
|
||||
},
|
||||
"bold-moves-case-study": {
|
||||
"content": "Bold Moves 是一个展示创新建筑设计的交互式网站项目。本文将深入介绍这个项目的设计思路、技术实现和最终成果。",
|
||||
"section1Title": "设计理念",
|
||||
"section1Content": "Bold Moves 希望通过数字方式展示建筑设计的魅力。我们决定采用 3D 可视化技术,让用户能够从任意角度欣赏建筑细节,获得沉浸式的体验。",
|
||||
"quote": "我们想要的不只是一个展示网站,而是一个能够让用户「走进」建筑的数字空间。",
|
||||
"section2Title": "技术挑战",
|
||||
"section2Content": "高质量的 3D 渲染需要强大的计算能力,而网页端的性能有限。我们通过模型优化、LOD 技术、WebGL 渲染等手段,在保证视觉质量的同时,实现了流畅的交互体验。",
|
||||
"section3Title": "最终成果",
|
||||
"section3Content": "项目上线后获得了广泛好评,赢得了多个设计奖项。用户平均停留时间超过 5 分钟,远高于行业平均水平。"
|
||||
},
|
||||
"new-tools-integration": {
|
||||
"content": "为了更好地服务客户,我们不断扩充和完善我们的工具箱。最近,我们新增了多款实用工具,涵盖设计、开发、协作等多个领域。",
|
||||
"section1Title": "设计工具升级",
|
||||
"section1Content": "我们引入了最新的设计协作平台,支持实时多人编辑、版本管理、设计系统集成等功能。设计师和开发者可以在同一个平台上无缝协作。",
|
||||
"quote": "工欲善其事,必先利其器。好的工具能够大幅提升团队效率。",
|
||||
"section2Title": "开发工具增强",
|
||||
"section2Content": "新增了自动化测试框架、性能监控工具、代码质量检查等开发工具。这些工具帮助我们在开发过程中及时发现和解决问题,保证代码质量。",
|
||||
"section3Title": "协作工具优化",
|
||||
"section3Content": "我们升级了项目管理平台,新增了看板视图、时间追踪、资源分配等功能。项目经理可以更直观地掌控项目进度,团队成员可以更高效地协作。"
|
||||
}
|
||||
}
|
||||
"relatedArticles": "相关文章"
|
||||
}
|
||||
},
|
||||
"auth": {
|
||||
@@ -511,6 +365,7 @@
|
||||
"loginButton": "登录",
|
||||
"loggingIn": "登录中...",
|
||||
"loginError": "登录失败,请检查您的凭据。",
|
||||
"demoHint": "演示:使用任意账号和密码即可登录",
|
||||
"noAccount": "还没有账号?",
|
||||
"createAccount": "立即注册",
|
||||
"register": "注册账号",
|
||||
@@ -531,12 +386,134 @@
|
||||
"invalidPhone": "手机号格式不正确",
|
||||
"alreadyHaveAccount": "已有账号?",
|
||||
"backToLogin": "返回登录",
|
||||
"invalidUsername": "用户名格式不正确(2-50 位,中英文、数字、下划线)",
|
||||
"invalidEmail": "邮箱格式不正确",
|
||||
"passwordTooShort": "密码长度至少 6 位",
|
||||
"usernameTaken": "该用户名已被注册",
|
||||
"usernameTaken": "用户名已被使用",
|
||||
"emailTaken": "该邮箱已被注册",
|
||||
"phoneTaken": "该手机号已被注册",
|
||||
"invalidCredentials": "账号或密码错误"
|
||||
"invalidCredentials": "账号或密码错误",
|
||||
"passwordTooShort": "密码至少需要 8 位",
|
||||
"invalidUsername": "用户名需为 2-20 位字符(字母、数字、下划线、中文)",
|
||||
"invalidEmail": "邮箱格式不正确",
|
||||
"loginRequired": "请先登录后操作",
|
||||
"serverError": "服务器开小差了,请稍后再试"
|
||||
},
|
||||
"account": {
|
||||
"title": "个人中心",
|
||||
"profile": "个人资料",
|
||||
"favorites": "我的收藏",
|
||||
"comments": "我的评论",
|
||||
"adminTitle": "管理面板",
|
||||
"username": "用户名",
|
||||
"email": "邮箱",
|
||||
"phone": "手机号",
|
||||
"joinedAt": "注册时间",
|
||||
"role": "角色",
|
||||
"roleAdmin": "管理员",
|
||||
"roleUser": "普通用户",
|
||||
"save": "保存修改",
|
||||
"saving": "保存中...",
|
||||
"saved": "已保存",
|
||||
"saveFailed": "保存失败,请重试",
|
||||
"emptyFavorites": "还没有收藏任何作品,去「作品」页看看吧",
|
||||
"emptyComments": "还没有发表过评论",
|
||||
"admin": {
|
||||
"contacts": "联系消息",
|
||||
"subscribers": "邮箱订阅",
|
||||
"emptyContacts": "暂无联系消息",
|
||||
"emptySubscribers": "暂无订阅用户",
|
||||
"name": "姓名",
|
||||
"email": "邮箱",
|
||||
"subject": "主题",
|
||||
"message": "留言内容",
|
||||
"date": "时间",
|
||||
"delivered": "已送达邮箱",
|
||||
"notDelivered": "未送达(SMTP 未配置)"
|
||||
},
|
||||
"adminEntry": "进入后台管理",
|
||||
"changePassword": {
|
||||
"title": "修改密码",
|
||||
"currentPassword": "当前密码",
|
||||
"newPassword": "新密码",
|
||||
"confirmPassword": "确认新密码",
|
||||
"submit": "确认修改",
|
||||
"saving": "提交中...",
|
||||
"success": "密码已修改",
|
||||
"failed": "修改失败,请重试",
|
||||
"wrongPassword": "当前密码不正确",
|
||||
"tooShort": "新密码至少需要 8 位",
|
||||
"mismatch": "两次输入的新密码不一致"
|
||||
},
|
||||
"deleteAccount": {
|
||||
"title": "删除账号",
|
||||
"hint": "删除后无法恢复,将同时清除你的评论与收藏。",
|
||||
"passwordPlaceholder": "输入当前密码确认",
|
||||
"confirmButton": "确认删除",
|
||||
"cancelButton": "取消",
|
||||
"success": "账号已删除",
|
||||
"wrongPassword": "密码不正确",
|
||||
"confirmText": "确定要永久删除账号吗?此操作不可撤销。"
|
||||
},
|
||||
"statFavorites": "收藏",
|
||||
"statComments": "评论",
|
||||
"statJoined": "加入于",
|
||||
"avatar": {
|
||||
"change": "更换头像",
|
||||
"uploading": "上传中...",
|
||||
"remove": "移除头像",
|
||||
"error": "头像更新失败",
|
||||
"success": "头像已更新"
|
||||
}
|
||||
},
|
||||
"comments": {
|
||||
"title": "评论",
|
||||
"placeholder": "写下你的想法…",
|
||||
"submit": "发表评论",
|
||||
"submitting": "发表中…",
|
||||
"empty": "还没有评论,来说两句吧",
|
||||
"loginToComment": "登录后参与评论",
|
||||
"commentError": "评论发表失败,请重试"
|
||||
},
|
||||
"favorites": {
|
||||
"add": "收藏",
|
||||
"remove": "取消收藏",
|
||||
"added": "已收藏",
|
||||
"loginToFavorite": "登录后收藏作品"
|
||||
},
|
||||
"search": {
|
||||
"placeholder": "搜索…",
|
||||
"empty": "未找到相关内容"
|
||||
},
|
||||
"pagination": {
|
||||
"loadMore": "加载更多",
|
||||
"noMore": "已加载全部"
|
||||
},
|
||||
"share": {
|
||||
"article": "分享文章",
|
||||
"copy": "复制链接",
|
||||
"copied": "链接已复制",
|
||||
"copyFailed": "复制失败,请手动复制地址栏链接"
|
||||
},
|
||||
"lang": {
|
||||
"toEnglish": "English",
|
||||
"toChinese": "中文"
|
||||
},
|
||||
"newsletter": {
|
||||
"subscribed": "订阅成功,感谢关注!",
|
||||
"alreadySubscribed": "您已在订阅列表中",
|
||||
"error": "订阅失败,请稍后再试"
|
||||
},
|
||||
"error": {
|
||||
"title": "出了点问题",
|
||||
"notFound": "页面不存在",
|
||||
"serverError": "服务器开小差了",
|
||||
"generic": "发生了一个错误",
|
||||
"backHome": "返回首页"
|
||||
},
|
||||
"unsubscribe": {
|
||||
"title": "退订",
|
||||
"description": "确认退订 ArcticNewOne 资讯邮件:",
|
||||
"unsubscribe": "确认退订",
|
||||
"unsubscribed": "已成功退订。感谢你曾经的关注!",
|
||||
"already": "该地址已不在订阅列表中。",
|
||||
"invalid": "退订链接无效或已失效。",
|
||||
"backHome": "返回首页"
|
||||
}
|
||||
}
|
||||
|
||||
+27
-13
@@ -18,6 +18,33 @@ export default defineNuxtConfig({
|
||||
compatibilityDate: '2025-07-15',
|
||||
devtools: { enabled: true },
|
||||
css: ['~/assets/css/tailwind.css'],
|
||||
// 组件注册去掉目录前缀(common/home/layouts 子目录不生成 Common*/Home* 前缀),
|
||||
// 与全站 `<AppLoader>`/`<CommentSection>` 等无前缀引用保持一致
|
||||
components: [{ path: '~/components', pathPrefix: false }],
|
||||
runtimeConfig: {
|
||||
// 服务端私有配置(环境变量自动映射:SESSION_SECRET / DB_PATH / SMTP_* / CONTACT_TO / ADMIN_EMAILS)
|
||||
sessionSecret: '',
|
||||
dbPath: process.env.DB_PATH || (process.env.NODE_ENV === 'production' ? '/data/arcticnewone.db' : '.data/arcticnewone.db'),
|
||||
smtpHost: '',
|
||||
smtpPort: 587,
|
||||
smtpUser: '',
|
||||
smtpPass: '',
|
||||
smtpFrom: '',
|
||||
contactTo: '',
|
||||
adminEmails: '',
|
||||
adminInitialPassword: '',
|
||||
// OSS 文件存储(RustFS / S3 v4 兼容;凭据仅走环境变量注入,绝不写入仓库)
|
||||
ossEndpoint: '',
|
||||
ossAccessKey: '',
|
||||
ossSecretKey: '',
|
||||
ossBucket: '',
|
||||
ossRegion: 'us-east-1',
|
||||
ossPublicBase: '',
|
||||
public: {
|
||||
// 客户端可见(环境变量:NUXT_PUBLIC_SITE_URL),用于 sitemap/robots/og 等绝对链接
|
||||
siteUrl: '',
|
||||
},
|
||||
},
|
||||
modules: [
|
||||
'@nuxtjs/i18n',
|
||||
'@nuxt/hints',
|
||||
@@ -44,17 +71,4 @@ export default defineNuxtConfig({
|
||||
strategy: 'no_prefix',
|
||||
detectBrowserLanguage: false,
|
||||
},
|
||||
runtimeConfig: {
|
||||
// 服务端私有配置(仅服务端可读,通过 NUXT_* 环境变量覆盖,绝不暴露给客户端)
|
||||
databaseUrl: '', // NUXT_DATABASE_URL 例: postgres://user:pass@host:5432/db
|
||||
jwtSecret: 'dev-only-secret-change-in-production', // NUXT_JWT_SECRET
|
||||
smtp: {
|
||||
host: '', // NUXT_SMTP_HOST
|
||||
port: 465, // NUXT_SMTP_PORT
|
||||
user: '', // NUXT_SMTP_USER
|
||||
pass: '', // NUXT_SMTP_PASS
|
||||
from: '', // NUXT_SMTP_FROM
|
||||
contactTo: '', // NUXT_SMTP_CONTACT_TO(联系表单/订阅通知收件人)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
+6
-6
@@ -8,20 +8,19 @@
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare",
|
||||
"start": "node .output/server/index.mjs"
|
||||
"start": "node .output/server/index.mjs",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nuxt/hints": "1.0.3",
|
||||
"@nuxt/icon": "2.2.1",
|
||||
"@nuxtjs/i18n": "10.3.0",
|
||||
"@pinia/nuxt": "0.11.3",
|
||||
"bcryptjs": "^3.0.3",
|
||||
"better-sqlite3": "^13.0.2",
|
||||
"gsap": "^3.15.0",
|
||||
"jose": "^6.2.8",
|
||||
"lenis": "^1.3.23",
|
||||
"nodemailer": "^9.0.4",
|
||||
"nuxt": "^4.4.2",
|
||||
"pg": "^8.22.0",
|
||||
"pinia": "^3.0.4",
|
||||
"vue": "^3.5.32",
|
||||
"vue-router": "^5.0.4"
|
||||
@@ -29,7 +28,8 @@
|
||||
"devDependencies": {
|
||||
"@iconify-json/ph": "1.2.2",
|
||||
"@nuxtjs/tailwindcss": "6.14.0",
|
||||
"@types/nodemailer": "^8.0.1",
|
||||
"@types/pg": "^8.20.4"
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
"@types/nodemailer": "^6.4.17",
|
||||
"vitest": "^4.1.10"
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+267
-167
@@ -10,25 +10,22 @@ importers:
|
||||
dependencies:
|
||||
'@nuxt/hints':
|
||||
specifier: 1.0.3
|
||||
version: 1.0.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(srvx@0.11.15)(supports-color@10.2.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))
|
||||
version: 1.0.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(better-sqlite3@13.0.2)(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(srvx@0.11.15)(supports-color@10.2.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vitest@4.1.10(@types/node@26.1.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3)))(vue@3.5.33(typescript@6.0.3))
|
||||
'@nuxt/icon':
|
||||
specifier: 2.2.1
|
||||
version: 2.2.1(magicast@0.5.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))
|
||||
'@nuxtjs/i18n':
|
||||
specifier: 10.3.0
|
||||
version: 10.3.0(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@vue/compiler-dom@3.5.33)(db0@0.3.4)(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup@4.60.2)(supports-color@10.2.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))
|
||||
version: 10.3.0(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@vue/compiler-dom@3.5.33)(db0@0.3.4(better-sqlite3@13.0.2))(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup@4.60.2)(supports-color@10.2.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))
|
||||
'@pinia/nuxt':
|
||||
specifier: 0.11.3
|
||||
version: 0.11.3(magicast@0.5.2)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))
|
||||
bcryptjs:
|
||||
specifier: ^3.0.3
|
||||
version: 3.0.3
|
||||
better-sqlite3:
|
||||
specifier: ^13.0.2
|
||||
version: 13.0.2
|
||||
gsap:
|
||||
specifier: ^3.15.0
|
||||
version: 3.15.0
|
||||
jose:
|
||||
specifier: ^6.2.8
|
||||
version: 6.2.8
|
||||
lenis:
|
||||
specifier: ^1.3.23
|
||||
version: 1.3.23(@nuxt/kit@4.4.2(magicast@0.5.2))(vue@3.5.33(typescript@6.0.3))
|
||||
@@ -37,10 +34,7 @@ importers:
|
||||
version: 9.0.4
|
||||
nuxt:
|
||||
specifier: ^4.4.2
|
||||
version: 4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(cac@6.7.14)(db0@0.3.4)(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3)
|
||||
pg:
|
||||
specifier: ^8.22.0
|
||||
version: 8.22.0
|
||||
version: 4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(better-sqlite3@13.0.2)(cac@6.7.14)(db0@0.3.4(better-sqlite3@13.0.2))(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3)
|
||||
pinia:
|
||||
specifier: ^3.0.4
|
||||
version: 3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3))
|
||||
@@ -57,12 +51,15 @@ importers:
|
||||
'@nuxtjs/tailwindcss':
|
||||
specifier: 6.14.0
|
||||
version: 6.14.0(magicast@0.5.2)(supports-color@10.2.2)(yaml@2.8.3)
|
||||
'@types/better-sqlite3':
|
||||
specifier: ^7.6.13
|
||||
version: 7.6.13
|
||||
'@types/nodemailer':
|
||||
specifier: ^8.0.1
|
||||
version: 8.0.1
|
||||
'@types/pg':
|
||||
specifier: ^8.20.4
|
||||
version: 8.20.4
|
||||
specifier: ^6.4.17
|
||||
version: 6.4.24
|
||||
vitest:
|
||||
specifier: ^4.1.10
|
||||
version: 4.1.10(@types/node@26.1.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))
|
||||
|
||||
packages:
|
||||
|
||||
@@ -2011,9 +2008,21 @@ packages:
|
||||
'@speed-highlight/core@1.2.15':
|
||||
resolution: {integrity: sha512-BMq1K3DsElxDWawkX6eLg9+CKJrTVGCBAWVuHXVUV2u0s2711qiChLSId6ikYPfxhdYocLNt3wWwSvDiTvFabw==}
|
||||
|
||||
'@standard-schema/spec@1.1.0':
|
||||
resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
resolution: {integrity: sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==}
|
||||
|
||||
'@types/better-sqlite3@7.6.13':
|
||||
resolution: {integrity: sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==}
|
||||
|
||||
'@types/chai@5.2.3':
|
||||
resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==}
|
||||
|
||||
'@types/deep-eql@4.0.2':
|
||||
resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==}
|
||||
|
||||
'@types/esrecurse@4.3.1':
|
||||
resolution: {integrity: sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==}
|
||||
|
||||
@@ -2029,11 +2038,8 @@ packages:
|
||||
'@types/node@26.1.2':
|
||||
resolution: {integrity: sha512-Vu4a5UFA9rIIFJ7rB/Vaafh9lrCQszopTCx6KjFboXTGQbPNasehVR5TEiithSDGyd1DEiUByggTZsg8jukeIg==}
|
||||
|
||||
'@types/nodemailer@8.0.1':
|
||||
resolution: {integrity: sha512-PxpaInm8V1JQDd4j0ds5HfvWQk8JupS1C0Picb96QJsrrRDjBH+DlK7L4ZdNSqNULhiZRQHc40nLVShaGxXAMw==}
|
||||
|
||||
'@types/pg@8.20.4':
|
||||
resolution: {integrity: sha512-Jz7UDOlIiFJuacC0TlBoLyNtmwlA/wpIyPDd3tvUqlRM+HzkWy2xUgpFpaXtbfTAFF6sIGq5lsCDBdJnhky1Xg==}
|
||||
'@types/nodemailer@6.4.24':
|
||||
resolution: {integrity: sha512-Ww4u0rT9wQNXh4JiQaIwx3QWdcOFXzOjQA2zc+jtFYNmQiT4mIUqcDin51bDFdkzKubFnQCZNK7FIHlPKQ/q9w==}
|
||||
|
||||
'@types/resolve@1.20.2':
|
||||
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
|
||||
@@ -2092,6 +2098,35 @@ packages:
|
||||
vite: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
vue: ^3.2.25
|
||||
|
||||
'@vitest/expect@4.1.10':
|
||||
resolution: {integrity: sha512-YsCn+qAk1GWjQOWFEsEcL2gNQ0zmVmQu3T03qP6UyjhtmdtwtbuI+DASn/7iQB3HGTXkdBwGddzxPlmiql5vlA==}
|
||||
|
||||
'@vitest/mocker@4.1.10':
|
||||
resolution: {integrity: sha512-v0xaezt+DKEmKfaxg133ldzADrwLGd7Ze1MfQQTYfvs8OqZIwbxyxaYURivwV7sWy5fqn3rH5uOrSp07bp44Ow==}
|
||||
peerDependencies:
|
||||
msw: ^2.4.9
|
||||
vite: ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
peerDependenciesMeta:
|
||||
msw:
|
||||
optional: true
|
||||
vite:
|
||||
optional: true
|
||||
|
||||
'@vitest/pretty-format@4.1.10':
|
||||
resolution: {integrity: sha512-W1HsjSH4MXQ9YfmmhLAoIYf1HRfekQCGngeIgcei6MP5QQGWUe0gkopdZQaVCFO+JDJMrAJGwa5pRpNpvy4P8Q==}
|
||||
|
||||
'@vitest/runner@4.1.10':
|
||||
resolution: {integrity: sha512-IKI6kpIH+LmpROplyLwBBaCfMgOZOMsygVa6BARD6ahA04VRuJSa6OaVG7kRvSEMD870Vd91rSSw0eegtWyLGg==}
|
||||
|
||||
'@vitest/snapshot@4.1.10':
|
||||
resolution: {integrity: sha512-xRkfOT1qpTAi/Ti4Y1LtfRc3kEuqxGw59eN2jN9pRWMtS/XDevekhcFSqvQqjUNGksfjMJu3Y+oJ+4Ypn2OaJw==}
|
||||
|
||||
'@vitest/spy@4.1.10':
|
||||
resolution: {integrity: sha512-PLf/Ugvoq5wO/b4rwYCR1h2PSIdXz7wnkQFMiUpLdtM7l6pqVFcQIBEHyT1+l+cj7mNwAfZHzqXqDyjvOuwbDw==}
|
||||
|
||||
'@vitest/utils@4.1.10':
|
||||
resolution: {integrity: sha512-fy9am/HWxbaGt/Sawrp90vt6Y6jQwf1RX77cz3uwoJwJVMli/e1IEwRPnMNJ7vKfPTwo0diXifkpPvwH9v7nGA==}
|
||||
|
||||
'@vue-macros/common@3.1.2':
|
||||
resolution: {integrity: sha512-h9t4ArDdniO9ekYHAD95t9AZcAbb19lEGK+26iAjUODOIJKmObDNBSe4+6ELQAA3vtYiFPPBtHh7+cQCKi3Dng==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
@@ -2250,6 +2285,10 @@ packages:
|
||||
argparse@2.0.1:
|
||||
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
|
||||
|
||||
assertion-error@2.0.1:
|
||||
resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
ast-kit@2.2.0:
|
||||
resolution: {integrity: sha512-m1Q/RaVOnTp9JxPX+F+Zn7IcLYMzM8kZofDImfsKZd8MbR+ikdOzTeztStWqfrqIxZnYWryyI9ePm3NGjnZgGw==}
|
||||
engines: {node: '>=20.19.0'}
|
||||
@@ -2339,9 +2378,9 @@ packages:
|
||||
engines: {node: '>=6.0.0'}
|
||||
hasBin: true
|
||||
|
||||
bcryptjs@3.0.3:
|
||||
resolution: {integrity: sha512-GlF5wPWnSa/X5LKM1o0wz0suXIINz1iHRLvTS+sLyi7XPbe5ycmYI3DlZqVGZZtDgl4DmasFg7gOB3JYbphV5g==}
|
||||
hasBin: true
|
||||
better-sqlite3@13.0.2:
|
||||
resolution: {integrity: sha512-jW6oufeDhXZaiX9Lw5A+oerVClx4iFrI6uDj1zu7SqUAjak9vbJvA0NEcKLNxHiQHb6kYCoFzzXYV0YOauhV3g==}
|
||||
engines: {node: '>=22'}
|
||||
|
||||
binary-extensions@2.3.0:
|
||||
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
|
||||
@@ -2426,6 +2465,10 @@ packages:
|
||||
caniuse-lite@1.0.30001790:
|
||||
resolution: {integrity: sha512-bOoxfJPyYo+ds6W0YfptaCWbFnJYjh2Y1Eow5lRv+vI2u8ganPZqNm1JwNh0t2ELQCqIWg4B3dWEusgAmsoyOw==}
|
||||
|
||||
chai@6.2.2:
|
||||
resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
chalk@4.1.2:
|
||||
resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==}
|
||||
engines: {node: '>=10'}
|
||||
@@ -2919,6 +2962,10 @@ packages:
|
||||
resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==}
|
||||
engines: {node: '>=16.17'}
|
||||
|
||||
expect-type@1.4.0:
|
||||
resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
exsolve@1.0.8:
|
||||
resolution: {integrity: sha512-LmDxfWXwcTArk8fUEnOfSZpHOJ6zOMUJKOtFLFqJLoKJetuQG874Uc7/Kki7zFLzYybmZhp1M7+98pfMqeX8yA==}
|
||||
|
||||
@@ -3340,9 +3387,6 @@ packages:
|
||||
resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==}
|
||||
hasBin: true
|
||||
|
||||
jose@6.2.8:
|
||||
resolution: {integrity: sha512-Bsdjwm3Qsd/P0jR+BHDe3LytDfY7WBq2HmCCLIwuVRHMuEC9ae7/R474GIUdF1NgCyZjzVo/A9DOiOBtXq8ZoQ==}
|
||||
|
||||
js-tokens@4.0.0:
|
||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||
|
||||
@@ -3635,6 +3679,10 @@ packages:
|
||||
node-addon-api@7.1.1:
|
||||
resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==}
|
||||
|
||||
node-addon-api@8.9.1:
|
||||
resolution: {integrity: sha512-4eUQWVPCUUUiBjLnHS3cXWeC6ryoPUc0U3rP7IuzapoGbzMqd/r6KKO0clr0b+snQhsrueFEhCZDdK+LK7hxKg==}
|
||||
engines: {node: ^18 || ^20 || >= 21}
|
||||
|
||||
node-fetch-native@1.6.7:
|
||||
resolution: {integrity: sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==}
|
||||
|
||||
@@ -3849,40 +3897,6 @@ packages:
|
||||
perfect-debounce@2.1.0:
|
||||
resolution: {integrity: sha512-LjgdTytVFXeUgtHZr9WYViYSM/g8MkcTPYDlPa3cDqMirHjKiSZPYd6DoL7pK8AJQr+uWkQvCjHNdiMqsrJs+g==}
|
||||
|
||||
pg-cloudflare@1.4.0:
|
||||
resolution: {integrity: sha512-Vo7z/6rrQYxpNRylp4Tlob2elzbh+N/MOQbxFVWCxS7oEx6jF53GTJFxK2WWpKuBRkmiin4Mt+xofFDjx09R0A==}
|
||||
|
||||
pg-connection-string@2.14.0:
|
||||
resolution: {integrity: sha512-XwWDGcLRGCXAR8F/AM5bG7Q+A3Wm2s6QeEjlOKZLlH3UYcguiqCWKyWXVag5TLTIjR7oOJUY8kcADaZgWPyLeg==}
|
||||
|
||||
pg-int8@1.0.1:
|
||||
resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==}
|
||||
engines: {node: '>=4.0.0'}
|
||||
|
||||
pg-pool@3.14.0:
|
||||
resolution: {integrity: sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==}
|
||||
peerDependencies:
|
||||
pg: '>=8.0'
|
||||
|
||||
pg-protocol@1.15.0:
|
||||
resolution: {integrity: sha512-cq9sECI5s0+uPUXjbz8ioyPJni6RzsRib0US67i5IoTZKw8fNeYlVE7u8F4dG7vEJJtc5wdD1K189lCCUwqWTQ==}
|
||||
|
||||
pg-types@2.2.0:
|
||||
resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
pg@8.22.0:
|
||||
resolution: {integrity: sha512-8wih1vVIBMxoUM2oB4soJsD9tDnDpLv4OXBJ+EJzFsvycD+lfyIreC2gGHq78f8jbLLt+bvlPTFdFZfJkOuzAA==}
|
||||
engines: {node: '>= 16.0.0'}
|
||||
peerDependencies:
|
||||
pg-native: '>=3.0.1'
|
||||
peerDependenciesMeta:
|
||||
pg-native:
|
||||
optional: true
|
||||
|
||||
pgpass@1.0.5:
|
||||
resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==}
|
||||
|
||||
picocolors@1.1.1:
|
||||
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||
|
||||
@@ -4143,22 +4157,6 @@ packages:
|
||||
resolution: {integrity: sha512-pMMHxBOZKFU6HgAZ4eyGnwXF/EvPGGqUr0MnZ5+99485wwW41kW91A4LOGxSHhgugZmSChL5AlElNdwlNgcnLQ==}
|
||||
engines: {node: ^10 || ^12 || >=14}
|
||||
|
||||
postgres-array@2.0.0:
|
||||
resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==}
|
||||
engines: {node: '>=4'}
|
||||
|
||||
postgres-bytea@1.0.1:
|
||||
resolution: {integrity: sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
postgres-date@1.0.7:
|
||||
resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
postgres-interval@1.1.0:
|
||||
resolution: {integrity: sha512-txJzyrdoPw5F06xk3BEtzl46JCr6qU2DM8gfulxBFgqGKmfREbrcFyVqllttHuqWtafoBmowgJtGjm6kPGA/bg==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
powershell-utils@0.1.0:
|
||||
resolution: {integrity: sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==}
|
||||
engines: {node: '>=20'}
|
||||
@@ -4368,6 +4366,9 @@ packages:
|
||||
resolution: {integrity: sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
siginfo@2.0.0:
|
||||
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
|
||||
|
||||
signal-exit@4.1.0:
|
||||
resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -4409,15 +4410,14 @@ packages:
|
||||
resolution: {integrity: sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
split2@4.2.0:
|
||||
resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==}
|
||||
engines: {node: '>= 10.x'}
|
||||
|
||||
srvx@0.11.15:
|
||||
resolution: {integrity: sha512-iXsux0UcOjdvs0LCMa2Ws3WwcDUozA3JN3BquNXkaFPP7TpRqgunKdEgoZ/uwb1J6xaYHfxtz9Twlh6yzwM6Tg==}
|
||||
engines: {node: '>=20.16.0'}
|
||||
hasBin: true
|
||||
|
||||
stackback@0.0.2:
|
||||
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
|
||||
|
||||
standard-as-callback@2.1.0:
|
||||
resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==}
|
||||
|
||||
@@ -4554,6 +4554,9 @@ packages:
|
||||
tiny-invariant@1.3.3:
|
||||
resolution: {integrity: sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==}
|
||||
|
||||
tinybench@2.9.0:
|
||||
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
|
||||
|
||||
tinyclip@0.1.12:
|
||||
resolution: {integrity: sha512-Ae3OVUqifDw0wBriIBS7yVaW44Dp6eSHQcyq4Igc7eN2TJH/2YsicswaW+J/OuMvhpDPOKEgpAZCjkb4hpoyeA==}
|
||||
engines: {node: ^16.14.0 || >= 17.3.0}
|
||||
@@ -4566,6 +4569,10 @@ packages:
|
||||
resolution: {integrity: sha512-pn99VhoACYR8nFHhxqix+uvsbXineAasWm5ojXoN8xEwK5Kd3/TrhNn1wByuD52UxWRLy8pu+kRMniEi6Eq9Zg==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
tinyrainbow@3.1.1:
|
||||
resolution: {integrity: sha512-yau8yJdTt989Mm0Bd/236QnzEiPf2xLLTqUZRUJOo/3CB078LSwzei343DgtJVmfJKJE3TMINY1u42SQsP6mXw==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
|
||||
to-regex-range@5.0.1:
|
||||
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
||||
engines: {node: '>=8.0'}
|
||||
@@ -4881,6 +4888,47 @@ packages:
|
||||
yaml:
|
||||
optional: true
|
||||
|
||||
vitest@4.1.10:
|
||||
resolution: {integrity: sha512-R9jUTe5S4Qb0HCd4TNqpC7oGcrMssMRGXLW80ubjWsW9VH5GF8y1Y0SFLY9AbqSk6nt0PnOx4H4WNJYZ13GUPw==}
|
||||
engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@edge-runtime/vm': '*'
|
||||
'@opentelemetry/api': ^1.9.0
|
||||
'@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0
|
||||
'@vitest/browser-playwright': 4.1.10
|
||||
'@vitest/browser-preview': 4.1.10
|
||||
'@vitest/browser-webdriverio': 4.1.10
|
||||
'@vitest/coverage-istanbul': 4.1.10
|
||||
'@vitest/coverage-v8': 4.1.10
|
||||
'@vitest/ui': 4.1.10
|
||||
happy-dom: '*'
|
||||
jsdom: '*'
|
||||
vite: ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
peerDependenciesMeta:
|
||||
'@edge-runtime/vm':
|
||||
optional: true
|
||||
'@opentelemetry/api':
|
||||
optional: true
|
||||
'@types/node':
|
||||
optional: true
|
||||
'@vitest/browser-playwright':
|
||||
optional: true
|
||||
'@vitest/browser-preview':
|
||||
optional: true
|
||||
'@vitest/browser-webdriverio':
|
||||
optional: true
|
||||
'@vitest/coverage-istanbul':
|
||||
optional: true
|
||||
'@vitest/coverage-v8':
|
||||
optional: true
|
||||
'@vitest/ui':
|
||||
optional: true
|
||||
happy-dom:
|
||||
optional: true
|
||||
jsdom:
|
||||
optional: true
|
||||
|
||||
vscode-uri@3.1.0:
|
||||
resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==}
|
||||
|
||||
@@ -4941,6 +4989,11 @@ packages:
|
||||
engines: {node: ^20.17.0 || >=22.9.0}
|
||||
hasBin: true
|
||||
|
||||
why-is-node-running@2.3.0:
|
||||
resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
|
||||
engines: {node: '>=8'}
|
||||
hasBin: true
|
||||
|
||||
word-wrap@1.2.5:
|
||||
resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -4980,10 +5033,6 @@ packages:
|
||||
resolution: {integrity: sha512-g/eziiSUNBSsdDJtCLB8bdYEUMj4jR7AGeUo96p/3dTafgjHhpF4RiCFPiRILwjQoDXx5MqkBr4fwWtR3Ky4Wg==}
|
||||
engines: {node: '>=20'}
|
||||
|
||||
xtend@4.0.2:
|
||||
resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==}
|
||||
engines: {node: '>=0.4'}
|
||||
|
||||
y18n@5.0.8:
|
||||
resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==}
|
||||
engines: {node: '>=10'}
|
||||
@@ -5773,7 +5822,7 @@ snapshots:
|
||||
- utf-8-validate
|
||||
- vue
|
||||
|
||||
'@nuxt/hints@1.0.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(srvx@0.11.15)(supports-color@10.2.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))':
|
||||
'@nuxt/hints@1.0.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(better-sqlite3@13.0.2)(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(srvx@0.11.15)(supports-color@10.2.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vitest@4.1.10(@types/node@26.1.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3)))(vue@3.5.33(typescript@6.0.3))':
|
||||
dependencies:
|
||||
'@nuxt/devtools-kit': 3.2.4(magicast@0.5.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))
|
||||
'@nuxt/kit': 4.4.2(magicast@0.5.2)
|
||||
@@ -5781,15 +5830,15 @@ snapshots:
|
||||
defu: 6.1.7
|
||||
devalue: 5.7.1
|
||||
h3: 1.15.11
|
||||
html-validate: 10.13.1
|
||||
html-validate: 10.13.1(vitest@4.1.10(@types/node@26.1.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3)))
|
||||
knitwork: 1.3.0
|
||||
magic-string: 0.30.21
|
||||
nitropack: 2.13.3(srvx@0.11.15)(supports-color@10.2.2)
|
||||
nitropack: 2.13.3(better-sqlite3@13.0.2)(srvx@0.11.15)(supports-color@10.2.2)
|
||||
oxc-parser: 0.121.0(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)
|
||||
prettier: 3.8.3
|
||||
sirv: 3.0.2
|
||||
unplugin: 3.0.0
|
||||
unstorage: 1.17.5(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2))
|
||||
unstorage: 1.17.5(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2))
|
||||
valibot: 1.3.1(typescript@6.0.3)
|
||||
vite-plugin-vue-tracer: 1.3.0(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))
|
||||
web-vitals: 5.2.0
|
||||
@@ -5911,7 +5960,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- magicast
|
||||
|
||||
'@nuxt/nitro-server@4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(nuxt@4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(cac@6.7.14)(db0@0.3.4)(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3))(srvx@0.11.15)(supports-color@10.2.2)(typescript@6.0.3)':
|
||||
'@nuxt/nitro-server@4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(better-sqlite3@13.0.2)(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(nuxt@4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(better-sqlite3@13.0.2)(cac@6.7.14)(db0@0.3.4(better-sqlite3@13.0.2))(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3))(srvx@0.11.15)(supports-color@10.2.2)(typescript@6.0.3)':
|
||||
dependencies:
|
||||
'@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.0(supports-color@10.2.2))
|
||||
'@nuxt/devalue': 2.0.2
|
||||
@@ -5929,8 +5978,8 @@ snapshots:
|
||||
impound: 1.1.5
|
||||
klona: 2.0.6
|
||||
mocked-exports: 0.1.1
|
||||
nitropack: 2.13.3(srvx@0.11.15)(supports-color@10.2.2)
|
||||
nuxt: 4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(cac@6.7.14)(db0@0.3.4)(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3)
|
||||
nitropack: 2.13.3(better-sqlite3@13.0.2)(srvx@0.11.15)(supports-color@10.2.2)
|
||||
nuxt: 4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(better-sqlite3@13.0.2)(cac@6.7.14)(db0@0.3.4(better-sqlite3@13.0.2))(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3)
|
||||
nypm: 0.6.6
|
||||
ohash: 2.0.11
|
||||
pathe: 2.0.3
|
||||
@@ -5939,7 +5988,7 @@ snapshots:
|
||||
std-env: 4.1.0
|
||||
ufo: 1.6.3
|
||||
unctx: 2.5.0
|
||||
unstorage: 1.17.5(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2))
|
||||
unstorage: 1.17.5(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2))
|
||||
vue: 3.5.33(typescript@6.0.3)
|
||||
vue-bundle-renderer: 2.2.0
|
||||
vue-devtools-stub: 0.1.0
|
||||
@@ -5998,7 +6047,7 @@ snapshots:
|
||||
rc9: 3.0.1
|
||||
std-env: 4.1.0
|
||||
|
||||
'@nuxt/vite-builder@4.4.2(56d15aa3ff77376966f610d34ec153ec)':
|
||||
'@nuxt/vite-builder@4.4.2(33c2df0c5ddd0297914f3b5431b96b75)':
|
||||
dependencies:
|
||||
'@nuxt/kit': 4.4.2(magicast@0.5.2)
|
||||
'@rollup/plugin-replace': 6.0.3(rollup@4.60.2)
|
||||
@@ -6016,7 +6065,7 @@ snapshots:
|
||||
magic-string: 0.30.21
|
||||
mlly: 1.8.2
|
||||
mocked-exports: 0.1.1
|
||||
nuxt: 4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(cac@6.7.14)(db0@0.3.4)(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3)
|
||||
nuxt: 4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(better-sqlite3@13.0.2)(cac@6.7.14)(db0@0.3.4(better-sqlite3@13.0.2))(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3)
|
||||
nypm: 0.6.6
|
||||
pathe: 2.0.3
|
||||
pkg-types: 2.3.0
|
||||
@@ -6058,7 +6107,7 @@ snapshots:
|
||||
- vue-tsc
|
||||
- yaml
|
||||
|
||||
'@nuxtjs/i18n@10.3.0(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@vue/compiler-dom@3.5.33)(db0@0.3.4)(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup@4.60.2)(supports-color@10.2.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))':
|
||||
'@nuxtjs/i18n@10.3.0(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@vue/compiler-dom@3.5.33)(db0@0.3.4(better-sqlite3@13.0.2))(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup@4.60.2)(supports-color@10.2.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))':
|
||||
dependencies:
|
||||
'@intlify/core': 11.4.0
|
||||
'@intlify/h3': 0.7.4
|
||||
@@ -6083,7 +6132,7 @@ snapshots:
|
||||
ufo: 1.6.3
|
||||
unplugin: 2.3.11
|
||||
unrouting: 0.1.7
|
||||
unstorage: 1.17.5(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2))
|
||||
unstorage: 1.17.5(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2))
|
||||
vue-i18n: 11.4.0(vue@3.5.33(typescript@6.0.3))
|
||||
vue-router: 5.0.6(@vue/compiler-sfc@3.5.33)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(vue@3.5.33(typescript@6.0.3))
|
||||
transitivePeerDependencies:
|
||||
@@ -6796,11 +6845,24 @@ snapshots:
|
||||
|
||||
'@speed-highlight/core@1.2.15': {}
|
||||
|
||||
'@standard-schema/spec@1.1.0': {}
|
||||
|
||||
'@tybys/wasm-util@0.10.1':
|
||||
dependencies:
|
||||
tslib: 2.8.1
|
||||
optional: true
|
||||
|
||||
'@types/better-sqlite3@7.6.13':
|
||||
dependencies:
|
||||
'@types/node': 26.1.2
|
||||
|
||||
'@types/chai@5.2.3':
|
||||
dependencies:
|
||||
'@types/deep-eql': 4.0.2
|
||||
assertion-error: 2.0.1
|
||||
|
||||
'@types/deep-eql@4.0.2': {}
|
||||
|
||||
'@types/esrecurse@4.3.1': {}
|
||||
|
||||
'@types/estree@1.0.8': {}
|
||||
@@ -6813,16 +6875,10 @@ snapshots:
|
||||
dependencies:
|
||||
undici-types: 8.3.0
|
||||
|
||||
'@types/nodemailer@8.0.1':
|
||||
'@types/nodemailer@6.4.24':
|
||||
dependencies:
|
||||
'@types/node': 26.1.2
|
||||
|
||||
'@types/pg@8.20.4':
|
||||
dependencies:
|
||||
'@types/node': 26.1.2
|
||||
pg-protocol: 1.15.0
|
||||
pg-types: 2.2.0
|
||||
|
||||
'@types/resolve@1.20.2': {}
|
||||
|
||||
'@typescript-eslint/project-service@8.59.0(supports-color@10.2.2)(typescript@6.0.3)':
|
||||
@@ -6908,6 +6964,47 @@ snapshots:
|
||||
vite: 7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3)
|
||||
vue: 3.5.33(typescript@6.0.3)
|
||||
|
||||
'@vitest/expect@4.1.10':
|
||||
dependencies:
|
||||
'@standard-schema/spec': 1.1.0
|
||||
'@types/chai': 5.2.3
|
||||
'@vitest/spy': 4.1.10
|
||||
'@vitest/utils': 4.1.10
|
||||
chai: 6.2.2
|
||||
tinyrainbow: 3.1.1
|
||||
|
||||
'@vitest/mocker@4.1.10(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))':
|
||||
dependencies:
|
||||
'@vitest/spy': 4.1.10
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.21
|
||||
optionalDependencies:
|
||||
vite: 7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3)
|
||||
|
||||
'@vitest/pretty-format@4.1.10':
|
||||
dependencies:
|
||||
tinyrainbow: 3.1.1
|
||||
|
||||
'@vitest/runner@4.1.10':
|
||||
dependencies:
|
||||
'@vitest/utils': 4.1.10
|
||||
pathe: 2.0.3
|
||||
|
||||
'@vitest/snapshot@4.1.10':
|
||||
dependencies:
|
||||
'@vitest/pretty-format': 4.1.10
|
||||
'@vitest/utils': 4.1.10
|
||||
magic-string: 0.30.21
|
||||
pathe: 2.0.3
|
||||
|
||||
'@vitest/spy@4.1.10': {}
|
||||
|
||||
'@vitest/utils@4.1.10':
|
||||
dependencies:
|
||||
'@vitest/pretty-format': 4.1.10
|
||||
convert-source-map: 2.0.0
|
||||
tinyrainbow: 3.1.1
|
||||
|
||||
'@vue-macros/common@3.1.2(vue@3.5.33(typescript@6.0.3))':
|
||||
dependencies:
|
||||
'@vue/compiler-sfc': 3.5.33
|
||||
@@ -7124,6 +7221,8 @@ snapshots:
|
||||
|
||||
argparse@2.0.1: {}
|
||||
|
||||
assertion-error@2.0.1: {}
|
||||
|
||||
ast-kit@2.2.0:
|
||||
dependencies:
|
||||
'@babel/parser': 7.29.2
|
||||
@@ -7191,7 +7290,9 @@ snapshots:
|
||||
|
||||
baseline-browser-mapping@2.10.22: {}
|
||||
|
||||
bcryptjs@3.0.3: {}
|
||||
better-sqlite3@13.0.2:
|
||||
dependencies:
|
||||
node-addon-api: 8.9.1
|
||||
|
||||
binary-extensions@2.3.0: {}
|
||||
|
||||
@@ -7288,6 +7389,8 @@ snapshots:
|
||||
|
||||
caniuse-lite@1.0.30001790: {}
|
||||
|
||||
chai@6.2.2: {}
|
||||
|
||||
chalk@4.1.2:
|
||||
dependencies:
|
||||
ansi-styles: 4.3.0
|
||||
@@ -7495,7 +7598,9 @@ snapshots:
|
||||
|
||||
csstype@3.2.3: {}
|
||||
|
||||
db0@0.3.4: {}
|
||||
db0@0.3.4(better-sqlite3@13.0.2):
|
||||
optionalDependencies:
|
||||
better-sqlite3: 13.0.2
|
||||
|
||||
debug@3.2.7(supports-color@10.2.2):
|
||||
dependencies:
|
||||
@@ -7794,6 +7899,8 @@ snapshots:
|
||||
signal-exit: 4.1.0
|
||||
strip-final-newline: 3.0.0
|
||||
|
||||
expect-type@1.4.0: {}
|
||||
|
||||
exsolve@1.0.8: {}
|
||||
|
||||
exsolve@1.1.1: {}
|
||||
@@ -8002,7 +8109,7 @@ snapshots:
|
||||
|
||||
hookable@6.1.1: {}
|
||||
|
||||
html-validate@10.13.1:
|
||||
html-validate@10.13.1(vitest@4.1.10(@types/node@26.1.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))):
|
||||
dependencies:
|
||||
'@html-validate/stylish': 5.2.0
|
||||
'@sidvind/better-ajv-errors': 5.0.0(ajv@8.20.0)
|
||||
@@ -8012,6 +8119,8 @@ snapshots:
|
||||
minimist: 1.2.8
|
||||
prompts: 2.4.2
|
||||
semver: 7.7.4
|
||||
optionalDependencies:
|
||||
vitest: 4.1.10(@types/node@26.1.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))
|
||||
|
||||
http-assert@1.5.0:
|
||||
dependencies:
|
||||
@@ -8189,8 +8298,6 @@ snapshots:
|
||||
|
||||
jiti@2.7.0: {}
|
||||
|
||||
jose@6.2.8: {}
|
||||
|
||||
js-tokens@4.0.0: {}
|
||||
|
||||
js-tokens@9.0.1: {}
|
||||
@@ -8478,7 +8585,7 @@ snapshots:
|
||||
|
||||
negotiator@0.6.3: {}
|
||||
|
||||
nitropack@2.13.3(srvx@0.11.15)(supports-color@10.2.2):
|
||||
nitropack@2.13.3(better-sqlite3@13.0.2)(srvx@0.11.15)(supports-color@10.2.2):
|
||||
dependencies:
|
||||
'@cloudflare/kv-asset-handler': 0.4.2
|
||||
'@rollup/plugin-alias': 6.0.0(rollup@4.60.2)
|
||||
@@ -8499,7 +8606,7 @@ snapshots:
|
||||
cookie-es: 2.0.1
|
||||
croner: 10.0.1
|
||||
crossws: 0.3.5
|
||||
db0: 0.3.4
|
||||
db0: 0.3.4(better-sqlite3@13.0.2)
|
||||
defu: 6.1.7
|
||||
destr: 2.0.5
|
||||
dot-prop: 10.1.0
|
||||
@@ -8545,7 +8652,7 @@ snapshots:
|
||||
unenv: 2.0.0-rc.24
|
||||
unimport: 6.1.1
|
||||
unplugin-utils: 0.3.1
|
||||
unstorage: 1.17.5(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2))
|
||||
unstorage: 1.17.5(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2))
|
||||
untyped: 2.0.0
|
||||
unwasm: 0.5.3
|
||||
youch: 4.1.1
|
||||
@@ -8584,6 +8691,8 @@ snapshots:
|
||||
|
||||
node-addon-api@7.1.1: {}
|
||||
|
||||
node-addon-api@8.9.1: {}
|
||||
|
||||
node-fetch-native@1.6.7: {}
|
||||
|
||||
node-fetch@2.7.0:
|
||||
@@ -8621,16 +8730,16 @@ snapshots:
|
||||
|
||||
nuxt-define@1.0.0: {}
|
||||
|
||||
nuxt@4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(cac@6.7.14)(db0@0.3.4)(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3):
|
||||
nuxt@4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(better-sqlite3@13.0.2)(cac@6.7.14)(db0@0.3.4(better-sqlite3@13.0.2))(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3):
|
||||
dependencies:
|
||||
'@dxup/nuxt': 0.4.1(magicast@0.5.2)(typescript@6.0.3)
|
||||
'@nuxt/cli': 3.34.0(@nuxt/schema@4.4.2)(cac@6.7.14)(magicast@0.5.2)(supports-color@10.2.2)
|
||||
'@nuxt/devtools': 3.2.4(supports-color@10.2.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(vue@3.5.33(typescript@6.0.3))
|
||||
'@nuxt/kit': 4.4.2(magicast@0.5.2)
|
||||
'@nuxt/nitro-server': 4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(nuxt@4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(cac@6.7.14)(db0@0.3.4)(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3))(srvx@0.11.15)(supports-color@10.2.2)(typescript@6.0.3)
|
||||
'@nuxt/nitro-server': 4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(better-sqlite3@13.0.2)(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(nuxt@4.4.2(@babel/core@7.29.0(supports-color@10.2.2))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0(supports-color@10.2.2)))(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(@parcel/watcher@2.5.6)(@types/node@26.1.2)(@vue/compiler-sfc@3.5.33)(better-sqlite3@13.0.2)(cac@6.7.14)(db0@0.3.4(better-sqlite3@13.0.2))(eslint@10.2.1(jiti@2.6.1)(supports-color@10.2.2))(ioredis@5.10.1(supports-color@10.2.2))(magicast@0.5.2)(optionator@0.9.4)(pinia@3.0.4(typescript@6.0.3)(vue@3.5.33(typescript@6.0.3)))(rollup-plugin-visualizer@7.0.1(rollup@4.60.2))(rollup@4.60.2)(srvx@0.11.15)(supports-color@10.2.2)(terser@5.46.2)(typescript@6.0.3)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))(yaml@2.8.3))(srvx@0.11.15)(supports-color@10.2.2)(typescript@6.0.3)
|
||||
'@nuxt/schema': 4.4.2
|
||||
'@nuxt/telemetry': 2.8.0(@nuxt/kit@4.4.2(magicast@0.5.2))
|
||||
'@nuxt/vite-builder': 4.4.2(56d15aa3ff77376966f610d34ec153ec)
|
||||
'@nuxt/vite-builder': 4.4.2(33c2df0c5ddd0297914f3b5431b96b75)
|
||||
'@unhead/vue': 2.1.13(vue@3.5.33(typescript@6.0.3))
|
||||
'@vue/shared': 3.5.33
|
||||
c12: 3.3.4(magicast@0.5.2)
|
||||
@@ -9038,41 +9147,6 @@ snapshots:
|
||||
|
||||
perfect-debounce@2.1.0: {}
|
||||
|
||||
pg-cloudflare@1.4.0:
|
||||
optional: true
|
||||
|
||||
pg-connection-string@2.14.0: {}
|
||||
|
||||
pg-int8@1.0.1: {}
|
||||
|
||||
pg-pool@3.14.0(pg@8.22.0):
|
||||
dependencies:
|
||||
pg: 8.22.0
|
||||
|
||||
pg-protocol@1.15.0: {}
|
||||
|
||||
pg-types@2.2.0:
|
||||
dependencies:
|
||||
pg-int8: 1.0.1
|
||||
postgres-array: 2.0.0
|
||||
postgres-bytea: 1.0.1
|
||||
postgres-date: 1.0.7
|
||||
postgres-interval: 1.1.0
|
||||
|
||||
pg@8.22.0:
|
||||
dependencies:
|
||||
pg-connection-string: 2.14.0
|
||||
pg-pool: 3.14.0(pg@8.22.0)
|
||||
pg-protocol: 1.15.0
|
||||
pg-types: 2.2.0
|
||||
pgpass: 1.0.5
|
||||
optionalDependencies:
|
||||
pg-cloudflare: 1.4.0
|
||||
|
||||
pgpass@1.0.5:
|
||||
dependencies:
|
||||
split2: 4.2.0
|
||||
|
||||
picocolors@1.1.1: {}
|
||||
|
||||
picomatch@2.3.2: {}
|
||||
@@ -9316,16 +9390,6 @@ snapshots:
|
||||
picocolors: 1.1.1
|
||||
source-map-js: 1.2.1
|
||||
|
||||
postgres-array@2.0.0: {}
|
||||
|
||||
postgres-bytea@1.0.1: {}
|
||||
|
||||
postgres-date@1.0.7: {}
|
||||
|
||||
postgres-interval@1.1.0:
|
||||
dependencies:
|
||||
xtend: 4.0.2
|
||||
|
||||
powershell-utils@0.1.0: {}
|
||||
|
||||
prelude-ls@1.2.1: {}
|
||||
@@ -9539,6 +9603,8 @@ snapshots:
|
||||
|
||||
shell-quote@1.8.3: {}
|
||||
|
||||
siginfo@2.0.0: {}
|
||||
|
||||
signal-exit@4.1.0: {}
|
||||
|
||||
simple-git@3.36.0(supports-color@10.2.2):
|
||||
@@ -9576,10 +9642,10 @@ snapshots:
|
||||
|
||||
speakingurl@14.0.1: {}
|
||||
|
||||
split2@4.2.0: {}
|
||||
|
||||
srvx@0.11.15: {}
|
||||
|
||||
stackback@0.0.2: {}
|
||||
|
||||
standard-as-callback@2.1.0: {}
|
||||
|
||||
statuses@1.5.0: {}
|
||||
@@ -9777,6 +9843,8 @@ snapshots:
|
||||
|
||||
tiny-invariant@1.3.3: {}
|
||||
|
||||
tinybench@2.9.0: {}
|
||||
|
||||
tinyclip@0.1.12: {}
|
||||
|
||||
tinyexec@1.1.1: {}
|
||||
@@ -9786,6 +9854,8 @@ snapshots:
|
||||
fdir: 6.5.0(picomatch@4.0.4)
|
||||
picomatch: 4.0.4
|
||||
|
||||
tinyrainbow@3.1.1: {}
|
||||
|
||||
to-regex-range@5.0.1:
|
||||
dependencies:
|
||||
is-number: 7.0.0
|
||||
@@ -9895,7 +9965,7 @@ snapshots:
|
||||
escape-string-regexp: 5.0.0
|
||||
ufo: 1.6.3
|
||||
|
||||
unstorage@1.17.5(db0@0.3.4)(ioredis@5.10.1(supports-color@10.2.2)):
|
||||
unstorage@1.17.5(db0@0.3.4(better-sqlite3@13.0.2))(ioredis@5.10.1(supports-color@10.2.2)):
|
||||
dependencies:
|
||||
anymatch: 3.1.3
|
||||
chokidar: 5.0.0
|
||||
@@ -9906,7 +9976,7 @@ snapshots:
|
||||
ofetch: 1.5.1
|
||||
ufo: 1.6.3
|
||||
optionalDependencies:
|
||||
db0: 0.3.4
|
||||
db0: 0.3.4(better-sqlite3@13.0.2)
|
||||
ioredis: 5.10.1(supports-color@10.2.2)
|
||||
|
||||
untun@0.1.3:
|
||||
@@ -10040,6 +10110,33 @@ snapshots:
|
||||
terser: 5.46.2
|
||||
yaml: 2.8.3
|
||||
|
||||
vitest@4.1.10(@types/node@26.1.2)(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3)):
|
||||
dependencies:
|
||||
'@vitest/expect': 4.1.10
|
||||
'@vitest/mocker': 4.1.10(vite@7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3))
|
||||
'@vitest/pretty-format': 4.1.10
|
||||
'@vitest/runner': 4.1.10
|
||||
'@vitest/snapshot': 4.1.10
|
||||
'@vitest/spy': 4.1.10
|
||||
'@vitest/utils': 4.1.10
|
||||
es-module-lexer: 2.1.0
|
||||
expect-type: 1.4.0
|
||||
magic-string: 0.30.21
|
||||
obug: 2.1.1
|
||||
pathe: 2.0.3
|
||||
picomatch: 4.0.4
|
||||
std-env: 4.1.0
|
||||
tinybench: 2.9.0
|
||||
tinyexec: 1.1.1
|
||||
tinyglobby: 0.2.16
|
||||
tinyrainbow: 3.1.1
|
||||
vite: 7.3.2(@types/node@26.1.2)(jiti@2.6.1)(terser@5.46.2)(yaml@2.8.3)
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
'@types/node': 26.1.2
|
||||
transitivePeerDependencies:
|
||||
- msw
|
||||
|
||||
vscode-uri@3.1.0: {}
|
||||
|
||||
vue-bundle-renderer@2.2.0:
|
||||
@@ -10109,6 +10206,11 @@ snapshots:
|
||||
dependencies:
|
||||
isexe: 4.0.0
|
||||
|
||||
why-is-node-running@2.3.0:
|
||||
dependencies:
|
||||
siginfo: 2.0.0
|
||||
stackback: 0.0.2
|
||||
|
||||
word-wrap@1.2.5: {}
|
||||
|
||||
wrap-ansi@7.0.0:
|
||||
@@ -10142,8 +10244,6 @@ snapshots:
|
||||
is-wsl: 3.1.1
|
||||
powershell-utils: 0.1.0
|
||||
|
||||
xtend@4.0.2: {}
|
||||
|
||||
y18n@5.0.8: {}
|
||||
|
||||
yallist@3.1.1: {}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
allowBuilds:
|
||||
"@parcel/watcher": true
|
||||
better-sqlite3: true
|
||||
esbuild: true
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 81 KiB |
@@ -1,2 +0,0 @@
|
||||
User-Agent: *
|
||||
Disallow:
|
||||
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* 生成站点 Open Graph 分享图 public/og-image.png(1200x630)。
|
||||
*
|
||||
* 手写 PNG 编码器(node:zlib deflateSync),零第三方依赖、确定性可复现:
|
||||
* - 深蓝渐变背景 + 中央白色菱形 logo 母题 + 星点(固定种子伪随机)
|
||||
*
|
||||
* 用法: node scripts/generate-og.mjs
|
||||
*/
|
||||
import { deflateSync } from 'node:zlib'
|
||||
import { writeFileSync } from 'node:fs'
|
||||
|
||||
const W = 1200
|
||||
const H = 630
|
||||
|
||||
// ---------- PNG 编码工具 ----------
|
||||
let crcTable = null
|
||||
function crc32(buf) {
|
||||
if (!crcTable) {
|
||||
crcTable = new Int32Array(256)
|
||||
for (let n = 0; n < 256; n++) {
|
||||
let c = n
|
||||
for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1
|
||||
crcTable[n] = c
|
||||
}
|
||||
}
|
||||
let c = 0xffffffff
|
||||
for (let i = 0; i < buf.length; i++) c = crcTable[(c ^ buf[i]) & 0xff] ^ (c >>> 8)
|
||||
return (c ^ 0xffffffff) >>> 0
|
||||
}
|
||||
|
||||
function chunk(type, data) {
|
||||
const len = Buffer.alloc(4)
|
||||
len.writeUInt32BE(data.length)
|
||||
const typeBuf = Buffer.from(type, 'ascii')
|
||||
const crcBuf = Buffer.alloc(4)
|
||||
crcBuf.writeUInt32BE(crc32(Buffer.concat([typeBuf, data])))
|
||||
return Buffer.concat([len, typeBuf, data, crcBuf])
|
||||
}
|
||||
|
||||
// ---------- 确定性伪随机(mulberry32)----------
|
||||
let seed = 20260806
|
||||
function rand() {
|
||||
seed = (seed + 0x6d2b79f5) | 0
|
||||
let t = seed
|
||||
t = Math.imul(t ^ (t >>> 15), t | 1)
|
||||
t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
|
||||
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
|
||||
}
|
||||
|
||||
// ---------- 像素绘制 ----------
|
||||
const raw = Buffer.alloc(H * (1 + W * 4))
|
||||
|
||||
const lerp = (a, b, t) => Math.round(a + (b - a) * t)
|
||||
const clamp255 = (v) => Math.max(0, Math.min(255, v))
|
||||
|
||||
const cTop = [15, 23, 42] // #0f172a
|
||||
const cBottom = [30, 41, 59] // #1e293b
|
||||
const cAccent = [99, 102, 241] // indigo
|
||||
const cx = W / 2
|
||||
const cy = H / 2
|
||||
const diamondHalf = 132 // 菱形对角线半长(L1 度量)
|
||||
const diamondEdge = 16 // 菱形边缘柔和过渡像素
|
||||
|
||||
// 基础渐变 + 中央径向光晕 + 菱形
|
||||
for (let y = 0; y < H; y++) {
|
||||
const rowStart = y * (1 + W * 4)
|
||||
raw[rowStart] = 0 // filter: none
|
||||
const t = y / (H - 1)
|
||||
let r = lerp(cTop[0], cBottom[0], t)
|
||||
let g = lerp(cTop[1], cBottom[1], t)
|
||||
let b = lerp(cTop[2], cBottom[2], t)
|
||||
|
||||
for (let x = 0; x < W; x++) {
|
||||
const dx = x - cx
|
||||
const dy = y - cy
|
||||
const dist = Math.sqrt(dx * dx + dy * dy)
|
||||
const glow = Math.max(0, 1 - dist / 520)
|
||||
let pr = lerp(r, cAccent[0], glow * 0.45)
|
||||
let pg = lerp(g, cAccent[1], glow * 0.45)
|
||||
let pb = lerp(b, cAccent[2], glow * 0.45)
|
||||
|
||||
const l1 = Math.abs(dx) + Math.abs(dy)
|
||||
if (l1 <= diamondHalf) {
|
||||
const edge = clamp255(Math.max(0, diamondHalf - l1) / diamondEdge)
|
||||
pr = lerp(pr, 255, edge * 0.94)
|
||||
pg = lerp(pg, 255, edge * 0.94)
|
||||
pb = lerp(pb, 255, edge * 0.94)
|
||||
}
|
||||
|
||||
const off = rowStart + 1 + x * 4
|
||||
raw[off] = clamp255(pr)
|
||||
raw[off + 1] = clamp255(pg)
|
||||
raw[off + 2] = clamp255(pb)
|
||||
raw[off + 3] = 255
|
||||
}
|
||||
}
|
||||
|
||||
// 星点(后画,覆盖在基色上)
|
||||
const stars = []
|
||||
for (let i = 0; i < 180; i++) {
|
||||
stars.push({ x: rand() * W, y: rand() * H, r: 0.5 + rand() * 2.2, a: 0.12 + rand() * 0.35 })
|
||||
}
|
||||
for (const s of stars) {
|
||||
const r = s.r + 1
|
||||
const x0 = Math.max(0, Math.floor(s.x - r))
|
||||
const x1 = Math.min(W - 1, Math.ceil(s.x + r))
|
||||
const y0 = Math.max(0, Math.floor(s.y - r))
|
||||
const y1 = Math.min(H - 1, Math.ceil(s.y + r))
|
||||
for (let y = y0; y <= y1; y++) {
|
||||
const rowStart = y * (1 + W * 4)
|
||||
for (let x = x0; x <= x1; x++) {
|
||||
if (Math.hypot(s.x - x, s.y - y) > s.r) continue
|
||||
const off = rowStart + 1 + x * 4
|
||||
raw[off] = clamp255(lerp(raw[off], 255, s.a))
|
||||
raw[off + 1] = clamp255(lerp(raw[off + 1], 255, s.a))
|
||||
raw[off + 2] = clamp255(lerp(raw[off + 2], 255, s.a))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 组装 PNG ----------
|
||||
const ihdr = Buffer.alloc(13)
|
||||
ihdr.writeUInt32BE(W, 0)
|
||||
ihdr.writeUInt32BE(H, 4)
|
||||
ihdr[8] = 8 // bit depth
|
||||
ihdr[9] = 6 // color type: RGBA
|
||||
ihdr[10] = 0 // compression
|
||||
ihdr[11] = 0 // filter
|
||||
ihdr[12] = 0 // interlace
|
||||
|
||||
const png = Buffer.concat([
|
||||
Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
|
||||
chunk('IHDR', ihdr),
|
||||
chunk('IDAT', deflateSync(raw, { level: 9 })),
|
||||
chunk('IEND', Buffer.alloc(0)),
|
||||
])
|
||||
|
||||
writeFileSync('public/og-image.png', png)
|
||||
console.log(`og-image.png generated: ${W}x${H}, ${png.length} bytes`)
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* 生成 server/utils/seed.ts(一次性工具)。
|
||||
*
|
||||
* 从当前 i18n 文案 + 内容元数据转录出 articles/works 双语种子数据,
|
||||
* 供 DB 初始化时灌入,保证站点初始内容与改造前一致。
|
||||
*
|
||||
* 用法: node scripts/generate-seed.mjs
|
||||
*/
|
||||
import { readFileSync, writeFileSync } from 'node:fs'
|
||||
|
||||
const zh = JSON.parse(readFileSync('i18n/locales/zh.json', 'utf8'))
|
||||
const en = JSON.parse(readFileSync('i18n/locales/en.json', 'utf8'))
|
||||
|
||||
// ---------- 动态元数据(与原 app/data/news.ts 一致) ----------
|
||||
const articleMeta = [
|
||||
{ slug: 'design-trends-2026', category: 'insights', date: '2026-05-28', readTime: 5, author: 'ArcticNewOne', image: 'https://picsum.photos/id/1/800/500' },
|
||||
{ slug: 'forma-digital-launch', category: 'projects', date: '2026-05-15', readTime: 3, author: 'ArcticNewOne', image: 'https://picsum.photos/id/201/800/500' },
|
||||
{ slug: 'studio-expansion', category: 'announcements', date: '2026-05-10', readTime: 2, author: 'ArcticNewOne', image: 'https://picsum.photos/id/164/800/500' },
|
||||
{ slug: 'ux-research-methods', category: 'insights', date: '2026-04-28', readTime: 7, author: 'ArcticNewOne', image: 'https://picsum.photos/id/180/800/500' },
|
||||
{ slug: 'bold-moves-case-study', category: 'projects', date: '2026-04-20', readTime: 6, author: 'ArcticNewOne', image: 'https://picsum.photos/id/119/800/500' },
|
||||
{ slug: 'new-tools-integration', category: 'announcements', date: '2026-04-12', readTime: 4, author: 'ArcticNewOne', image: 'https://picsum.photos/id/326/800/500' },
|
||||
]
|
||||
|
||||
// ---------- 作品元数据(与原 app/data/work.ts 一致) ----------
|
||||
const workMeta = [
|
||||
{ slug: 'forma-digital', category: 'webDesign', year: '2026', tags: ['Web Design', 'E-commerce', 'React'], image: 'https://picsum.photos/id/201/1200/800', gallery: ['https://picsum.photos/id/201/800/600', 'https://picsum.photos/id/202/800/600', 'https://picsum.photos/id/203/800/600', 'https://picsum.photos/id/204/800/600'], url: null },
|
||||
{ slug: 'one-step', category: 'branding', year: '2024', tags: ['Branding', 'Marketing', 'UI/UX'], image: 'https://picsum.photos/id/180/1200/800', gallery: ['https://picsum.photos/id/180/800/600', 'https://picsum.photos/id/181/800/600', 'https://picsum.photos/id/182/800/600', 'https://picsum.photos/id/183/800/600'], url: null },
|
||||
{ slug: 'nero-vision', category: 'development', year: '2025', tags: ['Development', 'Vue.js', 'Node.js'], image: 'https://picsum.photos/id/119/1200/800', gallery: ['https://picsum.photos/id/119/800/600', 'https://picsum.photos/id/120/800/600', 'https://picsum.photos/id/121/800/600', 'https://picsum.photos/id/122/800/600'], url: null },
|
||||
{ slug: 'bold-moves', category: 'webDesign', year: '2024', tags: ['Web Design', '3D', 'Three.js'], image: 'https://picsum.photos/id/164/1200/800', gallery: ['https://picsum.photos/id/164/800/600', 'https://picsum.photos/id/165/800/600', 'https://picsum.photos/id/166/800/600', 'https://picsum.photos/id/167/800/600'], url: null },
|
||||
{ slug: 'echo-labs', category: 'branding', year: '2025', tags: ['Branding', 'Visual Identity', 'Corporate'], image: 'https://picsum.photos/id/101/1200/800', gallery: ['https://picsum.photos/id/101/800/600', 'https://picsum.photos/id/102/800/600', 'https://picsum.photos/id/103/800/600', 'https://picsum.photos/id/104/800/600'], url: null },
|
||||
{ slug: 'flux-api', category: 'development', year: '2025', tags: ['Development', 'API', 'Python'], image: 'https://picsum.photos/id/326/1200/800', gallery: ['https://picsum.photos/id/326/800/600', 'https://picsum.photos/id/327/800/600', 'https://picsum.photos/id/328/800/600', 'https://picsum.photos/id/329/800/600'], url: null },
|
||||
]
|
||||
|
||||
// ---------- 文章正文块(从 i18n 转录) ----------
|
||||
function articleBlocks(locale, slug) {
|
||||
const d = locale.detail.items[slug]
|
||||
return [
|
||||
{ type: 'paragraph', text: d.content },
|
||||
{ type: 'heading', text: d.section1Title },
|
||||
{ type: 'paragraph', text: d.section1Content },
|
||||
{ type: 'quote', text: d.quote },
|
||||
{ type: 'heading', text: d.section2Title },
|
||||
{ type: 'paragraph', text: d.section2Content },
|
||||
{ type: 'heading', text: d.section3Title },
|
||||
{ type: 'paragraph', text: d.section3Content },
|
||||
]
|
||||
}
|
||||
|
||||
const articles = articleMeta.map((m) => ({
|
||||
slug: m.slug,
|
||||
category: m.category,
|
||||
titleZh: zh.news.items[m.slug].title,
|
||||
titleEn: en.news.items[m.slug].title,
|
||||
excerptZh: zh.news.items[m.slug].excerpt,
|
||||
excerptEn: en.news.items[m.slug].excerpt,
|
||||
contentZh: articleBlocks(zh.news, m.slug),
|
||||
contentEn: articleBlocks(en.news, m.slug),
|
||||
image: m.image,
|
||||
date: m.date,
|
||||
readTime: m.readTime,
|
||||
author: m.author,
|
||||
published: 1,
|
||||
}))
|
||||
|
||||
const works = workMeta.map((m) => ({
|
||||
slug: m.slug,
|
||||
category: m.category,
|
||||
titleZh: zh.work.items[m.slug].title,
|
||||
titleEn: en.work.items[m.slug].title,
|
||||
descriptionZh: zh.work.items[m.slug].description,
|
||||
descriptionEn: en.work.items[m.slug].description,
|
||||
overviewZh: zh.work.detail.items[m.slug].overview,
|
||||
overviewEn: en.work.detail.items[m.slug].overview,
|
||||
challengeZh: zh.work.detail.items[m.slug].challenge,
|
||||
challengeEn: en.work.detail.items[m.slug].challenge,
|
||||
solutionZh: zh.work.detail.items[m.slug].solution,
|
||||
solutionEn: en.work.detail.items[m.slug].solution,
|
||||
clientZh: zh.work.detail.items[m.slug].client,
|
||||
clientEn: en.work.detail.items[m.slug].client,
|
||||
durationZh: zh.work.detail.items[m.slug].duration,
|
||||
durationEn: en.work.detail.items[m.slug].duration,
|
||||
year: m.year,
|
||||
tags: m.tags,
|
||||
image: m.image,
|
||||
gallery: m.gallery,
|
||||
url: m.url,
|
||||
published: 1,
|
||||
}))
|
||||
|
||||
const out = `/**
|
||||
* 种子数据(由 scripts/generate-seed.mjs 生成,勿手改)。
|
||||
* 站点初始内容:6 篇动态 + 6 个作品(中英双语)。
|
||||
* DB 初始化(migrate)时若对应表为空则自动灌入。
|
||||
*/
|
||||
import type { ArticleBlock } from './db'
|
||||
|
||||
export interface ArticleSeed {
|
||||
slug: string
|
||||
category: 'insights' | 'projects' | 'announcements'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
excerptZh: string
|
||||
excerptEn: string
|
||||
contentZh: ArticleBlock[]
|
||||
contentEn: ArticleBlock[]
|
||||
image: string
|
||||
date: string
|
||||
readTime: number
|
||||
author: string
|
||||
published: number
|
||||
}
|
||||
|
||||
export interface WorkSeed {
|
||||
slug: string
|
||||
category: 'webDesign' | 'branding' | 'development'
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
descriptionZh: string
|
||||
descriptionEn: string
|
||||
overviewZh: string
|
||||
overviewEn: string
|
||||
challengeZh: string
|
||||
challengeEn: string
|
||||
solutionZh: string
|
||||
solutionEn: string
|
||||
clientZh: string
|
||||
clientEn: string
|
||||
durationZh: string
|
||||
durationEn: string
|
||||
year: string
|
||||
tags: string[]
|
||||
image: string
|
||||
gallery: string[]
|
||||
url: string | null
|
||||
published: number
|
||||
}
|
||||
|
||||
export const articlesSeed: ArticleSeed[] = ${JSON.stringify(articles, null, 2)}
|
||||
|
||||
export const worksSeed: WorkSeed[] = ${JSON.stringify(works, null, 2)}
|
||||
`
|
||||
|
||||
writeFileSync('server/utils/seed.ts', out)
|
||||
console.log(`seed.ts generated: ${articles.length} articles, ${works.length} works`)
|
||||
@@ -0,0 +1,15 @@
|
||||
import { requireUser } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 当前用户的全部评论(个人中心「我的评论」)
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
const user = requireUser(event)
|
||||
const rows = getDb()
|
||||
.prepare(
|
||||
'SELECT id, news_slug AS newsSlug, content, created_at AS createdAt FROM comments WHERE user_id = ? ORDER BY created_at DESC',
|
||||
)
|
||||
.all(user.id)
|
||||
return { comments: rows }
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { listArticles } from '../../utils/content'
|
||||
|
||||
/**
|
||||
* 后台动态列表(含未发布)
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
return { articles: listArticles({ publishedOnly: false }) }
|
||||
})
|
||||
@@ -0,0 +1,55 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { getArticleBySlug } from '../../utils/content'
|
||||
import { writeAudit } from '../../utils/audit'
|
||||
import { normalizeSlug, isValidSlug, isValidArticleCategory, normalizeBlocks } from '../../utils/validateContent'
|
||||
|
||||
/**
|
||||
* 后台新增动态
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdmin(event)
|
||||
const body = await readBody(event)
|
||||
const db = getDb()
|
||||
|
||||
const slug = normalizeSlug(body?.slug)
|
||||
if (!isValidSlug(slug)) {
|
||||
throw createError({ statusCode: 400, message: 'slug 需为 2-64 位小写字母/数字/中划线', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
if (!isValidArticleCategory(body?.category)) {
|
||||
throw createError({ statusCode: 400, message: '分类不合法', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const titleZh = String(body?.titleZh ?? '').trim()
|
||||
const titleEn = String(body?.titleEn ?? '').trim()
|
||||
if (!titleZh || !titleEn) {
|
||||
throw createError({ statusCode: 400, message: '中英文标题不能为空', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
if (getArticleBySlug(slug, { publishedOnly: false })) {
|
||||
throw createError({ statusCode: 400, message: 'slug 已存在', data: { code: 'SLUG_TAKEN' } })
|
||||
}
|
||||
|
||||
db.prepare(
|
||||
`INSERT INTO articles
|
||||
(slug, category, title_zh, title_en, excerpt_zh, excerpt_en, content_zh, content_en, image, date, read_time, author, published, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, datetime('now'))`,
|
||||
).run(
|
||||
slug,
|
||||
body.category,
|
||||
titleZh,
|
||||
titleEn,
|
||||
String(body?.excerptZh ?? ''),
|
||||
String(body?.excerptEn ?? ''),
|
||||
JSON.stringify(normalizeBlocks(body?.contentZh)),
|
||||
JSON.stringify(normalizeBlocks(body?.contentEn)),
|
||||
body?.image ? String(body.image).trim() : null,
|
||||
body?.date ? String(body.date).trim() : null,
|
||||
Number(body?.readTime) || 5,
|
||||
String(body?.author ?? 'ArcticNewOne').trim() || 'ArcticNewOne',
|
||||
body?.published ? 1 : 0,
|
||||
)
|
||||
|
||||
writeAudit(event, 'create', `article:${slug}`)
|
||||
|
||||
return { ok: true, article: getArticleBySlug(slug, { publishedOnly: false }) }
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
import { createError, getRouterParam } from 'h3'
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
import { writeAudit } from '../../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台删除动态(连带删除其评论)
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const db = getDb()
|
||||
|
||||
const row = db.prepare('SELECT slug FROM articles WHERE id = ?').get(id) as { slug: string } | undefined
|
||||
if (!row) {
|
||||
throw createError({ statusCode: 404, message: '动态不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
|
||||
const tx = db.transaction(() => {
|
||||
db.prepare('DELETE FROM comments WHERE news_slug = ?').run(row.slug)
|
||||
db.prepare('DELETE FROM articles WHERE id = ?').run(id)
|
||||
})
|
||||
tx()
|
||||
|
||||
writeAudit(event, 'delete', `article:${row.slug}`)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,84 @@
|
||||
import { readBody, createError, getRouterParam } from 'h3'
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
import { getArticleBySlug } from '../../../utils/content'
|
||||
import { normalizeSlug, isValidSlug, isValidArticleCategory, normalizeBlocks } from '../../../utils/validateContent'
|
||||
import { writeAudit } from '../../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台更新动态(部分字段)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const body = await readBody(event)
|
||||
const db = getDb()
|
||||
|
||||
const existing = db.prepare('SELECT slug FROM articles WHERE id = ?').get(id) as { slug: string } | undefined
|
||||
if (!existing) {
|
||||
throw createError({ statusCode: 404, message: '动态不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
|
||||
const sets: string[] = []
|
||||
const params: unknown[] = []
|
||||
|
||||
if (body?.slug !== undefined) {
|
||||
const slug = normalizeSlug(body.slug)
|
||||
if (!isValidSlug(slug)) {
|
||||
throw createError({ statusCode: 400, message: 'slug 需为 2-64 位小写字母/数字/中划线', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const taken = db.prepare('SELECT id FROM articles WHERE slug = ? AND id != ?').get(slug, id)
|
||||
if (taken) {
|
||||
throw createError({ statusCode: 400, message: 'slug 已存在', data: { code: 'SLUG_TAKEN' } })
|
||||
}
|
||||
sets.push('slug = ?'); params.push(slug)
|
||||
}
|
||||
if (body?.category !== undefined) {
|
||||
if (!isValidArticleCategory(body.category)) {
|
||||
throw createError({ statusCode: 400, message: '分类不合法', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
sets.push('category = ?'); params.push(body.category)
|
||||
}
|
||||
for (const field of ['titleZh', 'titleEn', 'excerptZh', 'excerptEn', 'image', 'date', 'author'] as const) {
|
||||
if (body?.[field] !== undefined) {
|
||||
if (field === 'titleZh' || field === 'titleEn') {
|
||||
if (!String(body[field]).trim()) {
|
||||
throw createError({ statusCode: 400, message: '中英文标题不能为空', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
}
|
||||
sets.push(fieldToCol(field) + ' = ?'); params.push(String(body[field]).trim())
|
||||
}
|
||||
}
|
||||
if (body?.readTime !== undefined) {
|
||||
sets.push('read_time = ?'); params.push(Number(body.readTime) || 5)
|
||||
}
|
||||
if (body?.published !== undefined) {
|
||||
sets.push('published = ?'); params.push(body.published ? 1 : 0)
|
||||
}
|
||||
if (body?.contentZh !== undefined) {
|
||||
sets.push('content_zh = ?'); params.push(JSON.stringify(normalizeBlocks(body.contentZh)))
|
||||
}
|
||||
if (body?.contentEn !== undefined) {
|
||||
sets.push('content_en = ?'); params.push(JSON.stringify(normalizeBlocks(body.contentEn)))
|
||||
}
|
||||
|
||||
if (sets.length === 0) {
|
||||
throw createError({ statusCode: 400, message: '没有可更新的字段', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
sets.push("updated_at = datetime('now')")
|
||||
db.prepare(`UPDATE articles SET ${sets.join(', ')} WHERE id = ?`).run(...params, id)
|
||||
|
||||
const row = db.prepare('SELECT slug FROM articles WHERE id = ?').get(id) as { slug: string }
|
||||
writeAudit(event, 'update', `article:${id}`)
|
||||
return { ok: true, article: getArticleBySlug(row.slug, { publishedOnly: false }) }
|
||||
})
|
||||
|
||||
function fieldToCol(field: string): string {
|
||||
const map: Record<string, string> = {
|
||||
titleZh: 'title_zh', titleEn: 'title_en',
|
||||
excerptZh: 'excerpt_zh', excerptEn: 'excerpt_en',
|
||||
image: 'image', date: 'date', author: 'author',
|
||||
}
|
||||
return map[field]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { writeAudit } from '../../utils/audit'
|
||||
|
||||
/**
|
||||
* 清空审计日志
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
getDb().prepare('DELETE FROM audit_logs').run()
|
||||
writeAudit(event, 'clear', 'audit')
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
import { getQuery } from 'h3'
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 后台操作审计日志(分页)
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const q = getQuery(event)
|
||||
const page = Math.max(1, Number(q?.page) || 1)
|
||||
const pageSize = Math.min(100, Math.max(1, Number(q?.pageSize) || 20))
|
||||
|
||||
const db = getDb()
|
||||
const total = (db.prepare('SELECT COUNT(*) AS c FROM audit_logs').get() as { c: number }).c
|
||||
const logs = db
|
||||
.prepare(
|
||||
`SELECT id, actor_id, actor_name, action, target, detail, created_at AS createdAt
|
||||
FROM audit_logs ORDER BY created_at DESC LIMIT ? OFFSET ?`,
|
||||
)
|
||||
.all(pageSize, (page - 1) * pageSize)
|
||||
|
||||
return { logs, total, page, pageSize }
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
import { getQuery } from 'h3'
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 后台全站评论列表(分页)
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const q = getQuery(event)
|
||||
const page = Math.max(1, Number(q?.page) || 1)
|
||||
const pageSize = Math.min(100, Math.max(1, Number(q?.pageSize) || 20))
|
||||
|
||||
const db = getDb()
|
||||
const total = (db.prepare('SELECT COUNT(*) AS c FROM comments').get() as { c: number }).c
|
||||
const comments = db
|
||||
.prepare(
|
||||
`SELECT c.id, c.news_slug AS newsSlug, c.content, c.created_at AS createdAt, u.username
|
||||
FROM comments c
|
||||
JOIN users u ON u.id = c.user_id
|
||||
ORDER BY c.created_at DESC LIMIT ? OFFSET ?`,
|
||||
)
|
||||
.all(pageSize, (page - 1) * pageSize)
|
||||
|
||||
return { comments, total, page, pageSize }
|
||||
})
|
||||
@@ -0,0 +1,20 @@
|
||||
import { createError, getRouterParam } from 'h3'
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
import { writeAudit } from '../../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台删除评论
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const db = getDb()
|
||||
const target = db.prepare('SELECT id FROM comments WHERE id = ?').get(id)
|
||||
if (!target) {
|
||||
throw createError({ statusCode: 404, message: '评论不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
db.prepare('DELETE FROM comments WHERE id = ?').run(id)
|
||||
writeAudit(event, 'delete', `comment:${id}`)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,13 @@
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 后台联系消息列表
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const contacts = getDb()
|
||||
.prepare('SELECT id, name, email, subject, message, delivered, read, created_at AS createdAt FROM contacts ORDER BY created_at DESC')
|
||||
.all()
|
||||
return { contacts }
|
||||
})
|
||||
@@ -0,0 +1,20 @@
|
||||
import { createError, getRouterParam } from 'h3'
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
import { writeAudit } from '../../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台删除联系消息
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const db = getDb()
|
||||
const target = db.prepare('SELECT id FROM contacts WHERE id = ?').get(id)
|
||||
if (!target) {
|
||||
throw createError({ statusCode: 404, message: '消息不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
db.prepare('DELETE FROM contacts WHERE id = ?').run(id)
|
||||
writeAudit(event, 'delete', `contact:${id}`)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,25 @@
|
||||
import { readBody, createError, getRouterParam } from 'h3'
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
import { writeAudit } from '../../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台更新联系消息(已读/未读标记)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const body = await readBody(event)
|
||||
const db = getDb()
|
||||
|
||||
const target = db.prepare('SELECT id FROM contacts WHERE id = ?').get(id)
|
||||
if (!target) {
|
||||
throw createError({ statusCode: 404, message: '消息不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
|
||||
if (body?.read !== undefined) {
|
||||
db.prepare('UPDATE contacts SET read = ? WHERE id = ?').run(body.read ? 1 : 0, id)
|
||||
writeAudit(event, 'update', `contact:${id}`, `read=${body.read ? 1 : 0}`)
|
||||
}
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getSettings } from '../../utils/settings'
|
||||
|
||||
/**
|
||||
* 后台读取站点配置
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
return getSettings()
|
||||
})
|
||||
@@ -0,0 +1,44 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getSettings, updateSetting } from '../../utils/settings'
|
||||
import { writeAudit } from '../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台更新站点配置。
|
||||
* body: { settings: Partial<SiteSettings> } —— 按叶节点展开写库,未提供的项保持不变。
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdmin(event)
|
||||
const body = await readBody(event)
|
||||
|
||||
const patch = body?.settings
|
||||
if (!patch || typeof patch !== 'object' || Array.isArray(patch)) {
|
||||
throw createError({ statusCode: 400, message: '缺少配置内容', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
// 将嵌套对象展开为点分叶键(数组整体作为一个值)
|
||||
const flatten = (obj: Record<string, unknown>, prefix = '', out: Record<string, unknown> = {}) => {
|
||||
for (const [k, v] of Object.entries(obj)) {
|
||||
const key = prefix ? `${prefix}.${k}` : k
|
||||
if (v && typeof v === 'object' && !Array.isArray(v)) {
|
||||
flatten(v as Record<string, unknown>, key, out)
|
||||
} else {
|
||||
out[key] = v
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
const flat = flatten(patch)
|
||||
const keys = Object.keys(flat)
|
||||
if (keys.length === 0) {
|
||||
throw createError({ statusCode: 400, message: '没有可更新的配置', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
for (const [k, v] of Object.entries(flat)) {
|
||||
updateSetting(k, v)
|
||||
}
|
||||
|
||||
writeAudit(event, 'update', 'settings', keys.slice(0, 5).join(','))
|
||||
return { ok: true, settings: getSettings() }
|
||||
})
|
||||
@@ -0,0 +1,20 @@
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { getContentStats } from '../../utils/content'
|
||||
|
||||
/**
|
||||
* 后台 Dashboard 统计
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const db = getDb()
|
||||
const one = (sql: string) => (db.prepare(sql).get() as { c: number }).c
|
||||
return {
|
||||
...getContentStats(),
|
||||
users: one('SELECT COUNT(*) AS c FROM users'),
|
||||
comments: one('SELECT COUNT(*) AS c FROM comments'),
|
||||
contacts: one('SELECT COUNT(*) AS c FROM contacts'),
|
||||
subscribers: one('SELECT COUNT(*) AS c FROM subscribers'),
|
||||
favorites: one('SELECT COUNT(*) AS c FROM favorites'),
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,13 @@
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 后台订阅列表
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const subscribers = getDb()
|
||||
.prepare('SELECT id, email, created_at AS createdAt FROM subscribers ORDER BY created_at DESC')
|
||||
.all()
|
||||
return { subscribers }
|
||||
})
|
||||
@@ -0,0 +1,20 @@
|
||||
import { createError, getRouterParam } from 'h3'
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
import { writeAudit } from '../../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台删除订阅
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const db = getDb()
|
||||
const target = db.prepare('SELECT id FROM subscribers WHERE id = ?').get(id)
|
||||
if (!target) {
|
||||
throw createError({ statusCode: 404, message: '订阅不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
db.prepare('DELETE FROM subscribers WHERE id = ?').run(id)
|
||||
writeAudit(event, 'delete', `subscriber:${id}`)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
|
||||
/**
|
||||
* 导出订阅 CSV(UTF-8 BOM,兼容 Excel)
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const rows = getDb()
|
||||
.prepare('SELECT email, created_at AS createdAt FROM subscribers ORDER BY created_at DESC')
|
||||
.all() as Array<{ email: string; createdAt: string }>
|
||||
|
||||
const escape = (v: string) => `"${String(v).replace(/"/g, '""')}"`
|
||||
const lines = ['email,created_at', ...rows.map((r) => `${escape(r.email)},${escape(r.createdAt)}`)]
|
||||
const csv = '' + lines.join('\n')
|
||||
|
||||
return new Response(csv, {
|
||||
headers: {
|
||||
'Content-Type': 'text/csv; charset=utf-8',
|
||||
'Content-Disposition': `attachment; filename="subscribers-${new Date().toISOString().slice(0, 10)}.csv"`,
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,34 @@
|
||||
import { readMultipartFormData, createError } from 'h3'
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { saveImage, IMAGE_EXT_BY_TYPE, UploadError } from '../../utils/upload'
|
||||
import { writeAudit } from '../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台图片上传:走 OSS(未配置时本地回退),返回 /uploads/<folder>/<name>
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdmin(event)
|
||||
|
||||
const parts = await readMultipartFormData(event)
|
||||
const file = parts?.find((p) => p.name === 'file' && p.data?.length)
|
||||
if (!file || !file.data) {
|
||||
throw createError({ statusCode: 400, message: '缺少文件', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const type = file.type || ''
|
||||
if (!IMAGE_EXT_BY_TYPE[type]) {
|
||||
throw createError({ statusCode: 400, message: '仅支持图片(png/jpg/gif/webp/svg/avif)', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
let url: string
|
||||
try {
|
||||
url = await saveImage(Buffer.from(file.data), type, 'images')
|
||||
} catch (err) {
|
||||
if (err instanceof UploadError) {
|
||||
throw createError({ statusCode: 400, message: err.message, data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
throw err
|
||||
}
|
||||
|
||||
writeAudit(event, 'upload', `oss:${url}`)
|
||||
return { ok: true, url }
|
||||
})
|
||||
@@ -0,0 +1,41 @@
|
||||
import { getQuery, createError } from 'h3'
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getConfig } from '../../utils/config'
|
||||
import { getOssConfig, deleteObject } from '../../utils/s3'
|
||||
import { writeAudit } from '../../utils/audit'
|
||||
import { unlinkSync, existsSync } from 'node:fs'
|
||||
import { join, dirname } from 'node:path'
|
||||
|
||||
/**
|
||||
* 后台删除上传的文件(DELETE /api/admin/uploads?name=<key>)
|
||||
* - OSS 已配置 -> deleteObject(name)(name 为完整对象 key,如 images/abc.png)
|
||||
* - 否则回退删除本地文件
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const q = getQuery(event)
|
||||
const name = String(q?.name ?? '')
|
||||
|
||||
if (!name || name.includes('..')) {
|
||||
throw createError({ statusCode: 400, message: '非法文件名', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
const oss = getOssConfig()
|
||||
if (oss) {
|
||||
deleteObject(name).then(() => writeAudit(event, 'delete', `oss:${name}`))
|
||||
return { ok: true }
|
||||
}
|
||||
|
||||
// 本地回退:仅允许纯文件名
|
||||
const basename = name.split('/').pop() ?? ''
|
||||
if (!basename || basename.includes('\\')) {
|
||||
throw createError({ statusCode: 400, message: '非法文件名', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const filePath = join(dirname(getConfig().dbPath), 'uploads', basename)
|
||||
if (!existsSync(filePath)) {
|
||||
throw createError({ statusCode: 404, message: '文件不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
unlinkSync(filePath)
|
||||
writeAudit(event, 'delete', `local:${basename}`)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -0,0 +1,35 @@
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getConfig } from '../../utils/config'
|
||||
import { getOssConfig, listObjectsV2 } from '../../utils/s3'
|
||||
import { readdirSync, statSync } from 'node:fs'
|
||||
import { join, dirname } from 'node:path'
|
||||
|
||||
/**
|
||||
* 后台图片管理:列出上传的文件
|
||||
* - OSS 已配置 -> ListObjectsV2(prefix=images/)
|
||||
* - 否则回退本地 /data/uploads
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdmin(event)
|
||||
|
||||
const oss = getOssConfig()
|
||||
if (oss) {
|
||||
const files = await listObjectsV2('images/')
|
||||
return { files, storage: 'oss' }
|
||||
}
|
||||
|
||||
const dir = join(dirname(getConfig().dbPath), 'uploads')
|
||||
const files: Array<{ name: string; size: number; modified: string; url: string }> = []
|
||||
try {
|
||||
for (const name of readdirSync(dir)) {
|
||||
const p = join(dir, name)
|
||||
const st = statSync(p)
|
||||
if (!st.isFile()) continue
|
||||
files.push({ name, size: st.size, modified: st.mtime.toISOString(), url: `/uploads/${name}` })
|
||||
}
|
||||
} catch {
|
||||
// 目录可能尚不存在
|
||||
}
|
||||
files.sort((a, b) => b.modified.localeCompare(a.modified))
|
||||
return { files, storage: 'local' }
|
||||
})
|
||||
@@ -0,0 +1,13 @@
|
||||
import { requireAdmin } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
|
||||
/**
|
||||
* 后台用户列表
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
requireAdmin(event)
|
||||
const users = getDb()
|
||||
.prepare('SELECT id, username, email, phone, role, created_at AS createdAt FROM users ORDER BY id DESC')
|
||||
.all()
|
||||
return { users }
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
import { createError, getRouterParam } from 'h3'
|
||||
import { requireAdmin } from '../../../utils/auth'
|
||||
import { getDb } from '../../../utils/db'
|
||||
import { writeAudit } from '../../../utils/audit'
|
||||
|
||||
/**
|
||||
* 后台删除用户(连带删除其会话/评论/收藏)
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
const me = requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const db = getDb()
|
||||
|
||||
if (me.id === id) {
|
||||
throw createError({ statusCode: 400, message: '不能删除自己的账号', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const target = db.prepare('SELECT id FROM users WHERE id = ?').get(id)
|
||||
if (!target) {
|
||||
throw createError({ statusCode: 404, message: '用户不存在', data: { code: 'NOT_FOUND' } })
|
||||
}
|
||||
db.prepare('DELETE FROM users WHERE id = ?').run(id) // 外键级联:sessions/comments/favorites
|
||||
writeAudit(event, 'delete', `user:${id}`)
|
||||
return { ok: true }
|
||||
})
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user