Skip to content

Commit

Permalink
Merge pull request #2 from vuongle2609/update-editor
Browse files Browse the repository at this point in the history
Update editor
  • Loading branch information
vuongle2609 authored Apr 1, 2024
2 parents 1bf8366 + b852b3e commit e831215
Show file tree
Hide file tree
Showing 37 changed files with 1,575 additions and 410 deletions.
2 changes: 1 addition & 1 deletion electron-builder.json5
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/master/packages/app-builder-lib/scheme.json",
"appId": "YourAppID",
"asar": true,
"productName": "YourAppName",
"productName": "Dori",
"directories": {
"output": "release/${version}"
},
Expand Down
31 changes: 26 additions & 5 deletions electron/main.ts
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
//
Expand All @@ -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",
Expand All @@ -38,7 +41,7 @@ function createWindow() {
webSecurity: false,
},
});

// win.setMenu(null);
win.maximize();

remoteMain.enable(win.webContents);
Expand All @@ -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
Expand All @@ -62,7 +67,7 @@ function createWindow() {
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
win = null;
wins = {};
}
});

Expand All @@ -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);
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
<title>Dori</title>
</head>
<body>
<div id="app"></div>
Expand Down
1 change: 1 addition & 0 deletions note.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
choco install visualstudio2019buildtools visualstudio2019-workload-vctools
Loading

0 comments on commit e831215

Please sign in to comment.