@@ -23,6 +23,18 @@ router.post('/resize', (req, res) => {
23
23
( _a = state . windows [ id ] ) === null || _a === void 0 ? void 0 : _a . setSize ( parseInt ( width ) , parseInt ( height ) ) ;
24
24
res . sendStatus ( 200 ) ;
25
25
} ) ;
26
+ router . post ( '/title' , ( req , res ) => {
27
+ var _a ;
28
+ const { id, title } = req . body ;
29
+ ( _a = state . windows [ id ] ) === null || _a === void 0 ? void 0 : _a . setTitle ( title ) ;
30
+ res . sendStatus ( 200 ) ;
31
+ } ) ;
32
+ router . post ( '/url' , ( req , res ) => {
33
+ var _a ;
34
+ const { id, url } = req . body ;
35
+ ( _a = state . windows [ id ] ) === null || _a === void 0 ? void 0 : _a . loadURL ( url ) ;
36
+ res . sendStatus ( 200 ) ;
37
+ } ) ;
26
38
router . post ( '/position' , ( req , res ) => {
27
39
var _a ;
28
40
const { id, x, y, animate } = req . body ;
@@ -50,25 +62,54 @@ router.post('/hide', (req, res) => {
50
62
}
51
63
return res . sendStatus ( 200 ) ;
52
64
} ) ;
65
+ router . post ( '/always-on-top' , ( req , res ) => {
66
+ var _a ;
67
+ const { id, alwaysOnTop } = req . body ;
68
+ ( _a = state . windows [ id ] ) === null || _a === void 0 ? void 0 : _a . setAlwaysOnTop ( alwaysOnTop ) ;
69
+ res . sendStatus ( 200 ) ;
70
+ } ) ;
53
71
router . get ( '/current' , ( req , res ) => {
54
72
const currentWindow = Object . values ( state . windows ) . find ( window => window . id === BrowserWindow . getFocusedWindow ( ) . id ) ;
55
73
const id = Object . keys ( state . windows ) . find ( key => state . windows [ key ] === currentWindow ) ;
56
- res . json ( {
74
+ res . json ( getWindowData ( id ) ) ;
75
+ } ) ;
76
+ router . get ( '/get/:id' , ( req , res ) => {
77
+ const { id } = req . params ;
78
+ if ( state . windows [ id ] === undefined ) {
79
+ res . sendStatus ( 404 ) ;
80
+ return ;
81
+ }
82
+ res . json ( getWindowData ( id ) ) ;
83
+ } ) ;
84
+ function getWindowData ( id ) {
85
+ const currentWindow = state . windows [ id ] ;
86
+ if ( state . windows [ id ] === undefined ) {
87
+ throw `Window [${ id } ] not found` ;
88
+ }
89
+ return {
57
90
id : id ,
58
91
x : currentWindow . getPosition ( ) [ 0 ] ,
59
92
y : currentWindow . getPosition ( ) [ 1 ] ,
60
93
width : currentWindow . getSize ( ) [ 0 ] ,
61
94
height : currentWindow . getSize ( ) [ 1 ] ,
62
95
title : currentWindow . getTitle ( ) ,
63
96
alwaysOnTop : currentWindow . isAlwaysOnTop ( ) ,
64
- } ) ;
65
- } ) ;
66
- router . post ( '/always-on-top' , ( req , res ) => {
67
- var _a ;
68
- const { id, alwaysOnTop } = req . body ;
69
- ( _a = state . windows [ id ] ) === null || _a === void 0 ? void 0 : _a . setAlwaysOnTop ( alwaysOnTop ) ;
70
- res . sendStatus ( 200 ) ;
71
- } ) ;
97
+ url : currentWindow . webContents . getURL ( ) ,
98
+ autoHideMenuBar : currentWindow . isMenuBarAutoHide ( ) ,
99
+ fullscreen : currentWindow . isFullScreen ( ) ,
100
+ fullscreenable : currentWindow . isFullScreenable ( ) ,
101
+ kiosk : currentWindow . isKiosk ( ) ,
102
+ showDevTools : currentWindow . webContents . isDevToolsOpened ( ) ,
103
+ resizable : currentWindow . isResizable ( ) ,
104
+ movable : currentWindow . isMovable ( ) ,
105
+ minimizable : currentWindow . isMinimizable ( ) ,
106
+ maximizable : currentWindow . isMaximizable ( ) ,
107
+ closable : currentWindow . isClosable ( ) ,
108
+ focusable : currentWindow . isFocusable ( ) ,
109
+ focused : currentWindow . isFocused ( ) ,
110
+ hasShadow : currentWindow . hasShadow ( ) ,
111
+ } ;
112
+ }
72
113
router . post ( '/open' , ( req , res ) => {
73
114
let { id, x, y, frame, width, height, minWidth, minHeight, maxWidth, maxHeight, focusable, hasShadow, url, resizable, movable, minimizable, maximizable, closable, title, alwaysOnTop, titleBarStyle, trafficLightPosition, vibrancy, backgroundColor, transparency, showDevTools, fullscreen, fullscreenable, kiosk, autoHideMenuBar, } = req . body ;
74
115
if ( state . windows [ id ] ) {
0 commit comments