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