chore: small update/fixes for quick ask window (#2279)

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
This commit is contained in:
NamH 2024-03-08 15:01:04 +07:00 committed by GitHub
parent e22fdec230
commit 3320162ea9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 8 deletions

View File

@ -1,4 +1,4 @@
import { app, BrowserWindow, globalShortcut, Menu, Tray } from 'electron' import { app, BrowserWindow, Menu, Tray } from 'electron'
import { join } from 'path' import { join } from 'path'
/** /**
@ -106,9 +106,6 @@ function createMainWindow() {
} }
function registerGlobalShortcuts() { function registerGlobalShortcuts() {
// TODO: Toggle below line when build production
// const ret = globalShortcut.register(quickAskHotKey, () => {
// const selectedText = ''
const ret = registerShortcut(quickAskHotKey, (selectedText: string) => { const ret = registerShortcut(quickAskHotKey, (selectedText: string) => {
if (!windowManager.isQuickAskWindowVisible()) { if (!windowManager.isQuickAskWindowVisible()) {
windowManager.showQuickAskWindow() windowManager.showQuickAskWindow()

View File

@ -6,7 +6,16 @@ export const quickAskWindowConfig: Electron.BrowserWindowConstructorOptions = {
width: DEFAULT_WIDTH, width: DEFAULT_WIDTH,
height: DEFAULT_HEIGHT, height: DEFAULT_HEIGHT,
skipTaskbar: true, skipTaskbar: true,
acceptFirstMouse: true,
hasShadow: true,
alwaysOnTop: true,
show: false,
fullscreenable: false,
resizable: false, resizable: false,
center: true,
movable: false,
maximizable: false,
focusable: true,
transparent: true, transparent: true,
frame: false, frame: false,
type: 'panel', type: 'panel',

View File

@ -64,7 +64,6 @@ class WindowManager {
this._quickAskWindow.on('blur', () => { this._quickAskWindow.on('blur', () => {
this.hideQuickAskWindow() this.hideQuickAskWindow()
}) })
this.hideQuickAskWindow()
} }
isMainWindowVisible(): boolean { isMainWindowVisible(): boolean {

View File

@ -18,10 +18,10 @@ const UserInput: React.FC = () => {
const selectedText = useAtomValue(selectedTextAtom) const selectedText = useAtomValue(selectedTextAtom)
useEffect(() => { useEffect(() => {
if (inputRef.current) { inputRef.current?.focus()
inputRef.current.focus() })
}
useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => { const onKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Escape') { if (e.key === 'Escape') {
window.core?.api?.hideQuickAskWindow() window.core?.api?.hideQuickAskWindow()