feat: 登录改为 Casdoor 统一身份认证(SSO),重建用户体系
- 移除内置密码注册/登录/改密/删号/头像,统一走 Casdoor OIDC 授权码 - 服务端 casdoor-nodejs-sdk:code 换 token + 证书公钥验签 + get-account 补齐资料 - 用户表重建为 provider+provider_id(Casdoor sub 为准),邮箱不再唯一 - 管理员由 Casdoor token 的 isAdmin/IsAdmin 字段或 admin 角色判定,删除角色切换接口 - 前端登录弹窗改为申统认证跳转,注册去 Casdoor;后台用户列表只读角色 - 会话沿用 an_session httpOnly Cookie,requireUser/requireAdmin 守卫保留 - 配置注入 deploy.sh/.env.example;新增 casdoor 单测,删除 password 单测
This commit is contained in:
+20
-5
@@ -25,11 +25,26 @@ NUXT_SMTP_FROM=
|
||||
# 联系表单留言的接收邮箱
|
||||
NUXT_CONTACT_TO=chenchun@virtheart.com
|
||||
|
||||
# 管理员邮箱(逗号分隔),命中邮箱的用户在个人中心显示管理面板
|
||||
NUXT_ADMIN_EMAILS=chenchun@virtheart.com
|
||||
|
||||
# 预置管理员初始密码(仅首次初始化数据库时创建 admin 账号用;生产由 deploy.sh 注入)
|
||||
# NUXT_ADMIN_INITIAL_PASSWORD=change-me
|
||||
# ---- Casdoor 统一身份认证(SSO)----
|
||||
# 登录/注册全部在 Casdoor 侧完成;本站仅记录用户身份并维护本地会话
|
||||
NUXT_CASDOOR_SERVER_URL=https://sys.virtheart.com
|
||||
NUXT_CASDOOR_CLIENT_ID=a0ba9570e0bcfbeb9f67
|
||||
NUXT_CASDOOR_CLIENT_SECRET=
|
||||
NUXT_CASDOOR_ORG_NAME=virtheart
|
||||
NUXT_CASDOOR_APP_NAME=virtheat-personal
|
||||
# 应用证书公钥 PEM:Casdoor「应用 -> Certificates」页复制,可 base64 或原文写入
|
||||
# base64: cat cert.pem | base64 | tr -d '\n'
|
||||
NUXT_CASDOOR_CERT_B64=
|
||||
# 命中任一角色名即管理员(对应 Casdoor 用户角色;token 的 IsAdmin 字段同样生效)
|
||||
NUXT_CASDOOR_ADMIN_ROLES=admin
|
||||
# 回调用路径(redirect_uri = NUXT_PUBLIC_SITE_URL + 该路径,需与 Casdoor 应用配置一致)
|
||||
NUXT_CASDOOR_CALLBACK_PATH=/api/auth/callback
|
||||
# 浏览器端可见的 Casdoor 配置(不含任何 secret;用于注册页/登出地址等)
|
||||
NUXT_PUBLIC_CASDOOR_SERVER_URL=https://sys.virtheart.com
|
||||
NUXT_PUBLIC_CASDOOR_CLIENT_ID=a0ba9570e0bcfbeb9f67
|
||||
NUXT_PUBLIC_CASDOOR_ORG_NAME=virtheart
|
||||
NUXT_PUBLIC_CASDOOR_APP_NAME=virtheat-personal
|
||||
NUXT_PUBLIC_CASDOOR_REDIRECT_PATH=/api/auth/callback
|
||||
|
||||
# ---- OSS 文件存储(RustFS / S3 v4 兼容;凭据不写入仓库,生产由 deploy.sh 注入 Secret)----
|
||||
NUXT_OSS_ENDPOINT=oss.virtheart.com
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Arcticnewone 个人网站
|
||||
|
||||
北极新一(Arcticnewone)的个人网站,提供个人介绍、作品集、工作室服务、动态资讯、工具箱与联系页面,是一个现代化的展示型站点。已内置**真实后端**(登录/注册、联系留言、邮箱订阅、作品收藏、新闻评论、管理员收件箱)与 **中英双语、SEO、搜索分页** 等完整功能。
|
||||
北极新一(Arcticnewone)的个人网站,提供个人介绍、作品集、工作室服务、动态资讯、工具箱与联系页面,是一个现代化的展示型站点。已内置**真实后端**(Casdoor 统一身份认证、联系留言、邮箱订阅、作品收藏、新闻评论、管理员收件箱)与 **中英双语、SEO、搜索分页** 等完整功能。
|
||||
|
||||
## 技术栈
|
||||
|
||||
@@ -55,28 +55,30 @@ pnpm dev
|
||||
| **后台管理** | `/admin`:Dashboard、动态/作品增删改(双语 CMS)、用户/评论/联系/订阅管理、图片管理(OSS)、操作审计日志、**站点动态配置** |
|
||||
| **动态配置** | 站点信息/联系方式/社交链接/工具箱/页脚文案/SEO 均可在 `/admin/settings` 后台修改,前台即时生效 |
|
||||
| **文件存储** | 图片上传/管理使用 OSS(RustFS,S3 v4 兼容,桶 `arcticnewone`),经 `/uploads` 代理服务 |
|
||||
| 用户系统 | 注册/登录/登出、修改密码、自助删除账号、预置 admin;个人中心(资料/收藏/评论) |
|
||||
| 用户系统 | Casdoor 统一身份认证(SSO)登录/注册/登出,管理员由认证中心角色(`IsAdmin` claim)判定;个人中心(资料/收藏/评论) |
|
||||
| 交互 | 作品收藏、新闻评论、分享(X/LinkedIn/复制链接)、搜索、加载更多 |
|
||||
| 国际化 | 中/英双语,Header 一键切换;内容双语存于数据库 |
|
||||
| SEO | 动态 `sitemap.xml`/`robots.txt`/`feed.xml`(RSS)、JSON-LD、canonical、`og-image.png` |
|
||||
| 工程 | `pnpm test`(vitest:密码/SigV4/校验器/种子/配置 17 例) |
|
||||
| 工程 | `pnpm test`(vitest:Casdoor 判定/登录地址/SigV4/校验器/种子 22 例) |
|
||||
|
||||
> **预置管理员**:首次部署设置 `ADMIN_INITIAL_PASSWORD`(或由 `deploy.sh` 自动生成并打印)会自动创建 `admin` 账号,登录后访问 `/admin` 管理内容与配置。
|
||||
> **管理员说明**:用户角色由 Casdoor 统一认证判定(token 的 `IsAdmin`/`isAdmin` 字段或命中 `NUXT_CASDOOR_ADMIN_ROLES` 角色名)。在 Casdoor 中将用户的 role 设为 `admin` 即可获得本站管理权限,本站不再内置密码/角色切换。
|
||||
|
||||
### 环境变量(详见 `.env.example`,Nuxt runtimeConfig 使用 `NUXT_` 前缀)
|
||||
|
||||
| 变量 | 说明 |
|
||||
| --- | --- |
|
||||
| `NUXT_PUBLIC_SITE_URL` | 站点公开地址(sitemap/robots/og 绝对链接) |
|
||||
| `NUXT_PUBLIC_SITE_URL` | 站点公开地址(sitemap/robots/og 绝对链接,作为 Casdoor 回跳基址) |
|
||||
| `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_CASDOOR_SERVER_URL/CLIENT_ID/CLIENT_SECRET/ORG_NAME/APP_NAME` | Casdoor 应用凭据(Secret 侧) |
|
||||
| `NUXT_CASDOOR_CERT_B64` | 应用证书公钥 PEM(base64,用于 JWT 验签) |
|
||||
| `NUXT_CASDOOR_ADMIN_ROLES` | 管理员角色名(逗号分隔,默认 `admin`) |
|
||||
| `NUXT_PUBLIC_CASDOOR_SERVER_URL/CLIENT_ID/ORG_NAME/APP_NAME/REDIRECT_PATH` | 浏览器端可见的 Casdoor 配置(无 secret) |
|
||||
| `NUXT_OSS_ENDPOINT/ACCESS_KEY/SECRET_KEY/BUCKET/REGION/PUBLIC_BASE` | OSS 文件存储(RustFS / S3 v4,凭据仅走 Secret,不写入仓库) |
|
||||
|
||||
> `deploy.sh` 中的对外变量名(`SESSION_SECRET`/`SMTP_*`/`CONTACT_TO`/`ADMIN_EMAILS`/`ADMIN_INITIAL_PASSWORD`/`OSS_*`)会在写入 K8s Secret 时自动加 `NUXT_` 前缀。
|
||||
> `deploy.sh` 中的对外变量名(`SESSION_SECRET`/`SMTP_*`/`CONTACT_TO`/`CASDOOR_*`/`OSS_*`)会在写入 K8s Secret/ConfigMap 时自动加 `NUXT_` 前缀。
|
||||
|
||||
## 项目结构
|
||||
|
||||
|
||||
@@ -7,7 +7,12 @@
|
||||
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>
|
||||
<template v-for="o in options" :key="isGroup(o) ? o.group : o.value">
|
||||
<optgroup v-if="isGroup(o)" :label="o.group">
|
||||
<option v-for="opt in o.options" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
|
||||
</optgroup>
|
||||
<option v-else :value="o.value">{{ o.label }}</option>
|
||||
</template>
|
||||
</select>
|
||||
</div>
|
||||
</template>
|
||||
@@ -17,9 +22,14 @@ interface Option {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
withDefaults(defineProps<{ modelValue: string; options: Option[]; label?: string; disabled?: boolean }>(), {
|
||||
label: '',
|
||||
disabled: false,
|
||||
})
|
||||
interface OptionGroup {
|
||||
group: string
|
||||
options: Option[]
|
||||
}
|
||||
withDefaults(
|
||||
defineProps<{ modelValue: string; options: Array<Option | OptionGroup>; label?: string; disabled?: boolean }>(),
|
||||
{ label: '', disabled: false },
|
||||
)
|
||||
const isGroup = (o: Option | OptionGroup): o is OptionGroup => 'group' in o && !!o.group
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: string] }>()
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<!-- 有图显示图片;无图显示品牌渐变兜底 + 标题文字,避免裂图 -->
|
||||
<img
|
||||
v-if="src"
|
||||
:src="src"
|
||||
:alt="alt"
|
||||
v-bind="$attrs"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
v-bind="$attrs"
|
||||
class="flex items-center justify-center bg-gradient-to-br from-gray-200 via-gray-100 to-gray-200"
|
||||
>
|
||||
<span class="px-4 text-center text-sm md:text-base font-bold tracking-tight text-gray-400">
|
||||
{{ title }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({ inheritAttrs: false })
|
||||
|
||||
defineProps<{
|
||||
src?: string | null
|
||||
alt?: string
|
||||
title?: string
|
||||
}>()
|
||||
</script>
|
||||
@@ -7,7 +7,6 @@
|
||||
@click.self="closeModal"
|
||||
>
|
||||
<div
|
||||
ref="modalRef"
|
||||
class="relative w-full max-w-md bg-white rounded-2xl shadow-2xl overflow-hidden"
|
||||
@click.stop
|
||||
>
|
||||
@@ -20,69 +19,30 @@
|
||||
<Icon name="ph:x" class="w-5 h-5 text-gray-600" />
|
||||
</button>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<!-- 统一身份认证 -->
|
||||
<div class="p-8">
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-2">{{ t('auth.login') }}</h2>
|
||||
<p class="text-gray-600 mb-8">{{ t('auth.loginDescription') }}</p>
|
||||
<p class="text-gray-600 mb-8">{{ t('auth.casdoorDescription') }}</p>
|
||||
|
||||
<form @submit.prevent="handleLogin" class="space-y-5">
|
||||
<div>
|
||||
<label for="account" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.account') }}
|
||||
</label>
|
||||
<input
|
||||
id="account"
|
||||
v-model="account"
|
||||
type="text"
|
||||
required
|
||||
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')"
|
||||
/>
|
||||
</div>
|
||||
<p class="text-sm text-gray-500 mb-4">{{ t('auth.casdoorHint') }}</p>
|
||||
|
||||
<div>
|
||||
<label for="password" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.password') }}
|
||||
</label>
|
||||
<input
|
||||
id="password"
|
||||
v-model="password"
|
||||
type="password"
|
||||
required
|
||||
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')"
|
||||
/>
|
||||
</div>
|
||||
<!-- 登录按钮:跳转 Casdoor,回跳当前页面 -->
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isRedirecting"
|
||||
class="w-full py-3 rounded-xl font-semibold text-white transition-all duration-300 flex items-center justify-center gap-2 bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl disabled:opacity-60 disabled:cursor-not-allowed"
|
||||
@click="handleLogin"
|
||||
>
|
||||
<Icon name="ph:shield-check" class="w-5 h-5" />
|
||||
<span>{{ isRedirecting ? t('auth.redirecting') : t('auth.loginWithCasdoor') }}</span>
|
||||
</button>
|
||||
|
||||
<!-- 错误消息 -->
|
||||
<div v-if="errorMessage" class="p-3 rounded-lg bg-red-50 border border-red-200 text-red-800 text-sm">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<button
|
||||
type="submit"
|
||||
: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="isSubmitting || !account || !password
|
||||
? 'bg-gray-400 cursor-not-allowed'
|
||||
: 'bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl'"
|
||||
>
|
||||
<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>
|
||||
|
||||
<!-- 注册账号链接 -->
|
||||
<!-- 注册:前往 Casdoor 注册页 -->
|
||||
<p class="mt-6 text-center text-sm text-gray-600">
|
||||
{{ t('auth.noAccount') }}
|
||||
<button @click="authModal.switchToRegister()" class="text-black font-semibold hover:underline">
|
||||
<a :href="signupUrl" target="_blank" rel="noopener" class="text-black font-semibold hover:underline">
|
||||
{{ t('auth.createAccount') }}
|
||||
</button>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -93,54 +53,39 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { useRoute } from '#app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
import { useApiError } from '~/composables/useApiError'
|
||||
import { getCasdoorSignupUrl } from '~/utils/casdoorClient'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const route = useRoute()
|
||||
const authModal = useAuthModalStore()
|
||||
const apiError = useApiError()
|
||||
|
||||
const account = ref('')
|
||||
const password = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const isRedirecting = ref(false)
|
||||
const signupUrl = getCasdoorSignupUrl()
|
||||
|
||||
const closeModal = () => {
|
||||
if (!isSubmitting.value) {
|
||||
if (!isRedirecting.value) {
|
||||
authModal.closeAll()
|
||||
}
|
||||
}
|
||||
|
||||
// 打开时重置表单
|
||||
// 打开时重置状态
|
||||
watch(
|
||||
() => authModal.isLoginOpen,
|
||||
(open) => {
|
||||
if (open) {
|
||||
account.value = ''
|
||||
password.value = ''
|
||||
errorMessage.value = ''
|
||||
}
|
||||
if (open) isRedirecting.value = false
|
||||
},
|
||||
)
|
||||
|
||||
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 = ''
|
||||
authModal.closeAll()
|
||||
} else {
|
||||
errorMessage.value = apiError({ data: { code: result.code } })
|
||||
}
|
||||
isSubmitting.value = false
|
||||
const handleLogin = () => {
|
||||
if (isRedirecting.value) return
|
||||
isRedirecting.value = true
|
||||
const next = route.fullPath
|
||||
const target = next.startsWith('/') && !next.startsWith('//') ? next : '/'
|
||||
const url = `/api/auth/casdoor-login?next=${encodeURIComponent(target)}`
|
||||
window.location.assign(url)
|
||||
}
|
||||
|
||||
// ESC 关闭
|
||||
|
||||
@@ -1,263 +0,0 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="modal">
|
||||
<div
|
||||
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"
|
||||
>
|
||||
<div
|
||||
ref="modalRef"
|
||||
class="relative w-full max-w-md bg-white rounded-2xl shadow-2xl overflow-hidden"
|
||||
@click.stop
|
||||
>
|
||||
<!-- 关闭按钮 -->
|
||||
<button
|
||||
@click="closeModal"
|
||||
class="absolute top-4 right-4 w-8 h-8 flex items-center justify-center rounded-full hover:bg-gray-100 transition-colors z-10"
|
||||
aria-label="Close"
|
||||
>
|
||||
<Icon name="ph:x" class="w-5 h-5 text-gray-600" />
|
||||
</button>
|
||||
|
||||
<!-- 注册表单 -->
|
||||
<div class="p-8">
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-2">{{ t('auth.register') }}</h2>
|
||||
<p class="text-gray-600 mb-8">{{ t('auth.registerDescription') }}</p>
|
||||
|
||||
<form @submit.prevent="handleRegister" class="space-y-5">
|
||||
<div>
|
||||
<label for="reg-username" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.username') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-username"
|
||||
v-model="username"
|
||||
type="text"
|
||||
required
|
||||
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')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="reg-email" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.email') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-email"
|
||||
v-model="email"
|
||||
type="email"
|
||||
required
|
||||
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')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="reg-phone" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.phone') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-phone"
|
||||
v-model="phone"
|
||||
type="tel"
|
||||
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')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="reg-password" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.password') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-password"
|
||||
v-model="password"
|
||||
type="password"
|
||||
required
|
||||
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')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="reg-confirm-password" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.confirmPassword') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-confirm-password"
|
||||
v-model="confirmPassword"
|
||||
type="password"
|
||||
required
|
||||
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')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 错误消息 -->
|
||||
<div v-if="errorMessage" class="p-3 rounded-lg bg-red-50 border border-red-200 text-red-800 text-sm">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<!-- 成功消息 -->
|
||||
<div v-if="successMessage" class="p-3 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm">
|
||||
{{ successMessage }}
|
||||
</div>
|
||||
|
||||
<!-- 注册按钮 -->
|
||||
<button
|
||||
type="submit"
|
||||
: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="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="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="authModal.switchToLogin()" class="text-black font-semibold hover:underline">
|
||||
{{ t('auth.backToLogin') }}
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
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()
|
||||
|
||||
const username = ref('')
|
||||
const email = ref('')
|
||||
const phone = ref('')
|
||||
const password = ref('')
|
||||
const confirmPassword = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const successMessage = ref('')
|
||||
|
||||
const closeModal = () => {
|
||||
if (!isSubmitting.value) {
|
||||
authModal.closeAll()
|
||||
}
|
||||
}
|
||||
|
||||
// 打开时重置表单
|
||||
watch(
|
||||
() => authModal.isRegisterOpen,
|
||||
(open) => {
|
||||
if (open) {
|
||||
username.value = ''
|
||||
email.value = ''
|
||||
phone.value = ''
|
||||
password.value = ''
|
||||
confirmPassword.value = ''
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
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 = ''
|
||||
setTimeout(() => {
|
||||
authModal.closeAll()
|
||||
}, 1500)
|
||||
} else {
|
||||
errorMessage.value = apiError({ data: { code: result.code } })
|
||||
}
|
||||
isSubmitting.value = false
|
||||
}
|
||||
|
||||
// ESC 关闭
|
||||
const handleKeydown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && authModal.isRegisterOpen) {
|
||||
closeModal()
|
||||
}
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('keydown', handleKeydown)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-enter-from,
|
||||
.modal-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.modal-enter-active .relative,
|
||||
.modal-leave-active .relative {
|
||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-enter-from .relative {
|
||||
transform: scale(0.95) translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.modal-leave-to .relative {
|
||||
transform: scale(0.95) translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<section ref="rootRef" class="relative bg-black text-white min-h-screen flex items-center justify-center overflow-hidden">
|
||||
<section v-if="achievements.length" ref="rootRef" class="relative bg-black text-white min-h-screen flex items-center justify-center overflow-hidden">
|
||||
<!-- 背景粒子 -->
|
||||
<canvas ref="canvasRef" class="absolute inset-0 w-full h-full opacity-30"></canvas>
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
<!-- 描述 -->
|
||||
<div class="flex-1">
|
||||
<h3 class="text-2xl md:text-3xl font-bold mb-3">
|
||||
{{ t(`home.achievements.items.${achievement.id}.title`) }}
|
||||
{{ achievement.title }}
|
||||
</h3>
|
||||
<p class="text-gray-400 text-base md:text-lg leading-relaxed">
|
||||
{{ t(`home.achievements.items.${achievement.id}.description`) }}
|
||||
{{ achievement.description }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,14 +45,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
import { ref, onMounted, onUnmounted, nextTick, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import gsap from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const { t } = useI18n()
|
||||
const { locale } = useI18n()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
||||
@@ -69,37 +71,28 @@ const setNumberRef = (el: any, index: number) => {
|
||||
if (el) numberElements.value[index] = el
|
||||
}
|
||||
|
||||
const achievements = [
|
||||
{
|
||||
id: 'projects',
|
||||
number: 150,
|
||||
suffix: '+',
|
||||
color: 'text-blue-400',
|
||||
bgColor: 'bg-blue-500'
|
||||
},
|
||||
{
|
||||
id: 'clients',
|
||||
number: 85,
|
||||
suffix: '+',
|
||||
color: 'text-purple-400',
|
||||
bgColor: 'bg-purple-500'
|
||||
},
|
||||
{
|
||||
id: 'experience',
|
||||
number: 12,
|
||||
suffix: '+',
|
||||
color: 'text-green-400',
|
||||
bgColor: 'bg-green-500'
|
||||
},
|
||||
{
|
||||
id: 'satisfaction',
|
||||
number: 98,
|
||||
suffix: '%',
|
||||
color: 'text-orange-400',
|
||||
bgColor: 'bg-orange-500'
|
||||
}
|
||||
// 颜色预设按序号循环,后台无需逐条选色
|
||||
const ACHIEVEMENT_STYLES = [
|
||||
{ color: 'text-blue-400', bgColor: 'bg-blue-500' },
|
||||
{ color: 'text-purple-400', bgColor: 'bg-purple-500' },
|
||||
{ color: 'text-green-400', bgColor: 'bg-green-500' },
|
||||
{ color: 'text-orange-400', bgColor: 'bg-orange-500' },
|
||||
]
|
||||
|
||||
const locStr = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
// 成就数据来自后台配置(/admin/settings 首页成就数据),空则不渲染该板块
|
||||
const achievements = computed(() =>
|
||||
(settings.value?.achievements ?? []).map((a, i) => ({
|
||||
id: a.id,
|
||||
number: Number(a.number) || 0,
|
||||
suffix: a.suffix,
|
||||
title: locStr(a.titleZh, a.titleEn),
|
||||
description: locStr(a.descriptionZh, a.descriptionEn),
|
||||
...ACHIEVEMENT_STYLES[i % ACHIEVEMENT_STYLES.length],
|
||||
})),
|
||||
)
|
||||
|
||||
// 粒子动画
|
||||
const initParticles = () => {
|
||||
const canvas = canvasRef.value
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onBeforeUnmount, ref } from 'vue'
|
||||
import { onMounted, onBeforeUnmount, ref, computed } from 'vue'
|
||||
import { useNuxtApp } from '#app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import gsap from 'gsap'
|
||||
import AnimatedButton from '~/components/common/AnimatedButton.vue'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
// 定义背景画廊与主视图绑定的总滚动距离(像素),数值越大,用户向下滚动时 Hero 面板缩放的过程就越长
|
||||
const heroPinDistance = 1200
|
||||
const heroGalleryColumns = [
|
||||
{ side: 'left', images: ['1018', '1015', '1024', '1039'].map(id => `https://picsum.photos/id/${id}/900/1200`) },
|
||||
{ side: 'right', images: ['1043', '1050', '1067', '1074'].map(id => `https://picsum.photos/id/${id}/900/1200`) },
|
||||
] as const
|
||||
// 背景画廊:由后台「首页 Hero 画廊」配置,图片均分到左右两列;为空时显示品牌纯色兜底
|
||||
const heroGalleryColumns = computed(() => {
|
||||
const gallery = settings.value?.hero?.gallery ?? []
|
||||
const left = gallery.filter((_, i) => i % 2 === 0)
|
||||
const right = gallery.filter((_, i) => i % 2 === 1)
|
||||
const columns: { side: 'left' | 'right'; images: string[] }[] = []
|
||||
if (left.length) columns.push({ side: 'left', images: left })
|
||||
if (right.length) columns.push({ side: 'right', images: right })
|
||||
return columns
|
||||
})
|
||||
|
||||
const heroStageRef = ref<HTMLElement | null>(null)
|
||||
const heroRef = ref<HTMLElement | null>(null)
|
||||
@@ -202,14 +210,16 @@ defineExpose({ play })
|
||||
class="relative bg-black"
|
||||
:style="{ height: `calc(100svh + ${heroPinDistance}px)` }"
|
||||
>
|
||||
<section ref="heroRef" class="sticky top-0 h-[100svh] overflow-hidden bg-[#111]" v-once>
|
||||
<section ref="heroRef" class="sticky top-0 h-[100svh] overflow-hidden bg-[#111]">
|
||||
<div class="absolute inset-0 overflow-hidden bg-black" aria-hidden="true">
|
||||
<div
|
||||
v-for="column in heroGalleryColumns"
|
||||
:key="column.side"
|
||||
class="absolute -bottom-10 -top-10 w-[49vw] overflow-hidden"
|
||||
:class="column.side === 'left' ? 'left-0' : 'right-0'"
|
||||
>
|
||||
<!-- 有后台画廊配置时渲染图片列;否则显示品牌纯色兜底 -->
|
||||
<template v-if="heroGalleryColumns.length">
|
||||
<div
|
||||
v-for="column in heroGalleryColumns"
|
||||
:key="column.side"
|
||||
class="absolute -bottom-10 -top-10 w-[49vw] overflow-hidden"
|
||||
:class="column.side === 'left' ? 'left-0' : 'right-0'"
|
||||
>
|
||||
<!-- 复制两份图片组,配合 translateY(-50%) 做无缝循环。 -->
|
||||
<div
|
||||
class="hero-gallery-track will-change-transform"
|
||||
@@ -228,6 +238,11 @@ defineExpose({ play })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<!-- 兜底:无后台画廊配置时的品牌背景 -->
|
||||
<div class="absolute inset-0 bg-gradient-to-br from-neutral-800 via-neutral-900 to-black"></div>
|
||||
</template>
|
||||
</div>
|
||||
<div ref="heroPanelRef" class="absolute inset-0 flex flex-col justify-between items-center bg-white text-black will-change-transform pt-24 pb-8 md:pt-36 md:pb-12 overflow-hidden">
|
||||
<div class="flex flex-col justify-between w-page-container max-w-[calc(100%-2rem)] mx-auto px-4 h-full">
|
||||
|
||||
@@ -3,10 +3,12 @@ import { onMounted, onUnmounted, ref, computed, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import gsap from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const { t, locale } = useI18n()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
interface WorkItem {
|
||||
slug: string
|
||||
@@ -26,40 +28,8 @@ const rootRef = ref<HTMLElement | null>(null)
|
||||
const workSectionRef = ref<HTMLElement | null>(null)
|
||||
const workPinRef = ref<HTMLElement | null>(null)
|
||||
|
||||
const partners = [
|
||||
{
|
||||
id: 'p1',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 44V20h12c7 0 12 4 12 10s-5 10-12 10h-6v4H20Z" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/><path d="M34 40l10 12" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p2',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 32c0-9.94 8.06-18 18-18s18 8.06 18 18-8.06 18-18 18-18-8.06-18-18Z" stroke="currentColor" stroke-width="3"/><path d="M24 32c0-4.42 3.58-8 8-8s8 3.58 8 8-3.58 8-8 8-8-3.58-8-8Z" stroke="currentColor" stroke-width="3"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p3',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M32 14v10M32 40v10M14 32h10M40 32h10" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M32 22c5.52 0 10 4.48 10 10s-4.48 10-10 10-10-4.48-10-10 4.48-10 10-10Z" stroke="currentColor" stroke-width="3"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p4',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 44c10-2 12-14 18-18s10-1 18-6" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M16 34c8-2 10 8 18 6s10-18 18-18" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p5',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 38c0-9 6-18 14-18s14 9 14 18" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M22 42h20" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p6',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 20v24M30 20v24M42 20v24" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M14 20h36M14 44h36" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p7',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 44V20h10c9 0 18 7 18 12s-9 12-18 12H18Z" stroke="currentColor" stroke-width="3" stroke-linejoin="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p8',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16 34c8-14 18-14 32-4" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M18 44c10-10 20-10 30-2" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
]
|
||||
// 合作伙伴来自后台配置(/admin/settings 合作伙伴),空则隐藏该排展示
|
||||
const partners = computed(() => settings.value?.partners ?? [])
|
||||
|
||||
let st: ScrollTrigger | null = null
|
||||
let madeTweens: gsap.core.Animation[] = []
|
||||
@@ -191,23 +161,39 @@ onUnmounted(() => {
|
||||
<template>
|
||||
<section ref="rootRef" class="bg-[#F5F5F5]">
|
||||
<div class="w-page-container max-w-[calc(100%-2rem)] mx-auto px-6 md:px-10 lg:px-14 pt-24 pb-20">
|
||||
<div class="grid grid-cols-[1fr_auto_1fr] items-center">
|
||||
<p class="justify-self-start text-xs font-semibold tracking-tight text-black">( {{ t('home.partners.label') }} )</p>
|
||||
<div class="flex items-center justify-self-center gap-8 text-xs font-semibold tracking-tight text-black">
|
||||
<span class="h-1 w-1 rounded-full bg-black" />
|
||||
<span>{{ t('home.partners.years') }}</span>
|
||||
<!-- 合作伙伴(后台配置;空则不展示该排) -->
|
||||
<template v-if="partners.length">
|
||||
<div class="grid grid-cols-[1fr_auto_1fr] items-center">
|
||||
<p class="justify-self-start text-xs font-semibold tracking-tight text-black">( {{ t('home.partners.label') }} )</p>
|
||||
<div class="flex items-center justify-self-center gap-8 text-xs font-semibold tracking-tight text-black">
|
||||
<span class="h-1 w-1 rounded-full bg-black" />
|
||||
<span>{{ t('home.partners.years') }}</span>
|
||||
</div>
|
||||
<span class="justify-self-end h-1 w-1 rounded-full bg-black" />
|
||||
</div>
|
||||
<span class="justify-self-end h-1 w-1 rounded-full bg-black" />
|
||||
</div>
|
||||
|
||||
<div class="mt-12 grid grid-cols-2 sm:grid-cols-4 gap-5">
|
||||
<div
|
||||
v-for="item in partners"
|
||||
:key="item.id"
|
||||
class="h-[152px] rounded-[20px] bg-white flex items-center justify-center text-black border-0 shadow-none outline-none ring-0"
|
||||
v-html="item.svg"
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-12 grid grid-cols-2 sm:grid-cols-4 gap-5">
|
||||
<template v-for="item in partners" :key="item.id">
|
||||
<a
|
||||
v-if="item.url"
|
||||
:href="item.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="h-[152px] rounded-[20px] bg-white flex items-center justify-center border-0 shadow-none outline-none ring-0 group"
|
||||
>
|
||||
<img v-if="item.logo" :src="item.logo" :alt="item.name" class="max-h-[72px] max-w-[80%] object-contain" />
|
||||
<span v-else class="text-lg font-bold text-gray-400 group-hover:text-black transition-colors">{{ item.name }}</span>
|
||||
</a>
|
||||
<div
|
||||
v-else
|
||||
class="h-[152px] rounded-[20px] bg-white flex items-center justify-center border-0 shadow-none outline-none ring-0"
|
||||
>
|
||||
<img v-if="item.logo" :src="item.logo" :alt="item.name" class="max-h-[72px] max-w-[80%] object-contain" />
|
||||
<span v-else class="text-lg font-bold text-gray-400">{{ item.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<section id="work" ref="workSectionRef" class="bg-white">
|
||||
@@ -244,12 +230,11 @@ onUnmounted(() => {
|
||||
:to="`/work/${item.slug}`"
|
||||
class="will-change-transform relative block"
|
||||
>
|
||||
<img
|
||||
class="h-full w-full object-cover"
|
||||
:src="item.image || ''"
|
||||
<CoverImage
|
||||
:src="item.image"
|
||||
:alt="locText(item.titleZh, item.titleEn)"
|
||||
loading="eager"
|
||||
decoding="async"
|
||||
:title="locText(item.titleZh, item.titleEn)"
|
||||
class="h-full w-full object-cover"
|
||||
@load="refresh"
|
||||
/>
|
||||
<div class="absolute left-6 top-6 flex items-baseline gap-3">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<section ref="rootRef" class="relative bg-gradient-to-b from-gray-50 to-white min-h-screen flex flex-col items-center justify-center overflow-hidden py-20">
|
||||
<section v-if="testimonials.length" ref="rootRef" class="relative bg-gradient-to-b from-gray-50 to-white min-h-screen flex flex-col items-center justify-center overflow-hidden py-20">
|
||||
<div class="w-full max-w-[1400px] mx-auto px-6 md:px-10">
|
||||
<!-- 标题 -->
|
||||
<div ref="headerRef" class="text-center mb-16 md:mb-20">
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
<!-- 评价内容 -->
|
||||
<p class="text-gray-700 text-base md:text-lg leading-relaxed mb-8 italic">
|
||||
"{{ t(`home.testimonials.items.${item.id}.content`) }}"
|
||||
"{{ item.content }}"
|
||||
</p>
|
||||
|
||||
<!-- 客户信息 -->
|
||||
@@ -45,10 +45,10 @@
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="text-lg md:text-xl font-bold text-black">
|
||||
{{ t(`home.testimonials.items.${item.id}.name`) }}
|
||||
{{ item.name }}
|
||||
</h4>
|
||||
<p class="text-sm md:text-base text-gray-500">
|
||||
{{ t(`home.testimonials.items.${item.id}.role`) }}
|
||||
{{ item.role }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -69,10 +69,12 @@ import { ref, onMounted, onUnmounted, nextTick, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import gsap from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const headerRef = ref<HTMLElement | null>(null)
|
||||
@@ -80,16 +82,31 @@ const trackRef = ref<HTMLElement | null>(null)
|
||||
let ctx: gsap.Context | null = null
|
||||
let animFrameId: number | null = null
|
||||
|
||||
const testimonials = [
|
||||
{ id: 'client1', initial: 'A', avatarGradient: 'from-blue-500 to-cyan-500' },
|
||||
{ id: 'client2', initial: 'B', avatarGradient: 'from-purple-500 to-pink-500' },
|
||||
{ id: 'client3', initial: 'C', avatarGradient: 'from-orange-500 to-red-500' },
|
||||
{ id: 'client4', initial: 'D', avatarGradient: 'from-green-500 to-emerald-500' },
|
||||
{ id: 'client5', initial: 'E', avatarGradient: 'from-indigo-500 to-purple-500' },
|
||||
// 头像渐变预设按序号循环,后台无需逐条选色
|
||||
const AVATAR_STYLES = [
|
||||
'from-blue-500 to-cyan-500',
|
||||
'from-purple-500 to-pink-500',
|
||||
'from-orange-500 to-red-500',
|
||||
'from-green-500 to-emerald-500',
|
||||
'from-indigo-500 to-purple-500',
|
||||
]
|
||||
|
||||
const locStr = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
// 客户评价来自后台配置(/admin/settings 客户评价),空则不渲染该板块
|
||||
const testimonials = computed(() =>
|
||||
(settings.value?.testimonials ?? []).map((t, i) => ({
|
||||
id: t.id,
|
||||
name: t.name,
|
||||
role: locStr(t.roleZh, t.roleEn),
|
||||
content: locStr(t.contentZh, t.contentEn),
|
||||
initial: (t.name || '?').trim().charAt(0).toUpperCase(),
|
||||
avatarGradient: AVATAR_STYLES[i % AVATAR_STYLES.length],
|
||||
})),
|
||||
)
|
||||
|
||||
// 复制一份用于无缝循环
|
||||
const allTestimonials = computed(() => [...testimonials, ...testimonials])
|
||||
const allTestimonials = computed(() => [...testimonials.value, ...testimonials.value])
|
||||
|
||||
// 自动滚动状态
|
||||
const offset = ref(0)
|
||||
@@ -98,7 +115,7 @@ let isPaused = false
|
||||
const cardWidth = 400 + 32 // 卡片宽度 + gap
|
||||
|
||||
const startAutoplay = () => {
|
||||
const totalWidth = testimonials.length * cardWidth
|
||||
const totalWidth = testimonials.value.length * cardWidth
|
||||
|
||||
const animate = () => {
|
||||
if (!isPaused) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { onMounted, ref, onUnmounted } from 'vue'
|
||||
import { onMounted, ref, onUnmounted, computed } from 'vue'
|
||||
import { gsap } from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
import FooterLogo from '~/components/common/FooterLogo.vue'
|
||||
@@ -10,6 +10,9 @@ import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
const { t } = useI18n()
|
||||
const { settings, loc } = useSiteSettings()
|
||||
|
||||
// 仅展示已填写 URL 的社交入口
|
||||
const socials = computed(() => (settings.value?.socials ?? []).filter((s) => s.url))
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const footerRef = ref<HTMLElement | null>(null)
|
||||
@@ -266,9 +269,9 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 animated-item">
|
||||
<div v-if="socials.length" class="flex gap-3 animated-item">
|
||||
<a
|
||||
v-for="social in settings?.socials ?? []"
|
||||
v-for="social in socials"
|
||||
:key="social.name"
|
||||
:href="social.url"
|
||||
target="_blank"
|
||||
|
||||
@@ -9,7 +9,6 @@ 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)
|
||||
|
||||
@@ -491,9 +490,6 @@ if (typeof window !== 'undefined') {
|
||||
<!-- 登录弹窗(由 authModal store 控制开关) -->
|
||||
<LoginModal />
|
||||
|
||||
<!-- 注册弹窗(由 authModal store 控制开关) -->
|
||||
<RegisterModal />
|
||||
|
||||
<header ref="bottomHeaderRef" class="site-header-bottom z-50 bg-white/80 backdrop-blur-md">
|
||||
<!-- 左侧菜单 (前两个菜单项) -->
|
||||
<nav class="flex items-center justify-evenly md:justify-end gap-3 md:gap-4 w-full">
|
||||
|
||||
+51
-4
@@ -26,6 +26,43 @@ export interface ToolItem {
|
||||
descEn: string
|
||||
}
|
||||
|
||||
/** 首页 Hero 背景画廊 */
|
||||
export interface HeroSettings {
|
||||
/** 图片 URL 列表,均分到左右两列;为空时显示品牌纯色兜底 */
|
||||
gallery: string[]
|
||||
}
|
||||
|
||||
/** 首页「成就数据」:数字统计(可在后台配置) */
|
||||
export interface AchievementItem {
|
||||
id: string
|
||||
number: number
|
||||
suffix: string
|
||||
titleZh: string
|
||||
titleEn: string
|
||||
descriptionZh: string
|
||||
descriptionEn: string
|
||||
}
|
||||
|
||||
/** 首页「客户评价」(可在后台配置) */
|
||||
export interface TestimonialItem {
|
||||
id: string
|
||||
name: string
|
||||
roleZh: string
|
||||
roleEn: string
|
||||
contentZh: string
|
||||
contentEn: string
|
||||
}
|
||||
|
||||
/** 首页「合作伙伴」(可在后台配置;无 logo 时显示名称文字) */
|
||||
export interface PartnerItem {
|
||||
id: string
|
||||
name: string
|
||||
/** logo 图片 URL,可留空 */
|
||||
logo?: string | null
|
||||
/** 合作伙伴官网链接,可留空 */
|
||||
url?: string | null
|
||||
}
|
||||
|
||||
export interface SiteSettings {
|
||||
site: {
|
||||
name: string
|
||||
@@ -40,6 +77,10 @@ export interface SiteSettings {
|
||||
}
|
||||
socials: SocialLink[]
|
||||
tools: ToolItem[]
|
||||
hero: HeroSettings
|
||||
achievements: AchievementItem[]
|
||||
testimonials: TestimonialItem[]
|
||||
partners: PartnerItem[]
|
||||
footer: {
|
||||
title: LocalizedText
|
||||
newsletterTitle: LocalizedText
|
||||
@@ -71,10 +112,10 @@ export const defaultSettings: SiteSettings = {
|
||||
},
|
||||
},
|
||||
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' },
|
||||
{ name: '微博', icon: 'ri:weibo-fill', url: '' },
|
||||
{ name: '知乎', icon: 'ri:zhihu-fill', url: '' },
|
||||
{ name: '哔哩哔哩', icon: 'ri:bilibili-fill', url: '' },
|
||||
{ name: 'GitHub', icon: 'ri:github-fill', url: '' },
|
||||
],
|
||||
tools: [
|
||||
{
|
||||
@@ -105,6 +146,12 @@ export const defaultSettings: SiteSettings = {
|
||||
descEn: 'An all-in-one practical tool collection for developers and IT professionals.',
|
||||
},
|
||||
],
|
||||
hero: {
|
||||
gallery: [],
|
||||
},
|
||||
achievements: [],
|
||||
testimonials: [],
|
||||
partners: [],
|
||||
footer: {
|
||||
title: {
|
||||
zh: '雕琢视觉,塑造故事。\n让我们共创卓越作品!',
|
||||
|
||||
+8
-193
@@ -3,7 +3,7 @@
|
||||
* 个人中心(重新设计)—— 对齐站点黑白编辑风:极简、大排版、充足留白。
|
||||
* - 资料区:头像 + 大号姓名 + 邮箱 + 角色/加入时间 + 三项统计(细分隔线)
|
||||
* - 导航:下划线页签
|
||||
* - profile:资料编辑 / 修改密码 / 删除账号(克制危险区)
|
||||
* - profile:资料编辑(仅用户名;账号信息由 Casdoor 管理)
|
||||
* - favorites:作品封面网格;comments:评论列表
|
||||
*/
|
||||
import { computed, nextTick, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
||||
@@ -46,107 +46,22 @@ const switchTab = (key: string) => {
|
||||
}
|
||||
|
||||
/* ---------- 资料编辑 ---------- */
|
||||
const profileForm = reactive({ username: '', phone: '' })
|
||||
const profileForm = reactive({ username: '' })
|
||||
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 })
|
||||
const result = await userStore.updateProfile({ username: profileForm.username })
|
||||
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[]>([])
|
||||
@@ -314,28 +229,8 @@ onBeforeUnmount(() => ctx?.revert())
|
||||
<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>
|
||||
<p class="text-sm text-gray-400">头像由 Casdoor 统一账号管理</p>
|
||||
</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>
|
||||
@@ -343,11 +238,6 @@ onBeforeUnmount(() => ctx?.revert())
|
||||
<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
|
||||
@@ -364,62 +254,10 @@ onBeforeUnmount(() => ctx?.revert())
|
||||
</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 class="px-6 md:px-8 py-7 bg-gray-50/60">
|
||||
<h3 class="text-lg font-bold text-black">{{ t('account.ssoAccount') }}</h3>
|
||||
<p class="text-sm text-gray-500 mt-1 leading-relaxed">{{ t('account.ssoAccountHint') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -500,29 +338,6 @@ onBeforeUnmount(() => ctx?.revert())
|
||||
</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>
|
||||
|
||||
|
||||
+202
-13
@@ -57,22 +57,82 @@ const saveAll = async () => {
|
||||
}
|
||||
|
||||
/* ---------- 社交链接 ---------- */
|
||||
// 分组图标:国内平台用 Remix Icon(ri),国际平台用 Phosphor(ph)
|
||||
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' },
|
||||
{
|
||||
group: '国内平台',
|
||||
options: [
|
||||
{ label: '微博', value: 'ri:weibo-fill' },
|
||||
{ label: '微信', value: 'ri:wechat-fill' },
|
||||
{ label: '知乎', value: 'ri:zhihu-fill' },
|
||||
{ label: '哔哩哔哩', value: 'ri:bilibili-fill' },
|
||||
{ label: 'QQ', value: 'ri:qq-fill' },
|
||||
{ label: '豆瓣', value: 'ri:douban-fill' },
|
||||
{ label: '淘宝', value: 'ri:taobao-fill' },
|
||||
{ label: '支付宝', value: 'ri:alipay-fill' },
|
||||
{ label: '网易云音乐', value: 'ri:netease-cloud-music-fill' },
|
||||
],
|
||||
},
|
||||
{
|
||||
group: '国际平台',
|
||||
options: [
|
||||
{ label: 'X (Twitter)', value: 'ph:x-logo' },
|
||||
{ label: 'Instagram', value: 'ph:instagram-logo' },
|
||||
{ label: 'LinkedIn', value: 'ph:linkedin-logo' },
|
||||
{ label: 'GitHub', value: 'ri:github-fill' },
|
||||
{ label: 'YouTube', value: 'ph:youtube-logo' },
|
||||
{ label: 'Facebook', value: 'ph:facebook-logo' },
|
||||
],
|
||||
},
|
||||
{
|
||||
group: '其他',
|
||||
options: [
|
||||
{ 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: '' })
|
||||
// 生成列表项稳定 id(仅用于前台 v-for key,非业务标识)
|
||||
const uid = () => 'id-' + Math.random().toString(36).slice(2, 9)
|
||||
|
||||
const addSocial = () => form.socials.push({ name: '', icon: 'ri:weibo-fill', url: '' })
|
||||
const removeSocial = (i: number) => form.socials.splice(i, 1)
|
||||
|
||||
/* ---------- 首页成就数据 ---------- */
|
||||
const addAchievement = () =>
|
||||
form.achievements.push({
|
||||
id: uid(),
|
||||
number: 100,
|
||||
suffix: '+',
|
||||
titleZh: '',
|
||||
titleEn: '',
|
||||
descriptionZh: '',
|
||||
descriptionEn: '',
|
||||
})
|
||||
const removeAchievement = (i: number) => form.achievements.splice(i, 1)
|
||||
|
||||
/* ---------- 客户评价 ---------- */
|
||||
const addTestimonial = () =>
|
||||
form.testimonials.push({
|
||||
id: uid(),
|
||||
name: '',
|
||||
roleZh: '',
|
||||
roleEn: '',
|
||||
contentZh: '',
|
||||
contentEn: '',
|
||||
})
|
||||
const removeTestimonial = (i: number) => form.testimonials.splice(i, 1)
|
||||
|
||||
/* ---------- 合作伙伴 ---------- */
|
||||
const addPartner = () => form.partners.push({ id: uid(), name: '', logo: null, url: null })
|
||||
const removePartner = (i: number) => form.partners.splice(i, 1)
|
||||
|
||||
/* ---------- 首页 Hero 画廊 ---------- */
|
||||
const addHeroImage = () => form.hero.gallery.push('')
|
||||
const removeHeroImage = (i: number) => form.hero.gallery.splice(i, 1)
|
||||
|
||||
/* ---------- 工具箱 ---------- */
|
||||
const TOOL_COLORS = [
|
||||
{ label: '橙 · 琥珀', value: 'from-orange-50/50 to-amber-100/50' },
|
||||
@@ -218,7 +278,136 @@ const removeTool = (i: number) => form.tools.splice(i, 1)
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 5. 页脚文案 -->
|
||||
<!-- 5. 首页成就数据 -->
|
||||
<AdminCard title="首页成就数据" subtitle="首页「成就」板块的数字统计;留空则不展示该板块">
|
||||
<template #actions><Icon name="ph:trend-up" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="(a, i) in form.achievements"
|
||||
: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="removeAchievement(i)"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
|
||||
</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-3">
|
||||
<AdminInput v-model="a.titleZh" label="标题(中文)" />
|
||||
<AdminInput v-model="a.titleEn" label="Title (EN)" />
|
||||
<AdminInput v-model="a.number" label="数字" type="number" />
|
||||
<AdminInput v-model="a.suffix" label="后缀" placeholder="+ 或 %" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<AdminTextarea v-model="a.descriptionZh" label="描述(中文)" :rows="2" />
|
||||
<AdminTextarea v-model="a.descriptionEn" label="Description (EN)" :rows="2" />
|
||||
</div>
|
||||
</div>
|
||||
<AdminButton variant="secondary" size="sm" @click="addAchievement">
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 添加成就
|
||||
</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 6. 客户评价 -->
|
||||
<AdminCard title="客户评价" subtitle="首页「客户评价」轮播内容;留空则不展示该板块">
|
||||
<template #actions><Icon name="ph:quotes-duotone" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="(tm, i) in form.testimonials"
|
||||
: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="removeTestimonial(i)"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
|
||||
</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||
<AdminInput v-model="tm.name" label="姓名" />
|
||||
<AdminInput v-model="tm.roleZh" label="角色(中文)" />
|
||||
<AdminInput v-model="tm.roleEn" label="Role (EN)" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3">
|
||||
<AdminTextarea v-model="tm.contentZh" label="评价内容(中文)" :rows="3" />
|
||||
<AdminTextarea v-model="tm.contentEn" label="Content (EN)" :rows="3" />
|
||||
</div>
|
||||
</div>
|
||||
<AdminButton variant="secondary" size="sm" @click="addTestimonial">
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 添加评价
|
||||
</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 7. 合作伙伴 -->
|
||||
<AdminCard title="合作伙伴" subtitle="首页「合作伙伴」排展示;留空则不展示该排">
|
||||
<template #actions><Icon name="ph:handshake" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="(p, i) in form.partners"
|
||||
: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="removePartner(i)"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-3.5 h-3.5" /> 删除
|
||||
</button>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-3">
|
||||
<AdminInput v-model="p.name" label="名称" />
|
||||
<AdminInput v-model="p.logo" label="Logo 图片 URL" placeholder="本地 /uploads/... 或 https://..." />
|
||||
<AdminInput v-model="p.url" label="官网链接(可选)" type="url" placeholder="https://..." />
|
||||
</div>
|
||||
</div>
|
||||
<AdminButton variant="secondary" size="sm" @click="addPartner">
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 添加合作方
|
||||
</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 8. 首页 Hero 画廊 -->
|
||||
<AdminCard title="首页 Hero 画廊" subtitle="首页背景滚动的图片,会均分到左右两列;留空时显示品牌纯色背景">
|
||||
<template #actions><Icon name="ph:images" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-4">
|
||||
<div
|
||||
v-for="(img, i) in form.hero.gallery"
|
||||
:key="i"
|
||||
class="rounded-xl border border-gray-100 bg-gray-50/50 p-4"
|
||||
>
|
||||
<div class="grid grid-cols-1 md:grid-cols-[1fr_auto] gap-3 items-end">
|
||||
<AdminInput v-model="form.hero.gallery[i]" label="图片 URL" placeholder="本地 /uploads/... 或 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="`删除图片 ${i + 1}`"
|
||||
@click="removeHeroImage(i)"
|
||||
>
|
||||
<Icon name="ph:trash" class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<AdminButton variant="secondary" size="sm" @click="addHeroImage">
|
||||
<Icon name="ph:plus" class="w-4 h-4" /> 添加图片
|
||||
</AdminButton>
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 9. 页脚文案 -->
|
||||
<AdminCard title="页脚文案" subtitle="前台页脚与订阅区的文案">
|
||||
<template #actions><Icon name="ph:paragraph" class="w-5 h-5 text-gray-300" /></template>
|
||||
<div class="space-y-5">
|
||||
@@ -241,7 +430,7 @@ const removeTool = (i: number) => form.tools.splice(i, 1)
|
||||
</div>
|
||||
</AdminCard>
|
||||
|
||||
<!-- 6. SEO -->
|
||||
<!-- 10. 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">
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 后台用户管理:列表 + 搜索/角色筛选 + 角色切换 + 删除确认 + 前端分页。
|
||||
* - GET /api/admin/users;PATCH /api/admin/users/[id](角色切换,不能操作自己);DELETE /api/admin/users/[id]
|
||||
* 后台用户管理:列表 + 搜索 + 删除确认 + 前端分页。
|
||||
* - GET /api/admin/users;DELETE /api/admin/users/[id]
|
||||
* - 角色由 Casdoor 统一身份认证决定(token 的 IsAdmin claim),本地仅缓存展示,不提供切换。
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
@@ -14,7 +15,6 @@ interface AdminUser {
|
||||
id: number
|
||||
username: string
|
||||
email: string | null
|
||||
phone: string | null
|
||||
role: 'user' | 'admin'
|
||||
createdAt: string
|
||||
}
|
||||
@@ -53,11 +53,7 @@ const filteredUsers = computed(() => {
|
||||
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)
|
||||
)
|
||||
return u.username.toLowerCase().includes(kw) || (u.email || '').toLowerCase().includes(kw)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -82,22 +78,6 @@ 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)
|
||||
@@ -138,7 +118,7 @@ const formatDate = (raw?: string) => {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<AdminPageHeader title="用户管理" subtitle="管理站点注册用户,调整角色或删除账号。">
|
||||
<AdminPageHeader title="用户管理" subtitle="查看站点 SSO 用户,角色由 Casdoor 统一身份判定。">
|
||||
<template #actions>
|
||||
<AdminButton variant="secondary" size="sm" @click="loadUsers">
|
||||
<Icon name="ph:arrows-clockwise" class="w-4 h-4" /> 刷新
|
||||
@@ -158,7 +138,7 @@ const formatDate = (raw?: string) => {
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
placeholder="搜索用户名 / 邮箱 / 手机号"
|
||||
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
|
||||
@@ -196,7 +176,7 @@ const formatDate = (raw?: string) => {
|
||||
</AdminCard>
|
||||
|
||||
<!-- 空态 -->
|
||||
<AdminEmptyState v-else-if="!users.length" icon="ph:users-three" title="暂无用户" description="还没有注册用户。" />
|
||||
<AdminEmptyState v-else-if="!users.length" icon="ph:users-three" title="暂无用户" description="还没有登录用户。" />
|
||||
|
||||
<AdminEmptyState
|
||||
v-else-if="!filteredUsers.length"
|
||||
@@ -216,9 +196,8 @@ const formatDate = (raw?: string) => {
|
||||
<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 whitespace-nowrap">加入时间</th>
|
||||
<th class="px-5 py-4 font-semibold text-xs uppercase tracking-wider text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -227,7 +206,6 @@ const formatDate = (raw?: string) => {
|
||||
<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" />
|
||||
@@ -238,14 +216,6 @@ const formatDate = (raw?: string) => {
|
||||
<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>
|
||||
@@ -289,25 +259,12 @@ const formatDate = (raw?: string) => {
|
||||
<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>
|
||||
<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>
|
||||
|
||||
@@ -172,7 +172,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="contact-info-card p-6 md:p-8 rounded-2xl bg-gradient-to-br from-black to-gray-800 text-white border border-gray-800">
|
||||
<div v-if="socials.length" class="contact-info-card p-6 md:p-8 rounded-2xl bg-gradient-to-br from-black to-gray-800 text-white border border-gray-800">
|
||||
<h3 class="text-base md:text-lg font-bold mb-4">{{ t('contact.info.social') }}</h3>
|
||||
<div class="flex gap-3">
|
||||
<a
|
||||
@@ -351,8 +351,8 @@ onBeforeUnmount(() => {
|
||||
contactCtx?.revert()
|
||||
})
|
||||
|
||||
// 社交链接统一取自站点动态配置(后台可改)
|
||||
const socials = computed(() => settings?.socials ?? [])
|
||||
// 社交链接统一取自站点动态配置(后台可改);仅展示已填写 URL 的条目
|
||||
const socials = computed(() => (settings?.socials ?? []).filter((s) => s.url))
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
|
||||
<!-- 文章 Hero -->
|
||||
<section class="relative h-[50vh] md:h-[60vh] overflow-hidden">
|
||||
<img
|
||||
:src="article.image || ''"
|
||||
<CoverImage
|
||||
:src="article.image"
|
||||
:alt="title"
|
||||
:title="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>
|
||||
@@ -132,7 +133,7 @@
|
||||
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="locText(related.titleZh, related.titleEn)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
<CoverImage :src="related.image" :alt="locText(related.titleZh, related.titleEn)" :title="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">{{ formatNewsDate(related.date, locale) }}</span>
|
||||
|
||||
@@ -57,10 +57,10 @@
|
||||
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 || ''"
|
||||
<CoverImage
|
||||
:src="article.image"
|
||||
:alt="locText(article.titleZh, article.titleEn)"
|
||||
:loading="'lazy'"
|
||||
:title="locText(article.titleZh, article.titleEn)"
|
||||
class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
|
||||
/>
|
||||
<div class="absolute top-4 left-4">
|
||||
|
||||
@@ -13,9 +13,10 @@
|
||||
|
||||
<!-- Hero 大图 -->
|
||||
<section class="relative h-[60vh] md:h-[70vh] overflow-hidden">
|
||||
<img
|
||||
:src="project.image || ''"
|
||||
<CoverImage
|
||||
:src="project.image"
|
||||
:alt="title"
|
||||
:title="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>
|
||||
@@ -178,7 +179,7 @@
|
||||
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="locText(related.titleZh, related.titleEn)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
|
||||
<CoverImage :src="related.image" :alt="locText(related.titleZh, related.titleEn)" :title="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">{{ locText(related.titleZh, related.titleEn) }}</h3>
|
||||
|
||||
@@ -57,10 +57,10 @@
|
||||
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 || ''"
|
||||
<CoverImage
|
||||
:src="project.image"
|
||||
:alt="locText(project.titleZh, project.titleEn)"
|
||||
:loading="'lazy'"
|
||||
:title="locText(project.titleZh, project.titleEn)"
|
||||
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>
|
||||
|
||||
+7
-29
@@ -2,55 +2,33 @@ import { defineStore } from 'pinia'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
/**
|
||||
* 登录/注册弹窗全局状态。
|
||||
* Header、个人中心、收藏/评论组件等都可直接 openLogin() 唤起登录弹窗,
|
||||
* 避免层层 prop/事件传递。
|
||||
* 登录弹窗全局状态(统一认证跳转由 LoginModal 触发)。
|
||||
* Header、个人中心、收藏/评论组件等都可直接 openLogin() 唤起,
|
||||
* 避免层层 prop/事件传递。注册账号统一跳转 Casdoor 完成,此处不再提供注册弹窗。
|
||||
*/
|
||||
export const useAuthModalStore = defineStore('authModal', () => {
|
||||
const isLoginOpen = ref(false)
|
||||
const isRegisterOpen = ref(false)
|
||||
|
||||
// 任一弹窗打开时锁定背景滚动
|
||||
// 弹窗打开时锁定背景滚动
|
||||
watch(
|
||||
() => [isLoginOpen.value, isRegisterOpen.value],
|
||||
([login, register]) => {
|
||||
() => isLoginOpen.value,
|
||||
(open) => {
|
||||
if (typeof document === 'undefined') return
|
||||
document.body.style.overflow = login || register ? 'hidden' : ''
|
||||
document.body.style.overflow = open ? '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,
|
||||
}
|
||||
})
|
||||
+13
-58
@@ -3,9 +3,9 @@ import { ref, computed } from 'vue'
|
||||
|
||||
export interface User {
|
||||
id: number
|
||||
providerId: string
|
||||
username: string
|
||||
email: string
|
||||
phone: string | null
|
||||
avatar: string | null
|
||||
role: 'user' | 'admin'
|
||||
createdAt: string
|
||||
@@ -21,46 +21,21 @@ const AVATAR_URL = (name: string) =>
|
||||
`https://ui-avatars.com/api/?name=${encodeURIComponent(name)}&background=000&color=fff&size=128`
|
||||
|
||||
/**
|
||||
* 用户会话状态(真实后端:httpOnly Cookie 会话)。
|
||||
* 用户会话状态(Casdoor 统一认证 + 服务端会话,仅恢复/登出两个动作)。
|
||||
* 登录不在此 store 发起表单请求:点击登录统一跳转 /api/auth/casdoor-login。
|
||||
*/
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const user = ref<User | null>(null)
|
||||
const isAuthenticated = computed(() => user.value !== null)
|
||||
|
||||
// 登录
|
||||
const login = async (account: string, password: string): Promise<ApiResult> => {
|
||||
try {
|
||||
const data = await $fetch<{ user: User }>('/api/auth/login', {
|
||||
method: 'POST',
|
||||
body: { account, password },
|
||||
})
|
||||
user.value = data.user
|
||||
return { success: true }
|
||||
} catch (err) {
|
||||
return { success: false, code: (err as any)?.data?.code || 'SERVER_ERROR' }
|
||||
}
|
||||
// 跳转 Casdoor 统一登录(next 为回跳路径,仅站内相对路径)
|
||||
const loginRedirect = (next = '/'): void => {
|
||||
const target = next.startsWith('/') && !next.startsWith('//') ? next : '/'
|
||||
const url = `/api/auth/casdoor-login?next=${encodeURIComponent(target)}`
|
||||
if (typeof window !== 'undefined') window.location.assign(url)
|
||||
}
|
||||
|
||||
// 注册(成功即自动登录)
|
||||
const register = async (data: {
|
||||
username: string
|
||||
email: string
|
||||
phone?: string
|
||||
password: string
|
||||
}): Promise<ApiResult> => {
|
||||
try {
|
||||
const res = await $fetch<{ user: User }>('/api/auth/register', {
|
||||
method: 'POST',
|
||||
body: data,
|
||||
})
|
||||
user.value = res.user
|
||||
return { success: true }
|
||||
} catch (err) {
|
||||
return { success: false, code: (err as any)?.data?.code || 'SERVER_ERROR' }
|
||||
}
|
||||
}
|
||||
|
||||
// 登出
|
||||
// 登出:销毁本地会话并清 Cookie;如需 Casdoor 单点登出再跳转其 logout 地址
|
||||
const logout = async (): Promise<void> => {
|
||||
try {
|
||||
await $fetch('/api/auth/logout', { method: 'POST' })
|
||||
@@ -80,8 +55,8 @@ export const useUserStore = defineStore('user', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 更新资料
|
||||
const updateProfile = async (patch: { username?: string; phone?: string }): Promise<ApiResult> => {
|
||||
// 仅支持修改用户名(头像/邮箱等账号信息统一由 Casdoor 管理)
|
||||
const updateProfile = async (patch: { username?: string }): Promise<ApiResult> => {
|
||||
try {
|
||||
const data = await $fetch<{ user: User }>('/api/auth/me', { method: 'PATCH', body: patch })
|
||||
user.value = data.user
|
||||
@@ -91,25 +66,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 更新头像(上传后由接口返回新 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' }
|
||||
}
|
||||
}
|
||||
|
||||
// 头像:用户自定义优先,否则按用户名生成
|
||||
// 头像:Casdoor 头像优先,否则按用户名生成
|
||||
const avatar = computed(() => {
|
||||
if (!user.value) return ''
|
||||
return user.value.avatar || AVATAR_URL(user.value.username)
|
||||
@@ -119,11 +76,9 @@ export const useUserStore = defineStore('user', () => {
|
||||
user,
|
||||
isAuthenticated,
|
||||
avatar,
|
||||
login,
|
||||
register,
|
||||
loginRedirect,
|
||||
logout,
|
||||
restoreUser,
|
||||
updateProfile,
|
||||
updateAvatar,
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,48 @@
|
||||
import { useRuntimeConfig } from '#app'
|
||||
|
||||
/**
|
||||
* Casdoor 客户端配置读取(public runtimeConfig 注入,不含任何 secret)。
|
||||
* 登录跳转走后端端点 /api/auth/casdoor-login,这里仅提供注册页与单点登出地址。
|
||||
*/
|
||||
|
||||
export interface CasdoorPublic {
|
||||
serverUrl: string
|
||||
clientId: string
|
||||
orgName: string
|
||||
appName: string
|
||||
redirectPath: string
|
||||
}
|
||||
|
||||
export function getCasdoorPublic(): CasdoorPublic {
|
||||
const c = useRuntimeConfig()
|
||||
const pub = (c.public ?? {}) as Record<string, string | undefined>
|
||||
return {
|
||||
serverUrl: (pub.casdoorServerUrl as string) || '',
|
||||
clientId: (pub.casdoorClientId as string) || '',
|
||||
orgName: (pub.casdoorOrgName as string) || '',
|
||||
appName: (pub.casdoorAppName as string) || '',
|
||||
redirectPath: (pub.casdoorRedirectPath as string) || '/api/auth/callback',
|
||||
}
|
||||
}
|
||||
|
||||
/** 注册账号统一在 Casdoor 完成 */
|
||||
export function getCasdoorSignupUrl(): string {
|
||||
const { serverUrl, appName } = getCasdoorPublic()
|
||||
if (!serverUrl || !appName) return ''
|
||||
return `${serverUrl}/signup/${appName}`
|
||||
}
|
||||
|
||||
/** 本站回调完整地址(用于登出回跳) */
|
||||
export function getCasdoorRedirectUri(): string {
|
||||
const { redirectPath } = getCasdoorPublic()
|
||||
const { public: p } = useRuntimeConfig()
|
||||
const siteUrl = String((p as any).siteUrl || '').replace(/\/$/, '')
|
||||
return `${siteUrl}${redirectPath}`
|
||||
}
|
||||
|
||||
/** 单点登出地址(可选使用:登出后跳回本站回调) */
|
||||
export function getCasdoorLogoutUrl(): string {
|
||||
const { serverUrl, clientId } = getCasdoorPublic()
|
||||
if (!serverUrl || !clientId) return ''
|
||||
return `${serverUrl}/logout?client_id=${clientId}&redirect_uri=${encodeURIComponent(getCasdoorRedirectUri())}`
|
||||
}
|
||||
@@ -16,8 +16,7 @@
|
||||
# SESSION_SECRET 会话密钥(缺省复用已有或自动生成)
|
||||
# SMTP_HOST/PORT/USER/PASS/FROM 邮件
|
||||
# CONTACT_TO 联系表单收件邮箱
|
||||
# ADMIN_EMAILS 管理员邮箱(逗号分隔)
|
||||
# ADMIN_INITIAL_PASSWORD 预置管理员初始密码(缺省自动生成并打印)
|
||||
# CASDOOR_CLIENT_ID/SECRET/CERT_B64 统一认证凭据(认证中心分配的客户端密钥与证书公钥)
|
||||
# SITE_URL 站点公开地址(默认 https://personal.virtheart.com)
|
||||
# =========================================================
|
||||
set -euo pipefail
|
||||
@@ -73,12 +72,7 @@ if [ -z "${SESSION_SECRET}" ]; then
|
||||
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
|
||||
# Casdoor 凭据(客户端密钥/证书公钥等机密,由环境变量注入,不写入仓库)
|
||||
|
||||
kubectl create secret generic app-secrets -n "${NAMESPACE}" \
|
||||
--from-literal="NUXT_SESSION_SECRET=${SESSION_SECRET}" \
|
||||
@@ -88,8 +82,9 @@ kubectl create secret generic app-secrets -n "${NAMESPACE}" \
|
||||
--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_CASDOOR_CLIENT_ID=${CASDOOR_CLIENT_ID:-}" \
|
||||
--from-literal="NUXT_CASDOOR_CLIENT_SECRET=${CASDOOR_CLIENT_SECRET:-}" \
|
||||
--from-literal="NUXT_CASDOOR_CERT_B64=${CASDOOR_CERT_B64:-}" \
|
||||
--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:-}" \
|
||||
@@ -101,6 +96,16 @@ kubectl create secret generic app-secrets -n "${NAMESPACE}" \
|
||||
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" \
|
||||
--from-literal="NUXT_CASDOOR_SERVER_URL=${CASDOOR_SERVER_URL:-https://sys.virtheart.com}" \
|
||||
--from-literal="NUXT_CASDOOR_ORG_NAME=${CASDOOR_ORG_NAME:-virtheart}" \
|
||||
--from-literal="NUXT_CASDOOR_APP_NAME=${CASDOOR_APP_NAME:-virtheat-personal}" \
|
||||
--from-literal="NUXT_CASDOOR_ADMIN_ROLES=${CASDOOR_ADMIN_ROLES:-admin}" \
|
||||
--from-literal="NUXT_CASDOOR_CALLBACK_PATH=${CASDOOR_CALLBACK_PATH:-/api/auth/callback}" \
|
||||
--from-literal="NUXT_PUBLIC_CASDOOR_SERVER_URL=${CASDOOR_SERVER_URL:-https://sys.virtheart.com}" \
|
||||
--from-literal="NUXT_PUBLIC_CASDOOR_CLIENT_ID=${CASDOOR_CLIENT_ID:-}" \
|
||||
--from-literal="NUXT_PUBLIC_CASDOOR_ORG_NAME=${CASDOOR_ORG_NAME:-virtheart}" \
|
||||
--from-literal="NUXT_PUBLIC_CASDOOR_APP_NAME=${CASDOOR_APP_NAME:-virtheat-personal}" \
|
||||
--from-literal="NUXT_PUBLIC_CASDOOR_REDIRECT_PATH=${CASDOOR_CALLBACK_PATH:-/api/auth/callback}" \
|
||||
--dry-run=client -o yaml | kubectl apply -f - >/dev/null
|
||||
|
||||
# ---------- 4. 应用全部资源 ----------
|
||||
|
||||
+8
-48
@@ -100,56 +100,10 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"achievements": {
|
||||
"items": {
|
||||
"projects": {
|
||||
"title": "Successful Projects",
|
||||
"description": "We've successfully delivered over 150 high-quality projects across various industries, earning client trust."
|
||||
},
|
||||
"clients": {
|
||||
"title": "Global Clients",
|
||||
"description": "Serving 85+ clients worldwide, from startups to large enterprises, building long-term partnerships."
|
||||
},
|
||||
"experience": {
|
||||
"title": "Industry Experience",
|
||||
"description": "12 years of deep expertise in the digital realm, staying ahead of industry trends with cutting-edge solutions."
|
||||
},
|
||||
"satisfaction": {
|
||||
"title": "Client Satisfaction",
|
||||
"description": "98% client satisfaction rate, driven by our commitment to quality and deep understanding of client needs."
|
||||
}
|
||||
}
|
||||
},
|
||||
"achievements": {},
|
||||
"testimonials": {
|
||||
"title": "Client Testimonials",
|
||||
"subtitle": "Hear what our clients have to say about us",
|
||||
"items": {
|
||||
"client1": {
|
||||
"name": "Alex Chen",
|
||||
"role": "CEO, Tech Company",
|
||||
"content": "Working with ArcticNewOne was an amazing experience. Their professionalism and creative thinking exceeded our expectations."
|
||||
},
|
||||
"client2": {
|
||||
"name": "Sarah Li",
|
||||
"role": "Founder, E-commerce",
|
||||
"content": "The team is incredibly professional, from design to development. The project was delivered on time with excellent quality!"
|
||||
},
|
||||
"client3": {
|
||||
"name": "Michael Wang",
|
||||
"role": "Brand Director",
|
||||
"content": "They truly understood our brand needs and created stunning designs. Collaboration was smooth and communication efficient."
|
||||
},
|
||||
"client4": {
|
||||
"name": "Emily Zhao",
|
||||
"role": "Marketing Manager",
|
||||
"content": "ArcticNewOne helped us complete our digital transformation. Website traffic increased by 300% and conversion rates soared."
|
||||
},
|
||||
"client5": {
|
||||
"name": "David Liu",
|
||||
"role": "Product Lead",
|
||||
"content": "From strategic planning to execution, every step was meticulously handled. One of the most professional teams I've worked with."
|
||||
}
|
||||
}
|
||||
"subtitle": "Hear what our clients have to say about us"
|
||||
},
|
||||
"process": {
|
||||
"title": "Our Process",
|
||||
@@ -358,6 +312,10 @@
|
||||
"login": "Login",
|
||||
"logout": "Logout",
|
||||
"loginDescription": "Welcome back! Please login to your account.",
|
||||
"casdoorDescription": "Sign in with the unified identity provider",
|
||||
"casdoorHint": "Click the button below to continue at the unified authentication center.",
|
||||
"loginWithCasdoor": "Sign in with SSO",
|
||||
"redirecting": "Redirecting to sign in",
|
||||
"account": "Account",
|
||||
"accountPlaceholder": "Username / Email / Phone",
|
||||
"password": "Password",
|
||||
@@ -412,6 +370,8 @@
|
||||
"saving": "Saving...",
|
||||
"saved": "Saved",
|
||||
"saveFailed": "Failed to save. Please try again.",
|
||||
"ssoAccount": "Unified SSO Account",
|
||||
"ssoAccountHint": "Email, avatar and password are managed by the unified identity provider (Casdoor). Visit the provider to update them.",
|
||||
"emptyFavorites": "No favorites yet. Go to the Work page to explore.",
|
||||
"emptyComments": "No comments posted yet",
|
||||
"admin": {
|
||||
|
||||
+8
-48
@@ -100,56 +100,10 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"achievements": {
|
||||
"items": {
|
||||
"projects": {
|
||||
"title": "成功项目",
|
||||
"description": "我们已经成功交付超过 150 个高质量项目,涵盖各行各业,赢得客户信赖。"
|
||||
},
|
||||
"clients": {
|
||||
"title": "合作客户",
|
||||
"description": "服务全球 85+ 客户,从初创公司到大型企业,建立长期合作关系。"
|
||||
},
|
||||
"experience": {
|
||||
"title": "行业经验",
|
||||
"description": "12 年深耕数字领域,积累丰富经验,紧跟行业趋势,提供前沿解决方案。"
|
||||
},
|
||||
"satisfaction": {
|
||||
"title": "客户满意度",
|
||||
"description": "98% 的客户满意度,源于我们对品质的执着追求和对客户需求的深刻理解。"
|
||||
}
|
||||
}
|
||||
},
|
||||
"achievements": {},
|
||||
"testimonials": {
|
||||
"title": "客户评价",
|
||||
"subtitle": "听听客户对我们的真实评价",
|
||||
"items": {
|
||||
"client1": {
|
||||
"name": "张伟",
|
||||
"role": "科技公司 CEO",
|
||||
"content": "与北极新一合作是一次非常愉快的体验。他们的专业能力和创意思维让我们的项目超出了预期。"
|
||||
},
|
||||
"client2": {
|
||||
"name": "李娜",
|
||||
"role": "电商平台创始人",
|
||||
"content": "团队非常专业,从设计到开发都展现出极高的水准。项目按时交付,质量优秀,强烈推荐!"
|
||||
},
|
||||
"client3": {
|
||||
"name": "王强",
|
||||
"role": "品牌总监",
|
||||
"content": "他们真正理解我们的品牌需求,创造出令人惊艳的设计。合作过程顺畅,沟通高效。"
|
||||
},
|
||||
"client4": {
|
||||
"name": "赵敏",
|
||||
"role": "市场部经理",
|
||||
"content": "北极新一帮助我们完成了数字化转型,网站流量提升了 300%,转化率也大幅提高。"
|
||||
},
|
||||
"client5": {
|
||||
"name": "刘洋",
|
||||
"role": "产品负责人",
|
||||
"content": "从战略规划到执行落地,每个环节都做得非常细致。这是我合作过最专业的团队之一。"
|
||||
}
|
||||
}
|
||||
"subtitle": "听听客户对我们的真实评价"
|
||||
},
|
||||
"process": {
|
||||
"title": "工作流程",
|
||||
@@ -358,6 +312,10 @@
|
||||
"login": "登录",
|
||||
"logout": "退出登录",
|
||||
"loginDescription": "欢迎回来!请登录您的账户。",
|
||||
"casdoorDescription": "使用统一身份认证,登录北极新站内账号",
|
||||
"casdoorHint": "选择下方按钮,将跳转到统一身份认证中心完成登录。",
|
||||
"loginWithCasdoor": "通过统一身份认证登录",
|
||||
"redirecting": "正在跳转登录…",
|
||||
"account": "账号",
|
||||
"accountPlaceholder": "用户名 / 邮箱 / 手机号",
|
||||
"password": "密码",
|
||||
@@ -412,6 +370,8 @@
|
||||
"saving": "保存中...",
|
||||
"saved": "已保存",
|
||||
"saveFailed": "保存失败,请重试",
|
||||
"ssoAccount": "统一身份认证账号",
|
||||
"ssoAccountHint": "邮箱、头像与密码等账号信息由统一身份认证中心(Casdoor)管理,如需修改请前往认证中心。",
|
||||
"emptyFavorites": "还没有收藏任何作品,去「作品」页看看吧",
|
||||
"emptyComments": "还没有发表过评论",
|
||||
"admin": {
|
||||
|
||||
+16
-3
@@ -22,7 +22,7 @@ export default defineNuxtConfig({
|
||||
// 与全站 `<AppLoader>`/`<CommentSection>` 等无前缀引用保持一致
|
||||
components: [{ path: '~/components', pathPrefix: false }],
|
||||
runtimeConfig: {
|
||||
// 服务端私有配置(环境变量自动映射:SESSION_SECRET / DB_PATH / SMTP_* / CONTACT_TO / ADMIN_EMAILS)
|
||||
// 服务端私有配置(环境变量自动映射:SESSION_SECRET / DB_PATH / SMTP_* / CONTACT_TO / CASDOOR_*)
|
||||
sessionSecret: '',
|
||||
dbPath: process.env.DB_PATH || (process.env.NODE_ENV === 'production' ? '/data/arcticnewone.db' : '.data/arcticnewone.db'),
|
||||
smtpHost: '',
|
||||
@@ -32,7 +32,15 @@ export default defineNuxtConfig({
|
||||
smtpFrom: '',
|
||||
contactTo: '',
|
||||
adminEmails: '',
|
||||
adminInitialPassword: '',
|
||||
// Casdoor 统一认证(凭据仅走环境变量注入,绝不写入代码)
|
||||
casdoorServerUrl: '',
|
||||
casdoorClientId: '',
|
||||
casdoorClientSecret: '',
|
||||
casdoorOrgName: '',
|
||||
casdoorAppName: '',
|
||||
casdoorCertB64: '',
|
||||
casdoorAdminRoles: '',
|
||||
casdoorCallbackPath: '/api/auth/callback',
|
||||
// OSS 文件存储(RustFS / S3 v4 兼容;凭据仅走环境变量注入,绝不写入仓库)
|
||||
ossEndpoint: '',
|
||||
ossAccessKey: '',
|
||||
@@ -41,8 +49,13 @@ export default defineNuxtConfig({
|
||||
ossRegion: 'us-east-1',
|
||||
ossPublicBase: '',
|
||||
public: {
|
||||
// 客户端可见(环境变量:NUXT_PUBLIC_SITE_URL),用于 sitemap/robots/og 等绝对链接
|
||||
// 客户端可见(环境变量:NUXT_PUBLIC_*)
|
||||
siteUrl: '',
|
||||
casdoorServerUrl: '',
|
||||
casdoorClientId: '',
|
||||
casdoorOrgName: '',
|
||||
casdoorAppName: '',
|
||||
casdoorRedirectPath: '/api/auth/callback',
|
||||
},
|
||||
},
|
||||
modules: [
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
"@nuxtjs/i18n": "10.3.0",
|
||||
"@pinia/nuxt": "0.11.3",
|
||||
"better-sqlite3": "^13.0.2",
|
||||
"casdoor-js-sdk": "^0.20.0",
|
||||
"casdoor-nodejs-sdk": "^1.34.0",
|
||||
"gsap": "^3.15.0",
|
||||
"lenis": "^1.3.23",
|
||||
"nodemailer": "^9.0.4",
|
||||
@@ -27,6 +29,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify-json/ph": "1.2.2",
|
||||
"@iconify-json/ri": "^1.2.10",
|
||||
"@nuxtjs/tailwindcss": "6.14.0",
|
||||
"@types/better-sqlite3": "^7.6.13",
|
||||
"@types/nodemailer": "^6.4.17",
|
||||
|
||||
Generated
+295
-1
@@ -23,6 +23,12 @@ importers:
|
||||
better-sqlite3:
|
||||
specifier: ^13.0.2
|
||||
version: 13.0.2
|
||||
casdoor-js-sdk:
|
||||
specifier: ^0.20.0
|
||||
version: 0.20.0
|
||||
casdoor-nodejs-sdk:
|
||||
specifier: ^1.34.0
|
||||
version: 1.34.0(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)
|
||||
gsap:
|
||||
specifier: ^3.15.0
|
||||
version: 3.15.0
|
||||
@@ -48,6 +54,9 @@ importers:
|
||||
'@iconify-json/ph':
|
||||
specifier: 1.2.2
|
||||
version: 1.2.2
|
||||
'@iconify-json/ri':
|
||||
specifier: ^1.2.10
|
||||
version: 1.2.10
|
||||
'@nuxtjs/tailwindcss':
|
||||
specifier: 6.14.0
|
||||
version: 6.14.0(magicast@0.5.2)(supports-color@10.2.2)(yaml@2.8.3)
|
||||
@@ -616,6 +625,9 @@ packages:
|
||||
'@iconify-json/ph@1.2.2':
|
||||
resolution: {integrity: sha512-PgkEZNtqa8hBGjHXQa4pMwZa93hmfu8FUSjs/nv4oUU6yLsgv+gh9nu28Kqi8Fz9CCVu4hj1MZs9/60J57IzFw==}
|
||||
|
||||
'@iconify-json/ri@1.2.10':
|
||||
resolution: {integrity: sha512-WWMhoncVVM+Xmu9T5fgu2lhYRrKTEWhKk3Com0KiM111EeEsRLiASjpsFKnC/SrB6covhUp95r2mH8tGxhgd5Q==}
|
||||
|
||||
'@iconify/collections@1.0.676':
|
||||
resolution: {integrity: sha512-dtV8s0QtP0fjsIZoCA4gURBp2DWGs7vJDz+Kh5+vpeNinBbtbNz+MABDz61ikcFGE27mdvNFmA3ygprBXHZJ4A==}
|
||||
|
||||
@@ -2234,6 +2246,10 @@ packages:
|
||||
engines: {node: '>=0.4.0'}
|
||||
hasBin: true
|
||||
|
||||
agent-base@6.0.0:
|
||||
resolution: {integrity: sha512-j1Q7cSCqN+AwrmDd+pzgqc0/NpC655x2bUf5ZjRIO77DcNBFmh+OgRNzF6OKdCC9RSCb19fGd99+bhXFdkRNqw==}
|
||||
engines: {node: '>= 6.0.0'}
|
||||
|
||||
agent-base@7.1.4:
|
||||
resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==}
|
||||
engines: {node: '>= 14'}
|
||||
@@ -2303,6 +2319,9 @@ packages:
|
||||
async@3.2.6:
|
||||
resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==}
|
||||
|
||||
asynckit@0.4.0:
|
||||
resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}
|
||||
|
||||
at-least-node@1.0.0:
|
||||
resolution: {integrity: sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==}
|
||||
engines: {node: '>= 4.0.0'}
|
||||
@@ -2314,6 +2333,9 @@ packages:
|
||||
peerDependencies:
|
||||
postcss: ^8.1.0
|
||||
|
||||
axios@1.19.0:
|
||||
resolution: {integrity: sha512-ht/iuYZXEjFxLH/Hkezgd7m6JKlHHXEUSneaDz8uZe1Gj5QZtCnpyDsckvAiEnT89OEbCLmnte4R4sn7P0EKFw==}
|
||||
|
||||
b4a@1.8.0:
|
||||
resolution: {integrity: sha512-qRuSmNSkGQaHwNbM7J78Wwy+ghLEYF1zNrSeMxj4Kgw6y33O3mXcQ6Ie9fRvfU/YnxWkOchPXbaLb73TkIsfdg==}
|
||||
peerDependencies:
|
||||
@@ -2421,6 +2443,9 @@ packages:
|
||||
resolution: {integrity: sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
|
||||
buffer-equal-constant-time@1.0.1:
|
||||
resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==}
|
||||
|
||||
buffer-from@1.1.2:
|
||||
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
||||
|
||||
@@ -2465,6 +2490,12 @@ packages:
|
||||
caniuse-lite@1.0.30001790:
|
||||
resolution: {integrity: sha512-bOoxfJPyYo+ds6W0YfptaCWbFnJYjh2Y1Eow5lRv+vI2u8ganPZqNm1JwNh0t2ELQCqIWg4B3dWEusgAmsoyOw==}
|
||||
|
||||
casdoor-js-sdk@0.20.0:
|
||||
resolution: {integrity: sha512-8miZkZHwKBP2VlAd8Rla5NsT0WzaSiNRMzO1mdpr3YVLuNHcE+CYwBrN4rMXk8JT5rkGt+rsHUBLXFf9wS3NFg==}
|
||||
|
||||
casdoor-nodejs-sdk@1.34.0:
|
||||
resolution: {integrity: sha512-OVYxaLvA18ZUK7L9y3AGJqLKRaV6b0GsaNs6gcMeR5oFdF18JeOuDl553ZI2sNdYxKWjxFXwKPlXEVxHInkreg==}
|
||||
|
||||
chai@6.2.2:
|
||||
resolution: {integrity: sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==}
|
||||
engines: {node: '>=18'}
|
||||
@@ -2518,6 +2549,10 @@ packages:
|
||||
color-name@1.1.4:
|
||||
resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}
|
||||
|
||||
combined-stream@1.0.8:
|
||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
commander@11.1.0:
|
||||
resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==}
|
||||
engines: {node: '>=16'}
|
||||
@@ -2615,6 +2650,10 @@ packages:
|
||||
srvx:
|
||||
optional: true
|
||||
|
||||
crypto-js@4.2.0:
|
||||
resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==}
|
||||
deprecated: Active development of CryptoJS has been discontinued. This library is no longer maintained.
|
||||
|
||||
css-declaration-sorter@7.4.0:
|
||||
resolution: {integrity: sha512-LTuzjPoyA2vMGKKcaOqKSp7Ub2eGrNfKiZH4LpezxpNrsICGCSFvsQOI29psISxNZtaXibkC2CXzrQ5enMeGGw==}
|
||||
engines: {node: ^14 || ^16 || >=18}
|
||||
@@ -2666,6 +2705,10 @@ packages:
|
||||
csstype@3.2.3:
|
||||
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
|
||||
|
||||
data-uri-to-buffer@4.0.0:
|
||||
resolution: {integrity: sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==}
|
||||
engines: {node: '>= 12'}
|
||||
|
||||
db0@0.3.4:
|
||||
resolution: {integrity: sha512-RiXXi4WaNzPTHEOu8UPQKMooIbqOEyqA1t7Z6MsdxSCeb8iUC9ko3LcmsLmeUt2SM5bctfArZKkRQggKZz7JNw==}
|
||||
peerDependencies:
|
||||
@@ -2731,6 +2774,10 @@ packages:
|
||||
defu@6.1.7:
|
||||
resolution: {integrity: sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==}
|
||||
|
||||
delayed-stream@1.0.0:
|
||||
resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
|
||||
delegates@1.0.0:
|
||||
resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==}
|
||||
|
||||
@@ -2801,6 +2848,9 @@ packages:
|
||||
eastasianwidth@0.2.0:
|
||||
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
|
||||
|
||||
ecdsa-sig-formatter@1.0.11:
|
||||
resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==}
|
||||
|
||||
ee-first@1.1.1:
|
||||
resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==}
|
||||
|
||||
@@ -2856,6 +2906,14 @@ packages:
|
||||
resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
es-object-atoms@1.1.2:
|
||||
resolution: {integrity: sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
es-set-tostringtag@2.1.0:
|
||||
resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
esbuild@0.25.12:
|
||||
resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==}
|
||||
engines: {node: '>=18'}
|
||||
@@ -3016,6 +3074,10 @@ packages:
|
||||
picomatch:
|
||||
optional: true
|
||||
|
||||
fetch-blob@3.2.0:
|
||||
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
|
||||
engines: {node: ^12.20 || >= 14.13}
|
||||
|
||||
file-entry-cache@8.0.0:
|
||||
resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==}
|
||||
engines: {node: '>=16.0.0'}
|
||||
@@ -3038,10 +3100,27 @@ packages:
|
||||
flatted@3.4.2:
|
||||
resolution: {integrity: sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==}
|
||||
|
||||
follow-redirects@1.16.0:
|
||||
resolution: {integrity: sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==}
|
||||
engines: {node: '>=4.0'}
|
||||
peerDependencies:
|
||||
debug: '*'
|
||||
peerDependenciesMeta:
|
||||
debug:
|
||||
optional: true
|
||||
|
||||
foreground-child@3.3.1:
|
||||
resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
form-data@4.0.6:
|
||||
resolution: {integrity: sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
formdata-polyfill@4.0.10:
|
||||
resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
|
||||
fraction.js@5.3.4:
|
||||
resolution: {integrity: sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ==}
|
||||
|
||||
@@ -3172,6 +3251,10 @@ packages:
|
||||
resolution: {integrity: sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
hasown@2.0.4:
|
||||
resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==}
|
||||
engines: {node: '>= 0.4'}
|
||||
|
||||
hookable@5.5.3:
|
||||
resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==}
|
||||
|
||||
@@ -3220,6 +3303,10 @@ packages:
|
||||
resolution: {integrity: sha512-S9wWkJ/VSY9/k4qcjG318bqJNruzE4HySUhFYknwmu6LBP97KLLfwNf+n4V1BHurvFNkSKLFnK/RsuUnRTf9Vw==}
|
||||
engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'}
|
||||
|
||||
https-proxy-agent@5.0.1:
|
||||
resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
https-proxy-agent@7.0.6:
|
||||
resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==}
|
||||
engines: {node: '>= 14'}
|
||||
@@ -3387,6 +3474,9 @@ packages:
|
||||
resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==}
|
||||
hasBin: true
|
||||
|
||||
js-pkce@1.5.1:
|
||||
resolution: {integrity: sha512-+NYxv4wAwa/aHKpXS+AhBswxeOtIpxVwoz36oBLHjznCcTg+v8L9ijDR6xtkZb5vsxdpQ7sEWtr4fCc9aIt8yA==}
|
||||
|
||||
js-tokens@4.0.0:
|
||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||
|
||||
@@ -3426,6 +3516,20 @@ packages:
|
||||
jsonfile@6.2.1:
|
||||
resolution: {integrity: sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==}
|
||||
|
||||
jsonwebtoken@9.0.2:
|
||||
resolution: {integrity: sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==}
|
||||
engines: {node: '>=12', npm: '>=6'}
|
||||
|
||||
jwa@1.4.2:
|
||||
resolution: {integrity: sha512-eeH5JO+21J78qMvTIDdBXidBd6nG2kZjg5Ohz/1fpa28Z4CcsWUzJ1ZZyFq/3z3N17aZy+ZuBoHljASbL1WfOw==}
|
||||
|
||||
jws@3.2.3:
|
||||
resolution: {integrity: sha512-byiJ0FLRdLdSVSReO/U4E7RoEyOCKnEnEPMjq3HxWtvzLsV08/i5RQKsFVNkCldrCaPr2vDNAOMsfs8T/Hze7g==}
|
||||
|
||||
jwt-decode@4.0.0:
|
||||
resolution: {integrity: sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
keygrip@1.1.0:
|
||||
resolution: {integrity: sha512-iYSchDJ+liQ8iwbSI2QqsQOvqv58eJCEanyJPJi+Khyu8smkcKSFUCbPwzFcL7YVtZ6eONjqRX/38caJ7QjRAQ==}
|
||||
engines: {node: '>= 0.6'}
|
||||
@@ -3514,12 +3618,33 @@ packages:
|
||||
lodash.defaults@4.2.0:
|
||||
resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==}
|
||||
|
||||
lodash.includes@4.3.0:
|
||||
resolution: {integrity: sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==}
|
||||
|
||||
lodash.isarguments@3.1.0:
|
||||
resolution: {integrity: sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==}
|
||||
|
||||
lodash.isboolean@3.0.3:
|
||||
resolution: {integrity: sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==}
|
||||
|
||||
lodash.isinteger@4.0.4:
|
||||
resolution: {integrity: sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==}
|
||||
|
||||
lodash.isnumber@3.0.3:
|
||||
resolution: {integrity: sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==}
|
||||
|
||||
lodash.isplainobject@4.0.6:
|
||||
resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==}
|
||||
|
||||
lodash.isstring@4.0.1:
|
||||
resolution: {integrity: sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==}
|
||||
|
||||
lodash.memoize@4.1.2:
|
||||
resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==}
|
||||
|
||||
lodash.once@4.1.1:
|
||||
resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==}
|
||||
|
||||
lodash.uniq@4.5.0:
|
||||
resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==}
|
||||
|
||||
@@ -3683,6 +3808,11 @@ packages:
|
||||
resolution: {integrity: sha512-4eUQWVPCUUUiBjLnHS3cXWeC6ryoPUc0U3rP7IuzapoGbzMqd/r6KKO0clr0b+snQhsrueFEhCZDdK+LK7hxKg==}
|
||||
engines: {node: ^18 || ^20 || >= 21}
|
||||
|
||||
node-domexception@1.0.0:
|
||||
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
||||
engines: {node: '>=10.5.0'}
|
||||
deprecated: Use your platform's native DOMException instead
|
||||
|
||||
node-fetch-native@1.6.7:
|
||||
resolution: {integrity: sha512-g9yhqoedzIUm0nTnTqAQvueMPVOuIY16bqgAJJC8XOOubYFNwz6IER9qs0Gq2Xd0+CecCKFjtdDTMA4u4xG06Q==}
|
||||
|
||||
@@ -3695,6 +3825,10 @@ packages:
|
||||
encoding:
|
||||
optional: true
|
||||
|
||||
node-fetch@3.3.2:
|
||||
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
|
||||
node-forge@1.4.0:
|
||||
resolution: {integrity: sha512-LarFH0+6VfriEhqMMcLX2F7SwSXeWwnEAJEsYm5QKWchiVYVvJyV9v7UDvUv+w5HO23ZpQTXDv/GxdDdMyOuoQ==}
|
||||
engines: {node: '>= 6.13.0'}
|
||||
@@ -4185,6 +4319,10 @@ packages:
|
||||
resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==}
|
||||
engines: {node: '>= 6'}
|
||||
|
||||
proxy-from-env@2.1.0:
|
||||
resolution: {integrity: sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
punycode@2.3.1:
|
||||
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -4967,6 +5105,10 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
web-streams-polyfill@3.0.3:
|
||||
resolution: {integrity: sha512-d2H/t0eqRNM4w2WvmTdoeIvzAUSpK7JmATB8Nr2lb7nQ9BTIJVjbQ/TRFVEh2gUH1HwclPdoPtfMoFfetXaZnA==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
web-vitals@5.2.0:
|
||||
resolution: {integrity: sha512-i2z98bEmaCqSDiHEDu+gHl/dmR4Q+TxFmG3/13KkMO+o8UxQzCqWaDRCiLgEa41nlO4VpXSI0ASa1xWmO9sBlA==}
|
||||
|
||||
@@ -5530,6 +5672,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@iconify/types': 2.0.0
|
||||
|
||||
'@iconify-json/ri@1.2.10':
|
||||
dependencies:
|
||||
'@iconify/types': 2.0.0
|
||||
|
||||
'@iconify/collections@1.0.676':
|
||||
dependencies:
|
||||
'@iconify/types': 2.0.0
|
||||
@@ -7158,6 +7304,12 @@ snapshots:
|
||||
|
||||
acorn@8.16.0: {}
|
||||
|
||||
agent-base@6.0.0(supports-color@10.2.2):
|
||||
dependencies:
|
||||
debug: 4.4.3(supports-color@10.2.2)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
agent-base@7.1.4: {}
|
||||
|
||||
ajv@6.15.0:
|
||||
@@ -7237,6 +7389,8 @@ snapshots:
|
||||
|
||||
async@3.2.6: {}
|
||||
|
||||
asynckit@0.4.0: {}
|
||||
|
||||
at-least-node@1.0.0: {}
|
||||
|
||||
autoprefixer@10.5.0(postcss@8.5.10):
|
||||
@@ -7248,6 +7402,16 @@ snapshots:
|
||||
postcss: 8.5.10
|
||||
postcss-value-parser: 4.2.0
|
||||
|
||||
axios@1.19.0(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2):
|
||||
dependencies:
|
||||
follow-redirects: 1.16.0(debug@4.4.3(supports-color@10.2.2))
|
||||
form-data: 4.0.6
|
||||
https-proxy-agent: 5.0.1(supports-color@10.2.2)
|
||||
proxy-from-env: 2.1.0
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
- supports-color
|
||||
|
||||
b4a@1.8.0: {}
|
||||
|
||||
balanced-match@1.0.2: {}
|
||||
@@ -7333,6 +7497,8 @@ snapshots:
|
||||
|
||||
buffer-crc32@1.0.0: {}
|
||||
|
||||
buffer-equal-constant-time@1.0.1: {}
|
||||
|
||||
buffer-from@1.1.2: {}
|
||||
|
||||
buffer@6.0.3:
|
||||
@@ -7389,6 +7555,21 @@ snapshots:
|
||||
|
||||
caniuse-lite@1.0.30001790: {}
|
||||
|
||||
casdoor-js-sdk@0.20.0:
|
||||
dependencies:
|
||||
js-pkce: 1.5.1
|
||||
jwt-decode: 4.0.0
|
||||
|
||||
casdoor-nodejs-sdk@1.34.0(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2):
|
||||
dependencies:
|
||||
axios: 1.19.0(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)
|
||||
form-data: 4.0.6
|
||||
jsonwebtoken: 9.0.2
|
||||
node-fetch: 3.3.2
|
||||
transitivePeerDependencies:
|
||||
- debug
|
||||
- supports-color
|
||||
|
||||
chai@6.2.2: {}
|
||||
|
||||
chalk@4.1.2:
|
||||
@@ -7446,6 +7627,10 @@ snapshots:
|
||||
|
||||
color-name@1.1.4: {}
|
||||
|
||||
combined-stream@1.0.8:
|
||||
dependencies:
|
||||
delayed-stream: 1.0.0
|
||||
|
||||
commander@11.1.0: {}
|
||||
|
||||
commander@2.20.3: {}
|
||||
@@ -7522,6 +7707,8 @@ snapshots:
|
||||
optionalDependencies:
|
||||
srvx: 0.11.15
|
||||
|
||||
crypto-js@4.2.0: {}
|
||||
|
||||
css-declaration-sorter@7.4.0(postcss@8.5.10):
|
||||
dependencies:
|
||||
postcss: 8.5.10
|
||||
@@ -7598,6 +7785,8 @@ snapshots:
|
||||
|
||||
csstype@3.2.3: {}
|
||||
|
||||
data-uri-to-buffer@4.0.0: {}
|
||||
|
||||
db0@0.3.4(better-sqlite3@13.0.2):
|
||||
optionalDependencies:
|
||||
better-sqlite3: 13.0.2
|
||||
@@ -7631,6 +7820,8 @@ snapshots:
|
||||
|
||||
defu@6.1.7: {}
|
||||
|
||||
delayed-stream@1.0.0: {}
|
||||
|
||||
delegates@1.0.0: {}
|
||||
|
||||
denque@2.1.0: {}
|
||||
@@ -7687,6 +7878,10 @@ snapshots:
|
||||
|
||||
eastasianwidth@0.2.0: {}
|
||||
|
||||
ecdsa-sig-formatter@1.0.11:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
ee-first@1.1.1: {}
|
||||
|
||||
electron-to-chromium@1.5.344: {}
|
||||
@@ -7721,6 +7916,17 @@ snapshots:
|
||||
dependencies:
|
||||
es-errors: 1.3.0
|
||||
|
||||
es-object-atoms@1.1.2:
|
||||
dependencies:
|
||||
es-errors: 1.3.0
|
||||
|
||||
es-set-tostringtag@2.1.0:
|
||||
dependencies:
|
||||
es-errors: 1.3.0
|
||||
get-intrinsic: 1.3.0
|
||||
has-tostringtag: 1.0.2
|
||||
hasown: 2.0.3
|
||||
|
||||
esbuild@0.25.12:
|
||||
optionalDependencies:
|
||||
'@esbuild/aix-ppc64': 0.25.12
|
||||
@@ -7943,6 +8149,11 @@ snapshots:
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.4
|
||||
|
||||
fetch-blob@3.2.0:
|
||||
dependencies:
|
||||
node-domexception: 1.0.0
|
||||
web-streams-polyfill: 3.0.3
|
||||
|
||||
file-entry-cache@8.0.0:
|
||||
dependencies:
|
||||
flat-cache: 4.0.1
|
||||
@@ -7965,11 +8176,27 @@ snapshots:
|
||||
|
||||
flatted@3.4.2: {}
|
||||
|
||||
follow-redirects@1.16.0(debug@4.4.3(supports-color@10.2.2)):
|
||||
optionalDependencies:
|
||||
debug: 4.4.3(supports-color@10.2.2)
|
||||
|
||||
foreground-child@3.3.1:
|
||||
dependencies:
|
||||
cross-spawn: 7.0.6
|
||||
signal-exit: 4.1.0
|
||||
|
||||
form-data@4.0.6:
|
||||
dependencies:
|
||||
asynckit: 0.4.0
|
||||
combined-stream: 1.0.8
|
||||
es-set-tostringtag: 2.1.0
|
||||
hasown: 2.0.4
|
||||
mime-types: 2.1.35
|
||||
|
||||
formdata-polyfill@4.0.10:
|
||||
dependencies:
|
||||
fetch-blob: 3.2.0
|
||||
|
||||
fraction.js@5.3.4: {}
|
||||
|
||||
fresh@0.5.2: {}
|
||||
@@ -8007,7 +8234,7 @@ snapshots:
|
||||
call-bind-apply-helpers: 1.0.2
|
||||
es-define-property: 1.0.1
|
||||
es-errors: 1.3.0
|
||||
es-object-atoms: 1.1.1
|
||||
es-object-atoms: 1.1.2
|
||||
function-bind: 1.1.2
|
||||
get-proto: 1.0.1
|
||||
gopd: 1.2.0
|
||||
@@ -8105,6 +8332,10 @@ snapshots:
|
||||
dependencies:
|
||||
function-bind: 1.1.2
|
||||
|
||||
hasown@2.0.4:
|
||||
dependencies:
|
||||
function-bind: 1.1.2
|
||||
|
||||
hookable@5.5.3: {}
|
||||
|
||||
hookable@6.1.1: {}
|
||||
@@ -8152,6 +8383,13 @@ snapshots:
|
||||
|
||||
http-shutdown@1.2.2: {}
|
||||
|
||||
https-proxy-agent@5.0.1(supports-color@10.2.2):
|
||||
dependencies:
|
||||
agent-base: 6.0.0(supports-color@10.2.2)
|
||||
debug: 4.4.3(supports-color@10.2.2)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
https-proxy-agent@7.0.6(supports-color@10.2.2):
|
||||
dependencies:
|
||||
agent-base: 7.1.4
|
||||
@@ -8298,6 +8536,10 @@ snapshots:
|
||||
|
||||
jiti@2.7.0: {}
|
||||
|
||||
js-pkce@1.5.1:
|
||||
dependencies:
|
||||
crypto-js: 4.2.0
|
||||
|
||||
js-tokens@4.0.0: {}
|
||||
|
||||
js-tokens@9.0.1: {}
|
||||
@@ -8331,6 +8573,32 @@ snapshots:
|
||||
optionalDependencies:
|
||||
graceful-fs: 4.2.11
|
||||
|
||||
jsonwebtoken@9.0.2:
|
||||
dependencies:
|
||||
jws: 3.2.3
|
||||
lodash.includes: 4.3.0
|
||||
lodash.isboolean: 3.0.3
|
||||
lodash.isinteger: 4.0.4
|
||||
lodash.isnumber: 3.0.3
|
||||
lodash.isplainobject: 4.0.6
|
||||
lodash.isstring: 4.0.1
|
||||
lodash.once: 4.1.1
|
||||
ms: 2.1.3
|
||||
semver: 7.7.4
|
||||
|
||||
jwa@1.4.2:
|
||||
dependencies:
|
||||
buffer-equal-constant-time: 1.0.1
|
||||
ecdsa-sig-formatter: 1.0.11
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
jws@3.2.3:
|
||||
dependencies:
|
||||
jwa: 1.4.2
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
jwt-decode@4.0.0: {}
|
||||
|
||||
keygrip@1.1.0:
|
||||
dependencies:
|
||||
tsscmp: 1.0.6
|
||||
@@ -8455,10 +8723,24 @@ snapshots:
|
||||
|
||||
lodash.defaults@4.2.0: {}
|
||||
|
||||
lodash.includes@4.3.0: {}
|
||||
|
||||
lodash.isarguments@3.1.0: {}
|
||||
|
||||
lodash.isboolean@3.0.3: {}
|
||||
|
||||
lodash.isinteger@4.0.4: {}
|
||||
|
||||
lodash.isnumber@3.0.3: {}
|
||||
|
||||
lodash.isplainobject@4.0.6: {}
|
||||
|
||||
lodash.isstring@4.0.1: {}
|
||||
|
||||
lodash.memoize@4.1.2: {}
|
||||
|
||||
lodash.once@4.1.1: {}
|
||||
|
||||
lodash.uniq@4.5.0: {}
|
||||
|
||||
lodash@4.18.1: {}
|
||||
@@ -8693,12 +8975,20 @@ snapshots:
|
||||
|
||||
node-addon-api@8.9.1: {}
|
||||
|
||||
node-domexception@1.0.0: {}
|
||||
|
||||
node-fetch-native@1.6.7: {}
|
||||
|
||||
node-fetch@2.7.0:
|
||||
dependencies:
|
||||
whatwg-url: 5.0.0
|
||||
|
||||
node-fetch@3.3.2:
|
||||
dependencies:
|
||||
data-uri-to-buffer: 4.0.0
|
||||
fetch-blob: 3.2.0
|
||||
formdata-polyfill: 4.0.10
|
||||
|
||||
node-forge@1.4.0: {}
|
||||
|
||||
node-gyp-build@4.8.4: {}
|
||||
@@ -9407,6 +9697,8 @@ snapshots:
|
||||
kleur: 3.0.3
|
||||
sisteransi: 1.0.5
|
||||
|
||||
proxy-from-env@2.1.0: {}
|
||||
|
||||
punycode@2.3.1: {}
|
||||
|
||||
quansync@0.2.11: {}
|
||||
@@ -10187,6 +10479,8 @@ snapshots:
|
||||
optionalDependencies:
|
||||
typescript: 6.0.3
|
||||
|
||||
web-streams-polyfill@3.0.3: {}
|
||||
|
||||
web-vitals@5.2.0: {}
|
||||
|
||||
webidl-conversions@3.0.1: {}
|
||||
|
||||
@@ -1,144 +0,0 @@
|
||||
/**
|
||||
* 生成 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`)
|
||||
@@ -7,7 +7,7 @@ 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')
|
||||
.prepare('SELECT id, provider, provider_id, username, email, role, created_at AS createdAt FROM users ORDER BY id DESC')
|
||||
.all()
|
||||
return { users }
|
||||
})
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
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) => {
|
||||
const me = requireAdmin(event)
|
||||
const id = Number(getRouterParam(event, 'id'))
|
||||
const body = await readBody(event)
|
||||
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' } })
|
||||
}
|
||||
if (body?.role !== undefined) {
|
||||
if (!['user', 'admin'].includes(body.role)) {
|
||||
throw createError({ statusCode: 400, message: '角色不合法', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
db.prepare('UPDATE users SET role = ? WHERE id = ?').run(body.role, id)
|
||||
}
|
||||
writeAudit(event, 'update', `user:${id}`)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -1,55 +0,0 @@
|
||||
import { readMultipartFormData, readBody, createError } from 'h3'
|
||||
import { requireUser, toPublicUser, type UserRow } from '../../utils/auth'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { saveImage, IMAGE_EXT_BY_TYPE, UploadError } from '../../utils/upload'
|
||||
|
||||
/**
|
||||
* 修改头像:
|
||||
* - multipart/form-data(字段 file)-> 上传图片到 OSS/本地,保存 URL
|
||||
* - JSON { clear: true } -> 清除头像(回退默认生成头像)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireUser(event)
|
||||
const db = getDb()
|
||||
const contentType = event.headers.get('content-type') || ''
|
||||
|
||||
if (contentType.includes('multipart/form-data')) {
|
||||
const parts = await readMultipartFormData(event)
|
||||
const file = parts?.find((p) => p.name === 'file' && p.data?.length)
|
||||
if (!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, 'avatars')
|
||||
} catch (err) {
|
||||
if (err instanceof UploadError) {
|
||||
throw createError({ statusCode: 400, message: err.message, data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
throw err
|
||||
}
|
||||
|
||||
db.prepare('UPDATE users SET avatar = ? WHERE id = ?').run(url, user.id)
|
||||
const updated = db
|
||||
.prepare('SELECT id, username, email, phone, avatar, role, created_at FROM users WHERE id = ?')
|
||||
.get(user.id) as UserRow
|
||||
return { ok: true, user: toPublicUser(updated) }
|
||||
}
|
||||
|
||||
// JSON:清除头像
|
||||
const body = await readBody(event).catch(() => ({}))
|
||||
if (body?.clear) {
|
||||
db.prepare('UPDATE users SET avatar = NULL WHERE id = ?').run(user.id)
|
||||
} else {
|
||||
throw createError({ statusCode: 400, message: '请上传图片或传入 clear', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
const updated = db
|
||||
.prepare('SELECT id, username, email, phone, avatar, role, created_at FROM users WHERE id = ?')
|
||||
.get(user.id) as UserRow
|
||||
return { ok: true, user: toPublicUser(updated) }
|
||||
})
|
||||
@@ -0,0 +1,36 @@
|
||||
import { getQuery, getCookie, deleteCookie, createError, sendRedirect } from 'h3'
|
||||
import { exchangeCodeForIdentity, getCasdoorState } from '../../utils/casdoor'
|
||||
import { upsertCasdoorUser, createSession, setSessionCookie } from '../../utils/auth'
|
||||
import { isCasdoorEnabled } from '../../utils/config'
|
||||
|
||||
/**
|
||||
* Casdoor OAuth 回调:
|
||||
* code -> 交换 access_token -> JWT 验签 -> upsert 本地用户 -> 建立会话 -> 回跳。
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
if (!isCasdoorEnabled()) {
|
||||
throw createError({ statusCode: 503, message: '未配置 Casdoor 统一认证', data: { code: 'CASDOOR_NOT_CONFIGURED' } })
|
||||
}
|
||||
|
||||
const query = getQuery(event)
|
||||
const code = String(query?.code ?? '')
|
||||
const state = String(query?.state ?? '')
|
||||
|
||||
// state 校验(SDK 以 appName 为 state;登录端点已写入同值 Cookie)
|
||||
const expectedState = getCasdoorState()
|
||||
if (expectedState && state && state !== expectedState) {
|
||||
throw createError({ statusCode: 400, message: 'state 校验失败', data: { code: 'OAUTH_STATE_MISMATCH' } })
|
||||
}
|
||||
|
||||
const identity = await exchangeCodeForIdentity(code)
|
||||
const user = upsertCasdoorUser(identity)
|
||||
const token = createSession(user.id)
|
||||
setSessionCookie(event, token)
|
||||
|
||||
const cookieNext = getCookie(event, 'an_oauth_next') || '/'
|
||||
const safeNext = cookieNext.startsWith('/') && !cookieNext.startsWith('//') ? cookieNext : '/'
|
||||
deleteCookie(event, 'an_oauth_state', { path: '/' })
|
||||
deleteCookie(event, 'an_oauth_next', { path: '/' })
|
||||
|
||||
return sendRedirect(event, safeNext)
|
||||
})
|
||||
@@ -0,0 +1,26 @@
|
||||
import { getQuery, setCookie, sendRedirect, createError } from 'h3'
|
||||
import { getCasdoorSignInUrl, getCasdoorState } from '../../utils/casdoor'
|
||||
import { isCasdoorEnabled } from '../../utils/config'
|
||||
|
||||
/**
|
||||
* 统一认证入口:跳转到 Casdoor 登录页。
|
||||
* - 记录期望 state 和回跳路径(短时效 Cookie,callback 消费)
|
||||
* - next 仅允许站内相对路径,防开放重定向
|
||||
*/
|
||||
export default defineEventHandler((event) => {
|
||||
if (!isCasdoorEnabled()) {
|
||||
throw createError({ statusCode: 503, message: '未配置 Casdoor 统一认证', data: { code: 'CASDOOR_NOT_CONFIGURED' } })
|
||||
}
|
||||
|
||||
const query = getQuery(event)
|
||||
const next = String(query?.next ?? '/')
|
||||
const safeNext = next.startsWith('/') && !next.startsWith('//') ? next : '/'
|
||||
|
||||
setCookie(event, 'an_oauth_state', getCasdoorState(), {
|
||||
path: '/', httpOnly: true, sameSite: 'lax', maxAge: 600,
|
||||
})
|
||||
setCookie(event, 'an_oauth_next', safeNext, {
|
||||
path: '/', httpOnly: true, sameSite: 'lax', maxAge: 600,
|
||||
})
|
||||
return sendRedirect(event, getCasdoorSignInUrl())
|
||||
})
|
||||
@@ -1,30 +0,0 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { verifyPassword, createSession, setSessionCookie, toPublicUser, type UserRow } from '../../utils/auth'
|
||||
|
||||
/**
|
||||
* 登录:账号(用户名或邮箱)+ 密码 -> 校验 -> 建立会话
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event)
|
||||
const account = String(body?.account ?? '').trim()
|
||||
const password = String(body?.password ?? '')
|
||||
|
||||
if (!account || !password) {
|
||||
throw createError({ statusCode: 400, message: '请输入账号与密码', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
const db = getDb()
|
||||
const user = db
|
||||
.prepare('SELECT * FROM users WHERE username = ? OR email = ?')
|
||||
.get(account, account.toLowerCase()) as (UserRow & { password_hash: string }) | undefined
|
||||
|
||||
if (!user || !(await verifyPassword(password, user.password_hash))) {
|
||||
throw createError({ statusCode: 401, message: '账号或密码错误', data: { code: 'INVALID_CREDENTIALS' } })
|
||||
}
|
||||
|
||||
const token = createSession(user.id)
|
||||
setSessionCookie(event, token)
|
||||
|
||||
return { user: toPublicUser(user) }
|
||||
})
|
||||
@@ -1,23 +0,0 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { requireUser, verifyPassword, clearSessionCookie } from '../../utils/auth'
|
||||
|
||||
/**
|
||||
* 自助删除账号(需验证当前密码;删除后登出,级联清理会话/评论/收藏)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireUser(event)
|
||||
const body = await readBody(event)
|
||||
const password = String(body?.password ?? '')
|
||||
|
||||
const row = getDb().prepare('SELECT password_hash FROM users WHERE id = ?').get(user.id) as
|
||||
| { password_hash: string }
|
||||
| undefined
|
||||
if (!row || !(await verifyPassword(password, row.password_hash))) {
|
||||
throw createError({ statusCode: 400, message: '密码不正确', data: { code: 'WRONG_PASSWORD' } })
|
||||
}
|
||||
|
||||
getDb().prepare('DELETE FROM users WHERE id = ?').run(user.id) // 外键级联:sessions/comments/favorites
|
||||
clearSessionCookie(event)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -1,10 +1,10 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { requireUser, toPublicUser, type UserRow } from '../../utils/auth'
|
||||
import { isValidUsername, isValidPhone } from '../../utils/validation'
|
||||
import { isValidUsername } from '../../utils/validation'
|
||||
|
||||
/**
|
||||
* 更新当前用户资料(用户名/手机号)
|
||||
* 更新当前用户资料(仅用户名;邮箱/头像/角色均由 Casdoor 管理)
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireUser(event)
|
||||
@@ -25,16 +25,8 @@ export default defineEventHandler(async (event) => {
|
||||
db.prepare('UPDATE users SET username = ? WHERE id = ?').run(username, user.id)
|
||||
}
|
||||
|
||||
if (body?.phone !== undefined) {
|
||||
const phone = String(body.phone).trim()
|
||||
if (!isValidPhone(phone)) {
|
||||
throw createError({ statusCode: 400, message: '手机号格式不正确', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
db.prepare('UPDATE users SET phone = ? WHERE id = ?').run(phone || null, user.id)
|
||||
}
|
||||
|
||||
const updated = db
|
||||
.prepare('SELECT id, username, email, phone, role, created_at FROM users WHERE id = ?')
|
||||
.prepare('SELECT id, provider, provider_id, username, email, avatar, role, created_at FROM users WHERE id = ?')
|
||||
.get(user.id) as UserRow
|
||||
|
||||
return { user: toPublicUser(updated) }
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { requireUser, verifyPassword, hashPassword } from '../../utils/auth'
|
||||
import { isValidPassword } from '../../utils/validation'
|
||||
|
||||
/**
|
||||
* 修改密码:校验当前密码 -> 新密码强度 -> 更新
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const user = requireUser(event)
|
||||
const body = await readBody(event)
|
||||
const currentPassword = String(body?.currentPassword ?? '')
|
||||
const newPassword = String(body?.newPassword ?? '')
|
||||
|
||||
const row = getDb().prepare('SELECT password_hash FROM users WHERE id = ?').get(user.id) as
|
||||
| { password_hash: string }
|
||||
| undefined
|
||||
if (!row || !(await verifyPassword(currentPassword, row.password_hash))) {
|
||||
throw createError({ statusCode: 400, message: '当前密码不正确', data: { code: 'WRONG_PASSWORD' } })
|
||||
}
|
||||
if (!isValidPassword(newPassword)) {
|
||||
throw createError({ statusCode: 400, message: '新密码至少需要 8 位', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
const passwordHash = await hashPassword(newPassword)
|
||||
getDb().prepare('UPDATE users SET password_hash = ? WHERE id = ?').run(passwordHash, user.id)
|
||||
return { ok: true }
|
||||
})
|
||||
@@ -1,57 +0,0 @@
|
||||
import { readBody, createError } from 'h3'
|
||||
import { getDb } from '../../utils/db'
|
||||
import { hashPassword, createSession, setSessionCookie, toPublicUser, type UserRow } from '../../utils/auth'
|
||||
import { isAdminEmail } from '../../utils/config'
|
||||
import { isValidUsername, isValidEmail, isValidPassword, isValidPhone } from '../../utils/validation'
|
||||
|
||||
/**
|
||||
* 注册:校验 -> scrypt 哈希 -> 落库 -> 建立会话
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event)
|
||||
const username = String(body?.username ?? '').trim()
|
||||
const email = String(body?.email ?? '').trim().toLowerCase()
|
||||
const phone = String(body?.phone ?? '').trim()
|
||||
const password = String(body?.password ?? '')
|
||||
|
||||
if (!isValidUsername(username)) {
|
||||
throw createError({ statusCode: 400, message: '用户名需为 2-20 位字符', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
if (!isValidEmail(email)) {
|
||||
throw createError({ statusCode: 400, message: '邮箱格式不正确', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
if (!isValidPassword(password)) {
|
||||
throw createError({ statusCode: 400, message: '密码至少需要 8 位', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
if (phone && !isValidPhone(phone)) {
|
||||
throw createError({ statusCode: 400, message: '手机号格式不正确', data: { code: 'VALIDATION_ERROR' } })
|
||||
}
|
||||
|
||||
const db = getDb()
|
||||
const existing = db
|
||||
.prepare('SELECT username, email FROM users WHERE username = ? OR email = ?')
|
||||
.get(username, email) as { username: string; email: string } | undefined
|
||||
|
||||
if (existing) {
|
||||
if (existing.username === username) {
|
||||
throw createError({ statusCode: 400, message: '用户名已被使用', data: { code: 'USERNAME_TAKEN' } })
|
||||
}
|
||||
throw createError({ statusCode: 400, message: '该邮箱已被注册', data: { code: 'EMAIL_TAKEN' } })
|
||||
}
|
||||
|
||||
const passwordHash = await hashPassword(password)
|
||||
// 管理员邮箱白名单命中者自动授予 admin 角色(后续可后台切换)
|
||||
const role = isAdminEmail(email) ? 'admin' : 'user'
|
||||
const info = db
|
||||
.prepare('INSERT INTO users (username, email, phone, password_hash, role) VALUES (?, ?, ?, ?, ?)')
|
||||
.run(username, email, phone || null, passwordHash, role)
|
||||
|
||||
const user = db
|
||||
.prepare('SELECT id, username, email, phone, role, created_at FROM users WHERE id = ?')
|
||||
.get(info.lastInsertRowid) as UserRow
|
||||
|
||||
const token = createSession(user.id)
|
||||
setSessionCookie(event, token)
|
||||
|
||||
return { user: toPublicUser(user) }
|
||||
})
|
||||
+47
-9
@@ -2,15 +2,14 @@ import { randomBytes } from 'node:crypto'
|
||||
import { createError, getCookie, setCookie, deleteCookie } from 'h3'
|
||||
import type { H3Event } from 'h3'
|
||||
import { getDb } from './db'
|
||||
import { hashPassword, verifyPassword } from './password'
|
||||
|
||||
export { hashPassword, verifyPassword }
|
||||
import type { CasdoorIdentity } from './casdoor'
|
||||
|
||||
export interface UserRow {
|
||||
id: number
|
||||
provider: string
|
||||
provider_id: string
|
||||
username: string
|
||||
email: string
|
||||
phone: string | null
|
||||
avatar: string | null
|
||||
role: 'user' | 'admin'
|
||||
created_at: string
|
||||
@@ -34,12 +33,12 @@ export function destroySession(token: string): void {
|
||||
getDb().prepare('DELETE FROM sessions WHERE token = ?').run(token)
|
||||
}
|
||||
|
||||
/** 根据 token 返回有效用户(过期会话返回 null);role 以数据库存储为准(后台可切换) */
|
||||
/** 根据 token 返回有效用户(过期会话返回 null);role 为登录时由 Casdoor claim 快照 */
|
||||
export function getSessionUser(token: string | null): UserRow | null {
|
||||
if (!token) return null
|
||||
const row = getDb()
|
||||
.prepare(
|
||||
`SELECT u.id, u.username, u.email, u.phone, u.avatar, u.role, u.created_at
|
||||
`SELECT u.id, u.provider, u.provider_id, u.username, u.email, u.avatar, u.role, u.created_at
|
||||
FROM sessions s
|
||||
JOIN users u ON u.id = s.user_id
|
||||
WHERE s.token = ? AND s.expires_at > datetime('now')`,
|
||||
@@ -89,21 +88,60 @@ export function clearSessionCookie(event: H3Event): void {
|
||||
deleteCookie(event, SESSION_COOKIE, { path: '/' })
|
||||
}
|
||||
|
||||
/** 返回给前端的脱敏用户对象(含 admin 角色,供个人中心/后台展示) */
|
||||
// ---------- Casdoor 用户映射 ----------
|
||||
|
||||
/**
|
||||
* 按 Casdoor 唯一标识(provider + sub)upsert 本地用户。
|
||||
* - 已存在:刷新资料(姓名/邮箱/头像)与角色快照(角色只从 Casdoor claim 派生)
|
||||
* - 不存在:首次登录自动建号
|
||||
*/
|
||||
export function upsertCasdoorUser(identity: CasdoorIdentity): UserRow {
|
||||
const db = getDb()
|
||||
const role: 'user' | 'admin' = identity.isAdmin ? 'admin' : 'user'
|
||||
|
||||
const existing = db
|
||||
.prepare('SELECT id FROM users WHERE provider = ? AND provider_id = ?')
|
||||
.get(identity.provider, identity.providerId) as { id: number } | undefined
|
||||
|
||||
if (existing) {
|
||||
db.prepare('UPDATE users SET username = ?, email = ?, avatar = ?, role = ? WHERE id = ?').run(
|
||||
identity.username,
|
||||
identity.email,
|
||||
identity.avatar || null,
|
||||
role,
|
||||
existing.id,
|
||||
)
|
||||
} else {
|
||||
db.prepare('INSERT INTO users (provider, provider_id, username, email, avatar, role) VALUES (?, ?, ?, ?, ?, ?)').run(
|
||||
identity.provider,
|
||||
identity.providerId,
|
||||
identity.username,
|
||||
identity.email,
|
||||
identity.avatar || null,
|
||||
role,
|
||||
)
|
||||
}
|
||||
|
||||
return db
|
||||
.prepare('SELECT id, provider, provider_id, username, email, avatar, role, created_at FROM users WHERE provider = ? AND provider_id = ?')
|
||||
.get(identity.provider, identity.providerId) as UserRow
|
||||
}
|
||||
|
||||
/** 返回给前端的脱敏用户对象 */
|
||||
export function toPublicUser(user: UserRow): {
|
||||
id: number
|
||||
providerId: string
|
||||
username: string
|
||||
email: string
|
||||
phone: string | null
|
||||
avatar: string | null
|
||||
role: 'user' | 'admin'
|
||||
createdAt: string
|
||||
} {
|
||||
return {
|
||||
id: user.id,
|
||||
providerId: user.provider_id,
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
phone: user.phone,
|
||||
avatar: user.avatar,
|
||||
role: user.role,
|
||||
createdAt: user.created_at,
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import { SDK } from 'casdoor-nodejs-sdk'
|
||||
import { getConfig } from './config'
|
||||
|
||||
/**
|
||||
* Casdoor 统一认证封装(服务端)。
|
||||
*
|
||||
* - 登录 URL、code->token 交换、JWT 验签全部走官方 casdoor-nodejs-sdk
|
||||
* - 客户端 secret / 证书公钥只存在于服务端环境变量,绝不进入浏览器
|
||||
* - 登录成功后再通过 get-account 补齐邮箱/头像/角色等字段(拿不到也不阻塞登录)
|
||||
*/
|
||||
let _sdk: SDK | null = null
|
||||
let _sdkKey = ''
|
||||
|
||||
function getSDK(): SDK {
|
||||
const { casdoor } = getConfig()
|
||||
const key = [casdoor.serverUrl, casdoor.clientId, casdoor.clientSecret, casdoor.orgName, casdoor.appName, casdoor.certificate].join('|')
|
||||
if (!_sdk || _sdkKey !== key) {
|
||||
_sdk = new SDK({
|
||||
endpoint: casdoor.serverUrl,
|
||||
clientId: casdoor.clientId,
|
||||
clientSecret: casdoor.clientSecret,
|
||||
certificate: casdoor.certificate,
|
||||
orgName: casdoor.orgName,
|
||||
appName: casdoor.appName || undefined,
|
||||
})
|
||||
_sdkKey = key
|
||||
}
|
||||
return _sdk
|
||||
}
|
||||
|
||||
/** 构造 Casdoor 登录授权地址(redirect_uri = 本站回调) */
|
||||
export function getCasdoorSignInUrl(): string {
|
||||
const { casdoor } = getConfig()
|
||||
return getSDK().getSignInUrl(casdoor.redirectUri)
|
||||
}
|
||||
|
||||
/** 构造 Casdoor 注册页地址(在 Casdoor 侧完成注册) */
|
||||
export function getCasdoorSignUpUrl(): string {
|
||||
const { casdoor } = getConfig()
|
||||
return `${casdoor.serverUrl}/signup/${casdoor.appName}`
|
||||
}
|
||||
|
||||
/** 单点登出地址(访问后跳回 redirectUri;未配置则返回空串) */
|
||||
export function getCasdoorLogoutUrl(): string {
|
||||
const { casdoor } = getConfig()
|
||||
if (!casdoor.serverUrl || !casdoor.clientId) return ''
|
||||
return `${casdoor.serverUrl}/logout?client_id=${casdoor.clientId}&redirect_uri=${encodeURIComponent(casdoor.redirectUri)}`
|
||||
}
|
||||
|
||||
/** 登录回调校验的期望 state(casdoor SDK 以 appName 作为 state 返回) */
|
||||
export function getCasdoorState(): string {
|
||||
return getConfig().casdoor.appName
|
||||
}
|
||||
|
||||
export interface CasdoorIdentity {
|
||||
/** 唯一用户标识(Casdoor 用户 UUID,即 JWT 的 sub) */
|
||||
providerId: string
|
||||
provider: string
|
||||
username: string
|
||||
email: string
|
||||
avatar: string
|
||||
isAdmin: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* 交换授权码并验签,返回可落库的身份信息。
|
||||
* @throws 交换失败 / 验签失败 / 缺少 sub
|
||||
*/
|
||||
export async function exchangeCodeForIdentity(code: string): Promise<CasdoorIdentity> {
|
||||
if (!code) {
|
||||
throw new Error('缺少授权码')
|
||||
}
|
||||
const { access_token } = await getSDK().getAuthToken(code)
|
||||
if (!access_token) {
|
||||
throw new Error('Casdoor 未返回 access_token')
|
||||
}
|
||||
|
||||
const claims = getSDK().parseJwtToken(access_token)
|
||||
const account = await getAccountProfile(access_token).catch(() => null)
|
||||
|
||||
const providerId = String(account?.sub || (claims as any).sub || (claims as any).id || '')
|
||||
if (!providerId) {
|
||||
throw new Error('Casdoor token 缺少用户标识(sub)')
|
||||
}
|
||||
|
||||
const username =
|
||||
String(account?.name || (claims as any).name || (claims as any).preferred_username || 'user').trim() ||
|
||||
'user'
|
||||
const email = String(account?.email || (claims as any).email || '').trim().toLowerCase()
|
||||
const avatar = String(account?.avatar || (claims as any).avatar || (claims as any).picture || '').trim()
|
||||
|
||||
return {
|
||||
providerId,
|
||||
provider: 'casdoor',
|
||||
username,
|
||||
email,
|
||||
avatar,
|
||||
isAdmin: isAdminClaim(account) || isAdminClaim(claims),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理员判定:
|
||||
* - token 字段 `IsAdmin` / `isAdmin` 为 true
|
||||
* - roles(对象数组 {name} 或字符串数组)命中 NUXT_CASDOOR_ADMIN_ROLES
|
||||
*/
|
||||
export function isAdminClaim(claims: Record<string, unknown> | undefined | null): boolean {
|
||||
if (!claims) return false
|
||||
if ((claims as any).isAdmin === true || (claims as any).IsAdmin === true) return true
|
||||
|
||||
const { casdoor } = getConfig()
|
||||
const roles = (claims as any).roles
|
||||
if (!Array.isArray(roles) || roles.length === 0) return false
|
||||
const names = roles
|
||||
.map((r: any) => (typeof r === 'string' ? r : r?.name))
|
||||
.filter(Boolean)
|
||||
.map((n: string) => n.toLowerCase())
|
||||
return names.some((n: string) => casdoor.adminRoles.includes(n))
|
||||
}
|
||||
|
||||
/** 通过 get-account 接口补齐完整账号信息(含邮箱/头像/角色);失败不阻塞登录 */
|
||||
async function getAccountProfile(accessToken: string): Promise<Record<string, unknown> | null> {
|
||||
const { casdoor } = getConfig()
|
||||
const url = `${casdoor.serverUrl}/api/get-account?access_token=${encodeURIComponent(accessToken)}`
|
||||
const res = await fetch(url)
|
||||
if (!res.ok) return null
|
||||
const body = (await res.json()) as { status?: string; data?: Record<string, unknown> }
|
||||
if (body?.status !== 'ok') return null
|
||||
return body.data ?? null
|
||||
}
|
||||
+66
-12
@@ -26,9 +26,22 @@ export interface AppConfig {
|
||||
}
|
||||
contactTo: string
|
||||
adminEmails: string[]
|
||||
/** 首次初始化时预置 admin 账号的密码(NUXT_ADMIN_INITIAL_PASSWORD),未设则不预置 */
|
||||
adminInitialPassword: string
|
||||
/** OSS 文件存储(RustFS / S3 v4 兼容) */
|
||||
/** Casdoor 统一认证 */
|
||||
casdoor: {
|
||||
serverUrl: string
|
||||
clientId: string
|
||||
clientSecret: string
|
||||
orgName: string
|
||||
appName: string
|
||||
/** 应用证书公钥 PEM(用于验证 JWT 签名),由 certB64 解码得到 */
|
||||
certificate: string
|
||||
/** 命中任一角色名即管理员 */
|
||||
adminRoles: string[]
|
||||
callbackPath: string
|
||||
/** 完整回调地址(siteUrl + callbackPath),用于 OAuth redirect_uri */
|
||||
redirectUri: string
|
||||
}
|
||||
/** OSS 服务(RustFS / S3 v4 兼容) */
|
||||
oss: {
|
||||
endpoint: string
|
||||
accessKey: string
|
||||
@@ -42,6 +55,15 @@ export interface AppConfig {
|
||||
|
||||
export function getConfig(): AppConfig {
|
||||
const c = useRuntimeConfig()
|
||||
const cfg = _buildConfig(c)
|
||||
// 回调地址依赖 siteUrl,在对象组装完成后补算
|
||||
const siteUrl = String((c.public as { siteUrl?: string })?.siteUrl || '').replace(/\/$/, '')
|
||||
cfg.siteUrl = siteUrl
|
||||
cfg.casdoor.redirectUri = `${siteUrl}${cfg.casdoor.callbackPath}`
|
||||
return cfg
|
||||
}
|
||||
|
||||
function _buildConfig(c: any): AppConfig {
|
||||
return {
|
||||
dbPath: (c.dbPath as string) || '.data/arcticnewone.db',
|
||||
sessionSecret: (c.sessionSecret as string) || '',
|
||||
@@ -57,19 +79,51 @@ export function getConfig(): AppConfig {
|
||||
.split(',')
|
||||
.map((s) => s.trim().toLowerCase())
|
||||
.filter(Boolean),
|
||||
adminInitialPassword: String((c as any).adminInitialPassword || ''),
|
||||
oss: {
|
||||
endpoint: String((c as any).ossEndpoint || '').replace(/^https?:\/\//, '').replace(/\/$/, ''),
|
||||
accessKey: String((c as any).ossAccessKey || ''),
|
||||
secretKey: String((c as any).ossSecretKey || ''),
|
||||
bucket: String((c as any).ossBucket || ''),
|
||||
region: String((c as any).ossRegion || 'us-east-1'),
|
||||
publicBase: String((c as any).ossPublicBase || '').replace(/\/$/, ''),
|
||||
casdoor: {
|
||||
serverUrl: String((c.casdoorServerUrl as string) || '').replace(/\/$/, ''),
|
||||
clientId: String((c.casdoorClientId as string) || ''),
|
||||
clientSecret: String((c.casdoorClientSecret as string) || ''),
|
||||
orgName: String((c.casdoorOrgName as string) || ''),
|
||||
appName: String((c.casdoorAppName as string) || ''),
|
||||
certificate: decodeCert(String((c.casdoorCertB64 as string) || '')),
|
||||
adminRoles: String((c.casdoorAdminRoles as string) || 'admin')
|
||||
.split(',')
|
||||
.map((s) => s.trim().toLowerCase())
|
||||
.filter(Boolean),
|
||||
callbackPath: String((c.casdoorCallbackPath as string) || '/api/auth/callback'),
|
||||
redirectUri: '',
|
||||
},
|
||||
siteUrl: String((c.public as { siteUrl?: string })?.siteUrl || '').replace(/\/$/, ''),
|
||||
oss: {
|
||||
endpoint: String((c.ossEndpoint as string) || '').replace(/^https?:\/\//, '').replace(/\/$/, ''),
|
||||
accessKey: String((c.ossAccessKey as string) || ''),
|
||||
secretKey: String((c.ossSecretKey as string) || ''),
|
||||
bucket: String((c.ossBucket as string) || ''),
|
||||
region: String((c.ossRegion as string) || 'us-east-1'),
|
||||
publicBase: String((c.ossPublicBase as string) || '').replace(/\/$/, ''),
|
||||
},
|
||||
siteUrl: '',
|
||||
}
|
||||
}
|
||||
|
||||
/** 将证书 PEM 以 base64(或原文)传入,统一还原为 PEM 字符串 */
|
||||
function decodeCert(input: string): string {
|
||||
const v = (input || '').trim()
|
||||
if (!v) return ''
|
||||
if (v.includes('BEGIN CERTIFICATE')) return v
|
||||
try {
|
||||
const pem = Buffer.from(v, 'base64').toString('utf-8')
|
||||
return pem.includes('BEGIN CERTIFICATE') ? pem : v
|
||||
} catch {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
/** Casdoor 配置已就绪(有了 clientId + 服务端地址即可启用统一登录) */
|
||||
export function isCasdoorEnabled(): boolean {
|
||||
const { casdoor } = getConfig()
|
||||
return Boolean(casdoor.serverUrl && casdoor.clientId)
|
||||
}
|
||||
|
||||
/** 判断某邮箱是否在管理员白名单中 */
|
||||
export function isAdminEmail(email: string): boolean {
|
||||
return getConfig().adminEmails.includes(email.toLowerCase())
|
||||
|
||||
+28
-25
@@ -1,7 +1,6 @@
|
||||
import Database from 'better-sqlite3'
|
||||
import { mkdirSync } from 'node:fs'
|
||||
import { dirname } from 'node:path'
|
||||
import { scryptSync, randomBytes } from 'node:crypto'
|
||||
import { getConfig } from './config'
|
||||
import { articlesSeed, worksSeed } from './seed'
|
||||
|
||||
@@ -43,18 +42,34 @@ export function getDb(): Database.Database {
|
||||
}
|
||||
|
||||
function migrate(db: Database.Database): void {
|
||||
// ---- 老库升级:内置密码认证已废弃,改由 Casdoor 统一认证 ----
|
||||
// 旧 users 表含 password_hash(自研密码认证)。检测到即清空用户相关数据并重建:
|
||||
// 账号唯一标识改为 provider + provider_id(Casdoor 的 sub),邮箱仅作资料展示不再唯一。
|
||||
const userCols = db.prepare('PRAGMA table_info(users)').all() as Array<{ name: string }>
|
||||
if (userCols.some((c) => c.name === 'password_hash')) {
|
||||
db.exec(`
|
||||
DROP TABLE IF EXISTS comments;
|
||||
DROP TABLE IF EXISTS favorites;
|
||||
DROP TABLE IF EXISTS sessions;
|
||||
DROP TABLE IF EXISTS users;
|
||||
`)
|
||||
console.log('[db] 检测到旧版内置认证用户表,已重置用户数据(会话/收藏/评论一并清空)')
|
||||
}
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
email TEXT NOT NULL UNIQUE,
|
||||
phone TEXT,
|
||||
avatar TEXT,
|
||||
password_hash TEXT NOT NULL,
|
||||
role TEXT NOT NULL DEFAULT 'user',
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
provider TEXT NOT NULL DEFAULT 'casdoor',
|
||||
provider_id TEXT NOT NULL UNIQUE,
|
||||
username TEXT NOT NULL,
|
||||
email TEXT NOT NULL,
|
||||
avatar TEXT,
|
||||
role TEXT NOT NULL DEFAULT 'user',
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_users_provider ON users(provider_id);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
token TEXT PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
@@ -179,7 +194,6 @@ function migrate(db: Database.Database): void {
|
||||
// 老库迁移:为已存在的表补充新增列(SQLite 不支持 ADD COLUMN IF NOT EXISTS)
|
||||
ensureColumn(db, 'contacts', 'read', 'INTEGER NOT NULL DEFAULT 0')
|
||||
ensureColumn(db, 'subscribers', 'token', 'TEXT')
|
||||
ensureColumn(db, 'users', 'avatar', 'TEXT')
|
||||
}
|
||||
|
||||
/** 若表中缺少某列则补上(用于老库升级) */
|
||||
@@ -191,11 +205,10 @@ function ensureColumn(db: Database.Database, table: string, column: string, ddl:
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化种子数据:内容表为空时灌入 articles/works 种子;
|
||||
* users 为空且配置了 adminInitialPassword 时创建预置管理员。
|
||||
* 初始化种子数据:内容表为空时灌入 articles/works 种子。
|
||||
* 用户账号由 Casdoor 统一认证管理,首次登录时自动建号。
|
||||
*/
|
||||
function seedIfEmpty(db: Database.Database): void {
|
||||
const { adminInitialPassword, adminEmails } = getConfig()
|
||||
|
||||
const articleCount = (db.prepare('SELECT COUNT(*) AS c FROM articles').get() as { c: number }).c
|
||||
if (articleCount === 0) {
|
||||
@@ -233,18 +246,8 @@ function seedIfEmpty(db: Database.Database): void {
|
||||
tx()
|
||||
}
|
||||
|
||||
// 预置管理员(仅当首次初始化且配置了初始密码)
|
||||
const userCount = (db.prepare('SELECT COUNT(*) AS c FROM users').get() as { c: number }).c
|
||||
if (userCount === 0 && adminInitialPassword && adminEmails.length > 0) {
|
||||
const email = adminEmails[0]
|
||||
const username = 'admin'
|
||||
// 与 auth.ts 相同的 salt:hash 存储格式(scrypt)
|
||||
const salt = randomBytes(16).toString('hex')
|
||||
const hash = scryptSync(adminInitialPassword, salt, 64).toString('hex')
|
||||
db.prepare('INSERT INTO users (username, email, password_hash, role) VALUES (?, ?, ?, ?)')
|
||||
.run(username, email, `${salt}:${hash}`, 'admin')
|
||||
console.log('[seed] 已创建预置管理员账号: admin(邮箱 ' + email + ')')
|
||||
}
|
||||
// 注:用户账号已完全交由 Casdoor 统一认证管理,此处不再预置本地 admin。
|
||||
// 用户角色(role)在每次 Casdoor 登录时由 claim 快照。
|
||||
}
|
||||
|
||||
/** 供服务端任意位置安全关闭数据库(测试/热更新用) */
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { randomBytes, scrypt, timingSafeEqual } from 'node:crypto'
|
||||
import { promisify } from 'node:util'
|
||||
|
||||
/**
|
||||
* 密码哈希/校验(scrypt,盐 + 哈希以冒号分隔存储)。
|
||||
* 独立于 Nuxt/Nitro 依赖,便于单元测试。
|
||||
*/
|
||||
const scryptAsync = promisify(scrypt) as (
|
||||
password: string,
|
||||
salt: string,
|
||||
keylen: number,
|
||||
) => Promise<Buffer>
|
||||
|
||||
export async function hashPassword(password: string): Promise<string> {
|
||||
const salt = randomBytes(16).toString('hex')
|
||||
const key = await scryptAsync(password, salt, 64)
|
||||
return `${salt}:${key.toString('hex')}`
|
||||
}
|
||||
|
||||
export async function verifyPassword(password: string, stored: string): Promise<boolean> {
|
||||
const [salt, hash] = stored.split(':')
|
||||
if (!salt || !hash) return false
|
||||
const key = await scryptAsync(password, salt, 64)
|
||||
const expected = Buffer.from(hash, 'hex')
|
||||
return key.length === expected.length && timingSafeEqual(key, expected)
|
||||
}
|
||||
+26
-56
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* 种子数据(由 scripts/generate-seed.mjs 生成,勿手改)。
|
||||
* 站点初始内容:6 篇动态 + 6 个作品(中英双语)。
|
||||
* 种子数据(站点初始内容,手维护)。
|
||||
* 6 篇动态 + 6 个作品(中英双语);图片留空,由后台 CMS 上传配置。
|
||||
* DB 初始化(migrate)时若对应表为空则自动灌入。
|
||||
*/
|
||||
import type { ArticleBlock } from './db'
|
||||
@@ -91,7 +91,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"contentEn": [
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "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."
|
||||
"text": "In 2026, the design industry is undergoing a profound transformation. From the return of minimalism to the rise of bold typography, from the proliferation of 3D elements to the maturity of AI-assisted design, these trends are redefining the boundaries of digital experiences."
|
||||
},
|
||||
{
|
||||
"type": "heading",
|
||||
@@ -99,7 +99,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "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."
|
||||
"text": "In an age of information overload, users increasingly crave 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."
|
||||
},
|
||||
{
|
||||
"type": "quote",
|
||||
@@ -122,7 +122,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"text": "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."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/1/800/500",
|
||||
"image": null,
|
||||
"date": "2026-05-28",
|
||||
"readTime": 5,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -200,10 +200,10 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "After launch, user停留 time increased by 60%, bounce rate decreased by 35%, and conversion rate improved by 45%."
|
||||
"text": "After launch, user engagement time increased by 60%, bounce rate decreased by 35%, and conversion rate improved by 45%."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/201/800/500",
|
||||
"image": null,
|
||||
"date": "2026-05-15",
|
||||
"readTime": 3,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -284,7 +284,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"text": "We plan to complete 50+ projects and serve 30+ new clients in the coming year while continuing to explore new possibilities."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/164/800/500",
|
||||
"image": null,
|
||||
"date": "2026-05-10",
|
||||
"readTime": 2,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -365,7 +365,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"text": "AI tools help us analyze user feedback more efficiently. Sentiment analysis, topic clustering, and trend prediction help extract valuable insights from massive data."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/180/800/500",
|
||||
"image": null,
|
||||
"date": "2026-04-28",
|
||||
"readTime": 7,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -415,7 +415,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"contentEn": [
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "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."
|
||||
"text": "Bold Moves is an interactive website showcasing innovative architectural designs. This article provides an in-depth look at the design approach, technical implementation, and final results."
|
||||
},
|
||||
{
|
||||
"type": "heading",
|
||||
@@ -443,10 +443,10 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "The project received widespread acclaim and won multiple design awards. Average user停留 time exceeded 5 minutes, well above industry average."
|
||||
"text": "The project received widespread acclaim and won multiple design awards. Average user engagement time exceeded 5 minutes, well above industry average."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/119/800/500",
|
||||
"image": null,
|
||||
"date": "2026-04-20",
|
||||
"readTime": 6,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -504,7 +504,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
},
|
||||
{
|
||||
"type": "paragraph",
|
||||
"text": "We've引入 the latest design collaboration platform supporting real-time multi-person editing, version management, and design system integration."
|
||||
"text": "We've introduced the latest design collaboration platform supporting real-time multi-person editing, version management, and design system integration."
|
||||
},
|
||||
{
|
||||
"type": "quote",
|
||||
@@ -527,7 +527,7 @@ export const articlesSeed: ArticleSeed[] = [
|
||||
"text": "We upgraded our project management platform with new Kanban views, time tracking, and resource allocation features for better project oversight."
|
||||
}
|
||||
],
|
||||
"image": "https://picsum.photos/id/326/800/500",
|
||||
"image": null,
|
||||
"date": "2026-04-12",
|
||||
"readTime": 4,
|
||||
"author": "ArcticNewOne",
|
||||
@@ -559,13 +559,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"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"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -592,13 +587,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"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"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -625,13 +615,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"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"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -658,13 +643,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"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"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -691,13 +671,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"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"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
},
|
||||
@@ -724,13 +699,8 @@ export const worksSeed: WorkSeed[] = [
|
||||
"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"
|
||||
],
|
||||
"image": null,
|
||||
"gallery": [],
|
||||
"url": null,
|
||||
"published": 1
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
|
||||
/**
|
||||
* Casdoor 认证逻辑单测(纯函数,不依赖外部服务)。
|
||||
* 覆盖:
|
||||
* - isAdminClaim:IsAdmin / isAdmin 字段与 roles 名单判定
|
||||
* - getCasdoorSignUpUrl / getCasdoorLogoutUrl:登录/注册/登出地址构造
|
||||
* - config.decodeCert:证书 base64 还原
|
||||
*/
|
||||
|
||||
vi.mock('../server/utils/config', () => ({
|
||||
getConfig: () => ({
|
||||
casdoor: {
|
||||
serverUrl: 'https://sys.virtheart.com',
|
||||
clientId: 'a0ba9570e0bcfbeb9f67',
|
||||
clientSecret: 'secret',
|
||||
orgName: 'virtheart',
|
||||
appName: 'virtheat-personal',
|
||||
certificate: 'FAKE_CERT',
|
||||
adminRoles: ['admin'],
|
||||
callbackPath: '/api/auth/callback',
|
||||
redirectUri: 'https://personal.virtheart.com/api/auth/callback',
|
||||
},
|
||||
}),
|
||||
isCasdoorEnabled: () => true,
|
||||
}))
|
||||
|
||||
import { isAdminClaim } from '../server/utils/casdoor'
|
||||
import { getConfig } from '../server/utils/config'
|
||||
|
||||
describe('isAdminClaim', () => {
|
||||
it('returns false for empty / null claims', () => {
|
||||
expect(isAdminClaim(null)).toBe(false)
|
||||
expect(isAdminClaim(undefined)).toBe(false)
|
||||
expect(isAdminClaim({})).toBe(false)
|
||||
})
|
||||
|
||||
it('honors isAdmin / IsAdmin boolean fields', () => {
|
||||
expect(isAdminClaim({ isAdmin: true })).toBe(true)
|
||||
expect(isAdminClaim({ IsAdmin: true })).toBe(true)
|
||||
expect(isAdminClaim({ isAdmin: false })).toBe(false)
|
||||
})
|
||||
|
||||
it('honors roles array (string form)', () => {
|
||||
expect(isAdminClaim({ roles: ['admin'] })).toBe(true)
|
||||
expect(isAdminClaim({ roles: ['user', 'editor'] })).toBe(false)
|
||||
})
|
||||
|
||||
it('honors roles array (object form with name)', () => {
|
||||
expect(isAdminClaim({ roles: [{ name: 'admin' }] })).toBe(true)
|
||||
expect(isAdminClaim({ roles: [{ name: 'user' }] })).toBe(false)
|
||||
})
|
||||
|
||||
it('is case-insensitive on role names', () => {
|
||||
expect(isAdminClaim({ roles: ['Admin'] })).toBe(true)
|
||||
})
|
||||
|
||||
it('falls back to configured admin roles', () => {
|
||||
const cfg = getConfig()
|
||||
expect(cfg.casdoor.adminRoles).toContain('admin')
|
||||
})
|
||||
})
|
||||
|
||||
describe('casdoor URLs', () => {
|
||||
it('builds signup url from config', async () => {
|
||||
const { getCasdoorSignUpUrl } = await import('../server/utils/casdoor')
|
||||
expect(getCasdoorSignUpUrl()).toBe('https://sys.virtheart.com/signup/virtheat-personal')
|
||||
})
|
||||
|
||||
it('builds logout url with client_id and redirect_uri', async () => {
|
||||
const { getCasdoorLogoutUrl } = await import('../server/utils/casdoor')
|
||||
const url = getCasdoorLogoutUrl()
|
||||
expect(url).toContain('https://sys.virtheart.com/logout')
|
||||
expect(url).toContain('client_id=a0ba9570e0bcfbeb9f67')
|
||||
expect(decodeURIComponent(url)).toContain('https://personal.virtheart.com/api/auth/callback')
|
||||
})
|
||||
})
|
||||
@@ -1,26 +0,0 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { hashPassword, verifyPassword } from '../server/utils/password'
|
||||
|
||||
describe('password hashing (scrypt)', () => {
|
||||
it('hashes and verifies the correct password', async () => {
|
||||
const hash = await hashPassword('secret123')
|
||||
expect(hash).toContain(':')
|
||||
expect(await verifyPassword('secret123', hash)).toBe(true)
|
||||
})
|
||||
|
||||
it('rejects a wrong password', async () => {
|
||||
const hash = await hashPassword('secret123')
|
||||
expect(await verifyPassword('wrong-pass', hash)).toBe(false)
|
||||
})
|
||||
|
||||
it('rejects a malformed stored hash', async () => {
|
||||
expect(await verifyPassword('secret123', 'no-separator')).toBe(false)
|
||||
expect(await verifyPassword('secret123', '')).toBe(false)
|
||||
})
|
||||
|
||||
it('produces a unique salt per call', async () => {
|
||||
const a = await hashPassword('secret123')
|
||||
const b = await hashPassword('secret123')
|
||||
expect(a).not.toBe(b)
|
||||
})
|
||||
})
|
||||
+5
-2
@@ -23,7 +23,8 @@ describe('seed data integrity', () => {
|
||||
expect(a.excerptEn).toBeTruthy()
|
||||
expect(a.contentZh.length).toBeGreaterThan(0)
|
||||
expect(a.contentEn.length).toBeGreaterThan(0)
|
||||
expect(a.image).toBeTruthy()
|
||||
// 图片留空由后台上传配置,种子不携带演示图
|
||||
expect(a.image).toBeNull()
|
||||
expect(a.published).toBe(1)
|
||||
}
|
||||
})
|
||||
@@ -37,8 +38,10 @@ describe('seed data integrity', () => {
|
||||
expect(w.descriptionEn).toBeTruthy()
|
||||
expect(w.overviewZh).toBeTruthy()
|
||||
expect(w.overviewEn).toBeTruthy()
|
||||
expect(w.gallery.length).toBeGreaterThan(0)
|
||||
expect(Array.isArray(w.gallery)).toBe(true)
|
||||
expect(w.gallery.length).toBe(0)
|
||||
expect(w.tags.length).toBeGreaterThan(0)
|
||||
expect(w.image).toBeNull()
|
||||
expect(w.published).toBe(1)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -14,13 +14,20 @@ describe('default site settings', () => {
|
||||
expect(defaultSettings.contact.address.en).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has non-empty socials and tools', () => {
|
||||
it('has non-empty socials (domestic-first, url left blank) and tools', () => {
|
||||
expect(defaultSettings.socials.length).toBeGreaterThan(0)
|
||||
expect(defaultSettings.socials.every((s) => s.name && s.icon && s.url)).toBe(true)
|
||||
expect(defaultSettings.socials.every((s) => s.name && s.icon)).toBe(true)
|
||||
expect(defaultSettings.tools.length).toBeGreaterThan(0)
|
||||
expect(defaultSettings.tools.every((t) => t.id && t.url && t.descZh && t.descEn)).toBe(true)
|
||||
})
|
||||
|
||||
it('home page content defaults are empty (no demo data, configured via admin)', () => {
|
||||
expect(defaultSettings.hero.gallery).toEqual([])
|
||||
expect(defaultSettings.achievements).toEqual([])
|
||||
expect(defaultSettings.testimonials).toEqual([])
|
||||
expect(defaultSettings.partners).toEqual([])
|
||||
})
|
||||
|
||||
it('has bilingual footer texts', () => {
|
||||
for (const k of ['title', 'newsletterTitle', 'newsletterNote', 'copyright'] as const) {
|
||||
expect(defaultSettings.footer[k].zh).toBeTruthy()
|
||||
|
||||
Reference in New Issue
Block a user