markpdfdown 0.1.7-beta.5 → 0.1.7-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main/index.js +29 -6
- package/package.json +1 -1
package/dist/main/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { app, ipcMain, dialog, protocol, BrowserWindow, shell } from "electron";
|
|
1
|
+
import { app, ipcMain, dialog, protocol, nativeImage, BrowserWindow, shell } from "electron";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs, { promises } from "fs";
|
|
4
4
|
import isDev from "electron-is-dev";
|
|
@@ -3407,7 +3407,13 @@ if (!app.isPackaged) {
|
|
|
3407
3407
|
}
|
|
3408
3408
|
}
|
|
3409
3409
|
function getIconPath() {
|
|
3410
|
-
const
|
|
3410
|
+
const useNativeFormat = app.isPackaged;
|
|
3411
|
+
let iconName;
|
|
3412
|
+
if (useNativeFormat) {
|
|
3413
|
+
iconName = process.platform === "darwin" ? "icons/mac/icon.icns" : process.platform === "win32" ? "icons/win/icon.ico" : "icons/png/512x512.png";
|
|
3414
|
+
} else {
|
|
3415
|
+
iconName = "icons/png/512x512.png";
|
|
3416
|
+
}
|
|
3411
3417
|
if (process.env.ELECTRON_RENDERER_URL) {
|
|
3412
3418
|
return path.join(process.cwd(), "public", iconName);
|
|
3413
3419
|
}
|
|
@@ -3483,6 +3489,19 @@ async function stopTask() {
|
|
|
3483
3489
|
function createWindow() {
|
|
3484
3490
|
const iconPath = getIconPath();
|
|
3485
3491
|
const iconExists = fs.existsSync(iconPath);
|
|
3492
|
+
let appIcon;
|
|
3493
|
+
if (iconExists) {
|
|
3494
|
+
try {
|
|
3495
|
+
appIcon = nativeImage.createFromPath(iconPath);
|
|
3496
|
+
if (appIcon.isEmpty()) {
|
|
3497
|
+
console.warn("[Main] Icon loaded but is empty:", iconPath);
|
|
3498
|
+
appIcon = void 0;
|
|
3499
|
+
}
|
|
3500
|
+
} catch (err) {
|
|
3501
|
+
console.warn("[Main] Failed to load icon:", iconPath, err);
|
|
3502
|
+
appIcon = void 0;
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3486
3505
|
mainWindow = new BrowserWindow({
|
|
3487
3506
|
width: 1200,
|
|
3488
3507
|
height: 800,
|
|
@@ -3494,11 +3513,15 @@ function createWindow() {
|
|
|
3494
3513
|
contextIsolation: true,
|
|
3495
3514
|
preload: path.join(__dirname, "../preload/index.js")
|
|
3496
3515
|
},
|
|
3497
|
-
//
|
|
3498
|
-
...
|
|
3516
|
+
// 仅在图标成功加载时设置
|
|
3517
|
+
...appIcon ? { icon: appIcon } : {}
|
|
3499
3518
|
});
|
|
3500
|
-
if (process.platform === "darwin" && app.dock &&
|
|
3501
|
-
|
|
3519
|
+
if (process.platform === "darwin" && app.dock && appIcon) {
|
|
3520
|
+
try {
|
|
3521
|
+
app.dock.setIcon(appIcon);
|
|
3522
|
+
} catch (err) {
|
|
3523
|
+
console.warn("[Main] Failed to set dock icon:", err);
|
|
3524
|
+
}
|
|
3502
3525
|
}
|
|
3503
3526
|
windowManager.setMainWindow(mainWindow);
|
|
3504
3527
|
if (process.env.ELECTRON_RENDERER_URL) {
|
package/package.json
CHANGED