|
1 |
| -import { useQueryClient } from "@tanstack/react-query" |
2 | 1 | import { useDarkMode } from "~/hooks/useDarkmode"
|
3 |
| -import { useMessageOption } from "~/hooks/useMessageOption" |
4 |
| -import { PageAssitDatabase } from "@/db" |
5 | 2 | import { Select, Switch } from "antd"
|
6 | 3 | import { SUPPORTED_LANGUAGES } from "~/utils/supported-languages"
|
7 | 4 | import { MoonIcon, SunIcon } from "lucide-react"
|
8 | 5 | import { SearchModeSettings } from "./search-mode"
|
9 | 6 | import { useTranslation } from "react-i18next"
|
10 | 7 | import { useI18n } from "@/hooks/useI18n"
|
11 | 8 | import { TTSModeSettings } from "./tts-mode"
|
12 |
| -import { |
13 |
| - exportPageAssistData, |
14 |
| - importPageAssistData |
15 |
| -} from "@/libs/export-import" |
16 | 9 | import { useStorage } from "@plasmohq/storage/hook"
|
| 10 | +import { SystemSettings } from "./system-settings" |
17 | 11 |
|
18 | 12 | export const GeneralSettings = () => {
|
19 |
| - const { clearChat } = useMessageOption() |
20 | 13 | const [userChatBubble, setUserChatBubble] = useStorage("userChatBubble", true)
|
21 | 14 |
|
22 | 15 | const [speechToTextLanguage, setSpeechToTextLanguage] = useStorage(
|
@@ -59,7 +52,6 @@ export const GeneralSettings = () => {
|
59 | 52 |
|
60 | 53 | const [openReasoning, setOpenReasoning] = useStorage("openReasoning", false)
|
61 | 54 |
|
62 |
| - const queryClient = useQueryClient() |
63 | 55 |
|
64 | 56 | const { mode, toggleDarkMode } = useDarkMode()
|
65 | 57 | const { t } = useTranslation("settings")
|
@@ -272,78 +264,7 @@ export const GeneralSettings = () => {
|
272 | 264 | </div>
|
273 | 265 | <SearchModeSettings />
|
274 | 266 | <TTSModeSettings />
|
275 |
| - <div> |
276 |
| - <div className="mb-5"> |
277 |
| - <h2 className="text-base font-semibold leading-7 text-gray-900 dark:text-white"> |
278 |
| - {t("generalSettings.system.heading")} |
279 |
| - </h2> |
280 |
| - <div className="border border-b border-gray-200 dark:border-gray-600 mt-3"></div> |
281 |
| - </div> |
282 |
| - |
283 |
| - <div className="flex flex-row mb-3 justify-between"> |
284 |
| - <span className="text-gray-700 dark:text-neutral-50 "> |
285 |
| - {t("generalSettings.system.export.label")} |
286 |
| - </span> |
287 |
| - <button |
288 |
| - onClick={exportPageAssistData} |
289 |
| - className="bg-gray-800 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-md cursor-pointer"> |
290 |
| - {t("generalSettings.system.export.button")} |
291 |
| - </button> |
292 |
| - </div> |
293 |
| - <div className="flex flex-row mb-3 justify-between"> |
294 |
| - <span className="text-gray-700 dark:text-neutral-50 "> |
295 |
| - {t("generalSettings.system.import.label")} |
296 |
| - </span> |
297 |
| - <label |
298 |
| - htmlFor="import" |
299 |
| - className="bg-gray-800 dark:bg-white text-white dark:text-gray-900 px-4 py-2 rounded-md cursor-pointer"> |
300 |
| - {t("generalSettings.system.import.button")} |
301 |
| - </label> |
302 |
| - <input |
303 |
| - type="file" |
304 |
| - accept=".json" |
305 |
| - id="import" |
306 |
| - className="hidden" |
307 |
| - onChange={(e) => { |
308 |
| - if (e.target.files) { |
309 |
| - importPageAssistData(e.target.files[0]) |
310 |
| - } |
311 |
| - }} |
312 |
| - /> |
313 |
| - </div> |
314 |
| - |
315 |
| - <div className="flex flex-row mb-3 justify-between"> |
316 |
| - <span className="text-gray-700 dark:text-neutral-50 "> |
317 |
| - {t("generalSettings.system.deleteChatHistory.label")} |
318 |
| - </span> |
319 |
| - |
320 |
| - <button |
321 |
| - onClick={async () => { |
322 |
| - const confirm = window.confirm( |
323 |
| - t("generalSettings.system.deleteChatHistory.confirm") |
324 |
| - ) |
325 |
| - |
326 |
| - if (confirm) { |
327 |
| - const db = new PageAssitDatabase() |
328 |
| - await db.deleteAllChatHistory() |
329 |
| - queryClient.invalidateQueries({ |
330 |
| - queryKey: ["fetchChatHistory"] |
331 |
| - }) |
332 |
| - clearChat() |
333 |
| - try { |
334 |
| - await browser.storage.sync.clear() |
335 |
| - await browser.storage.local.clear() |
336 |
| - await browser.storage.session.clear() |
337 |
| - } catch (e) { |
338 |
| - console.error("Error clearing storage:", e) |
339 |
| - } |
340 |
| - } |
341 |
| - }} |
342 |
| - className="bg-red-500 dark:bg-red-600 text-white dark:text-gray-200 px-4 py-2 rounded-md"> |
343 |
| - {t("generalSettings.system.deleteChatHistory.button")} |
344 |
| - </button> |
345 |
| - </div> |
346 |
| - </div> |
| 267 | + <SystemSettings /> |
347 | 268 | </dl>
|
348 | 269 | )
|
349 | 270 | }
|
0 commit comments