From f4b95f095f2740d6f1cde3afa2025960301fd917 Mon Sep 17 00:00:00 2001 From: Yuhang Wu Date: Mon, 12 Oct 2026 17:56:23 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20README=20=E4=B8=BA?= =?UTF-8?q?=20Frpilot=20=E9=A1=B9=E7=9B=AE=E8=AF=B4=E6=98=8E=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 全面重写 README,替换原 Tauri + Vue + TypeScript 模板内容,新增 Frpilot 项目介绍、功能特性、技术栈、环境要求、快速开始、项目结构、开发指南等完整文档内容,帮助用户了解和使用项目。 --- README.md | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 227 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 12920b6..3a6cfaf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,230 @@ -# Tauri + Vue + TypeScript +# Frpilot -This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 ` + + +``` + +新增语言:在 `src/i18n/locales/` 添加 JSON,并在 `src/i18n/index.ts` 的 `messages` 与 `languageOptions` 中注册。 + +### 新增侧边栏菜单项与页面 + +1. 在 `src/views/` 新建页面组件。 +2. 在 `src/router/router.ts` 的 `Layout` 子路由中注册(路径需以 `/` 开头,与菜单 `key` 一致)。 +3. 在 `src/layout/aside/Aside.vue` 的 `menuItems` 中追加一项(`key` = 路由路径)。 +4. 在语言包中补充对应 `menu.*` 文案。 + +### 明暗主题 + +- 主题状态在 `src/stores/app.ts`(`isDark` / `toggleDark`),由 `useDark` 在 `` 上切换 `.dark` 类名并持久化。 +- Tailwind 使用 class 策略:在 `src/assets/main.css` 中已声明 `@custom-variant dark`。 +- Ant Design Vue 主题在 `src/App.vue` 中通过 `a-config-provider` 的 `theme.algorithm` 联动。 + +### 玻璃拟态样式 + +`src/assets/main.css` 中的 `.glass-panel` 为通用毛玻璃面板,直接给元素加 `class="glass-panel"` 即可(已含暗色适配)。 + +### 接入真实的 CPU / 内存占用 + +`src/composables/useSystemStats.ts` 会优先调用 Tauri 命令 `get_system_info`,在命令不存在时回退到**模拟数据**。接入真实数据只需在 Rust 端实现该命令: + +```rust +// src-tauri/src/lib.rs +#[tauri::command] +fn get_system_info() -> serde_json::Value { + // 返回 { "cpu": f64, "memory": f64 },单位为百分比 + serde_json::json!({ "cpu": 12.0, "memory": 45.0 }) +} + +pub fn run() { + tauri::Builder::default() + .plugin(tauri_plugin_opener::init()) + .invoke_handler(tauri::generate_handler![get_system_info]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} +``` + +前端会自动切换为真实数据(`isMock` 会变为 `false`)。 + +### 运行状态指示点 + +运行状态由 `src/stores/app.ts` 的 `runStatus` 控制,取值: + +```ts +type RunStatus = 'running' | 'error' | 'stopped' // 🟢 | 🔴 | 🟡 +``` + +后续接入 frpc 进程状态时,更新该字段即可。 + +### 窗口控制与权限 + +- 前端封装:`src/utils/window.ts`(`minimizeWindow` / `toggleMaximizeWindow` / `closeWindow` / `startDragging`),在非 Tauri 环境(浏览器)下自动空转。 +- 自定义标题栏依赖无边框窗口(`src-tauri/tauri.conf.json` 中 `decorations: false`),拖拽区域通过 `data-tauri-drag-region` 实现。 +- 相关权限在 `src-tauri/capabilities/default.json` 中声明(`core:window:allow-minimize`、`allow-close`、`allow-toggle-maximize`、`allow-start-dragging` 等)。**新增窗口 API 调用时需同步补充对应权限**,否则会报 `not allowed` 错误。 + +--- + +## 📚 参考链接 + +- [Tauri 2 文档](https://v2.tauri.app/) +- [Vue 3 文档](https://vuejs.org/) +- [Ant Design Vue 4](https://antdv.com/) +- [Tailwind CSS 4](https://tailwindcss.com/) +- [Vue I18n](https://vue-i18n.intlify.dev/) +- [VueUse](https://vueuse.org/) +- [frp 官方仓库](https://github.com/fatedier/frp) + +--- + +## 📄 License + +License 待定(待补充)。