mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-26 06:24:32 +08:00
85334d8dce
Backend improvements:
- Add InvalidHttpMethod error enum for better error semantics
- Clamp HTTP timeout to 2-30s to prevent config abuse
- Strict HTTP method validation instead of silent fallback to GET
Frontend improvements:
- Add i18n support for usage query errors (en/zh)
- Improve error handling with type-safe unknown instead of any
- Optimize i18n import (direct import instead of dynamic)
- Disable auto-retry for usage queries to avoid API stampede
Additional changes:
- Apply prettier formatting to affected files
Files changed:
- src-tauri/src/error.rs (+2)
- src-tauri/src/usage_script.rs (+8 -2)
- src/i18n/locales/{en,zh}.json (+4 -1 each)
- src/lib/api/usage.ts (+21 -4)
- src/lib/query/queries.ts (+1)
- style: prettier formatting on 6 other files
19 lines
541 B
TypeScript
19 lines
541 B
TypeScript
import { settingsApi } from "@/lib/api";
|
|
|
|
/**
|
|
* 统一的“后置同步”工具:将当前使用的供应商写回对应应用的 live 配置。
|
|
* 不抛出异常,由调用方根据返回值决定提示策略。
|
|
*/
|
|
export async function syncCurrentProvidersLiveSafe(): Promise<{
|
|
ok: boolean;
|
|
error?: Error;
|
|
}> {
|
|
try {
|
|
await settingsApi.syncCurrentProvidersLive();
|
|
return { ok: true };
|
|
} catch (err) {
|
|
const error = err instanceof Error ? err : new Error(String(err ?? ""));
|
|
return { ok: false, error };
|
|
}
|
|
}
|