|
@@ -30,14 +30,14 @@ const loadURL = isdev
|
|
|
let mainWindow = null
|
|
|
async function createWindow() {
|
|
|
// Create the browser window.
|
|
|
- const mainWindow = new BrowserWindow({
|
|
|
+ mainWindow = new BrowserWindow({
|
|
|
width: 132, //悬浮窗口的宽度 比实际DIV的宽度要多2px 因为有1px的边框
|
|
|
height: 80, //悬浮窗口的高度 比实际DIV的高度要多2px 因为有1px的边框
|
|
|
frame: false,
|
|
|
resizable: isdev,
|
|
|
show: true,
|
|
|
icon: iconSrc,
|
|
|
- skipTaskbar: false, // 任务栏中不显示窗口
|
|
|
+ skipTaskbar: true, // 任务栏中不显示窗口
|
|
|
autoHideMenuBar: false,// 任务栏中不显示窗口
|
|
|
transparent: true, //设置透明
|
|
|
hasShadow: process.platform !== "darwin", //不显示阴影
|
|
@@ -54,27 +54,7 @@ async function createWindow() {
|
|
|
sandbox: false
|
|
|
}
|
|
|
})
|
|
|
- //禁止程序多开,此处需要单例锁的打开注释即可
|
|
|
- //只存在一个
|
|
|
- const gotTheLock = app.requestSingleInstanceLock()
|
|
|
- if (!gotTheLock) {
|
|
|
- app.quit()
|
|
|
- } {
|
|
|
- app.on('second-instance', (event, argv) => {
|
|
|
- if (process.platform === 'win32') {
|
|
|
- if (win) {
|
|
|
- if (win.isMinimized()) {
|
|
|
- win.restore()
|
|
|
- }
|
|
|
- if (win.isVisible()) {
|
|
|
- win.focus()
|
|
|
- } else {
|
|
|
- win.show()
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ global.mainWindow = mainWindow
|
|
|
mainWindow.on('ready-to-show', () => {
|
|
|
mainWindow.show()
|
|
|
})
|
|
@@ -94,6 +74,26 @@ async function createWindow() {
|
|
|
mainWinEvent(mainWindow)
|
|
|
updatewin()
|
|
|
}
|
|
|
+
|
|
|
+/* 限制只启动一个exe程序 */
|
|
|
+const additionalData = { myKey: "doctor-xklr" };
|
|
|
+const gotTheLock = app.requestSingleInstanceLock(additionalData);
|
|
|
+if (!gotTheLock) {
|
|
|
+ app.quit();
|
|
|
+ app.exit(0)
|
|
|
+} else {
|
|
|
+ app.on("second-instance",(event, commandLine, workingDirectory, additionalData) => {
|
|
|
+ //输入从第二个实例中接收到的数据
|
|
|
+ console.log(157,additionalData);
|
|
|
+ //有人试图运行第二个实例,我们应该关注我们的窗口
|
|
|
+ if (mainWindow) {
|
|
|
+ if (mainWindow.isMinimized()) mainWindow.restore();
|
|
|
+ /* 展示屏幕 */
|
|
|
+ mainWindow.show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+}
|
|
|
app.whenReady().then(async () => {
|
|
|
// if (isdev && !process.env.IS_TEST) {
|
|
|
// Install Vue Devtools
|