fix(prompt): improve i18n and error handling for auto-import

Address code review feedback for PR #214:

- Replace hardcoded Chinese strings with English in auto-imported prompts
  - Prompt name: "Auto-imported Prompt" instead of "初始提示词"
  - Description: "Automatically imported on first launch"
- Remove panic risk by replacing expect() with proper error propagation
- Use AppError::localized for bilingual error messages
- Extract get_base_dir_with_fallback() helper to eliminate code duplication
- Update test assertions to match new English strings
- Suppress false-positive dead_code warning on TempHome.dir field

All 5 tests passing with zero compiler warnings.
This commit is contained in:
Jason
2025-11-13 15:43:37 +08:00
parent e4d7999294
commit 30c763ffe3
4 changed files with 81 additions and 45 deletions

View File

@@ -58,9 +58,7 @@ pub async fn import_prompt_from_file(
}
#[tauri::command]
pub async fn get_current_prompt_file_content(
app: String,
) -> Result<Option<String>, String> {
pub async fn get_current_prompt_file_content(app: String) -> Result<Option<String>, String> {
let app_type = AppType::from_str(&app).map_err(|e| e.to_string())?;
PromptService::get_current_file_content(app_type).map_err(|e| e.to_string())
}