Skip to content

Commit ec206c5

Browse files
committed
support close action from studio
1 parent 9efac5f commit ec206c5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

electron/main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function createDatabaseWindow(conn: ConnectionStoreItem) {
6262
show: false,
6363
width: 1024,
6464
height: 768,
65-
// autoHideMenuBar: true,
65+
autoHideMenuBar: true,
6666
webPreferences: {
6767
devTools: true,
6868
additionalArguments: ["--database=" + conn.id],
@@ -74,7 +74,7 @@ function createDatabaseWindow(conn: ConnectionStoreItem) {
7474

7575
const queryString = new URLSearchParams({ name: conn.name }).toString();
7676

77-
dbWindow.on("close", () => {
77+
dbWindow.on("closed", () => {
7878
win?.show();
7979
ConnectionPool.close(conn.id);
8080
});
@@ -200,6 +200,12 @@ ipcMain.handle(
200200
},
201201
);
202202

203+
ipcMain.handle("close", async (sender) => {
204+
sender.sender.close({
205+
waitForBeforeUnload: true,
206+
});
207+
});
208+
203209
ipcMain.handle("connect", (_, conn: ConnectionStoreItem) => {
204210
createDatabaseWindow(conn);
205211
if (win) win.hide();

electron/preload.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ const outerbaseIpc = {
4646
return ipcRenderer.invoke("transaction", connectionId, statements);
4747
},
4848

49+
close() {
50+
return ipcRenderer.invoke("close");
51+
},
52+
4953
connect(conn: ConnectionStoreItem) {
5054
return ipcRenderer.invoke("connect", conn);
5155
},

0 commit comments

Comments
 (0)