|
@@ -5,7 +5,34 @@ import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
|
|
|
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
|
|
|
import { updateHandle } from './update'
|
|
|
const isDevelopment = process.env.NODE_ENV !== 'production'
|
|
|
-let mainWindow
|
|
|
+
|
|
|
+if (!isDevelopment) {
|
|
|
+ global.__static = require("path")
|
|
|
+ .join(__dirname, "/static")
|
|
|
+ .replace(/\\/g, "\\\\");
|
|
|
+}
|
|
|
+let mainWindow, loadingWindow;
|
|
|
+
|
|
|
+const loadingURL =
|
|
|
+ isDevelopment //加载loading.html页面地址
|
|
|
+ ? require("path").join(__static, "loading.html")
|
|
|
+ : `file://${__static}/loading.html`;
|
|
|
+
|
|
|
+const showLoading = (cb) => {
|
|
|
+ loadingWindow = new BrowserWindow({
|
|
|
+ show: false,
|
|
|
+ frame: false, // 无边框(窗口、工具栏等),只包含网页内容
|
|
|
+ width: 400,
|
|
|
+ height: 300,
|
|
|
+ resizable: false,
|
|
|
+ transparent: true, // 窗口是否支持透明,如果想做高级效果最好为true
|
|
|
+ });
|
|
|
+
|
|
|
+ loadingWindow.once("show", cb);
|
|
|
+ loadingWindow.loadURL(loadingURL);
|
|
|
+ loadingWindow.show();
|
|
|
+};
|
|
|
+
|
|
|
// Scheme must be registered before the app is ready
|
|
|
protocol.registerSchemesAsPrivileged([
|
|
|
{ scheme: 'app', privileges: { secure: true, standard: true } }
|
|
@@ -41,8 +68,10 @@ async function createWindow() {
|
|
|
createProtocol('app')
|
|
|
win.loadURL(process.env.VUE_APP_API_BASE_URL)
|
|
|
win.on('ready-to-show', function () {
|
|
|
+ loadingWindow.hide();
|
|
|
+ loadingWindow.close();
|
|
|
win.show() // 初始化后再显示
|
|
|
- })
|
|
|
+ })
|
|
|
}
|
|
|
// 在开发环境和生产环境均可通过快捷键打开devTools
|
|
|
globalShortcut.register('CommandOrControl+Shift+i', function () {
|
|
@@ -92,7 +121,7 @@ if (!gotTheLock) {
|
|
|
console.error('Vue Devtools failed to install:', e.toString())
|
|
|
}
|
|
|
}
|
|
|
- createWindow()
|
|
|
+ showLoading(createWindow);
|
|
|
})
|
|
|
}
|
|
|
|