Merge remote-tracking branch 'origin/enhance/browser_data_import' - Resolved conflicts in translation files and General.tsx

This commit is contained in:
puzhen 2025-10-22 14:33:46 +01:00
commit 3ffaf50fb9
3 changed files with 126 additions and 15 deletions

View file

@ -162,7 +162,34 @@
"recommended": "Recommended",
"reset": "Reset",
"reset-success": "Reset successfully!",
"reset-failed": "Reset failed!"
"reset-failed": "Reset failed!",
"browser-login": "Browser Login",
"browser-login-description": "Open a Chrome browser to log in to your accounts. Your login data will be saved locally in a secure profile.",
"open-browser-login": "Open Browser for Login",
"opening-browser": "Opening Browser...",
"browser-opened-successfully": "Browser opened successfully. Please log in to your accounts.",
"failed-to-open-browser": "Failed to open browser. Please try again.",
"restart-to-apply": "Restart to Apply",
"cookie-manager": "Cookie Manager",
"cookie-manager-description": "Manage cookies saved from your browser sessions. Delete cookies for specific sites or all at once.",
"refresh": "Refresh",
"delete-all": "Delete All",
"search-domains": "Search domains...",
"loading-cookies": "Loading cookies...",
"no-cookies-found": "No cookies found",
"no-matching-domains": "No matching domains",
"login-to-save-cookies": "Use the browser login feature above to save cookies from your accounts.",
"cookies-count": "{{count}} cookies",
"last-access": "Last access",
"deleting": "Deleting...",
"cookies-deleted-successfully": "Successfully deleted cookies for {{domain}}",
"failed-to-load-cookies": "Failed to load cookies. Please try again.",
"failed-to-delete-cookies": "Failed to delete cookies. Please try again.",
"confirm-delete-all-cookies": "Are you sure you want to delete all cookies? This action cannot be undone.",
"all-cookies-deleted": "All cookies have been deleted successfully.",
"cookie-delete-warning": "Note: Deleting cookies will log you out of the associated websites. You may need to restart the browser to see changes take effect."
}

View file

@ -159,8 +159,35 @@
"connection-test-failed": "连接测试失败。",
"configuration-saved-successfully": "配置保存成功!",
"failed-to-save-configuration": "保存配置失败。",
"recommended": "推荐",
"reset": "重置",
"reset-success": "重置成功!",
"reset-failed": "重置失败!"
"recommended": "推荐",
"reset": "重置",
"reset-success": "重置成功!",
"reset-failed": "重置失败!",
"browser-login": "浏览器登录",
"browser-login-description": "打开 Chrome 浏览器以登录您的账户。您的登录数据将安全地保存在本地配置文件中。",
"open-browser-login": "打开浏览器登录",
"opening-browser": "正在打开浏览器...",
"browser-opened-successfully": "浏览器已成功打开。请登录您的账户。",
"failed-to-open-browser": "打开浏览器失败,请重试。",
"restart-to-apply": "重启应用",
"cookie-manager": "Cookie 管理器",
"cookie-manager-description": "管理从浏览器会话中保存的 Cookie。可以删除特定网站或全部 Cookie。",
"refresh": "刷新",
"delete-all": "全部删除",
"search-domains": "搜索域名...",
"loading-cookies": "正在加载 Cookie...",
"no-cookies-found": "未找到 Cookie",
"no-matching-domains": "没有匹配的域名",
"login-to-save-cookies": "使用上面的浏览器登录功能来保存您账户的 Cookie。",
"cookies-count": "{{count}} 个 Cookie",
"last-access": "最后访问",
"deleting": "删除中...",
"cookies-deleted-successfully": "已成功删除 {{domain}} 的 Cookie",
"failed-to-load-cookies": "加载 Cookie 失败,请重试。",
"failed-to-delete-cookies": "删除 Cookie 失败,请重试。",
"confirm-delete-all-cookies": "确定要删除所有 Cookie 吗?此操作无法撤销。",
"all-cookies-deleted": "所有 Cookie 已成功删除。",
"cookie-delete-warning": "注意:删除 Cookie 会使您从相关网站登出。您可能需要重启浏览器才能看到更改生效。"
}

View file

@ -1,17 +1,20 @@
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { LogOut, Settings, Check } from "lucide-react";
import { LogOut, Settings, Check, Chrome, RefreshCw } from "lucide-react";
import light from "@/assets/light.png";
import dark from "@/assets/dark.png";
import transparent from "@/assets/transparent.png";
import { useAuthStore } from "@/store/authStore";
import { useNavigate } from "react-router-dom";
import { proxyFetchPut, proxyFetchGet } from "@/api/http";
import { proxyFetchPut, proxyFetchGet, fetchPost } from "@/api/http";
import { createRef, RefObject } from "react";
import { useEffect, useState } from "react";
import { useChatStore } from "@/store/chatStore";
import { LocaleEnum, switchLanguage } from "@/i18n";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import CookieManager from "./components/CookieManager";
import {
Select,
@ -29,6 +32,7 @@ export default function SettingGeneral() {
const authStore = useAuthStore();
const navigate = useNavigate();
const [isLoading, setIsLoading] = useState(false);
const [isBrowserOpening, setIsBrowserOpening] = useState(false);
const setAppearance = authStore.setAppearance;
const language = authStore.language;
const setLanguage = authStore.setLanguage;
@ -130,14 +134,32 @@ export default function SettingGeneral() {
}
}, []);
const handleOpenBrowserLogin = async () => {
try {
setIsBrowserOpening(true);
const response = await fetchPost("/browser/login");
if (response.success) {
toast.success(t("setting.browser-opened-successfully"));
console.log("Browser session info:", response);
} else {
toast.error(t("setting.failed-to-open-browser"));
}
} catch (error) {
console.error("Error opening browser:", error);
toast.error(t("setting.failed-to-open-browser"));
} finally {
setIsBrowserOpening(false);
}
};
return (
<div className="flex flex-col gap-4 pb-40">
<div className="px-6 py-4 flex flex-col w-fullitems-center justify-between gap-2 bg-surface-secondary rounded-2xl">
<div className="text-body-lg font-bold text-text-heading">
<div className="space-y-8">
<div className="px-6 py-4 bg-surface-secondary rounded-2xl">
<div className="text-base font-bold leading-12 text-text-body">
{t("setting.account")}
</div>
<div className="flex flex-row items-center justify-between gap-2">
<div className="text-body-sm text-text-body font-normal">
<div className="text-sm leading-13 mb-4">
{t("setting.you-are-currently-signed-in-with", {
email: authStore.email,
})}
@ -166,10 +188,45 @@ export default function SettingGeneral() {
{t("setting.log-out")}
</Button>
</div>
</div>
</div>
<div className="px-6 py-4 bg-surface-secondary rounded-2xl">
<div className="text-body-lg font-bold text-text-heading">
<div className="text-base font-bold leading-12 text-text-primary">
{t("setting.browser-login")}
</div>
<div className="text-sm leading-13 mb-4 text-text-secondary">
{t("setting.browser-login-description")}
</div>
<div className="flex gap-2">
<Button
onClick={handleOpenBrowserLogin}
variant="outline"
size="sm"
disabled={isBrowserOpening}
>
<Chrome className="w-4 h-4" />
{isBrowserOpening ? t("setting.opening-browser") : t("setting.open-browser-login")}
</Button>
<Button
onClick={async () => {
try {
console.log("Attempting to restart app...");
await window.ipcRenderer.invoke("restart-app");
} catch (error) {
console.error("Failed to restart app:", error);
toast.error("Failed to restart app");
}
}}
variant="outline"
size="sm"
>
<RefreshCw className="w-4 h-4" />
{t("setting.restart-to-apply")}
</Button>
</div>
</div>
<CookieManager />
<div className="px-6 py-4 bg-surface-secondary rounded-2xl">
<div className="text-base font-bold leading-12 text-text-primary">
{t("setting.language")}
</div>
<div className="mt-md">
@ -193,7 +250,7 @@ export default function SettingGeneral() {
</div>
</div>
<div className="px-6 py-4 bg-surface-secondary rounded-2xl">
<div className="text-body-lg font-bold text-text-heading">
<div className="text-base font-bold leading-12 text-text-primary">
{t("setting.appearance")}
</div>
<div className="flex items-center gap-md mt-md">