-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from vuongle2609/update-editor
Update editor
- Loading branch information
Showing
37 changed files
with
1,575 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { app, BrowserWindow } from "electron"; | ||
import { app, BrowserWindow, globalShortcut } from "electron"; | ||
import * as remoteMain from "@electron/remote/main"; | ||
import path from "node:path"; | ||
import { ipcMain } from "electron"; | ||
|
||
// The built directory structure | ||
// | ||
|
@@ -16,18 +17,20 @@ process.env.VITE_PUBLIC = app.isPackaged | |
? process.env.DIST | ||
: path.join(process.env.DIST, "../public"); | ||
|
||
let win: BrowserWindow | null; | ||
let wins: Record<string, BrowserWindow> = {}; | ||
|
||
// 🚧 Use ['ENV_NAME'] avoid vite:define plugin - [email protected] | ||
const VITE_DEV_SERVER_URL = process.env["VITE_DEV_SERVER_URL"]; | ||
|
||
remoteMain.initialize(); | ||
|
||
function createWindow() { | ||
win = new BrowserWindow({ | ||
const win = new BrowserWindow({ | ||
icon: path.join(process.env.VITE_PUBLIC, "electron-vite.svg"), | ||
minWidth: 1024, | ||
minHeight: 720, | ||
autoHideMenuBar: true, | ||
title: "Dori", | ||
// frame: false, | ||
webPreferences: { | ||
preload: "preload.js", | ||
|
@@ -38,7 +41,7 @@ function createWindow() { | |
webSecurity: false, | ||
}, | ||
}); | ||
|
||
// win.setMenu(null); | ||
win.maximize(); | ||
|
||
remoteMain.enable(win.webContents); | ||
|
@@ -54,6 +57,8 @@ function createWindow() { | |
// win.loadFile('dist/index.html') | ||
win.loadFile(path.join(process.env.DIST, "index.html")); | ||
} | ||
|
||
wins[win.id] = win; | ||
} | ||
|
||
// Quit when all windows are closed, except on macOS. There, it's common | ||
|
@@ -62,7 +67,7 @@ function createWindow() { | |
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
win = null; | ||
wins = {}; | ||
} | ||
}); | ||
|
||
|
@@ -74,4 +79,20 @@ app.on("activate", () => { | |
} | ||
}); | ||
|
||
ipcMain.on("asynchronous-message", function (evt, message) { | ||
if (message == "createNewWindow") { | ||
createWindow(); | ||
} | ||
|
||
if (message == "quitCurrentWindow") { | ||
wins[evt.sender.id].close(); | ||
} | ||
}); | ||
|
||
// app.on("ready", () => { | ||
// globalShortcut.register("CommandOrControl+W", () => { | ||
// //stuff here | ||
// }); | ||
// }); | ||
|
||
app.whenReady().then(createWindow); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
choco install visualstudio2019buildtools visualstudio2019-workload-vctools |
Oops, something went wrong.