fix: 为主窗口设置应用图标及打包包含图标文件
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { BrowserWindow, screen } from 'electron'
|
import { BrowserWindow, screen, nativeImage } from 'electron'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
import * as fs from 'fs'
|
||||||
|
|
||||||
let mainWindow: BrowserWindow | null = null
|
let mainWindow: BrowserWindow | null = null
|
||||||
export let baseAppUrl = ''
|
export let baseAppUrl = ''
|
||||||
@@ -12,6 +13,9 @@ export function createMainWindow(): BrowserWindow {
|
|||||||
cursor.y >= d.bounds.y && cursor.y <= d.bounds.y + d.bounds.height
|
cursor.y >= d.bounds.y && cursor.y <= d.bounds.y + d.bounds.height
|
||||||
) || displays[0]
|
) || displays[0]
|
||||||
|
|
||||||
|
const iconPath = path.join(__dirname, '../../src/assets/icon.png')
|
||||||
|
const appIcon = fs.existsSync(iconPath) ? nativeImage.createFromPath(iconPath) : undefined
|
||||||
|
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
x: Math.round(targetDisplay.bounds.x + targetDisplay.bounds.width / 2 - 300),
|
x: Math.round(targetDisplay.bounds.x + targetDisplay.bounds.width / 2 - 300),
|
||||||
y: targetDisplay.bounds.y,
|
y: targetDisplay.bounds.y,
|
||||||
@@ -21,6 +25,7 @@ export function createMainWindow(): BrowserWindow {
|
|||||||
transparent: true,
|
transparent: true,
|
||||||
alwaysOnTop: true,
|
alwaysOnTop: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
|
icon: appIcon,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, '../preload/preload.js'),
|
preload: path.join(__dirname, '../preload/preload.js'),
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
"files": [
|
"files": [
|
||||||
"dist/**/*",
|
"dist/**/*",
|
||||||
"dist-electron/**/*",
|
"dist-electron/**/*",
|
||||||
|
"src/assets/icon.png",
|
||||||
"package.json"
|
"package.json"
|
||||||
],
|
],
|
||||||
"win": {
|
"win": {
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 483 B After Width: | Height: | Size: 408 KiB |
Reference in New Issue
Block a user