feat(quick-assistant): Add setting - Auto-paste to Quick Assistant (#3484)
* feat(quick-assistant): Add setting - Auto-paste to Quick Assistant * refactor(quick-assistant): Rename `auto_paste_to_quick_assistant` to `read_clipboard_at_startup` - Rename the "auto_paste_to_quick_assistant" feature to "read_clipboard_at_startup"
This commit is contained in:
parent
2d1ab70818
commit
d22a101fd1
@ -984,7 +984,8 @@
|
||||
"click_tray_to_show": "Click the tray icon to start",
|
||||
"enable_quick_assistant": "Enable Quick Assistant",
|
||||
"title": "Quick Assistant",
|
||||
"use_shortcut_to_show": "Right-click the tray icon or use shortcuts to start"
|
||||
"use_shortcut_to_show": "Right-click the tray icon or use shortcuts to start",
|
||||
"read_clipboard_at_startup": "Read clipboard at startup"
|
||||
},
|
||||
"shortcuts": {
|
||||
"action": "Action",
|
||||
|
||||
@ -984,7 +984,8 @@
|
||||
"click_tray_to_show": "トレイアイコンをクリックして起動",
|
||||
"enable_quick_assistant": "クイックアシスタントを有効にする",
|
||||
"title": "クイックアシスタント",
|
||||
"use_shortcut_to_show": "トレイアイコンを右クリックするか、ショートカットキーで起動できます"
|
||||
"use_shortcut_to_show": "トレイアイコンを右クリックするか、ショートカットキーで起動できます",
|
||||
"read_clipboard_at_startup": "起動時にクリップボードを読み取る"
|
||||
},
|
||||
"shortcuts": {
|
||||
"action": "操作",
|
||||
|
||||
@ -984,7 +984,8 @@
|
||||
"click_tray_to_show": "Нажмите на иконку трея для запуска",
|
||||
"enable_quick_assistant": "Включить быстрый помощник",
|
||||
"title": "Быстрый помощник",
|
||||
"use_shortcut_to_show": "Нажмите на иконку трея или используйте горячие клавиши для запуска"
|
||||
"use_shortcut_to_show": "Нажмите на иконку трея или используйте горячие клавиши для запуска",
|
||||
"read_clipboard_at_startup": "Чтение буфера обмена при запуске"
|
||||
},
|
||||
"shortcuts": {
|
||||
"action": "Действие",
|
||||
|
||||
@ -984,7 +984,8 @@
|
||||
"click_tray_to_show": "点击托盘图标启动",
|
||||
"enable_quick_assistant": "启用快捷助手",
|
||||
"title": "快捷助手",
|
||||
"use_shortcut_to_show": "右键点击托盘图标或使用快捷键启动"
|
||||
"use_shortcut_to_show": "右键点击托盘图标或使用快捷键启动",
|
||||
"read_clipboard_at_startup": "启动时读取剪贴板"
|
||||
},
|
||||
"shortcuts": {
|
||||
"action": "操作",
|
||||
|
||||
@ -984,7 +984,8 @@
|
||||
"click_tray_to_show": "點選工具列圖示啟動",
|
||||
"enable_quick_assistant": "啟用快捷助手",
|
||||
"title": "快捷助手",
|
||||
"use_shortcut_to_show": "右鍵點選工具列圖示或使用快捷鍵啟動"
|
||||
"use_shortcut_to_show": "右鍵點選工具列圖示或使用快捷鍵啟動",
|
||||
"read_clipboard_at_startup": "啟動時讀取剪貼簿"
|
||||
},
|
||||
"shortcuts": {
|
||||
"action": "操作",
|
||||
|
||||
@ -2,7 +2,11 @@ import { InfoCircleOutlined } from '@ant-design/icons'
|
||||
import { useTheme } from '@renderer/context/ThemeProvider'
|
||||
import { useSettings } from '@renderer/hooks/useSettings'
|
||||
import { useAppDispatch } from '@renderer/store'
|
||||
import { setClickTrayToShowQuickAssistant, setEnableQuickAssistant } from '@renderer/store/settings'
|
||||
import {
|
||||
setClickTrayToShowQuickAssistant,
|
||||
setEnableQuickAssistant,
|
||||
setReadClipboardAtStartup
|
||||
} from '@renderer/store/settings'
|
||||
import HomeWindow from '@renderer/windows/mini/home/HomeWindow'
|
||||
import { Switch, Tooltip } from 'antd'
|
||||
import { FC } from 'react'
|
||||
@ -14,7 +18,7 @@ import { SettingContainer, SettingDivider, SettingGroup, SettingRow, SettingRowT
|
||||
const QuickAssistantSettings: FC = () => {
|
||||
const { t } = useTranslation()
|
||||
const { theme } = useTheme()
|
||||
const { enableQuickAssistant, clickTrayToShowQuickAssistant, setTray } = useSettings()
|
||||
const { enableQuickAssistant, clickTrayToShowQuickAssistant, setTray, readClipboardAtStartup } = useSettings()
|
||||
const dispatch = useAppDispatch()
|
||||
|
||||
const handleEnableQuickAssistant = async (enable: boolean) => {
|
||||
@ -44,6 +48,12 @@ const QuickAssistantSettings: FC = () => {
|
||||
checked && setTray(true)
|
||||
}
|
||||
|
||||
const handleClickReadClipboardAtStartup = async (checked: boolean) => {
|
||||
dispatch(setReadClipboardAtStartup(checked))
|
||||
await window.api.config.set('readClipboardAtStartup', checked)
|
||||
window.api.miniWindow.close()
|
||||
}
|
||||
|
||||
return (
|
||||
<SettingContainer theme={theme}>
|
||||
<SettingGroup theme={theme}>
|
||||
@ -67,6 +77,15 @@ const QuickAssistantSettings: FC = () => {
|
||||
</SettingRow>
|
||||
</>
|
||||
)}
|
||||
{enableQuickAssistant && (
|
||||
<>
|
||||
<SettingDivider />
|
||||
<SettingRow>
|
||||
<SettingRowTitle>{t('settings.quickAssistant.read_clipboard_at_startup')}</SettingRowTitle>
|
||||
<Switch checked={readClipboardAtStartup} onChange={handleClickReadClipboardAtStartup} />
|
||||
</SettingRow>
|
||||
</>
|
||||
)}
|
||||
</SettingGroup>
|
||||
{enableQuickAssistant && (
|
||||
<AssistantContainer>
|
||||
|
||||
@ -66,9 +66,11 @@ export interface SettingsState {
|
||||
disabled: SidebarIcon[]
|
||||
}
|
||||
narrowMode: boolean
|
||||
// QuickAssistant
|
||||
enableQuickAssistant: boolean
|
||||
clickTrayToShowQuickAssistant: boolean
|
||||
multiModelMessageStyle: MultiModelMessageStyle
|
||||
readClipboardAtStartup: boolean
|
||||
notionDatabaseID: string | null
|
||||
notionApiKey: string | null
|
||||
notionPageNameKey: string | null
|
||||
@ -135,6 +137,7 @@ const initialState: SettingsState = {
|
||||
narrowMode: false,
|
||||
enableQuickAssistant: false,
|
||||
clickTrayToShowQuickAssistant: false,
|
||||
readClipboardAtStartup: true,
|
||||
multiModelMessageStyle: 'fold',
|
||||
notionDatabaseID: '',
|
||||
notionApiKey: '',
|
||||
@ -304,6 +307,9 @@ const settingsSlice = createSlice({
|
||||
setEnableQuickAssistant: (state, action: PayloadAction<boolean>) => {
|
||||
state.enableQuickAssistant = action.payload
|
||||
},
|
||||
setReadClipboardAtStartup: (state, action: PayloadAction<boolean>) => {
|
||||
state.readClipboardAtStartup = action.payload
|
||||
},
|
||||
setMultiModelMessageStyle: (state, action: PayloadAction<'horizontal' | 'vertical' | 'fold' | 'grid'>) => {
|
||||
state.multiModelMessageStyle = action.payload
|
||||
},
|
||||
@ -395,6 +401,7 @@ export const {
|
||||
setNarrowMode,
|
||||
setClickTrayToShowQuickAssistant,
|
||||
setEnableQuickAssistant,
|
||||
setReadClipboardAtStartup,
|
||||
setMultiModelMessageStyle,
|
||||
setNotionDatabaseID,
|
||||
setNotionApiKey,
|
||||
|
||||
@ -29,7 +29,7 @@ const HomeWindow: FC = () => {
|
||||
const textChange = useState(() => {})[1]
|
||||
const { defaultAssistant } = useDefaultAssistant()
|
||||
const { defaultModel: model } = useDefaultModel()
|
||||
const { language } = useSettings()
|
||||
const { language, readClipboardAtStartup } = useSettings()
|
||||
const { t } = useTranslation()
|
||||
const inputBarRef = useRef<HTMLDivElement>(null)
|
||||
const featureMenusRef = useRef<FeatureMenusRef>(null)
|
||||
@ -39,12 +39,14 @@ const HomeWindow: FC = () => {
|
||||
const content = isFirstMessage ? (referenceText === text ? text : `${referenceText}\n\n${text}`).trim() : text.trim()
|
||||
|
||||
const readClipboard = useCallback(async () => {
|
||||
if (!readClipboardAtStartup) return
|
||||
|
||||
const text = await navigator.clipboard.readText().catch(() => null)
|
||||
if (text && text !== lastClipboardText) {
|
||||
setLastClipboardText(text)
|
||||
setClipboardText(text.trim())
|
||||
}
|
||||
}, [lastClipboardText])
|
||||
}, [readClipboardAtStartup, lastClipboardText])
|
||||
|
||||
const focusInput = () => {
|
||||
if (inputBarRef.current) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user