File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,6 +39,12 @@ window.rubick = {
3939 openPlugin ( plugin ) {
4040 ipcSendSync ( 'loadPlugin' , plugin ) ;
4141 } ,
42+ onShow ( cb ) {
43+ typeof cb === 'function' && ( window . rubick . hooks . onShow = cb ) ;
44+ } ,
45+ onHide ( cb ) {
46+ typeof cb === 'function' && ( window . rubick . hooks . onHide = cb ) ;
47+ } ,
4248 // 窗口交互
4349 hideMainWindow ( ) {
4450 ipcSendSync ( 'hideMainWindow' ) ;
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ export default () => {
5959 } ) ;
6060
6161 win . on ( 'show' , ( ) => {
62+ // 触发主窗口的 onShow hook
6263 win . webContents . executeJavaScript (
6364 `window.rubick && window.rubick.hooks && typeof window.rubick.hooks.onShow === "function" && window.rubick.hooks.onShow()`
6465 ) ;
@@ -67,6 +68,7 @@ export default () => {
6768 } ) ;
6869
6970 win . on ( 'hide' , ( ) => {
71+ // 触发主窗口的 onHide hook
7072 win . webContents . executeJavaScript (
7173 `window.rubick && window.rubick.hooks && typeof window.rubick.hooks.onHide === "function" && window.rubick.hooks.onHide()`
7274 ) ;
Original file line number Diff line number Diff line change @@ -68,6 +68,20 @@ class API extends DBInstance {
6868 mainWindow . webContents . on ( 'before-input-event' , ( event , input ) =>
6969 this . __EscapeKeyDown ( event , input , mainWindow )
7070 ) ;
71+ // 设置主窗口的 show/hide 事件监听
72+ this . setupMainWindowHooks ( mainWindow ) ;
73+ }
74+
75+ private setupMainWindowHooks ( mainWindow : BrowserWindow ) {
76+ mainWindow . on ( 'show' , ( ) => {
77+ // 触发插件的 onShow hook
78+ runnerInstance . executeHooks ( 'Show' , null ) ;
79+ } ) ;
80+
81+ mainWindow . on ( 'hide' , ( ) => {
82+ // 触发插件的 onHide hook
83+ runnerInstance . executeHooks ( 'Hide' , null ) ;
84+ } ) ;
7185 }
7286
7387 public getCurrentWindow = ( window , e ) => {
You can’t perform that action at this time.
0 commit comments