2025-03-17 09:19:59 +08:00
|
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
|
import Shortcuts from "./components/Shortcuts";
|
|
|
|
|
import SettingsItem from "../SettingsItem";
|
|
|
|
|
import { AppWindowMac, MessageSquareMore, Search, Unplug } from "lucide-react";
|
|
|
|
|
import { useStartupStore } from "@/stores/startupStore";
|
|
|
|
|
import { useEffect } from "react";
|
|
|
|
|
import { useConnectStore } from "@/stores/connectStore";
|
2025-04-29 17:08:01 +08:00
|
|
|
import Appearance from "./components/Appearance";
|
|
|
|
|
import SettingsInput from "../SettingsInput";
|
|
|
|
|
import platformAdapter from "@/utils/platformAdapter";
|
2025-05-07 16:43:44 +08:00
|
|
|
import UpdateSettings from "./components/UpdateSettings";
|
2025-03-17 09:19:59 +08:00
|
|
|
|
|
|
|
|
const Advanced = () => {
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const defaultStartupWindow = useStartupStore((state) => {
|
|
|
|
|
return state.defaultStartupWindow;
|
|
|
|
|
});
|
|
|
|
|
const setDefaultStartupWindow = useStartupStore((state) => {
|
|
|
|
|
return state.setDefaultStartupWindow;
|
|
|
|
|
});
|
|
|
|
|
const defaultContentForSearchWindow = useStartupStore((state) => {
|
|
|
|
|
return state.defaultContentForSearchWindow;
|
|
|
|
|
});
|
|
|
|
|
const setDefaultContentForSearchWindow = useStartupStore((state) => {
|
|
|
|
|
return state.setDefaultContentForSearchWindow;
|
|
|
|
|
});
|
|
|
|
|
const defaultContentForChatWindow = useStartupStore((state) => {
|
|
|
|
|
return state.defaultContentForChatWindow;
|
|
|
|
|
});
|
|
|
|
|
const setDefaultContentForChatWindow = useStartupStore((state) => {
|
|
|
|
|
return state.setDefaultContentForChatWindow;
|
|
|
|
|
});
|
|
|
|
|
const connectionTimeout = useConnectStore((state) => {
|
|
|
|
|
return state.connectionTimeout;
|
|
|
|
|
});
|
|
|
|
|
const setConnectionTimeout = useConnectStore((state) => {
|
|
|
|
|
return state.setConnectionTimeout;
|
|
|
|
|
});
|
2025-04-22 18:32:20 +08:00
|
|
|
const queryTimeout = useConnectStore((state) => {
|
2025-04-27 20:10:54 +08:00
|
|
|
return state.querySourceTimeout;
|
2025-04-22 18:32:20 +08:00
|
|
|
});
|
|
|
|
|
const setQueryTimeout = useConnectStore((state) => {
|
2025-04-27 20:10:54 +08:00
|
|
|
return state.setQuerySourceTimeout;
|
2025-04-22 18:32:20 +08:00
|
|
|
});
|
2025-03-17 09:19:59 +08:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2025-04-22 18:32:20 +08:00
|
|
|
const unsubscribeStartup = useStartupStore.subscribe((state) => {
|
2025-04-29 17:08:01 +08:00
|
|
|
platformAdapter.emitEvent("change-startup-store", state);
|
2025-03-17 09:19:59 +08:00
|
|
|
});
|
|
|
|
|
|
2025-04-22 18:32:20 +08:00
|
|
|
const unsubscribeConnect = useConnectStore.subscribe((state) => {
|
2025-04-29 17:08:01 +08:00
|
|
|
platformAdapter.emitEvent("change-connect-store", state);
|
2025-04-22 18:32:20 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
unsubscribeStartup();
|
|
|
|
|
unsubscribeConnect();
|
|
|
|
|
};
|
2025-03-17 09:19:59 +08:00
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const startupList = [
|
|
|
|
|
{
|
|
|
|
|
icon: AppWindowMac,
|
|
|
|
|
title: "settings.advanced.startup.defaultStartupWindow.title",
|
|
|
|
|
description: "settings.advanced.startup.defaultStartupWindow.description",
|
|
|
|
|
value: defaultStartupWindow,
|
|
|
|
|
items: [
|
|
|
|
|
{
|
|
|
|
|
label:
|
|
|
|
|
"settings.advanced.startup.defaultStartupWindow.select.searchMode",
|
|
|
|
|
value: "searchMode",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label:
|
|
|
|
|
"settings.advanced.startup.defaultStartupWindow.select.chatMode",
|
|
|
|
|
value: "chatMode",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
onChange: setDefaultStartupWindow,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: Search,
|
|
|
|
|
title: "settings.advanced.startup.defaultContentForSearchWindow.title",
|
|
|
|
|
description:
|
|
|
|
|
"settings.advanced.startup.defaultContentForSearchWindow.description",
|
|
|
|
|
value: defaultContentForSearchWindow,
|
|
|
|
|
items: [
|
|
|
|
|
{
|
|
|
|
|
label:
|
|
|
|
|
"settings.advanced.startup.defaultContentForSearchWindow.select.systemDefault",
|
|
|
|
|
value: "systemDefault",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
onChange: setDefaultContentForSearchWindow,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
icon: MessageSquareMore,
|
|
|
|
|
title: "settings.advanced.startup.defaultContentForChatWindow.title",
|
|
|
|
|
description:
|
|
|
|
|
"settings.advanced.startup.defaultContentForChatWindow.description",
|
|
|
|
|
value: defaultContentForChatWindow,
|
|
|
|
|
items: [
|
|
|
|
|
{
|
|
|
|
|
label:
|
|
|
|
|
"settings.advanced.startup.defaultContentForChatWindow.select.newChat",
|
|
|
|
|
value: "newChat",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label:
|
|
|
|
|
"settings.advanced.startup.defaultContentForChatWindow.select.oldChat",
|
|
|
|
|
value: "oldChat",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
onChange: setDefaultContentForChatWindow,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-8">
|
|
|
|
|
<h2 className="text-lg font-semibold text-gray-900 dark:text-white mb-4">
|
|
|
|
|
{t("settings.advanced.startup.title")}
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
{startupList.map((item) => {
|
|
|
|
|
const { icon, title, description, value, items, onChange } = item;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<SettingsItem
|
|
|
|
|
key={title}
|
|
|
|
|
icon={icon}
|
|
|
|
|
title={t(title)}
|
|
|
|
|
description={t(description)}
|
|
|
|
|
>
|
|
|
|
|
<select
|
|
|
|
|
value={value}
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
onChange(event.target.value as never);
|
|
|
|
|
}}
|
|
|
|
|
className="px-3 py-1.5 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
|
|
|
>
|
|
|
|
|
{items.map((item) => {
|
|
|
|
|
const { label, value } = item;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<option key={value} value={value}>
|
|
|
|
|
{t(label)}
|
|
|
|
|
</option>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</select>
|
|
|
|
|
</SettingsItem>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Shortcuts />
|
|
|
|
|
|
|
|
|
|
<h2 className="text-lg font-semibold text-gray-900 dark:text-white mb-4">
|
|
|
|
|
{t("settings.advanced.connect.title")}
|
|
|
|
|
</h2>
|
|
|
|
|
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
<SettingsItem
|
|
|
|
|
icon={Unplug}
|
|
|
|
|
title={t("settings.advanced.connect.connectionTimeout.title")}
|
|
|
|
|
description={t(
|
|
|
|
|
"settings.advanced.connect.connectionTimeout.description"
|
|
|
|
|
)}
|
|
|
|
|
>
|
2025-04-29 17:08:01 +08:00
|
|
|
<SettingsInput
|
2025-03-17 09:19:59 +08:00
|
|
|
type="number"
|
|
|
|
|
min={10}
|
|
|
|
|
value={connectionTimeout}
|
2025-05-14 15:03:17 +08:00
|
|
|
onChange={(value) => {
|
|
|
|
|
setConnectionTimeout(!value ? void 0 : Number(value));
|
2025-03-17 09:19:59 +08:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</SettingsItem>
|
2025-04-22 18:32:20 +08:00
|
|
|
|
|
|
|
|
<SettingsItem
|
|
|
|
|
icon={Unplug}
|
|
|
|
|
title={t("settings.advanced.connect.queryTimeout.title")}
|
|
|
|
|
description={t("settings.advanced.connect.queryTimeout.description")}
|
|
|
|
|
>
|
2025-04-29 17:08:01 +08:00
|
|
|
<SettingsInput
|
2025-04-22 18:32:20 +08:00
|
|
|
type="number"
|
|
|
|
|
min={1}
|
|
|
|
|
value={queryTimeout}
|
2025-05-14 15:03:17 +08:00
|
|
|
onChange={(value) => {
|
|
|
|
|
setQueryTimeout(!value ? void 0 : Number(value));
|
2025-04-22 18:32:20 +08:00
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</SettingsItem>
|
2025-03-17 09:19:59 +08:00
|
|
|
</div>
|
2025-04-29 17:08:01 +08:00
|
|
|
|
|
|
|
|
<Appearance />
|
2025-05-07 16:43:44 +08:00
|
|
|
|
|
|
|
|
<UpdateSettings />
|
2025-03-17 09:19:59 +08:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default Advanced;
|