mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-25 13:45:03 +08:00
feat(prompts+i18n): add prompt management and improve prompt editor i18n (#193)
* feat(prompts): add prompt management across Tauri service and React UI
- backend: add commands/prompt.rs, services/prompt.rs, register in commands/mod.rs and lib.rs, refine app_config.rs
- frontend: add PromptPanel, PromptFormModal, PromptListItem, MarkdownEditor, usePromptActions, integrate in App.tsx
- api: add src/lib/api/prompts.ts
- i18n: update src/i18n/locales/{en,zh}.json
- build: update package.json and pnpm-lock.yaml
* feat(i18n): improve i18n for prompts and Markdown editor
- update src/i18n/locales/{en,zh}.json keys and strings
- apply i18n in PromptFormModal, PromptPanel, and MarkdownEditor
- align prompt text with src-tauri/src/services/prompt.rs
* feat(prompts): add enable/disable toggle and simplify panel UI
- Add PromptToggle component and integrate in prompt list items
- Implement toggleEnabled with optimistic update; enable via API, disable via upsert with enabled=false;
reload after success
- Simplify PromptPanel: remove file import and current-file preview to keep CRUD flow focused
- Tweak header controls style (use mcp variant) and minor copy: rename “Prompt Management” to “Prompts”
- i18n: add disableSuccess/disableFailed messages
- Backend (Tauri): prevent duplicate backups when importing original prompt content
* style: unify code formatting with trailing commas
* feat(prompts): add Gemini filename support to PromptFormModal
Update filename mapping to use Record<AppId, string> pattern, supporting
GEMINI.md alongside CLAUDE.md and AGENTS.md.
* fix(prompts): sync enabled prompt to file when updating
When updating a prompt that is currently enabled, automatically sync
the updated content to the corresponding live file (CLAUDE.md/AGENTS.md/GEMINI.md).
This ensures the active prompt file always reflects the latest content
when editing enabled prompts.
This commit is contained in:
@@ -2,6 +2,8 @@ export type { AppId } from "./types";
|
||||
export { providersApi } from "./providers";
|
||||
export { settingsApi } from "./settings";
|
||||
export { mcpApi } from "./mcp";
|
||||
export { promptsApi } from "./prompts";
|
||||
export { usageApi } from "./usage";
|
||||
export { vscodeApi } from "./vscode";
|
||||
export type { ProviderSwitchEvent } from "./providers";
|
||||
export type { Prompt } from "./prompts";
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import type { AppId } from "./types";
|
||||
|
||||
export interface Prompt {
|
||||
id: string;
|
||||
name: string;
|
||||
content: string;
|
||||
description?: string;
|
||||
enabled: boolean;
|
||||
createdAt?: number;
|
||||
updatedAt?: number;
|
||||
}
|
||||
|
||||
export const promptsApi = {
|
||||
async getPrompts(app: AppId): Promise<Record<string, Prompt>> {
|
||||
return await invoke("get_prompts", { app });
|
||||
},
|
||||
|
||||
async upsertPrompt(app: AppId, id: string, prompt: Prompt): Promise<void> {
|
||||
return await invoke("upsert_prompt", { app, id, prompt });
|
||||
},
|
||||
|
||||
async deletePrompt(app: AppId, id: string): Promise<void> {
|
||||
return await invoke("delete_prompt", { app, id });
|
||||
},
|
||||
|
||||
async enablePrompt(app: AppId, id: string): Promise<void> {
|
||||
return await invoke("enable_prompt", { app, id });
|
||||
},
|
||||
|
||||
async importFromFile(app: AppId): Promise<string> {
|
||||
return await invoke("import_prompt_from_file", { app });
|
||||
},
|
||||
|
||||
async getCurrentFileContent(app: AppId): Promise<string | null> {
|
||||
return await invoke("get_current_prompt_file_content", { app });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user