-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71f7737
commit 318169a
Showing
15 changed files
with
200 additions
and
88 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"appId": "cc.hellowmonkey.tool", | ||
"productName": "沃德工具箱", | ||
"copyright": "2022", | ||
"directories": { | ||
"output": "release/${version}", | ||
"buildResources": "electron/resource" | ||
}, | ||
"win": { | ||
"icon": "electron/image/logo.png", | ||
"target": "nsis", | ||
"legalTrademarks": "hellowmonkey", | ||
"artifactName": "${productName}-Windows-${version}-Setup.${ext}" | ||
}, | ||
"nsis": { | ||
"oneClick": false, | ||
"perMachine": true, | ||
"allowToChangeInstallationDirectory": true, | ||
"createDesktopShortcut": true, | ||
"createStartMenuShortcut": false | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
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,3 @@ | ||
export function compressImage() { | ||
return Promise.resolve("hahaha"); | ||
} |
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,83 @@ | ||
import { app, BrowserWindow, ipcMain } from "electron"; | ||
import { join } from "path"; | ||
import { compressImage } from "./image"; | ||
|
||
const width = 1200; | ||
const height = 800; | ||
const title = "沃德工具箱"; | ||
const icon = join(__dirname, "../resource/image/logo.png"); | ||
|
||
function createWindow() { | ||
const win = new BrowserWindow({ | ||
width, | ||
height, | ||
minWidth: width, | ||
minHeight: height, | ||
title, | ||
transparent: true, | ||
frame: false, | ||
autoHideMenuBar: true, | ||
backgroundColor: "#ffffff", | ||
webPreferences: { | ||
preload: join(__dirname, "../preload/index.js"), | ||
}, | ||
show: false, | ||
}); | ||
|
||
win.loadURL("http://127.0.0.1:3030").then(() => { | ||
win.maximize(); | ||
}); | ||
|
||
const loading = new BrowserWindow({ | ||
autoHideMenuBar: true, | ||
title, | ||
width, | ||
height, | ||
show: false, | ||
}); | ||
|
||
loading.loadFile(join(__dirname, "../resource/html/loading.html")); | ||
loading.setIcon(icon); | ||
|
||
loading.once("ready-to-show", () => { | ||
loading.show(); | ||
}); | ||
|
||
win.once("ready-to-show", () => { | ||
win.show(); | ||
loading.hide(); | ||
loading.close(); | ||
if (import.meta.env.DEV) { | ||
win.webContents.openDevTools(); | ||
} | ||
}); | ||
|
||
win.setIcon(icon); | ||
win.removeMenu(); | ||
|
||
// 设置title | ||
ipcMain.on("set-title", (event, title) => { | ||
const webContents = event.sender; | ||
const win = BrowserWindow.fromWebContents(webContents); | ||
win?.setTitle(title); | ||
}); | ||
|
||
// 图片压缩 | ||
ipcMain.handle("compress-image", compressImage); | ||
} | ||
|
||
app.whenReady().then(() => { | ||
createWindow(); | ||
|
||
app.on("activate", () => { | ||
if (BrowserWindow.getAllWindows().length === 0) { | ||
createWindow(); | ||
} | ||
}); | ||
}); | ||
|
||
app.on("window-all-closed", () => { | ||
if (process.platform !== "darwin") { | ||
app.quit(); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
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,9 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
import { contextBridge, ipcRenderer } from "electron"; | ||
|
||
contextBridge.exposeInMainWorld("electronAPI", { | ||
// 设置title | ||
setTitle: (title: string) => ipcRenderer.send("set-title", title), | ||
// 图片压缩 | ||
compressImage: (file: string) => ipcRenderer.invoke("compress-image", file), | ||
}); |
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>加载中...</title> | ||
</head> | ||
<body> | ||
<div style="text-align: center; padding: 20% 0; color: #888; font-size: 14px">玩命加载中...</div> | ||
</body> | ||
</html> |
File renamed without changes
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
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
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