diff --git a/.env.example b/.env.example index 41dc9fa..a3432d5 100644 --- a/.env.example +++ b/.env.example @@ -30,3 +30,12 @@ NUXT_ADMIN_EMAILS=chenchun@virtheart.com # 预置管理员初始密码(仅首次初始化数据库时创建 admin 账号用;生产由 deploy.sh 注入) # NUXT_ADMIN_INITIAL_PASSWORD=change-me + +# ---- OSS 文件存储(RustFS / S3 v4 兼容;凭据不写入仓库,生产由 deploy.sh 注入 Secret)---- +NUXT_OSS_ENDPOINT=oss.virtheart.com +NUXT_OSS_ACCESS_KEY= +NUXT_OSS_SECRET_KEY= +NUXT_OSS_BUCKET=arcticnewone +NUXT_OSS_REGION=us-east-1 +# 若桶公开可读,可填 https://oss.virtheart.com/arcticnewone 用于直链;留空则走 /uploads 代理 +NUXT_OSS_PUBLIC_BASE= diff --git a/README.md b/README.md index 2ce12ca..19592c0 100644 --- a/README.md +++ b/README.md @@ -52,16 +52,16 @@ pnpm dev | 模块 | 说明 | | --- | --- | | 页面 | 首页、工作室、作品(列表/详情)、动态(列表/详情)、工具箱、联系、个人中心 | -| **后台管理** | `/admin`:Dashboard 统计、动态/作品增删改(中英双语 CMS)、用户管理、评论审核、联系/订阅管理、图片上传 | -| 用户系统 | 真实注册/登录/登出(scrypt 密码哈希 + httpOnly Cookie 会话);预置 admin 账号 | -| 个人中心 | `/account`:资料编辑、作品收藏、我的评论;管理员可进入 `/admin` | +| **后台管理** | `/admin`:Dashboard、动态/作品增删改(双语 CMS)、用户/评论/联系/订阅管理、图片管理(OSS)、操作审计日志、**站点动态配置** | +| **动态配置** | 站点信息/联系方式/社交链接/工具箱/页脚文案/SEO 均可在 `/admin/settings` 后台修改,前台即时生效 | +| **文件存储** | 图片上传/管理使用 OSS(RustFS,S3 v4 兼容,桶 `arcticnewone`),经 `/uploads` 代理服务 | +| 用户系统 | 注册/登录/登出、修改密码、自助删除账号、预置 admin;个人中心(资料/收藏/评论) | | 交互 | 作品收藏、新闻评论、分享(X/LinkedIn/复制链接)、搜索、加载更多 | -| 国际化 | 中/英双语,Header 一键切换(`no_prefix`,默认中文);内容双语存于数据库 | -| SEO | 动态 `sitemap.xml`(数据来自 DB)/ `robots.txt`、JSON-LD、自动生成的 `og-image.png` | -| 邮件 | SMTP 发送联系/订阅邮件;未配置 SMTP 时数据仍真实写入 SQLite | +| 国际化 | 中/英双语,Header 一键切换;内容双语存于数据库 | +| SEO | 动态 `sitemap.xml`/`robots.txt`/`feed.xml`(RSS)、JSON-LD、canonical、`og-image.png` | +| 工程 | `pnpm test`(vitest:密码/SigV4/校验器/种子/配置 17 例) | -> **预置管理员**:首次部署时若设置 `ADMIN_INITIAL_PASSWORD`(或由 `deploy.sh` 自动生成并打印), -> 数据库初始化会自动创建 `admin` 账号(邮箱取 `ADMIN_EMAILS` 第一个)。登录后访问 `/admin` 即可管理内容。 +> **预置管理员**:首次部署设置 `ADMIN_INITIAL_PASSWORD`(或由 `deploy.sh` 自动生成并打印)会自动创建 `admin` 账号,登录后访问 `/admin` 管理内容与配置。 ### 环境变量(详见 `.env.example`,Nuxt runtimeConfig 使用 `NUXT_` 前缀) @@ -74,8 +74,9 @@ pnpm dev | `NUXT_CONTACT_TO` | 联系表单留言收件邮箱 | | `NUXT_ADMIN_EMAILS` | 管理员邮箱(逗号分隔),命中者个人中心可见管理面板 | | `NUXT_ADMIN_INITIAL_PASSWORD` | 预置管理员初始密码(仅首次初始化创建 admin 账号用) | +| `NUXT_OSS_ENDPOINT/ACCESS_KEY/SECRET_KEY/BUCKET/REGION/PUBLIC_BASE` | OSS 文件存储(RustFS / S3 v4,凭据仅走 Secret,不写入仓库) | -> `deploy.sh` 中的对外变量名(`SESSION_SECRET`/`SMTP_*`/`CONTACT_TO`/`ADMIN_EMAILS`/`ADMIN_INITIAL_PASSWORD`)会在写入 K8s Secret 时自动加 `NUXT_` 前缀。 +> `deploy.sh` 中的对外变量名(`SESSION_SECRET`/`SMTP_*`/`CONTACT_TO`/`ADMIN_EMAILS`/`ADMIN_INITIAL_PASSWORD`/`OSS_*`)会在写入 K8s Secret 时自动加 `NUXT_` 前缀。 ## 项目结构 diff --git a/app/app.vue b/app/app.vue index 1bc7239..9d71d37 100755 --- a/app/app.vue +++ b/app/app.vue @@ -2,9 +2,10 @@ import { computed } from 'vue' import { useHead, useSeoMeta, useRuntimeConfig, useRoute } from '#imports' import { useI18n } from 'vue-i18n' -import { siteConfig } from '~/config/site' +import { useSiteSettings } from '~/composables/useSiteSettings' const { t } = useI18n() +const { settings, loc } = useSiteSettings() const { public: publicCfg } = useRuntimeConfig() const route = useRoute() const baseUrl = String(publicCfg.siteUrl || '').replace(/\/$/, '') @@ -15,40 +16,41 @@ const siteImage = baseUrl ? `${baseUrl}/og-image.png` : '/og-image.png' // 配置全局 Title 模板 + canonical(SEO) useHead({ titleTemplate: (titleChunk?: string) => { - const siteName = t('app.name') + const siteName = settings.value?.site.name || t('app.name') return titleChunk ? `${titleChunk} - ${siteName}` : siteName }, link: [ { rel: 'canonical', href: computed(() => (baseUrl ? `${baseUrl}${route.path}` : undefined)) }, ], - // JSON-LD 结构化数据(Organization) + // JSON-LD 结构化数据(Organization,取自后台动态配置) script: [ { type: 'application/ld+json', innerHTML: JSON.stringify({ '@context': 'https://schema.org', '@type': 'Organization', - name: t('app.name'), - alternateName: siteConfig.brandZh, - description: t('app.description'), + name: settings.value?.site.name || t('app.name'), + alternateName: settings.value?.site.brand || '', + description: loc(settings.value?.site.description) || t('app.description'), url: baseUrl || undefined, logo: siteImage, - sameAs: siteConfig.socials.map((s) => s.url), + sameAs: (settings.value?.socials ?? []).map((s) => s.url), }), }, ], }) -// 配置全局基础 SEO 和 Meta (响应式支持国际化) +// 配置全局基础 SEO 和 Meta (取自后台动态配置,响应式国际化) useSeoMeta({ - description: () => t('app.description'), - ogTitle: () => t('app.name'), - ogDescription: () => t('app.description'), + description: () => loc(settings.value?.site.description) || t('app.description'), + keywords: () => loc(settings.value?.seo.keywords) || undefined, + ogTitle: () => settings.value?.site.name || t('app.name'), + ogDescription: () => loc(settings.value?.site.description) || t('app.description'), ogImage: siteImage, ogType: 'website', twitterCard: 'summary_large_image', - twitterTitle: () => t('app.name'), - twitterDescription: () => t('app.description'), + twitterTitle: () => settings.value?.site.name || t('app.name'), + twitterDescription: () => loc(settings.value?.site.description) || t('app.description'), twitterImage: siteImage, }) diff --git a/app/components/admin/AdminBadge.vue b/app/components/admin/AdminBadge.vue new file mode 100644 index 0000000..1a4b540 --- /dev/null +++ b/app/components/admin/AdminBadge.vue @@ -0,0 +1,22 @@ + + + diff --git a/app/components/admin/AdminButton.vue b/app/components/admin/AdminButton.vue new file mode 100644 index 0000000..f71384a --- /dev/null +++ b/app/components/admin/AdminButton.vue @@ -0,0 +1,40 @@ + + + diff --git a/app/components/admin/AdminCard.vue b/app/components/admin/AdminCard.vue new file mode 100644 index 0000000..8c4528b --- /dev/null +++ b/app/components/admin/AdminCard.vue @@ -0,0 +1,16 @@ + + + diff --git a/app/components/admin/AdminConfirm.vue b/app/components/admin/AdminConfirm.vue new file mode 100644 index 0000000..e6f977c --- /dev/null +++ b/app/components/admin/AdminConfirm.vue @@ -0,0 +1,27 @@ + + + diff --git a/app/components/admin/AdminEmptyState.vue b/app/components/admin/AdminEmptyState.vue new file mode 100644 index 0000000..be1da50 --- /dev/null +++ b/app/components/admin/AdminEmptyState.vue @@ -0,0 +1,17 @@ + + + diff --git a/app/components/admin/AdminInput.vue b/app/components/admin/AdminInput.vue new file mode 100644 index 0000000..0dd329f --- /dev/null +++ b/app/components/admin/AdminInput.vue @@ -0,0 +1,32 @@ + + + diff --git a/app/components/admin/AdminModal.vue b/app/components/admin/AdminModal.vue new file mode 100644 index 0000000..2bc80b6 --- /dev/null +++ b/app/components/admin/AdminModal.vue @@ -0,0 +1,48 @@ + + + + + diff --git a/app/components/admin/AdminPageHeader.vue b/app/components/admin/AdminPageHeader.vue new file mode 100644 index 0000000..ce26a0f --- /dev/null +++ b/app/components/admin/AdminPageHeader.vue @@ -0,0 +1,13 @@ + + + diff --git a/app/components/admin/AdminPagination.vue b/app/components/admin/AdminPagination.vue new file mode 100644 index 0000000..7d914bf --- /dev/null +++ b/app/components/admin/AdminPagination.vue @@ -0,0 +1,20 @@ + + + diff --git a/app/components/admin/AdminSelect.vue b/app/components/admin/AdminSelect.vue new file mode 100644 index 0000000..f618b49 --- /dev/null +++ b/app/components/admin/AdminSelect.vue @@ -0,0 +1,25 @@ + + + diff --git a/app/components/admin/AdminSidebar.vue b/app/components/admin/AdminSidebar.vue index 115e062..5af8112 100644 --- a/app/components/admin/AdminSidebar.vue +++ b/app/components/admin/AdminSidebar.vue @@ -1,24 +1,52 @@ diff --git a/app/components/admin/AdminTextarea.vue b/app/components/admin/AdminTextarea.vue new file mode 100644 index 0000000..3d7916b --- /dev/null +++ b/app/components/admin/AdminTextarea.vue @@ -0,0 +1,31 @@ + - diff --git a/app/pages/admin/settings.vue b/app/pages/admin/settings.vue new file mode 100644 index 0000000..2d7963e --- /dev/null +++ b/app/pages/admin/settings.vue @@ -0,0 +1,260 @@ + + + diff --git a/app/pages/admin/subscribers.vue b/app/pages/admin/subscribers.vue index 1b406e7..a14217e 100644 --- a/app/pages/admin/subscribers.vue +++ b/app/pages/admin/subscribers.vue @@ -1,110 +1,13 @@ - - + + diff --git a/app/pages/admin/uploads.vue b/app/pages/admin/uploads.vue index 7900d33..b872637 100644 --- a/app/pages/admin/uploads.vue +++ b/app/pages/admin/uploads.vue @@ -1,95 +1,13 @@ - - + + diff --git a/app/pages/admin/users.vue b/app/pages/admin/users.vue index d6fa44f..325824a 100644 --- a/app/pages/admin/users.vue +++ b/app/pages/admin/users.vue @@ -1,129 +1,14 @@ - - + + diff --git a/app/pages/admin/work.vue b/app/pages/admin/work.vue index d96b27a..940bfdb 100644 --- a/app/pages/admin/work.vue +++ b/app/pages/admin/work.vue @@ -1,14 +1,14 @@