Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@
<img src="src-tauri/icons/logo.svg" alt="Codex Switcher" width="128" height="128">
</p>

<h1 align="center">Codex Switcher</h1>
<h1 align="center">Codex 多账号切换</h1>

<p align="center">
A Desktop Application for Managing Multiple OpenAI <a href="https://github.com/openai/codex">Codex CLI</a> Accounts<br>
Easily switch between accounts, monitor usage limits, and stay in control of your quota
一款用于管理多个 OpenAI <a href="https://github.com/openai/codex">Codex CLI</a> 账号的桌面应用<br>
可快速切换账号、查看配额使用情况,并更方便地管理你的额度
</p>

## Features
## 功能特性

- **Multi-Account Management** – Add and manage multiple Codex accounts in one place
- **Quick Switching** – Switch between accounts with a single click
- **Usage Monitoring** – View real-time usage for both 5-hour and weekly limits
- **Dual Login Mode** – OAuth authentication or import existing `auth.json` files
- **多账号管理**:在一个界面中添加并管理多个 Codex 账号
- **快速切换**:一键切换当前使用的账号
- **配额监控**:实时查看 5 小时配额和周配额的使用情况
- **双登录模式**:支持 OAuth 登录,也支持导入现有的 `auth.json` 文件

## Installation
## 安装

### Prerequisites
### 环境要求

- [Node.js](https://nodejs.org/) (v18+)
- [pnpm](https://pnpm.io/)
- [Rust](https://rustup.rs/)

### Build from Source
### 从源码构建

```bash
# Clone the repository
# 克隆仓库
git clone https://github.com/Lampese/codex-switcher.git
cd codex-switcher

# Install dependencies
# 安装依赖
pnpm install

# Run in development mode
# 开发模式运行
pnpm tauri dev

# Build for production
# 构建生产版本
pnpm tauri build
```

The built application will be in `src-tauri/target/release/bundle/`.
构建产物位于 `src-tauri/target/release/bundle/`

## Disclaimer
## 免责声明

This tool is designed **exclusively for individuals who personally own multiple OpenAI/ChatGPT accounts**. It is intended to help users manage their own accounts more conveniently.
本工具**仅适用于本人合法持有多个 OpenAI/ChatGPT 账号的个人用户**,目的是帮助用户更方便地管理自己的账号。

**This tool is NOT intended for:**
- Sharing accounts between multiple users
- Circumventing OpenAI's terms of service
- Any form of account pooling or credential sharing
**本工具不适用于以下用途:**
- 多人之间共享账号
- 规避 OpenAI 的服务条款
- 任何形式的账号池化或凭据共享

By using this software, you agree that you are the rightful owner of all accounts you add to the application. The authors are not responsible for any misuse or violations of OpenAI's terms of service.
使用本软件即表示你确认自己是添加到应用中的所有账号的合法持有人。作者不对任何滥用行为或违反 OpenAI 服务条款的行为承担责任。
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!doctype html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Codex Switcher</title>
<title>Codex 多账号切换</title>
</head>

<body>
Expand Down
11 changes: 10 additions & 1 deletion src-tauri/src/commands/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::auth::{
add_account, create_chatgpt_account_from_refresh_token, get_active_account,
import_from_auth_json, load_accounts, remove_account, save_accounts, set_active_account,
switch_to_account, touch_account,
switch_to_account, touch_account, get_codex_auth_file,
};
use crate::types::{AccountInfo, AccountsStore, AuthData, ImportAccountsSummary, StoredAccount};

Expand Down Expand Up @@ -109,6 +109,15 @@ pub async fn add_account_from_file(path: String, name: String) -> Result<Account
Ok(AccountInfo::from_stored(&stored, active_id))
}

/// Get the default Codex auth.json path for the current user
#[tauri::command]
pub async fn get_default_auth_json_path() -> Result<String, String> {
let path = get_codex_auth_file().map_err(|e| e.to_string())?;
path.to_str()
.map(str::to_owned)
.ok_or_else(|| "Failed to resolve auth.json path".to_string())
}

/// Switch to a different account
#[tauri::command]
pub async fn switch_account(account_id: String) -> Result<(), String> {
Expand Down
7 changes: 4 additions & 3 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ pub mod types;
use commands::{
add_account_from_file, cancel_login, check_codex_processes, complete_login, delete_account,
export_accounts_full_encrypted_file, export_accounts_slim_text, get_active_account_info,
get_usage, import_accounts_full_encrypted_file, import_accounts_slim_text, list_accounts,
refresh_all_accounts_usage, rename_account, start_login, switch_account, warmup_account,
warmup_all_accounts,
get_default_auth_json_path, get_usage, import_accounts_full_encrypted_file,
import_accounts_slim_text, list_accounts, refresh_all_accounts_usage, rename_account,
start_login, switch_account, warmup_account, warmup_all_accounts,
};

#[cfg_attr(mobile, tauri::mobile_entry_point)]
Expand All @@ -23,6 +23,7 @@ pub fn run() {
list_accounts,
get_active_account_info,
add_account_from_file,
get_default_auth_json_path,
switch_account,
delete_account,
rename_account,
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "Codex Switcher",
"productName": "Codex 多账号切换",
"version": "0.1.1",
"identifier": "com.lampese.codex-switcher",
"build": {
Expand All @@ -12,7 +12,7 @@
"app": {
"windows": [
{
"title": "Codex Switcher",
"title": "Codex 多账号切换",
"width": 900,
"height": 700,
"minWidth": 600,
Expand Down
Loading