This commit is contained in:
fengchuanhn@gmail.com
2026-05-15 17:51:47 +08:00
parent bac4ced1fe
commit 584d4c47a1
23 changed files with 1952 additions and 304 deletions

View File

@@ -0,0 +1,37 @@
---
description: aiclient 项目总览与通用约定
alwaysApply: true
---
# aiclient 项目约定
## 技术栈
- **桌面壳**Tauri 2Rust单例、无边框、可拖动标题栏
- **前端**Vue 3 + Vite 6**纯 JavaScript**(不使用 TypeScript
- **UI**Tailwind CSS v4`@tailwindcss/vite`+ PrimeVue 4Aura 深色预设)
- **状态/路由**Pinia + Vue Router
## 目录结构
```
src/ # Vue 前端
main.js # 入口:插件与全局组件注册
App.vue # 布局:标题栏 + router-view
styles/main.css # Tailwind + 科技感主题令牌
router/ # 路由与守卫
stores/ # Piniaauth 等)
views/ # 页面
components/ # 可复用组件
src-tauri/ # Tauri Rust 与配置
```
## 常用命令
- `npm run dev` — 仅前端(端口 1420
- `npm run tauri dev` — 桌面开发
- `npm run build` / `npm run tauri build` — 构建(前端无 `tsc` 步骤)
## 通用原则
- 用户界面文案默认使用简体中文

View File

@@ -0,0 +1,51 @@
---
description: Vue 前端、路由、认证与 UI 规范
globs: src/**/*
alwaysApply: false
---
# 前端规范Vue 3
## 语言与构建
- 使用 `.js` / `.vue`**禁止**引入 TypeScript无 `tsconfig`、无 `.ts` 入口)
- 全局样式仅通过 `src/styles/main.css``@import "tailwindcss"` + `@theme` 令牌)
- PrimeVue 在 `src/main.js` 注册Aura 主题 + `html.dark` 深色模式
## 目录职责
| 路径 | 用途 |
|------|------|
| `views/` | 路由页面Login、Register、Home |
| `components/` | 布局与复用 UI`AppTitlebar`、`AuthLayout` |
| `stores/` | Pinia 状态(`auth.js` |
| `router/index.js` | 路由表 + `beforeEach` 守卫 |
## 路由
| 路径 | 组件 | 说明 |
|------|------|------|
| `/login` | LoginView | 未登录入口 |
| `/register` | RegisterView | 注册后自动登录 |
| `/` | HomeView | `meta.requiresAuth: true` |
守卫逻辑:
- 无 token 访问需登录页 → `/login`
- 已登录访问 `/login` 或 `/register` → `/`
- 未知路径 → `/login`
## UI / 科技感配色
- 设计令牌在 `styles/main.css` 的 `@theme``bg-deep`、`accent-cyan`、`accent-indigo` 等
- 登录/注册共用 `AuthLayout`:网格背景 + `glass-card` + `gradient-text`
- 布局类名示例:`bg-bg-base`、`text-text-muted`、`auth-link`
- 表单组件:`InputText`、`Password``fluid`、`toggle-mask`)、`Button`
- **Tauri 拖动**:标题栏保留 `data-tauri-drag-region`(见 `AppTitlebar.vue`),按钮/输入框勿加该属性
## 新增页面 checklist
1. 在 `router/index.js` 注册路由与 `meta`
2. 需登录则设 `requiresAuth: true`
3. 业务状态放 PiniaView 只做展示与提交

View File

@@ -0,0 +1,45 @@
---
description: Tauri 2 桌面壳、窗口与单例规范
globs: src-tauri/**/*
alwaysApply: false
---
# Tauri 桌面规范
## 窗口配置(`tauri.conf.json`
- 主窗口 `label`: `"main"`(单例回调中通过此 label 获取窗口)
- `decorations: false` — 无边框;`resizable: true`
- `identifier`: `com.aiclient.desktop`(避免以 `.app` 结尾)
## 单例运行
- 插件:`tauri-plugin-single-instance`
- 二次启动时:对 `main` 窗口 `unminimize` → `show` → `set_focus`**不**新建窗口
- 注册于 `src-tauri/src/lib.rs`,需 `use tauri::Manager`
```rust
.plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| {
if let Some(window) = app.get_webview_window("main") {
let _ = window.unminimize();
let _ = window.show();
let _ = window.set_focus();
}
}))
```
## 权限(`capabilities/default.json`
- 拖动窗口需:`core:window:allow-start-dragging`
- 前端标题栏元素使用 `data-tauri-drag-region`(在 `AppTitlebar.vue`
## Rust 约定
- 入口逻辑在 `src/lib.rs``main.rs` 仅调用 `tauri_app_lib::run()`
- 新增 Tauri 命令:在 `lib.rs` 用 `#[tauri::command]` 定义,并在 `invoke_handler` 注册
- 前端调用:`import { invoke } from "@tauri-apps/api/core"`
## 开发注意
- Vite 固定端口 `1420`(见 `vite.config.js`),与 `tauri.conf.json` 的 `devUrl` 一致
- 修改 capabilities 或插件后需重新 `tauri dev` / `tauri build`