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'
/**
@ -106,9 +106,6 @@ function createMainWindow() {
}
function registerGlobalShortcuts() {
// TODO: Toggle below line when build production
// const ret = globalShortcut.register(quickAskHotKey, () => {
// const selectedText = ''
const ret = registerShortcut(quickAskHotKey, (selectedText: string) => {
if (!windowManager.isQuickAskWindowVisible()) {
windowManager.showQuickAskWindow()

View File

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

View File

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

View File

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