feat: add a startup switch for quick assistant
This commit is contained in:
parent
aecc5fefcf
commit
9c55b4516c
@ -14,6 +14,7 @@ import FileStorage from './services/FileStorage'
|
|||||||
import { GeminiService } from './services/GeminiService'
|
import { GeminiService } from './services/GeminiService'
|
||||||
import KnowledgeService from './services/KnowledgeService'
|
import KnowledgeService from './services/KnowledgeService'
|
||||||
import { registerShortcuts, unregisterAllShortcuts } from './services/ShortcutService'
|
import { registerShortcuts, unregisterAllShortcuts } from './services/ShortcutService'
|
||||||
|
import { TrayService } from './services/TrayService'
|
||||||
import { windowService } from './services/WindowService'
|
import { windowService } from './services/WindowService'
|
||||||
import { compress, decompress } from './utils/zip'
|
import { compress, decompress } from './utils/zip'
|
||||||
|
|
||||||
@ -52,6 +53,8 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
|
|||||||
configManager.setTray(isActive)
|
configManager.setTray(isActive)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
ipcMain.handle('app:restart-tray', () => TrayService.getInstance().restartTray())
|
||||||
|
|
||||||
ipcMain.handle('config:set', (_, key: string, value: any) => {
|
ipcMain.handle('config:set', (_, key: string, value: any) => {
|
||||||
configManager.set(key, value)
|
configManager.set(key, value)
|
||||||
})
|
})
|
||||||
@ -184,4 +187,10 @@ export function registerIpc(mainWindow: BrowserWindow, app: Electron.App) {
|
|||||||
ipcMain.handle('gemini:retrieve-file', GeminiService.retrieveFile)
|
ipcMain.handle('gemini:retrieve-file', GeminiService.retrieveFile)
|
||||||
ipcMain.handle('gemini:list-files', GeminiService.listFiles)
|
ipcMain.handle('gemini:list-files', GeminiService.listFiles)
|
||||||
ipcMain.handle('gemini:delete-file', GeminiService.deleteFile)
|
ipcMain.handle('gemini:delete-file', GeminiService.deleteFile)
|
||||||
|
|
||||||
|
// mini window
|
||||||
|
ipcMain.handle('miniwindow:show', () => windowService.showMiniWindow())
|
||||||
|
ipcMain.handle('miniwindow:hide', () => windowService.hideMiniWindow())
|
||||||
|
ipcMain.handle('miniwindow:close', () => windowService.closeMiniWindow())
|
||||||
|
ipcMain.handle('miniwindow:toggle', () => windowService.toggleMiniWindow())
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,6 +92,14 @@ export class ConfigManager {
|
|||||||
this.store.set('clickTrayToShowQuickAssistant', value)
|
this.store.set('clickTrayToShowQuickAssistant', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getEnableQuickAssistant(): boolean {
|
||||||
|
return this.store.get('enableQuickAssistant', false) as boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
setEnableQuickAssistant(value: boolean) {
|
||||||
|
this.store.set('enableQuickAssistant', value)
|
||||||
|
}
|
||||||
|
|
||||||
set(key: string, value: any) {
|
set(key: string, value: any) {
|
||||||
this.store.set(key, value)
|
this.store.set(key, value)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { isMac } from '@main/constant'
|
import { isMac } from '@main/constant'
|
||||||
import { locales } from '@main/utils/locales'
|
import { locales } from '@main/utils/locales'
|
||||||
import { app, Menu, nativeImage, nativeTheme, Tray } from 'electron'
|
import { app, Menu, MenuItemConstructorOptions, nativeImage, nativeTheme, Tray } from 'electron'
|
||||||
|
|
||||||
import icon from '../../../build/tray_icon.png?asset'
|
import icon from '../../../build/tray_icon.png?asset'
|
||||||
import iconDark from '../../../build/tray_icon_dark.png?asset'
|
import iconDark from '../../../build/tray_icon_dark.png?asset'
|
||||||
@ -9,11 +9,17 @@ import { configManager } from './ConfigManager'
|
|||||||
import { windowService } from './WindowService'
|
import { windowService } from './WindowService'
|
||||||
|
|
||||||
export class TrayService {
|
export class TrayService {
|
||||||
|
private static instance: TrayService
|
||||||
private tray: Tray | null = null
|
private tray: Tray | null = null
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.updateTray()
|
this.updateTray()
|
||||||
this.watchTrayChanges()
|
this.watchTrayChanges()
|
||||||
|
TrayService.instance = this
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getInstance() {
|
||||||
|
return TrayService.instance
|
||||||
}
|
}
|
||||||
|
|
||||||
private createTray() {
|
private createTray() {
|
||||||
@ -40,12 +46,14 @@ export class TrayService {
|
|||||||
const locale = locales[configManager.getLanguage()]
|
const locale = locales[configManager.getLanguage()]
|
||||||
const { tray: trayLocale } = locale.translation
|
const { tray: trayLocale } = locale.translation
|
||||||
|
|
||||||
const contextMenu = Menu.buildFromTemplate([
|
const enableQuickAssistant = configManager.getEnableQuickAssistant()
|
||||||
|
|
||||||
|
const template = [
|
||||||
{
|
{
|
||||||
label: trayLocale.show_window,
|
label: trayLocale.show_window,
|
||||||
click: () => windowService.showMainWindow()
|
click: () => windowService.showMainWindow()
|
||||||
},
|
},
|
||||||
{
|
enableQuickAssistant && {
|
||||||
label: trayLocale.show_mini_window,
|
label: trayLocale.show_mini_window,
|
||||||
click: () => windowService.showMiniWindow()
|
click: () => windowService.showMiniWindow()
|
||||||
},
|
},
|
||||||
@ -54,7 +62,9 @@ export class TrayService {
|
|||||||
label: trayLocale.quit,
|
label: trayLocale.quit,
|
||||||
click: () => this.quit()
|
click: () => this.quit()
|
||||||
}
|
}
|
||||||
])
|
].filter(Boolean) as MenuItemConstructorOptions[]
|
||||||
|
|
||||||
|
const contextMenu = Menu.buildFromTemplate(template)
|
||||||
|
|
||||||
if (process.platform === 'linux') {
|
if (process.platform === 'linux') {
|
||||||
this.tray.setContextMenu(contextMenu)
|
this.tray.setContextMenu(contextMenu)
|
||||||
@ -67,7 +77,7 @@ export class TrayService {
|
|||||||
})
|
})
|
||||||
|
|
||||||
this.tray.on('click', () => {
|
this.tray.on('click', () => {
|
||||||
if (configManager.getClickTrayToShowQuickAssistant()) {
|
if (enableQuickAssistant && configManager.getClickTrayToShowQuickAssistant()) {
|
||||||
windowService.showMiniWindow()
|
windowService.showMiniWindow()
|
||||||
} else {
|
} else {
|
||||||
windowService.showMainWindow()
|
windowService.showMainWindow()
|
||||||
@ -84,6 +94,13 @@ export class TrayService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public restartTray() {
|
||||||
|
if (configManager.getTray()) {
|
||||||
|
this.destroyTray()
|
||||||
|
this.createTray()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private destroyTray() {
|
private destroyTray() {
|
||||||
if (this.tray) {
|
if (this.tray) {
|
||||||
this.tray.destroy()
|
this.tray.destroy()
|
||||||
|
|||||||
@ -67,8 +67,6 @@ export class WindowService {
|
|||||||
|
|
||||||
this.setupMainWindow(this.mainWindow, mainWindowState)
|
this.setupMainWindow(this.mainWindow, mainWindowState)
|
||||||
|
|
||||||
setTimeout(() => this.showMiniWindow(), 5000)
|
|
||||||
|
|
||||||
return this.mainWindow
|
return this.mainWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,6 +239,12 @@ export class WindowService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public showMiniWindow() {
|
public showMiniWindow() {
|
||||||
|
const enableQuickAssistant = configManager.getEnableQuickAssistant()
|
||||||
|
|
||||||
|
if (!enableQuickAssistant) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.selectionMenuWindow) {
|
if (this.selectionMenuWindow) {
|
||||||
this.selectionMenuWindow.hide()
|
this.selectionMenuWindow.hide()
|
||||||
}
|
}
|
||||||
@ -260,7 +264,7 @@ export class WindowService {
|
|||||||
this.miniWindow = new BrowserWindow({
|
this.miniWindow = new BrowserWindow({
|
||||||
width: 500,
|
width: 500,
|
||||||
height: 520,
|
height: 520,
|
||||||
show: false,
|
show: true,
|
||||||
autoHideMenuBar: true,
|
autoHideMenuBar: true,
|
||||||
transparent: isMac,
|
transparent: isMac,
|
||||||
vibrancy: 'under-window',
|
vibrancy: 'under-window',
|
||||||
@ -282,14 +286,6 @@ export class WindowService {
|
|||||||
this.miniWindow?.hide()
|
this.miniWindow?.hide()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.miniWindow.on('close', (event) => {
|
|
||||||
if (this.isQuitting) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
event.preventDefault()
|
|
||||||
this.miniWindow?.hide()
|
|
||||||
})
|
|
||||||
|
|
||||||
this.miniWindow.on('closed', () => {
|
this.miniWindow.on('closed', () => {
|
||||||
this.miniWindow = null
|
this.miniWindow = null
|
||||||
})
|
})
|
||||||
@ -313,9 +309,19 @@ export class WindowService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public hideMiniWindow() {
|
||||||
|
this.miniWindow?.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
public closeMiniWindow() {
|
||||||
|
this.miniWindow?.close()
|
||||||
|
}
|
||||||
|
|
||||||
public toggleMiniWindow() {
|
public toggleMiniWindow() {
|
||||||
if (this.miniWindow) {
|
if (this.miniWindow) {
|
||||||
this.miniWindow.isVisible() ? this.miniWindow.hide() : this.miniWindow.show()
|
this.miniWindow.isVisible() ? this.miniWindow.hide() : this.miniWindow.show()
|
||||||
|
} else {
|
||||||
|
this.showMiniWindow()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
src/preload/index.d.ts
vendored
7
src/preload/index.d.ts
vendored
@ -18,6 +18,7 @@ declare global {
|
|||||||
setProxy: (proxy: string | undefined) => void
|
setProxy: (proxy: string | undefined) => void
|
||||||
setLanguage: (theme: LanguageVarious) => void
|
setLanguage: (theme: LanguageVarious) => void
|
||||||
setTray: (isActive: boolean) => void
|
setTray: (isActive: boolean) => void
|
||||||
|
restartTray: () => void
|
||||||
setTheme: (theme: 'light' | 'dark') => void
|
setTheme: (theme: 'light' | 'dark') => void
|
||||||
minApp: (options: { url: string; windowOptions?: Electron.BrowserWindowConstructorOptions }) => void
|
minApp: (options: { url: string; windowOptions?: Electron.BrowserWindowConstructorOptions }) => void
|
||||||
reload: () => void
|
reload: () => void
|
||||||
@ -96,6 +97,12 @@ declare global {
|
|||||||
set: (key: string, value: any) => Promise<void>
|
set: (key: string, value: any) => Promise<void>
|
||||||
get: (key: string) => Promise<any>
|
get: (key: string) => Promise<any>
|
||||||
}
|
}
|
||||||
|
miniWindow: {
|
||||||
|
show: () => Promise<void>
|
||||||
|
hide: () => Promise<void>
|
||||||
|
close: () => Promise<void>
|
||||||
|
toggle: () => Promise<void>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@ const api = {
|
|||||||
checkForUpdate: () => ipcRenderer.invoke('app:check-for-update'),
|
checkForUpdate: () => ipcRenderer.invoke('app:check-for-update'),
|
||||||
setLanguage: (lang: string) => ipcRenderer.invoke('app:set-language', lang),
|
setLanguage: (lang: string) => ipcRenderer.invoke('app:set-language', lang),
|
||||||
setTray: (isActive: boolean) => ipcRenderer.invoke('app:set-tray', isActive),
|
setTray: (isActive: boolean) => ipcRenderer.invoke('app:set-tray', isActive),
|
||||||
|
restartTray: () => ipcRenderer.invoke('app:restart-tray'),
|
||||||
setTheme: (theme: 'light' | 'dark') => ipcRenderer.invoke('app:set-theme', theme),
|
setTheme: (theme: 'light' | 'dark') => ipcRenderer.invoke('app:set-theme', theme),
|
||||||
openWebsite: (url: string) => ipcRenderer.invoke('open:website', url),
|
openWebsite: (url: string) => ipcRenderer.invoke('open:website', url),
|
||||||
minApp: (url: string) => ipcRenderer.invoke('minapp', url),
|
minApp: (url: string) => ipcRenderer.invoke('minapp', url),
|
||||||
@ -89,6 +90,12 @@ const api = {
|
|||||||
config: {
|
config: {
|
||||||
set: (key: string, value: any) => ipcRenderer.invoke('config:set', key, value),
|
set: (key: string, value: any) => ipcRenderer.invoke('config:set', key, value),
|
||||||
get: (key: string) => ipcRenderer.invoke('config:get', key)
|
get: (key: string) => ipcRenderer.invoke('config:get', key)
|
||||||
|
},
|
||||||
|
miniWindow: {
|
||||||
|
show: () => ipcRenderer.invoke('miniwindow:show'),
|
||||||
|
hide: () => ipcRenderer.invoke('miniwindow:hide'),
|
||||||
|
close: () => ipcRenderer.invoke('miniwindow:close'),
|
||||||
|
toggle: () => ipcRenderer.invoke('miniwindow:toggle')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -387,7 +387,9 @@
|
|||||||
},
|
},
|
||||||
"quickAssistant": {
|
"quickAssistant": {
|
||||||
"title": "Quick Assistant",
|
"title": "Quick Assistant",
|
||||||
"click_tray_to_show": "Click the system tray icon to open"
|
"click_tray_to_show": "Click the tray icon to start",
|
||||||
|
"enable_quick_assistant": "Enable Quick Assistant",
|
||||||
|
"use_shortcut_to_show": "Right-click the tray icon or use shortcuts to start"
|
||||||
},
|
},
|
||||||
"display.title": "Display Settings",
|
"display.title": "Display Settings",
|
||||||
"font_size.title": "Message font size",
|
"font_size.title": "Message font size",
|
||||||
|
|||||||
@ -385,7 +385,9 @@
|
|||||||
},
|
},
|
||||||
"quickAssistant": {
|
"quickAssistant": {
|
||||||
"title": "クイックアシスタント",
|
"title": "クイックアシスタント",
|
||||||
"click_tray_to_show": "システムトレイアイコンをクリックして開く"
|
"click_tray_to_show": "トレイアイコンをクリックして起動",
|
||||||
|
"enable_quick_assistant": "クイックアシスタントを有効にする",
|
||||||
|
"use_shortcut_to_show": "トレイアイコンを右クリックするか、ショートカットキーで起動できます"
|
||||||
},
|
},
|
||||||
"display.title": "表示設定",
|
"display.title": "表示設定",
|
||||||
"font_size.title": "メッセージのフォントサイズ",
|
"font_size.title": "メッセージのフォントサイズ",
|
||||||
|
|||||||
@ -387,7 +387,9 @@
|
|||||||
},
|
},
|
||||||
"quickAssistant": {
|
"quickAssistant": {
|
||||||
"title": "Быстрый помощник",
|
"title": "Быстрый помощник",
|
||||||
"click_tray_to_show": "Нажмите на иконку системного трея для открытия"
|
"click_tray_to_show": "Нажмите на иконку трея для запуска",
|
||||||
|
"enable_quick_assistant": "Включить быстрый помощник",
|
||||||
|
"use_shortcut_to_show": "Нажмите на иконку трея или используйте горячие клавиши для запуска"
|
||||||
},
|
},
|
||||||
"display.title": "Настройки отображения",
|
"display.title": "Настройки отображения",
|
||||||
"font_size.title": "Размер шрифта сообщений",
|
"font_size.title": "Размер шрифта сообщений",
|
||||||
|
|||||||
@ -388,7 +388,9 @@
|
|||||||
},
|
},
|
||||||
"quickAssistant": {
|
"quickAssistant": {
|
||||||
"title": "快捷助手",
|
"title": "快捷助手",
|
||||||
"click_tray_to_show": "点击系统托盘图标打开"
|
"click_tray_to_show": "点击托盘图标启动",
|
||||||
|
"enable_quick_assistant": "启用快捷助手",
|
||||||
|
"use_shortcut_to_show": "右键点击托盘图标或使用快捷键启动"
|
||||||
},
|
},
|
||||||
"display.title": "显示设置",
|
"display.title": "显示设置",
|
||||||
"font_size.title": "消息字体大小",
|
"font_size.title": "消息字体大小",
|
||||||
|
|||||||
@ -387,7 +387,9 @@
|
|||||||
},
|
},
|
||||||
"quickAssistant": {
|
"quickAssistant": {
|
||||||
"title": "快捷助手",
|
"title": "快捷助手",
|
||||||
"click_tray_to_show": "點擊系統托盤圖標打開"
|
"click_tray_to_show": "點擊托盤圖標啟動",
|
||||||
|
"enable_quick_assistant": "啟用快捷助手",
|
||||||
|
"use_shortcut_to_show": "右鍵點擊托盤圖標或使用快捷鍵啟動"
|
||||||
},
|
},
|
||||||
"display.title": "顯示設定",
|
"display.title": "顯示設定",
|
||||||
"font_size.title": "訊息字體大小",
|
"font_size.title": "訊息字體大小",
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
|
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 } from '@renderer/store/settings'
|
import { setClickTrayToShowQuickAssistant, setEnableQuickAssistant } from '@renderer/store/settings'
|
||||||
import HomeWindow from '@renderer/windows/mini/home/HomeWindow'
|
import HomeWindow from '@renderer/windows/mini/home/HomeWindow'
|
||||||
import { Switch } from 'antd'
|
import { Switch, Tooltip } from 'antd'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
@ -13,9 +14,26 @@ 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 { clickTrayToShowQuickAssistant, setTray } = useSettings()
|
const { enableQuickAssistant, clickTrayToShowQuickAssistant, setTray } = useSettings()
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
|
const handleEnableQuickAssistant = async (enable: boolean) => {
|
||||||
|
dispatch(setEnableQuickAssistant(enable))
|
||||||
|
await window.api.config.set('enableQuickAssistant', enable)
|
||||||
|
window.api.restartTray()
|
||||||
|
const disable = !enable
|
||||||
|
disable && window.api.miniWindow.close()
|
||||||
|
|
||||||
|
if (enable && !clickTrayToShowQuickAssistant) {
|
||||||
|
window.message.info({
|
||||||
|
content: t('settings.quickAssistant.use_shortcut_to_show'),
|
||||||
|
duration: 4,
|
||||||
|
icon: <InfoCircleOutlined />,
|
||||||
|
key: 'quick-assistant-info'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleClickTrayToShowQuickAssistant = async (checked: boolean) => {
|
const handleClickTrayToShowQuickAssistant = async (checked: boolean) => {
|
||||||
dispatch(setClickTrayToShowQuickAssistant(checked))
|
dispatch(setClickTrayToShowQuickAssistant(checked))
|
||||||
await window.api.config.set('clickTrayToShowQuickAssistant', checked)
|
await window.api.config.set('clickTrayToShowQuickAssistant', checked)
|
||||||
@ -29,15 +47,31 @@ const QuickAssistantSettings: FC = () => {
|
|||||||
<SettingContainer theme={theme}>
|
<SettingContainer theme={theme}>
|
||||||
<SettingGroup theme={theme}>
|
<SettingGroup theme={theme}>
|
||||||
<SettingTitle>{t('settings.quickAssistant.title')}</SettingTitle>
|
<SettingTitle>{t('settings.quickAssistant.title')}</SettingTitle>
|
||||||
|
<SettingDivider />
|
||||||
|
<SettingRow>
|
||||||
|
<SettingRowTitle style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
||||||
|
<span>{t('settings.quickAssistant.enable_quick_assistant')}</span>
|
||||||
|
<Tooltip title={t('settings.quickAssistant.use_shortcut_to_show')} placement="right">
|
||||||
|
<InfoCircleOutlined style={{ cursor: 'pointer' }} />
|
||||||
|
</Tooltip>
|
||||||
|
</SettingRowTitle>
|
||||||
|
<Switch checked={enableQuickAssistant} onChange={handleEnableQuickAssistant} />
|
||||||
|
</SettingRow>
|
||||||
|
{enableQuickAssistant && (
|
||||||
|
<>
|
||||||
<SettingDivider />
|
<SettingDivider />
|
||||||
<SettingRow>
|
<SettingRow>
|
||||||
<SettingRowTitle>{t('settings.quickAssistant.click_tray_to_show')}</SettingRowTitle>
|
<SettingRowTitle>{t('settings.quickAssistant.click_tray_to_show')}</SettingRowTitle>
|
||||||
<Switch checked={clickTrayToShowQuickAssistant} onChange={handleClickTrayToShowQuickAssistant} />
|
<Switch checked={clickTrayToShowQuickAssistant} onChange={handleClickTrayToShowQuickAssistant} />
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</SettingGroup>
|
</SettingGroup>
|
||||||
<AssistantContainer onClick={() => {}}>
|
{enableQuickAssistant && (
|
||||||
|
<AssistantContainer>
|
||||||
<HomeWindow />
|
<HomeWindow />
|
||||||
</AssistantContainer>
|
</AssistantContainer>
|
||||||
|
)}
|
||||||
</SettingContainer>
|
</SettingContainer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -846,6 +846,8 @@ const migrateConfig = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
state.settings.enableQuickAssistant = false
|
||||||
|
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,7 @@ export interface SettingsState {
|
|||||||
disabled: SidebarIcon[]
|
disabled: SidebarIcon[]
|
||||||
}
|
}
|
||||||
narrowMode: boolean
|
narrowMode: boolean
|
||||||
|
enableQuickAssistant: boolean
|
||||||
clickTrayToShowQuickAssistant: boolean
|
clickTrayToShowQuickAssistant: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,6 +108,7 @@ const initialState: SettingsState = {
|
|||||||
disabled: []
|
disabled: []
|
||||||
},
|
},
|
||||||
narrowMode: false,
|
narrowMode: false,
|
||||||
|
enableQuickAssistant: false,
|
||||||
clickTrayToShowQuickAssistant: false
|
clickTrayToShowQuickAssistant: false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,6 +247,9 @@ const settingsSlice = createSlice({
|
|||||||
},
|
},
|
||||||
setClickTrayToShowQuickAssistant: (state, action: PayloadAction<boolean>) => {
|
setClickTrayToShowQuickAssistant: (state, action: PayloadAction<boolean>) => {
|
||||||
state.clickTrayToShowQuickAssistant = action.payload
|
state.clickTrayToShowQuickAssistant = action.payload
|
||||||
|
},
|
||||||
|
setEnableQuickAssistant: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.enableQuickAssistant = action.payload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -291,7 +296,8 @@ export const {
|
|||||||
setTopicNamingPrompt,
|
setTopicNamingPrompt,
|
||||||
setSidebarIcons,
|
setSidebarIcons,
|
||||||
setNarrowMode,
|
setNarrowMode,
|
||||||
setClickTrayToShowQuickAssistant
|
setClickTrayToShowQuickAssistant,
|
||||||
|
setEnableQuickAssistant
|
||||||
} = settingsSlice.actions
|
} = settingsSlice.actions
|
||||||
|
|
||||||
export default settingsSlice.reducer
|
export default settingsSlice.reducer
|
||||||
|
|||||||
@ -34,8 +34,6 @@ const HomeWindow: FC = () => {
|
|||||||
|
|
||||||
textRef.current = `${referenceText}\n\n${text}`
|
textRef.current = `${referenceText}\n\n${text}`
|
||||||
|
|
||||||
const isMiniWindow = window.location.hash === '#/mini'
|
|
||||||
|
|
||||||
const onReadClipboard = useCallback(async () => {
|
const onReadClipboard = useCallback(async () => {
|
||||||
const text = await navigator.clipboard.readText()
|
const text = await navigator.clipboard.readText()
|
||||||
setClipboardText(text.trim())
|
setClipboardText(text.trim())
|
||||||
@ -49,7 +47,7 @@ const HomeWindow: FC = () => {
|
|||||||
i18n.changeLanguage(language || navigator.language || 'en-US')
|
i18n.changeLanguage(language || navigator.language || 'en-US')
|
||||||
}, [language])
|
}, [language])
|
||||||
|
|
||||||
const onCloseWindow = () => isMiniWindow && window.close()
|
const onCloseWindow = () => window.api.miniWindow.hide()
|
||||||
|
|
||||||
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
if (e.key === 'Escape') {
|
if (e.key === 'Escape') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user