refactor(ui): extract shared components and deduplicate MCP/Skills panels (#897)

* refactor(ui): add tooltips and icons to MCP and Skills panels

* refactor: deduplicate UnifiedSkillsPanel and UnifiedMcpPanel shared code
This commit is contained in:
PeanutSplash
2026-02-04 10:10:45 +08:00
committed by GitHub
parent f0e8ba1d8f
commit e65360e68a
9 changed files with 254 additions and 302 deletions
+8 -8
View File
@@ -1,8 +1,8 @@
import { invoke } from "@tauri-apps/api/core";
// ========== 类型定义 ==========
import type { AppId } from "@/lib/api/types";
export type AppType = "claude" | "codex" | "gemini" | "opencode";
// ========== 类型定义 ==========
/** Skill 应用启用状态 */
export interface SkillApps {
@@ -80,7 +80,7 @@ export const skillsApi = {
/** 安装 Skill(统一安装) */
async installUnified(
skill: DiscoverableSkill,
currentApp: AppType,
currentApp: AppId,
): Promise<InstalledSkill> {
return await invoke("install_skill_unified", { skill, currentApp });
},
@@ -93,7 +93,7 @@ export const skillsApi = {
/** 切换 Skill 的应用启用状态 */
async toggleApp(
id: string,
app: AppType,
app: AppId,
enabled: boolean,
): Promise<boolean> {
return await invoke("toggle_skill_app", { id, app, enabled });
@@ -117,7 +117,7 @@ export const skillsApi = {
// ========== 兼容旧 API ==========
/** 获取技能列表(兼容旧 API) */
async getAll(app: AppType = "claude"): Promise<Skill[]> {
async getAll(app: AppId = "claude"): Promise<Skill[]> {
if (app === "claude") {
return await invoke("get_skills");
}
@@ -125,7 +125,7 @@ export const skillsApi = {
},
/** 安装技能(兼容旧 API) */
async install(directory: string, app: AppType = "claude"): Promise<boolean> {
async install(directory: string, app: AppId = "claude"): Promise<boolean> {
if (app === "claude") {
return await invoke("install_skill", { directory });
}
@@ -135,7 +135,7 @@ export const skillsApi = {
/** 卸载技能(兼容旧 API) */
async uninstall(
directory: string,
app: AppType = "claude",
app: AppId = "claude",
): Promise<boolean> {
if (app === "claude") {
return await invoke("uninstall_skill", { directory });
@@ -170,7 +170,7 @@ export const skillsApi = {
/** 从 ZIP 文件安装 Skills */
async installFromZip(
filePath: string,
currentApp: AppType,
currentApp: AppId,
): Promise<InstalledSkill[]> {
return await invoke("install_skills_from_zip", { filePath, currentApp });
},