This commit is contained in:
2025-08-06 15:39:05 +08:00
parent 351a79d54c
commit 6798be3b42
26 changed files with 1243 additions and 469 deletions

View File

@@ -6,6 +6,7 @@ import { Button } from "@/components/ui/button";
import { Toast, ToastContainer } from "@/components/ui/toast";
import { api, type ClaudeMdFile } from "@/lib/api";
import { cn } from "@/lib/utils";
import { useTranslation } from "@/hooks/useTranslation";
interface ClaudeFileEditorProps {
/**
@@ -36,6 +37,7 @@ export const ClaudeFileEditor: React.FC<ClaudeFileEditorProps> = ({
onBack,
className,
}) => {
const { t } = useTranslation();
const [content, setContent] = useState<string>("");
const [originalContent, setOriginalContent] = useState<string>("");
const [loading, setLoading] = useState(true);
@@ -59,7 +61,7 @@ export const ClaudeFileEditor: React.FC<ClaudeFileEditorProps> = ({
setOriginalContent(fileContent);
} catch (err) {
console.error("Failed to load file:", err);
setError("Failed to load CLAUDE.md file");
setError(t('loadFileFailed'));
} finally {
setLoading(false);
}
@@ -72,11 +74,11 @@ export const ClaudeFileEditor: React.FC<ClaudeFileEditorProps> = ({
setToast(null);
await api.saveClaudeMdFile(file.absolute_path, content);
setOriginalContent(content);
setToast({ message: "File saved successfully", type: "success" });
setToast({ message: t('fileSavedSuccess'), type: "success" });
} catch (err) {
console.error("Failed to save file:", err);
setError("Failed to save CLAUDE.md file");
setToast({ message: "Failed to save file", type: "error" });
setError(t('saveFileFailed'));
setToast({ message: t('saveFileFailed'), type: "error" });
} finally {
setSaving(false);
}
@@ -85,7 +87,7 @@ export const ClaudeFileEditor: React.FC<ClaudeFileEditorProps> = ({
const handleBack = () => {
if (hasChanges) {
const confirmLeave = window.confirm(
"You have unsaved changes. Are you sure you want to leave?"
t('unsavedChangesConfirm')
);
if (!confirmLeave) return;
}
@@ -114,7 +116,7 @@ export const ClaudeFileEditor: React.FC<ClaudeFileEditorProps> = ({
<div className="min-w-0 flex-1">
<h2 className="text-lg font-semibold truncate">{file.relative_path}</h2>
<p className="text-xs text-muted-foreground">
Edit project-specific Claude Code system prompt
{t('editProjectSpecificPrompt')}
</p>
</div>
</div>
@@ -129,7 +131,7 @@ export const ClaudeFileEditor: React.FC<ClaudeFileEditorProps> = ({
) : (
<Save className="mr-2 h-4 w-4" />
)}
{saving ? "Saving..." : "Save"}
{saving ? t('saving') : t('app.save')}
</Button>
</motion.div>