修改计算规则

This commit is contained in:
2025-08-08 12:27:56 +08:00
parent f3324b1107
commit 5016c1d9d6
13 changed files with 1462 additions and 132 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -58,7 +58,7 @@ const DEFAULT_CUSTOM_COLORS: CustomThemeColors = {
};
export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const [theme, setThemeState] = useState<ThemeMode>('dark');
const [theme, setThemeState] = useState<ThemeMode>('gray');
const [customColors, setCustomColorsState] = useState<CustomThemeColors>(DEFAULT_CUSTOM_COLORS);
const [isLoading, setIsLoading] = useState(true);
@@ -73,6 +73,9 @@ export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({ childre
const themeMode = savedTheme as ThemeMode;
setThemeState(themeMode);
applyTheme(themeMode, customColors);
} else {
// Apply default theme if no saved preference
applyTheme('gray', customColors);
}
// Load custom colors

View File

@@ -446,6 +446,7 @@ export interface ImportServerResult {
/** 中转站适配器类型 */
export type RelayStationAdapter =
| 'packycode' // PackyCode 平台(默认)
| 'newapi' // NewAPI 兼容平台
| 'oneapi' // OneAPI 兼容平台
| 'yourapi' // YourAPI 特定平台
@@ -548,7 +549,32 @@ export interface TokenPaginationResponse {
total: number;
page: number;
size: number;
has_more: boolean;
}
// ============= PackyCode Nodes =============
/** PackyCode 节点类型 */
export type NodeType =
| 'direct' // 直连节点
| 'backup' // 备用节点
| 'emergency'; // 紧急节点
/** PackyCode 节点信息 */
export interface PackycodeNode {
name: string; // 节点名称
url: string; // 节点 URL
node_type: NodeType; // 节点类型
description: string; // 节点描述
response_time?: number; // 响应时间(毫秒)
available?: boolean; // 是否可用
}
/** 节点测速结果 */
export interface NodeSpeedTestResult {
node: PackycodeNode; // 节点信息
response_time: number; // 响应时间
success: boolean; // 是否成功
error?: string; // 错误信息
}
/**
@@ -2303,5 +2329,48 @@ export const api = {
console.error("Failed to delete token:", error);
throw error;
}
},
// ============= PackyCode Nodes =============
/**
* Tests all PackyCode nodes and returns speed test results
* @param token - API token for authentication
* @returns Promise resolving to array of node speed test results
*/
async testAllPackycodeNodes(token: string): Promise<NodeSpeedTestResult[]> {
try {
return await invoke<NodeSpeedTestResult[]>("test_all_packycode_nodes", { token });
} catch (error) {
console.error("Failed to test PackyCode nodes:", error);
throw error;
}
},
/**
* Automatically selects the best PackyCode node based on speed
* @param token - API token for authentication
* @returns Promise resolving to the best node
*/
async autoSelectBestNode(token: string): Promise<PackycodeNode> {
try {
return await invoke<PackycodeNode>("auto_select_best_node", { token });
} catch (error) {
console.error("Failed to auto-select best node:", error);
throw error;
}
},
/**
* Gets all available PackyCode nodes
* @returns Promise resolving to array of PackyCode nodes
*/
async getPackycodeNodes(): Promise<PackycodeNode[]> {
try {
return await invoke<PackycodeNode[]>("get_packycode_nodes");
} catch (error) {
console.error("Failed to get PackyCode nodes:", error);
throw error;
}
}
};

View File

@@ -719,6 +719,10 @@
"editTitle": "Edit Relay Station",
"delete": "Delete Station",
"deleteConfirm": "Are you sure you want to delete this relay station?",
"confirmDeleteTitle": "Confirm Delete",
"deleteSuccess": "Successfully deleted",
"createSuccess": "Successfully created",
"updateSuccess": "Successfully updated",
"noStations": "No relay stations configured",
"noStationsDesc": "Add a relay station to access Claude API through proxy services",
"name": "Station Name",
@@ -754,7 +758,30 @@
"syncFailed": "Failed to sync configuration",
"currentConfig": "Current Configuration",
"notConfigured": "Not configured",
"configLocation": "Config file location"
"configLocation": "Config file location",
"serviceType": "Service Type",
"taxiService": "Taxi",
"busService": "Bus",
"taxiServiceDesc": "Fast & Stable (share-api.packycode.com)",
"busServiceDesc": "Shared Economy (api.packycode.com)",
"selectService": "Select a service type",
"fixedUrl": "Fixed URL",
"busServiceNote": "Select a node or use auto-selection for optimal performance",
"nodeSelection": "Node Selection",
"selectNode": "Select a node",
"autoSelect": "Auto-select fastest",
"autoSelectDesc": "Will automatically test and select the fastest node",
"selectedNode": "Selected",
"testSpeed": "Test Speed",
"testResults": "Speed Test Results",
"failed": "Failed",
"testCompleted": "Speed test completed",
"testFailed": "Speed test failed",
"autoSelectedNode": "Auto-selected node",
"autoSelectFailed": "Failed to auto-select node",
"selectingBestNode": "Testing nodes to find the fastest...",
"packycodeTokenNote": "PackyCode uses API Key authentication only",
"enabledNote": "Enable this station to make it available for use"
},
"status": {
"connected": "Connected",

View File

@@ -646,6 +646,10 @@
"editTitle": "编辑中转站",
"delete": "删除中转站",
"deleteConfirm": "确定要删除这个中转站吗?",
"confirmDeleteTitle": "确认删除",
"deleteSuccess": "删除成功",
"createSuccess": "创建成功",
"updateSuccess": "更新成功",
"noStations": "未配置中转站",
"noStationsDesc": "添加中转站以通过代理服务访问 Claude API",
"name": "中转站名称",
@@ -681,7 +685,30 @@
"syncFailed": "同步配置失败",
"currentConfig": "当前配置",
"notConfigured": "未配置",
"configLocation": "配置文件位置"
"configLocation": "配置文件位置",
"serviceType": "服务类型",
"taxiService": "滴滴车",
"busService": "公交车",
"taxiServiceDesc": "高速稳定 (share-api.packycode.com)",
"busServiceDesc": "共享经济 (api.packycode.com)",
"selectService": "选择服务类型",
"fixedUrl": "固定地址",
"busServiceNote": "选择节点或使用自动选择以获得最佳性能",
"nodeSelection": "节点选择",
"selectNode": "选择节点",
"autoSelect": "自动选择最快",
"autoSelectDesc": "将自动测试并选择最快的节点",
"selectedNode": "已选择",
"testSpeed": "测速",
"testResults": "测速结果",
"failed": "失败",
"testCompleted": "测速完成",
"testFailed": "测速失败",
"autoSelectedNode": "自动选择节点",
"autoSelectFailed": "自动选择节点失败",
"selectingBestNode": "正在测试节点以寻找最快的...",
"packycodeTokenNote": "PackyCode 仅支持 API Key 认证方式",
"enabledNote": "启用此中转站以使其可用"
},
"status": {
"connected": "已连接",