Skip to content

Commit ca02273

Browse files
wutongciclaude
andcommitted
feat: 初始化 Config Switch 插件
- 一键切换 API 配置,支持 Claude Code、Codex、Gemini 等客户端 - 配置同步检测,自动检测外部配置变更 - 添加 ProxyCast 配置可将凭证池转为标准 API - GitHub Actions 自动发布 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
0 parents  commit ca02273

File tree

18 files changed

+2953
-0
lines changed

18 files changed

+2953
-0
lines changed

.github/workflows/release.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Release Plugin
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: 'Version to release (e.g., v0.1.0)'
11+
required: true
12+
default: 'v0.1.0'
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Package plugin
25+
run: |
26+
# 创建插件包目录
27+
mkdir -p release
28+
29+
# 复制插件配置文件并打包
30+
cd plugin
31+
zip -j ../release/config-switch-plugin.zip plugin.json config.json
32+
cd ..
33+
34+
# 生成 checksum
35+
cd release
36+
sha256sum config-switch-plugin.zip > checksums.txt
37+
cd ..
38+
39+
# 显示打包结果
40+
ls -la release/
41+
42+
- name: Create Release
43+
uses: softprops/action-gh-release@v1
44+
with:
45+
tag_name: ${{ github.event.inputs.version || github.ref_name }}
46+
name: Config Switch ${{ github.event.inputs.version || github.ref_name }}
47+
body: |
48+
## Config Switch Plugin
49+
50+
一键切换 API 配置的 ProxyCast 插件,支持 Claude Code、Codex、Gemini 等客户端。
51+
52+
### 功能特性
53+
- **一键切换**:快速切换不同客户端的 API 配置
54+
- **多客户端支持**:支持 Claude Code、Codex、Gemini 等主流 AI 客户端
55+
- **配置同步检测**:自动检测外部配置变更,支持导入新配置
56+
- **ProxyCast 集成**:添加 "ProxyCast" 配置可将凭证池转为标准 API
57+
58+
### 支持的客户端
59+
| 客户端 | 配置文件路径 |
60+
|--------|-------------|
61+
| Claude Code | `~/.claude.json` |
62+
| Codex | `~/.codex/config.json` |
63+
| Gemini | `~/.gemini/config.json` |
64+
65+
### 安装
66+
1. 下载 `config-switch-plugin.zip`
67+
2. 在 ProxyCast 插件中心通过本地文件安装
68+
3. 或通过插件中心推荐插件一键安装
69+
draft: false
70+
prerelease: false
71+
files: release/*
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build outputs
5+
dist/
6+
7+
# IDE
8+
.idea/
9+
.vscode/
10+
*.swp
11+
*.swo
12+
13+
# OS
14+
.DS_Store
15+
Thumbs.db
16+
17+
# Logs
18+
*.log
19+
20+
# Environment
21+
.env
22+
.env.local

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 ProxyCast Team
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Config Switch
2+
3+
一键切换 API 配置的 ProxyCast 插件,支持 Claude Code、Codex、Gemini 等客户端。
4+
5+
## 功能特性
6+
7+
- **一键切换**:快速切换不同客户端的 API 配置
8+
- **多客户端支持**:支持 Claude Code、Codex、Gemini 等主流 AI 客户端
9+
- **配置同步检测**:自动检测外部配置变更,支持导入新配置
10+
- **ProxyCast 集成**:添加 "ProxyCast" 配置可将凭证池转为标准 API
11+
12+
## 支持的客户端
13+
14+
| 客户端 | 配置文件路径 |
15+
|--------|-------------|
16+
| Claude Code | `~/.claude.json` |
17+
| Codex | `~/.codex/config.json` |
18+
| Gemini | `~/.gemini/config.json` |
19+
20+
## 安装
21+
22+
### 通过 ProxyCast 插件中心安装
23+
24+
1. 打开 ProxyCast
25+
2. 进入插件中心
26+
3. 在推荐插件中找到 "Config Switch"
27+
4. 点击安装
28+
29+
### 手动安装
30+
31+
```bash
32+
# 下载插件包
33+
curl -LO https://github.com/aiclientproxy/config-switch/releases/latest/download/config-switch-plugin.zip
34+
35+
# 在 ProxyCast 中通过本地文件安装
36+
```
37+
38+
## 使用方法
39+
40+
1. 安装插件后,在侧边栏或工具页面找到 "配置管理"
41+
2. 选择要管理的客户端 Tab(Claude Code / Codex / Gemini)
42+
3. 添加或选择配置项
43+
4. 点击配置卡片即可一键切换
44+
45+
### 添加 ProxyCast 配置
46+
47+
添加名为 "ProxyCast" 的配置,可将 ProxyCast 凭证池转为标准 API:
48+
- API Base: `http://localhost:8999`
49+
- API Key: ProxyCast 的 API Key
50+
51+
## 配置项说明
52+
53+
每个配置项包含:
54+
- **名称**:配置的显示名称
55+
- **API Key**:对应服务的 API 密钥
56+
- **API Base**(可选):自定义 API 端点
57+
- **备注**(可选):配置说明
58+
59+
## 配置同步
60+
61+
当检测到外部配置文件变更时:
62+
- 显示 "检测到外部配置变更" 提示
63+
- 可选择 "导入为新配置" 保存变更
64+
- 可选择 "查看详情" 对比差异
65+
66+
## 开发
67+
68+
```bash
69+
# 安装依赖
70+
pnpm install
71+
72+
# 开发模式
73+
pnpm dev
74+
75+
# 构建
76+
pnpm build
77+
```
78+
79+
## 技术栈
80+
81+
- React + TypeScript
82+
- Tailwind CSS
83+
- Tauri API
84+
85+
## 许可证
86+
87+
MIT License
88+
89+
## 相关链接
90+
91+
- [ProxyCast](https://github.com/aiclientproxy/proxycast)
92+
- [问题反馈](https://github.com/aiclientproxy/config-switch/issues)

plugin/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"enabled": true,
3+
"settings": {}
4+
}

plugin/plugin.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "config-switch",
3+
"version": "0.1.0",
4+
"description": "Config Switch - 一键切换 API 配置,支持 Claude Code、Codex、Gemini 等客户端",
5+
"author": "ProxyCast Team",
6+
"plugin_type": "builtin",
7+
"min_proxycast_version": "1.0.0",
8+
"ui": {
9+
"surfaces": ["tools", "sidebar"],
10+
"icon": "FileCode",
11+
"title": "配置管理",
12+
"description": "一键切换 API 配置,可独立使用。添加 ProxyCast 可将凭证池转为标准 API",
13+
"default_width": 1000,
14+
"default_height": 700
15+
},
16+
"permissions": [
17+
"fs:read",
18+
"fs:write",
19+
"system:clipboard"
20+
],
21+
"tags": ["config", "switch", "api", "claude", "codex", "gemini"]
22+
}

src/components/clients/AppTabs.tsx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { cn } from "@/lib/utils";
2+
import { AppType } from "@/lib/api/switch";
3+
import { ProviderIcon } from "@/icons/providers";
4+
5+
interface AppTabsProps {
6+
activeApp: AppType;
7+
onAppChange: (app: AppType) => void;
8+
}
9+
10+
const apps: {
11+
id: AppType;
12+
label: string;
13+
description: string;
14+
iconType: string;
15+
}[] = [
16+
{
17+
id: "claude",
18+
label: "Claude Code",
19+
description: "Claude CLI 配置",
20+
iconType: "claude",
21+
},
22+
{
23+
id: "codex",
24+
label: "Codex",
25+
description: "OpenAI Codex CLI",
26+
iconType: "openai",
27+
},
28+
{
29+
id: "gemini",
30+
label: "Gemini",
31+
description: "Google Gemini CLI",
32+
iconType: "gemini",
33+
},
34+
];
35+
36+
export function AppTabs({ activeApp, onAppChange }: AppTabsProps) {
37+
return (
38+
<div className="flex gap-2 border-b pb-2">
39+
{apps.map((app) => (
40+
<button
41+
key={app.id}
42+
onClick={() => onAppChange(app.id)}
43+
className={cn(
44+
"flex items-center gap-2 px-4 py-2 rounded-lg border text-sm font-medium transition-colors",
45+
activeApp === app.id
46+
? "border-primary bg-primary/10 text-primary"
47+
: "border-border bg-card hover:bg-muted text-muted-foreground hover:text-foreground",
48+
)}
49+
title={app.description}
50+
>
51+
<ProviderIcon providerType={app.iconType} size={16} />
52+
{app.label}
53+
</button>
54+
))}
55+
</div>
56+
);
57+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { useState } from "react";
2+
import { AppType } from "@/lib/api/switch";
3+
import { AppTabs } from "./AppTabs";
4+
import { ProviderList } from "./ProviderList";
5+
6+
interface ClientsPageProps {
7+
hideHeader?: boolean;
8+
}
9+
10+
export function ClientsPage({ hideHeader = false }: ClientsPageProps) {
11+
const [activeApp, setActiveApp] = useState<AppType>("claude");
12+
13+
return (
14+
<div className="space-y-4">
15+
{!hideHeader && (
16+
<div>
17+
<h2 className="text-2xl font-bold">配置切换</h2>
18+
<p className="text-muted-foreground text-sm">
19+
一键切换 API 配置,可独立使用。添加 "ProxyCast" 可将凭证池转为标准
20+
API(
21+
<code className="px-1 py-0.5 rounded bg-muted text-xs">
22+
localhost:8999
23+
</code>
24+
25+
</p>
26+
</div>
27+
)}
28+
29+
<AppTabs activeApp={activeApp} onAppChange={setActiveApp} />
30+
<ProviderList appType={activeApp} />
31+
</div>
32+
);
33+
}

0 commit comments

Comments
 (0)