From 2c69b3f1c3b983d64f1775b4ff3108060c5ba64c Mon Sep 17 00:00:00 2001 From: youzi <2410633923@qq.com> Date: Tue, 4 Aug 2026 17:33:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E4=BD=93=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGENTS.md | 44 ++ auto-imports.d.ts | 1 + components.d.ts | 1 + env.d.ts | 19 +- package.json | 2 +- src/Index.vue | 37 +- src/components/Gallery.vue | 9 - src/components/Login.vue | 40 +- src/components/aplayer.vue | 109 ++-- src/components/backTop.vue | 24 +- src/components/homeSide.vue | 194 +++++-- src/components/menuH.vue | 34 +- src/config/index.ts | 11 +- src/lib/components/LazyImg.vue | 10 +- src/lib/components/Waterfall.vue | 2 +- src/main.ts | 4 + src/router/index.ts | 31 +- src/stores/log.ts | 16 +- src/stores/nav.ts | 13 +- src/util/index.ts | 56 +- src/util/request.ts | 28 +- src/util/theme.ts | 28 +- src/views/Gallery.vue | 139 ++++- src/views/Plink.vue | 32 +- src/views/Widget.vue | 2 +- src/views/blog/[bid].vue | 637 ++++++++++++++++------ src/views/blog/index.vue | 30 +- src/views/{Home.vue => index.vue} | 848 +++++++++++++++++++++++++----- tsconfig.app.json | 2 +- typed-router.d.ts | 173 ++++-- vite.config.ts | 5 +- yarn.lock | 274 +++++++++- 32 files changed, 2212 insertions(+), 643 deletions(-) create mode 100644 AGENTS.md rename src/views/{Home.vue => index.vue} (54%) diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..4b82776 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,44 @@ +# AGENTS.md — 博客前端项目 + +Vue 3 + TypeScript + Vite 7 博客前端(后端 API 为 `https://www.hxyouzi.com/api`)。UI:naive-ui + UnoCSS + vue-devui(Tag) + md-editor-v3。风格为暖色玻璃拟态(主色 `#ec66ab`)。 + +## 常用命令 + +| 命令 | 用途 | +| -------------------- | --------------------------------------------------------- | +| `npm run dev` | 开发服务器(端口 8989,路径 base `/blog/`,首页 `/home`) | +| `npm run type-check` | vue-tsc 类型检查(**改完代码必跑**) | +| `npm run b` | type-check + build | +| `npm run build-only` | 仅构建 | + +## 全局约定(勿重复 import / 注册) + +- 全局变量直接使用、**无需 import**(类型在 `env.d.ts`):`$http`(API)、`$msg`(naive message)、`$store`(pinia)、`$cookies`、`$modal`(弹窗,参数 `{title, content, contType: 'text'|'input', ...}`)。 +- 组合式 API 已自动导入(`ref/computed/watch/useRoute/defineStore/useMessage` 等,见 `auto-imports.d.ts`),**不要重复 import**。 +- `src/components/` 下组件与 naive-ui `` 自动注册(`components.d.ts`),模板直接用。 +- 图标:`src/icon/` 顶层 svg 注册为 ` />`;`icon/menu/`、`icon/plink/` 子目录**不自动注册**,需手动 import(vite-svg-loader)。 +- API 模块:新建 `src/api//index.ts` 即自动挂到 `$http.`(`import.meta.glob`)。**新增 icon/api/store 文件后需重启 dev server**(glob 构建时静态分析)。 + +## 架构速览 + +- **路由**:unplugin-vue-router 文件系统路由(`src/views/`),视图用 `definePage()`;`src/router/index.ts` 中 `/` 重定向到 `/home`,带 NProgress 守卫。 +- **API 调用**:`$http.<模块>.<函数>()` → 请求层 `src/util/request.ts`(baseURL `https://www.hxyouzi.com/api`,token 从 cookie 自动带 Bearer,响应拦截直接返回 `response.data`)。 +- **Stores**:`src/stores/` setup 风格;`nav.ts` 提供 `navH`(导航栏高度,页面布局需减它)、`log.ts` 提供 `isLogin`。访问:`$store.nav.useNavStore()`。 +- **UnoCSS**:重度使用 arbitrary values(`bg-[...]`、`shadow-[...]`);卡片类优先用 `uno.config.ts` 的 shortcuts(`blog-list-panel`、`blog-detail-card`、`blog-detail-card-soft`、`home-glass-surface` 等)。 +- **Less**:vite 已全局注入 `@primary: #ec66ab` 等变量,less 块内直接用。字体:霞鹜文楷(正文)+ Fira Code(代码)。 +- **页面背景模板**:所有视图沿用统一背景 — 暖色径向渐变 + 两个 blur 圆 + 网格 overlay(参考 `src/views/Home.vue` 顶部)。 + +## 常见陷阱 + +- `console.log` 在 build 时会被 esbuild 删除(`pure: ["console.log"]`),调试用 dev 模式。 +- 登录态:cookie `userinfo` 存在即视为已登录。 +- `$http.mix.getHoli()` 后端 500 不可用,必须 try/catch 防御式处理(失败静默隐藏)。 +- 内部滚动容器用 naive-ui `n-scrollbar` 时监听 `@scroll`,**不要监听 window scroll**(内部滚动不冒泡)。 +- `Waterfall` 组件需传 `row-key="filepath"`(GalleryItem 无 id 字段)。 +- 阴影规范:三层体系(接触 `rgba(97,121,146,0.05)` + 主体 `0.08-0.13` + 暖色 `rgba(178,128,88,*)` + `inset 0 1px 0 rgba(255,255,255,0.7)` 高光),避免纯冷灰 `rgba(86,111,137,*)`。 +- 修改 `Home.vue` 导航卡片动画时先阅读 `/memories/repo/blog-nav.md`(FLIP 动画有特殊约束)。 + +## 相关资料 + +- 导航首页细节(FLIP 动画、侧边栏、画廊约定):仓库记忆 `/memories/repo/blog-nav.md` +- UI 截图批量转 Vue 组件:技能 `.agents/skills/ui/SKILL.md` diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 36b6df4..2d4643f 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -70,6 +70,7 @@ declare global { const useCssVars: typeof import('vue')['useCssVars'] const useDialog: typeof import('naive-ui')['useDialog'] const useId: typeof import('vue')['useId'] + const useLink: typeof import('vue-router')['useLink'] const useLoadingBar: typeof import('naive-ui')['useLoadingBar'] const useMessage: typeof import('naive-ui')['useMessage'] const useModel: typeof import('vue')['useModel'] diff --git a/components.d.ts b/components.d.ts index 039b34b..a9ca12b 100644 --- a/components.d.ts +++ b/components.d.ts @@ -45,6 +45,7 @@ declare module 'vue' { NPagination: typeof import('naive-ui')['NPagination'] NScrollbar: typeof import('naive-ui')['NScrollbar'] NSelect: typeof import('naive-ui')['NSelect'] + NSpin: typeof import('naive-ui')['NSpin'] NTabPane: typeof import('naive-ui')['NTabPane'] NTabs: typeof import('naive-ui')['NTabs'] NUpload: typeof import('naive-ui')['NUpload'] diff --git a/env.d.ts b/env.d.ts index 554aeb2..d42d78c 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1,24 +1,29 @@ /// /// +/// +// 全局变量:由 src/config/index.ts 的 useConfig() 与 src/Index.vue 注册, +// 使用时不需 import(均挂载在 window 上) declare global { + // API 聚合对象:$http.<模块>.<函数>(),模块见 src/api/*/index.ts let $http: any; + // vue3-cookies 封装:$cookies.get/set/remove let $cookies: any; + // naive-ui useMessage 实例:$msg.success/warning/error/info let $msg: any; - let $store:any; - let $modal :any + // pinia store 聚合:$store.nav.useNavStore() / $store.log.useLogStore() + let $store: any; + // 全局弹窗:$modal({ title, content, contType: 'text'|'input', ... }) + let $modal: any; interface Window { // 扩展Windows环境下的全局$http对象 $http: any; $cookies: any; $msg: any; - $store:any - $modal:any + $store: any; + $modal: any; } } - - - export { }; diff --git a/package.json b/package.json index 24b1f94..3a552dc 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "unplugin-vue-router": "^0.15.0", "vite-svg-loader": "^5.1.0", "vue": "^3.6.0-alpha.2", - "vue-router": "^4.5.1", + "vue-router": "^5.2.0", "vue3-cookies": "^1.0.6" }, "devDependencies": { diff --git a/src/Index.vue b/src/Index.vue index f1b29d7..f197cb9 100644 --- a/src/Index.vue +++ b/src/Index.vue @@ -7,7 +7,7 @@ -
+ @@ -36,8 +36,20 @@