feat: 系统托盘 (#12)

* feat: 系统托盘

1. 添加系统托盘
2. 托盘添加切换供应商功能
3. 整理组件目录

* feat: 优化系统托盘菜单结构

- 扁平化Claude和Codex的菜单结构,直接将所有供应商添加到主菜单,简化用户交互。
- 添加无供应商时的提示信息,提升用户体验。
- 更新分隔符文本以增强可读性。

* feat: integrate Tailwind CSS and Lucide icons

- Added Tailwind CSS for styling and layout improvements.
- Integrated Lucide icons for enhanced UI elements.
- Updated project structure by removing unused CSS files and components.
- Refactored configuration files to support new styling and component structure.
- Introduced new components for managing providers with improved UI interactions.   

* fix: 修复类型声明和分隔符实现问题

- 修复 updateTrayMenu 返回类型不一致(Promise<void> -> Promise<boolean>)
- 添加缺失的 UnlistenFn 类型导入
- 使用 MenuBuilder.separator() 替代文本分隔符

---------

Co-authored-by: farion1231 <farion1231@gmail.c
This commit is contained in:
TinsFox
2025-09-06 16:21:21 +08:00
committed by GitHub
parent 07b870488d
commit 5af476d376
21 changed files with 1222 additions and 1193 deletions

View File

@@ -1,4 +1,5 @@
import { invoke } from "@tauri-apps/api/core";
import { listen, UnlistenFn } from "@tauri-apps/api/event";
import { Provider } from "../types";
// 应用类型
@@ -52,7 +53,7 @@ export const tauriAPI = {
// 更新供应商
updateProvider: async (
provider: Provider,
app?: AppType,
app?: AppType
): Promise<boolean> => {
try {
return await invoke("update_provider", { provider, app_type: app, app });
@@ -75,7 +76,7 @@ export const tauriAPI = {
// 切换供应商
switchProvider: async (
providerId: string,
app?: AppType,
app?: AppType
): Promise<boolean> => {
try {
return await invoke("switch_provider", {
@@ -91,7 +92,7 @@ export const tauriAPI = {
// 导入当前配置为默认供应商
importCurrentConfigAsDefault: async (
app?: AppType,
app?: AppType
): Promise<ImportResult> => {
try {
const success = await invoke<boolean>("import_default_config", {
@@ -167,6 +168,25 @@ export const tauriAPI = {
}
},
// 更新托盘菜单
updateTrayMenu: async (): Promise<boolean> => {
try {
return await invoke("update_tray_menu");
} catch (error) {
console.error("更新托盘菜单失败:", error);
return false;
}
},
// 监听供应商切换事件
onProviderSwitched: async (
callback: (data: { appType: string; providerId: string }) => void
): Promise<UnlistenFn> => {
return await listen("provider-switched", (event) => {
callback(event.payload as { appType: string; providerId: string });
});
},
// (保留空位,取消迁移提示)
// 选择配置文件Tauri 暂不实现,保留接口兼容性)