feat(common-config): add extract from current provider functionality

- Add backend command to extract common config snippet from current provider
- Automatically extract common config on first run after importing default provider
- Auto-enable common config checkbox in new provider mode when snippet exists
- Refactor Gemini common config to operate on .env instead of config.json
- Add "Extract from Current" button to all three common config modals
- Update i18n translations for new extraction feature
This commit is contained in:
Jason
2026-01-03 23:43:39 +08:00
parent c049c5f2bb
commit 188c94f2e3
17 changed files with 892 additions and 295 deletions
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react";
import { Save } from "lucide-react";
import { Save, Download, Loader2 } from "lucide-react";
import { useTranslation } from "react-i18next";
import { FullScreenPanel } from "@/components/common/FullScreenPanel";
import { Button } from "@/components/ui/button";
@@ -11,6 +11,8 @@ interface CodexCommonConfigModalProps {
value: string;
onChange: (value: string) => void;
error?: string;
onExtract?: () => void;
isExtracting?: boolean;
}
/**
@@ -23,6 +25,8 @@ export const CodexCommonConfigModal: React.FC<CodexCommonConfigModalProps> = ({
value,
onChange,
error,
onExtract,
isExtracting,
}) => {
const { t } = useTranslation();
const [isDarkMode, setIsDarkMode] = useState(false);
@@ -49,6 +53,24 @@ export const CodexCommonConfigModal: React.FC<CodexCommonConfigModalProps> = ({
onClose={onClose}
footer={
<>
{onExtract && (
<Button
type="button"
variant="outline"
onClick={onExtract}
disabled={isExtracting}
className="gap-2"
>
{isExtracting ? (
<Loader2 className="w-4 h-4 animate-spin" />
) : (
<Download className="w-4 h-4" />
)}
{t("codexConfig.extractFromCurrent", {
defaultValue: "从当前供应商提取",
})}
</Button>
)}
<Button type="button" variant="outline" onClick={onClose}>
{t("common.cancel")}
</Button>