@@ -47,13 +47,14 @@ window.__page.onPluginInit((data: {
4747 alwaysOnTop: boolean
4848 }
4949}) => {
50- // console.log('main.onPluginInit', data)
50+ console .log (' main.onPluginInit' , data )
5151 manager .setActivePlugin (data .plugin )
5252 manager .setSubInput ({
5353 placeholder: ' ' ,
5454 isFocus: false ,
5555 })
5656 manager .setSubInputValue (' ' )
57+ mainSearch .value ?.focus ()
5758})
5859window .__page .onPluginAlreadyOpened (() => {
5960 // console.log('main.onPluginAlreadyOpened')
@@ -97,7 +98,38 @@ window.__page.onSetSubInputValue((value: string) => {
9798 manager .setSubInputValue (value );
9899})
99100
101+ let detachHotKey: any = null
102+ let detachHotkeyExpire = 0
103+ let detachHotkeyTimes = 0
100104window .addEventListener (' keydown' , (e ) => {
105+ if (! detachHotKey ) {
106+ detachHotKey = manager .configGet (' detachWindowTrigger' , null )
107+ }
108+ // console.log('keydown', detachHotKey.value, detachHotkeyExpire)
109+ // {"key":"D","altKey":false,"ctrlKey":false,"metaKey":true,"shiftKey":false,"times":1}
110+ if (detachHotKey && detachHotKey .value ) {
111+ // console.log('detachHotkeyExpire', detachHotKey.value.key, detachHotkeyExpire)
112+ if (
113+ detachHotKey .value .key === e .key .toUpperCase ()
114+ && detachHotKey .value .altKey === e .altKey
115+ && detachHotKey .value .ctrlKey === e .ctrlKey
116+ && detachHotKey .value .metaKey === e .metaKey
117+ && detachHotKey .value .shiftKey === e .shiftKey
118+ ) {
119+ if (! detachHotkeyExpire || Date .now () > detachHotkeyExpire ) {
120+ detachHotkeyExpire = Date .now () + 500
121+ detachHotkeyTimes = 1
122+ } else {
123+ detachHotkeyTimes ++
124+ }
125+ if (detachHotkeyTimes >= detachHotKey .value .times ) {
126+ detachHotkeyExpire = 0
127+ detachHotkeyTimes = 0
128+ manager .detachPlugin ()
129+ return
130+ }
131+ }
132+ }
101133 if (! manager .activePlugin ) {
102134 mainSearch .value ?.onKeyDown (e )
103135 }
0 commit comments