From 5c3f3bca63b57ffa998cbd6cfd5000f8fcf6e166 Mon Sep 17 00:00:00 2001 From: chenchun Date: Thu, 6 Aug 2026 15:00:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=A8=E9=87=8F=E8=90=BD=E5=9C=B0?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E4=B8=8E=E5=8A=9F=E8=83=BD=E9=97=AD=E7=8E=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 真实后端(server/):SQLite 存储 + scrypt 会话鉴权 + SMTP 邮件 - auth 注册/登录/登出/me/资料更新 - contact 联系表单(落库+邮件)、newsletter 订阅(去重) - favorites 作品收藏、comments 新闻评论、account 管理收件箱 - 用户系统 UI:个人中心 /account(资料/收藏/评论/管理员面板)、 收藏按钮、评论组件、登录/注册弹窗接真实 API(useApiError 错误映射) - 内容单点事实源:app/data/news|work 消除三处重复,页面全部引用 - 修复断链:首页动态/作品卡可点击、分享按钮真实动作、移除 # 死链、 语言切换器、社交链接统一 siteConfig - SEO:动态 sitemap/robots、JSON-LD、脚本生成真实 og-image.png - 列表增强:搜索 + 加载更多 - 部署自动化:build-and-push.sh 支持 git tag 版本化镜像; deploy.sh 一条命令构建推送+注入 Secret/ConfigMap+kubectl 滚动升级; deployment 挂 PVC 持久化;Dockerfile 支持 better-sqlite3 原生编译 - 组件注册去目录前缀,修复 AppLoader/AnimatedButton 等未渲染问题 --- .dockerignore | 7 +- .env.example | 29 + Dockerfile | 11 +- README.md | 122 ++-- app/app.vue | 26 +- app/components/common/CommentSection.vue | 154 +++++ app/components/common/FavoriteButton.vue | 71 +++ app/components/common/LoginModal.vue | 109 ++-- app/components/common/RegisterModal.vue | 156 +++-- app/components/home/HomePartnersWork.vue | 92 +-- app/components/home/HomeTechStack.vue | 2 +- app/components/home/HomeUpdates.vue | 95 +--- app/components/layouts/ArcticNewOneFooter.vue | 47 +- app/components/layouts/ArcticNewOneHeader.vue | 98 ++-- app/composables/useApiError.ts | 31 + app/config/site.ts | 27 + app/data/news.ts | 98 ++++ app/data/work.ts | 108 ++++ app/pages/account.vue | 308 ++++++++++ app/pages/contact.vue | 46 +- app/pages/news/[slug].vue | 175 +++--- app/pages/news/index.vue | 176 +++--- app/pages/work/[slug].vue | 164 +----- app/pages/work/index.vue | 156 ++--- app/stores/authModal.ts | 56 ++ app/stores/user.ts | 159 +++--- build-and-push.sh | 83 ++- deploy.sh | 108 ++++ deploy/README.md | 87 +-- deploy/deployment.yaml | 33 +- deploy/pvc.yaml | 19 + i18n/locales/en.json | 171 ++++-- i18n/locales/zh.json | 171 ++++-- nuxt.config.ts | 19 + package.json | 6 +- pnpm-lock.yaml | 535 +++++++++++------- pnpm-workspace.yaml | 1 + public/og-image.png | Bin 0 -> 82869 bytes public/robots.txt | 2 - scripts/generate-og.mjs | 139 +++++ server/api/account/admin.get.ts | 30 + server/api/account/comments.get.ts | 15 + server/api/auth/login.post.ts | 30 + server/api/auth/logout.post.ts | 14 + server/api/auth/me.get.ts | 13 + server/api/auth/me.patch.ts | 41 ++ server/api/auth/register.post.ts | 54 ++ server/api/comments.get.ts | 34 ++ server/api/comments.post.ts | 41 ++ server/api/contact.post.ts | 43 ++ server/api/favorites.delete.ts | 16 + server/api/favorites.get.ts | 13 + server/api/favorites.post.ts | 23 + server/api/newsletter.post.ts | 32 ++ server/routes/robots.txt.ts | 18 + server/routes/sitemap.xml.ts | 44 ++ server/utils/auth.ts | 134 +++++ server/utils/config.ts | 56 ++ server/utils/db.ts | 101 ++++ server/utils/email.ts | 52 ++ server/utils/validation.ts | 25 + 61 files changed, 3408 insertions(+), 1318 deletions(-) create mode 100644 .env.example create mode 100644 app/components/common/CommentSection.vue create mode 100644 app/components/common/FavoriteButton.vue create mode 100644 app/composables/useApiError.ts create mode 100644 app/config/site.ts create mode 100644 app/data/news.ts create mode 100644 app/data/work.ts create mode 100644 app/pages/account.vue create mode 100644 app/stores/authModal.ts create mode 100755 deploy.sh create mode 100644 deploy/pvc.yaml create mode 100644 public/og-image.png delete mode 100755 public/robots.txt create mode 100644 scripts/generate-og.mjs create mode 100644 server/api/account/admin.get.ts create mode 100644 server/api/account/comments.get.ts create mode 100644 server/api/auth/login.post.ts create mode 100644 server/api/auth/logout.post.ts create mode 100644 server/api/auth/me.get.ts create mode 100644 server/api/auth/me.patch.ts create mode 100644 server/api/auth/register.post.ts create mode 100644 server/api/comments.get.ts create mode 100644 server/api/comments.post.ts create mode 100644 server/api/contact.post.ts create mode 100644 server/api/favorites.delete.ts create mode 100644 server/api/favorites.get.ts create mode 100644 server/api/favorites.post.ts create mode 100644 server/api/newsletter.post.ts create mode 100644 server/routes/robots.txt.ts create mode 100644 server/routes/sitemap.xml.ts create mode 100644 server/utils/auth.ts create mode 100644 server/utils/config.ts create mode 100644 server/utils/db.ts create mode 100644 server/utils/email.ts create mode 100644 server/utils/validation.ts diff --git a/.dockerignore b/.dockerignore index d69511a..71a935c 100755 --- a/.dockerignore +++ b/.dockerignore @@ -1,10 +1,15 @@ # 依赖目录 node_modules/ -pnpm-workspace.yaml # 编译产出目录 .output/ .nuxt/ +.nitro/ +.cache/ +dist/ + +# 本地数据(开发数据库,不进镜像) +.data/ # 环境变量文件(通常不应该被打包进去) .env diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a12906d --- /dev/null +++ b/.env.example @@ -0,0 +1,29 @@ +# ========================================================= +# Arcticnewone 本地开发环境变量示例 +# 复制为 .env 使用(.env 已被 gitignore,不会提交) +# +# Nuxt runtimeConfig 的环境变量映射约定:一律使用 NUXT_ 前缀 +# ========================================================= + +# 站点公开地址(用于 sitemap/robots/og 等绝对链接) +NUXT_PUBLIC_SITE_URL=https://personal.virtheart.com + +# 会话安全密钥(生产必须设置为高强度随机值) +# 生成方式: node -e "console.log(require('crypto').randomBytes(48).toString('hex'))" +NUXT_SESSION_SECRET=dev-change-me-to-a-long-random-string + +# 数据文件路径(默认:生产 /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 diff --git a/Dockerfile b/Dockerfile index 60c86e4..637a88e 100755 --- a/Dockerfile +++ b/Dockerfile @@ -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 # 复制项目源代码 diff --git a/README.md b/README.md index 5104a48..15f8d4f 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,17 @@ # Arcticnewone 个人网站 -北极新一(Arcticnewone)的个人网站,提供个人介绍、作品集、工作室服务、动态资讯、工具箱与联系页面,是一个现代化的展示型站点。 +北极新一(Arcticnewone)的个人网站,提供个人介绍、作品集、工作室服务、动态资讯、工具箱与联系页面,是一个现代化的展示型站点。已内置**真实后端**(登录/注册、联系留言、邮箱订阅、作品收藏、新闻评论、管理员收件箱)与 **中英双语、SEO、搜索分页** 等完整功能。 ## 技术栈 -- [Nuxt 4](https://nuxt.com/) — 应用框架(服务端渲染 + 静态生成) +- [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) — 图标 - [pnpm](https://pnpm.io/) — 包管理器 @@ -26,7 +28,10 @@ # 1. 安装依赖 pnpm install -# 2. 启动开发服务器(默认 http://localhost:3000) +# 2. 配置环境变量(可选,SMTP 未配置时联系/订阅仍会真实落库) +cp .env.example .env + +# 3. 启动开发服务器(默认 http://localhost:3000) pnpm dev ``` @@ -42,64 +47,101 @@ pnpm dev | `pnpm preview` | 本地预览生产构建 | | `pnpm start` | 以 Node 方式启动 `.output/server/index.mjs` | +## 功能一览 + +| 模块 | 说明 | +| --- | --- | +| 页面 | 首页、工作室、作品(列表/详情)、动态(列表/详情)、工具箱、联系、个人中心 | +| 用户系统 | 真实注册/登录/登出(scrypt 密码哈希 + httpOnly Cookie 会话) | +| 个人中心 | `/account`:资料编辑、作品收藏、我的评论;管理员可见联系/订阅收件箱 | +| 交互 | 作品收藏、新闻评论、分享(X/LinkedIn/复制链接)、搜索、加载更多 | +| 国际化 | 中/英双语,Header 一键切换(`no_prefix`,默认中文) | +| SEO | 动态 `sitemap.xml` / `robots.txt`、JSON-LD、自动生成的 `og-image.png` | +| 邮件 | SMTP 发送联系/订阅邮件;未配置 SMTP 时数据仍真实写入 SQLite | + +### 环境变量(详见 `.env.example`,Nuxt runtimeConfig 使用 `NUXT_` 前缀) + +| 变量 | 说明 | +| --- | --- | +| `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` | 管理员邮箱(逗号分隔),命中者个人中心可见管理面板 | + +> `deploy.sh` 中的对外变量名(`SESSION_SECRET`/`SMTP_*`/`CONTACT_TO`/`ADMIN_EMAILS`)会在写入 K8s Secret 时自动加 `NUXT_` 前缀。 + ## 项目结构 ```text . ├── app/ # 应用源码(Nuxt 4 约定目录) -│ ├── app.vue # 应用入口(全局 SEO / Meta) -│ ├── assets/ # 静态资源(样式、图片等) -│ ├── components/ # 组件(common / home) -│ ├── composables/ # 组合式函数 -│ ├── layouts/ # 布局 -│ ├── pages/ # 页面(首页、工作室、作品、动态、工具、联系) -│ ├── plugins/ # 插件(如 Lenis 平滑滚动) -│ ├── stores/ # Pinia 状态 -│ └── types/ # 类型定义 -├── i18n/ -│ └── locales/ # 国际化文案(zh.json / en.json) -├── public/ # 公开静态文件(favicon、robots.txt 等) -├── Dockerfile # 容器镜像构建 -├── deploy/ # 生产部署配置(Kubernetes Deployment/Service/Ingress) -├── docker-compose.yml # 本地容器编排(使用 SWR 镜像) -├── nuxt.config.ts # Nuxt 配置(模块、i18n、Tailwind 等) -├── tailwind.config.js # Tailwind 配置 -└── package.json # 项目依赖与脚本 +│ ├── app.vue # 应用入口(全局 SEO / Meta / JSON-LD) +│ ├── config/ # 站点配置(品牌、邮箱、社交链接) +│ ├── data/ # 内容单一事实源(news / work,列表/详情/首页共用) +│ ├── pages/ # 页面(含 account.vue 个人中心) +│ ├── components/ # 组件(common / home / layouts) +│ ├── stores/ # Pinia 状态(用户、认证弹窗) +│ └── ... +├── server/ # Nitro 后端(utils 数据/鉴权/邮件 + api 路由 + sitemap/robots) +├── 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:分架构推送后用 `docker manifest` 合并为 `latest`(标准 Docker manifest list,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 在国内不可达)。 - -本地启动(使用 SWR 镜像,与生产一致): +### 仅构建镜像(不部署) ```bash -docker compose up -d +./build-and-push.sh # 版本取最新 git tag +./build-and-push.sh 0.0.1-dev # 显式指定版本 ``` -生产部署使用 `deploy/` 目录下的 Kubernetes 配置(Deployment / Service / Ingress), -镜像统一推送到华为云 SWR(`swr.cn-north-4.myhuaweicloud.com/virtheart/arcticnewone:latest`), -部署与回滚步骤见 [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')` - -新增文案时,在 `zh.json` 和 `en.json` 中同步添加对应键即可。 +- 默认语言为中文(`defaultLocale: 'zh'`),URL 不包含语言前缀(`strategy: 'no_prefix'`),Header 提供中/EN 切换 +- 组件中通过 `useI18n()` 的 `t()` 方法读取文案;新增文案时同步更新两个语言文件(可用根目录脚本校验键对齐) ## 说明 -本项目不含任何密钥或敏感信息;本地环境变量请使用 `.env` 文件(已被 `.gitignore` 忽略)。 +- 本项目不含任何密钥或敏感信息;本地环境变量请使用 `.env` 文件(已被 `.gitignore` 忽略) +- 联系/订阅依赖 SMTP:未配置时数据仍真实写入数据库,仅在管理面板可见但不会发邮件 +- 社交链接为品牌占位地址(`app/config/site.ts`),正式上线前请替换为真实账号 diff --git a/app/app.vue b/app/app.vue index 976880d..b68c4bf 100755 --- a/app/app.vue +++ b/app/app.vue @@ -1,18 +1,37 @@ diff --git a/app/components/common/FavoriteButton.vue b/app/components/common/FavoriteButton.vue new file mode 100644 index 0000000..e1c3d0f --- /dev/null +++ b/app/components/common/FavoriteButton.vue @@ -0,0 +1,71 @@ + + + diff --git a/app/components/common/LoginModal.vue b/app/components/common/LoginModal.vue index 8d87411..d83a5cc 100644 --- a/app/components/common/LoginModal.vue +++ b/app/components/common/LoginModal.vue @@ -2,7 +2,7 @@
@@ -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,26 +66,21 @@ - -

- {{ t('auth.demoHint') }} -

- -

+

{{ t('auth.noAccount') }} -

@@ -98,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() -const emit = defineEmits<{ - close: [] - switchToRegister: [] -}>() - -const modalRef = ref(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('auth.loginError') + 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) } diff --git a/app/components/common/RegisterModal.vue b/app/components/common/RegisterModal.vue index cb600c5..c2c94fc 100644 --- a/app/components/common/RegisterModal.vue +++ b/app/components/common/RegisterModal.vue @@ -2,7 +2,7 @@
@@ -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 @@

{{ t('auth.alreadyHaveAccount') }} -

@@ -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() -const emit = defineEmits<{ - close: [] - switchToLogin: [] -}>() - -const modalRef = ref(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 = result.error || t('auth.registerError') + 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) } diff --git a/app/components/home/HomePartnersWork.vue b/app/components/home/HomePartnersWork.vue index ed9d80b..bf14abe 100755 --- a/app/components/home/HomePartnersWork.vue +++ b/app/components/home/HomePartnersWork.vue @@ -3,6 +3,7 @@ import { onMounted, onUnmounted, ref, nextTick } from 'vue' import { useI18n } from 'vue-i18n' import gsap from 'gsap' import { ScrollTrigger } from 'gsap/ScrollTrigger' +import { workItems } from '~/data/work' gsap.registerPlugin(ScrollTrigger) @@ -49,46 +50,6 @@ 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 const refresh = () => { @@ -140,12 +101,12 @@ onMounted(async () => { tl.to( next, { y: 0, duration: 1, ease: 'power2.out' }, - start + start, ) tl.to( prev, { scale: scaleTo, y: depthOffsetY, duration: 0.6, ease: 'power2.out' }, - start + 0.35 + start + 0.35, ) tl.set(prev, { scale: scaleTo, y: depthOffsetY }, start + 1) } @@ -235,29 +196,30 @@ onUnmounted(() => {
-
- -
-

- {{ t(item.titleKey) }} -

-

- {{ item.year }} © -

-
-
+ + +
+

+ {{ t(`work.items.${item.slug}.title`) }} +

+

+ {{ item.year }} © +

+
+
diff --git a/app/components/home/HomeTechStack.vue b/app/components/home/HomeTechStack.vue index 617eea6..a7738b0 100644 --- a/app/components/home/HomeTechStack.vue +++ b/app/components/home/HomeTechStack.vue @@ -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)" > diff --git a/app/components/home/HomeUpdates.vue b/app/components/home/HomeUpdates.vue index 5dfe25d..ed3b57b 100644 --- a/app/components/home/HomeUpdates.vue +++ b/app/components/home/HomeUpdates.vue @@ -13,11 +13,12 @@
-
- {{ t(`home.updates.categories.${item.category}`) }} + {{ t(`news.categories.${item.category}`) }}

- {{ t(`home.updates.items.${item.id}.title`) }} + {{ t(`news.items.${item.slug}.title`) }}

- {{ t(`home.updates.items.${item.id}.description`) }} + {{ t(`news.items.${item.slug}.excerpt`) }}

- {{ item.date }} + {{ formatNewsDate(item.date, locale) }}
-
+
@@ -73,10 +74,11 @@ import { ref, onMounted, onUnmounted, nextTick } from 'vue' import { useI18n } from 'vue-i18n' import gsap from 'gsap' import { ScrollTrigger } from 'gsap/ScrollTrigger' +import { newsItems, formatNewsDate } from '~/data/news' gsap.registerPlugin(ScrollTrigger) -const { t } = useI18n() +const { t, locale } = useI18n() const rootRef = ref(null) const headerRef = ref(null) @@ -87,62 +89,21 @@ 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' - } -] +// 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 = newsItems.slice(0, 6).map((item, i) => ({ + ...item, + ...layout[i], +})) // 卡片悬浮效果 const handleCardHover = (index: number, isHover: boolean) => { @@ -155,7 +116,7 @@ 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', }) } @@ -171,7 +132,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) diff --git a/app/components/layouts/ArcticNewOneFooter.vue b/app/components/layouts/ArcticNewOneFooter.vue index 8a096b5..914c202 100755 --- a/app/components/layouts/ArcticNewOneFooter.vue +++ b/app/components/layouts/ArcticNewOneFooter.vue @@ -5,6 +5,7 @@ import { gsap } from 'gsap' import { ScrollTrigger } from 'gsap/ScrollTrigger' import FooterLogo from '~/components/common/FooterLogo.vue' import AnimatedButton from '~/components/common/AnimatedButton.vue' +import { siteConfig } from '~/config/site' gsap.registerPlugin(ScrollTrigger) @@ -43,14 +44,8 @@ const handleNewsletterSubmit = async () => { subscribeStatus.value = 'idle' try { - // 模拟 API 调用 - 你需要替换为真实的 Newsletter 服务 - // 可选方案: - // 1. Mailchimp: await $fetch('/api/newsletter/subscribe', { method: 'POST', body: { email: newsletterEmail.value } }) - // 2. ConvertKit, SendGrid, 或其他邮件服务 - - await new Promise(resolve => setTimeout(resolve, 1000)) // 模拟网络延迟 - - console.log('Newsletter subscription:', newsletterEmail.value) + // 真实订阅:落库 + 尽力发送欢迎邮件 + await $fetch('/api/newsletter', { method: 'POST', body: { email: newsletterEmail.value } }) subscribeStatus.value = 'success' newsletterEmail.value = '' @@ -61,8 +56,12 @@ const handleNewsletterSubmit = async () => { }, 3000) } catch (error) { - console.error('Newsletter subscription error:', error) - subscribeStatus.value = 'error' + // 已在订阅列表视为成功(用户确实已订阅) + if ((error as any)?.data?.code === 'ALREADY_SUBSCRIBED') { + subscribeStatus.value = 'success' + } else { + subscribeStatus.value = 'error' + } setTimeout(() => { subscribeStatus.value = 'idle' @@ -227,10 +226,10 @@ onUnmounted(() => {
diff --git a/app/components/layouts/ArcticNewOneHeader.vue b/app/components/layouts/ArcticNewOneHeader.vue index a6484cf..20bfd85 100755 --- a/app/components/layouts/ArcticNewOneHeader.vue +++ b/app/components/layouts/ArcticNewOneHeader.vue @@ -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(null) const bottomHeaderRef = ref(null) const mobileMenuRef = ref(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 | null = null let isBottomHeaderVisible = false let fallbackTimer: ReturnType | 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') { - + - - + + - - + +
diff --git a/app/composables/useApiError.ts b/app/composables/useApiError.ts new file mode 100644 index 0000000..465f332 --- /dev/null +++ b/app/composables/useApiError.ts @@ -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 = { + 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) + } +} diff --git a/app/config/site.ts b/app/config/site.ts new file mode 100644 index 0000000..0eb3903 --- /dev/null +++ b/app/config/site.ts @@ -0,0 +1,27 @@ +/** + * 站点全局元数据(品牌、联系、社交)。 + * + * 单一事实源:Footer、联系页、账号页等不再各自硬编码邮箱/社交链接。 + * + * 注意:社交地址为品牌官方占位链接,正式上线前请替换为北极新一真实账号。 + */ +export interface SocialLink { + name: string + icon: string + url: string +} + +export const siteConfig = { + brand: 'ArcticNewOne', + brandZh: '北极新一', + email: 'chenchun@virtheart.com', + infoEmail: 'info@virtheart.com', + wechat: 'LucskyNew', + copyright: '© 2026 北极新一工作室', + 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' }, + ], +} diff --git a/app/data/news.ts b/app/data/news.ts new file mode 100644 index 0000000..89a612b --- /dev/null +++ b/app/data/news.ts @@ -0,0 +1,98 @@ +/** + * 动态(news)单一事实源。 + * + * 列表页、详情页、首页 HomeUpdates 一律引用本模块,杜绝三处重复。 + * 标题/摘要/正文属于本地化文案,按 slug 存放在 i18n(news.items..*), + * 本模块只保存与语言无关的结构化元数据。 + */ +export interface NewsItem { + slug: string + category: 'insights' | 'projects' | 'announcements' + /** 分类徽章 tailwind 类(静态字符串,Tailwind 扫描 ./app/** 可命中) */ + badge: string + date: string + readTime: string + author: string + image: string +} + +export const newsItems: NewsItem[] = [ + { + slug: 'design-trends-2026', + category: 'insights', + badge: 'bg-purple-100 text-purple-700', + date: '2026-05-28', + readTime: '5', + author: 'ArcticNewOne', + image: 'https://picsum.photos/id/1/800/500', + }, + { + slug: 'forma-digital-launch', + category: 'projects', + badge: 'bg-blue-100 text-blue-700', + date: '2026-05-15', + readTime: '3', + author: 'ArcticNewOne', + image: 'https://picsum.photos/id/201/800/500', + }, + { + slug: 'studio-expansion', + category: 'announcements', + badge: 'bg-green-100 text-green-700', + date: '2026-05-10', + readTime: '2', + author: 'ArcticNewOne', + image: 'https://picsum.photos/id/164/800/500', + }, + { + slug: 'ux-research-methods', + category: 'insights', + badge: 'bg-purple-100 text-purple-700', + date: '2026-04-28', + readTime: '7', + author: 'ArcticNewOne', + image: 'https://picsum.photos/id/180/800/500', + }, + { + slug: 'bold-moves-case-study', + category: 'projects', + badge: 'bg-blue-100 text-blue-700', + date: '2026-04-20', + readTime: '6', + author: 'ArcticNewOne', + image: 'https://picsum.photos/id/119/800/500', + }, + { + slug: 'new-tools-integration', + category: 'announcements', + badge: 'bg-green-100 text-green-700', + date: '2026-04-12', + readTime: '4', + author: 'ArcticNewOne', + image: 'https://picsum.photos/id/326/800/500', + }, +] + +export const newsBySlug: Record = Object.fromEntries( + newsItems.map((item) => [item.slug, item]), +) + +export function getNewsCategories(): Array { + return ['insights', 'projects', 'announcements'] +} + +/** 显示用的日期(本地化格式化在组件内完成) */ +export function formatNewsDate(date: string, locale: string): string { + const d = new Date(`${date}T00:00:00`) + if (Number.isNaN(d.getTime())) return date + return new Intl.DateTimeFormat(locale === 'zh' ? 'zh-CN' : 'en-US', { + year: 'numeric', + month: 'long', + day: 'numeric', + }).format(d) +} + +/** 显示用的阅读时长(本地化文案在 i18n,数字在此) */ +export function newsReadTime(item: NewsItem): string { + return item.readTime +} diff --git a/app/data/work.ts b/app/data/work.ts new file mode 100644 index 0000000..5220b16 --- /dev/null +++ b/app/data/work.ts @@ -0,0 +1,108 @@ +/** + * 作品(work)单一事实源。 + * + * 列表页、详情页、首页 HomePartnersWork 一律引用本模块,杜绝三处重复。 + * 标题/概述属于本地化文案,按 slug 存放在 i18n(work.items..*)。 + * + * 说明:`url` 只在存在真实线上地址时填写;没有真实地址的作品 + * 详情页不渲染「访问项目」按钮,避免 `#` 死链。 + */ +export interface WorkItem { + slug: string + category: 'webDesign' | 'branding' | 'development' + year: string + tags: string[] + image: string + gallery: string[] + /** 真实线上地址;不存在时省略,详情页隐藏「访问项目」按钮 */ + url?: string +} + +export const workItems: WorkItem[] = [ + { + 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', + ], + }, + { + 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', + ], + }, + { + 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', + ], + }, + { + 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', + ], + }, + { + 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', + ], + }, + { + 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', + ], + }, +] + +export const workBySlug: Record = Object.fromEntries( + workItems.map((item) => [item.slug, item]), +) + +export function getWorkCategories(): Array { + return ['webDesign', 'branding', 'development'] +} diff --git a/app/pages/account.vue b/app/pages/account.vue new file mode 100644 index 0000000..7ea4556 --- /dev/null +++ b/app/pages/account.vue @@ -0,0 +1,308 @@ + + + diff --git a/app/pages/contact.vue b/app/pages/contact.vue index 0f6b230..54ec377 100755 --- a/app/pages/contact.vue +++ b/app/pages/contact.vue @@ -139,7 +139,7 @@ @@ -198,6 +198,7 @@ import { useI18n } from 'vue-i18n' import { useSeoMeta } from '#imports' import gsap from 'gsap' import { useAppStore } from '~/stores/app' +import { siteConfig } from '~/config/site' const { t } = useI18n() const appStore = useAppStore() @@ -234,16 +235,8 @@ const handleSubmit = async () => { statusMessage.value = '' try { - // 模拟 API 调用 - 你需要替换为真实的邮件服务 - // 可选方案: - // 1. 使用 Nuxt server API: await $fetch('/api/contact', { method: 'POST', body: form }) - // 2. 使用 Formspree: await fetch('https://formspree.io/f/YOUR_ID', { ... }) - // 3. 使用 EmailJS 等第三方服务 - - await new Promise(resolve => setTimeout(resolve, 1500)) // 模拟网络延迟 - - // 模拟成功 - console.log('Form submitted:', form) + // 真实提交到后端(落库 + 尽力发送邮件) + await $fetch('/api/contact', { method: 'POST', body: { ...form } }) submitStatus.value = 'success' statusMessage.value = t('contact.form.successMessage') || 'Message sent successfully! We will get back to you soon.' @@ -253,16 +246,17 @@ const handleSubmit = async () => { form[key as keyof typeof form] = '' }) - // 3秒后重置状态 + // 4秒后重置状态 setTimeout(() => { submitStatus.value = 'idle' statusMessage.value = '' - }, 3000) + }, 4000) } catch (error) { console.error('Form submission error:', error) submitStatus.value = 'error' - statusMessage.value = t('contact.form.errorMessage') || 'Failed to send message. Please try again or contact us directly.' + // 如实展示后端错误 + 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 } @@ -362,28 +356,8 @@ interface SocialLink { 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: SocialLink[] = siteConfig.socials