refactor: migrate all Tauri commands to camelCase parameters
This commit addresses parameter naming inconsistencies caused by Tauri v2's requirement for camelCase parameter names in IPC commands. Backend changes (Rust): - Updated all command parameters from snake_case to camelCase - Commands affected: * provider.rs: providerId (×4), timeoutSecs * import_export.rs: filePath (×2), defaultName * config.rs: defaultPath - Added #[allow(non_snake_case)] attributes for camelCase parameters - Removed unused QueryUsageParams struct Frontend changes (TypeScript): - Removed redundant snake_case parameters from all invoke() calls - Updated API files: * usage.ts: removed debug logs, unified to providerId * vscode.ts: updated 8 functions (providerId, timeoutSecs, filePath, defaultName) * settings.ts: updated 4 functions (defaultPath, filePath, defaultName) - Ensured all parameters now use camelCase exclusively Test updates: - Updated MSW handlers to accept both old and new parameter formats during transition - Added i18n mock compatibility for tests Root cause: The issue stemmed from Tauri v2 strictly requiring camelCase for command parameters, while the codebase was using snake_case. This caused parameters like 'provider_id' to not be recognized by the backend, resulting in "missing providerId parameter" errors. BREAKING CHANGE: All Tauri command invocations now require camelCase parameters. Any external tools or scripts calling these commands must be updated accordingly. Fixes: Usage query always failing with "missing providerId" error Fixes: Custom endpoint management not receiving provider ID Fixes: Import/export dialogs not respecting default paths
This commit is contained in:
@@ -19,6 +19,8 @@ vi.mock("react-i18next", () => ({
|
||||
t: (key: string, params?: Record<string, unknown>) =>
|
||||
params ? `${key}:${JSON.stringify(params)}` : key,
|
||||
}),
|
||||
// 提供 initReactI18next 以兼容 i18n 初始化路径
|
||||
initReactI18next: { type: "3rdParty", init: () => {} },
|
||||
}));
|
||||
|
||||
vi.mock("@/config/mcpPresets", () => ({
|
||||
|
||||
@@ -169,13 +169,21 @@ export const handlers = [
|
||||
http.post(`${TAURI_ENDPOINT}/is_portable_mode`, () => success(false)),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/select_config_directory`, async ({ request }) => {
|
||||
const { default_path } = await withJson<{ default_path?: string }>(request);
|
||||
return success(default_path ? `${default_path}/picked` : "/mock/selected-dir");
|
||||
const { defaultPath, default_path } = await withJson<{
|
||||
defaultPath?: string;
|
||||
default_path?: string;
|
||||
}>(request);
|
||||
const initial = defaultPath ?? default_path;
|
||||
return success(initial ? `${initial}/picked` : "/mock/selected-dir");
|
||||
}),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/pick_directory`, async ({ request }) => {
|
||||
const { default_path } = await withJson<{ default_path?: string }>(request);
|
||||
return success(default_path ? `${default_path}/picked` : "/mock/selected-dir");
|
||||
const { defaultPath, default_path } = await withJson<{
|
||||
defaultPath?: string;
|
||||
default_path?: string;
|
||||
}>(request);
|
||||
const initial = defaultPath ?? default_path;
|
||||
return success(initial ? `${initial}/picked` : "/mock/selected-dir");
|
||||
}),
|
||||
|
||||
http.post(`${TAURI_ENDPOINT}/open_file_dialog`, () =>
|
||||
|
||||
Reference in New Issue
Block a user