11import { FC , PropsWithChildren , useCallback , useEffect , useState } from 'react'
22import toast , { Toaster } from 'react-hot-toast'
33import { useTranslation } from 'react-i18next'
4- import { BiExport , BiImport } from 'react-icons/bi'
54import Browser from 'webextension-polyfill'
6- import Button , { MotionButton } from '~app/components/Button'
5+ import { MotionButton } from '~app/components/Button'
76import { Input } from '~app/components/Input'
87import RadioGroup from '~app/components/RadioGroup'
98import Select from '~app/components/Select'
@@ -18,10 +17,10 @@ import ClaudeOpenRouterSettings from '~app/components/Settings/ClaudeOpenRouterS
1817import ClaudePoeSettings from '~app/components/Settings/ClaudePoeSettings'
1918import ClaudeWebappSettings from '~app/components/Settings/ClaudeWebappSettings'
2019import EnabledBotsSettings from '~app/components/Settings/EnabledBotsSettings'
21- import KDB from '~app/components/Settings/KDB '
20+ import ExportDataPanel from '~app/components/Settings/ExportDataPanel '
2221import PerplexityAPISettings from '~app/components/Settings/PerplexityAPISettings'
22+ import ShortcutPanel from '~app/components/Settings/ShortcutPanel'
2323import { ALL_IN_ONE_PAGE_ID , CHATBOTS } from '~app/consts'
24- import { exportData , importData } from '~app/utils/export'
2524import {
2625 BingConversationStyle ,
2726 ChatGPTMode ,
@@ -49,56 +48,6 @@ const ChatBotSettingPanel: FC<PropsWithChildren<{ title: string }>> = (props) =>
4948 )
5049}
5150
52- function ExportDataPanel ( ) {
53- const { t } = useTranslation ( )
54- return (
55- < div >
56- < p className = "font-bold mb-1 text-lg" > { t ( 'Export/Import All Data' ) } </ p >
57- < p className = "mb-3 opacity-80" > { t ( 'Data includes all your settings, chat histories, and local prompts' ) } </ p >
58- < div className = "flex flex-row gap-3" >
59- < Button size = "small" text = { t ( 'Export' ) } icon = { < BiExport /> } onClick = { exportData } />
60- < Button size = "small" text = { t ( 'Import' ) } icon = { < BiImport /> } onClick = { importData } />
61- </ div >
62- </ div >
63- )
64- }
65-
66- function ShortcutPanel ( ) {
67- const [ shortcuts , setShortcuts ] = useState < string [ ] > ( [ ] )
68- const { t } = useTranslation ( )
69-
70- useEffect ( ( ) => {
71- Browser . commands . getAll ( ) . then ( ( commands ) => {
72- for ( const c of commands ) {
73- if ( c . name === 'open-app' && c . shortcut ) {
74- console . debug ( c . shortcut )
75- setShortcuts ( c . shortcut ? [ c . shortcut ] : [ ] )
76- }
77- }
78- } )
79- } , [ ] )
80-
81- return (
82- < div className = "flex flex-col gap-2" >
83- < p className = "font-bold text-lg" > { t ( 'Shortcut to open this app' ) } </ p >
84- < div className = "flex flex-row gap-2 items-center" >
85- { shortcuts . length > 0 && (
86- < div className = "flex flex-row gap-1" >
87- { shortcuts . map ( ( s ) => (
88- < KDB key = { s } text = { s } />
89- ) ) }
90- </ div >
91- ) }
92- < Button
93- text = { t ( 'Change shortcut' ) }
94- size = "small"
95- onClick = { ( ) => Browser . tabs . create ( { url : 'chrome://extensions/shortcuts' } ) }
96- />
97- </ div >
98- </ div >
99- )
100- }
101-
10251function SettingPage ( ) {
10352 const { t } = useTranslation ( )
10453 const [ userConfig , setUserConfig ] = useState < UserConfig | undefined > ( undefined )
0 commit comments