diff --git a/assets/LoadingPage.html b/assets/LoadingPage.html new file mode 100644 index 0000000..6b0b497 --- /dev/null +++ b/assets/LoadingPage.html @@ -0,0 +1,75 @@ + + + + + + + Living Together + + + +
+
+
+ +
+
+
+ Living Together +
+ + + \ No newline at end of file diff --git a/package.json b/package.json index 67b5b24..8a4ba53 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "build-run-web": "npm run build-web & npm run build-service & npm run run-service", "release-run-web": "npm run release-web & npm run release-service & npm run run-service", "copy-fluent-icon": "fse mkdirp ./build/font-icon/ & fse emptyDir ./build/font-icon/ & fse copy ./node_modules/@fluentui/font-icons-mdl2/fonts/ ./build/font-icon/", + "copy-loading-page": "fse mkdirp ./build & fse copy ./assets/LoadingPage.html ./build/LoadingPage.html", "build-run-desktop-web": "npm run build-desktop-web & npm run copy-fluent-icon & npm run build-service & npm run run-service", "release-run-desktop-web": "npm run release-desktop-web & npm run copy-fluent-icon & npm run release-service & npm run run-service", "skip-electron-ci": "set ELECTRON_SKIP_BINARY_DOWNLOAD=1& npm ci", @@ -28,8 +29,8 @@ "electron-cache": "set ELECTRON_SKIP_BINARY_DOWNLOAD=& set ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/& set ELECTRON_CUSTOM_DIR={{ version }}& node ./node_modules/electron/install.js", "electron": "set LIVING_TOGETHER_BASE_PATH=./build& set LIVING_TOGETHER_WEB_PATH=/& npx electron ./build/Electron.js", "hmr-electron": "npm run build-electron & set LIVING_TOGETHER_SERVICE=http://127.0.0.1:12000& npm run electron", - "build-run-electron": "npm run build-desktop-web & npm run copy-fluent-icon & npm run build-electron & npm run electron", - "release-run-electron": "npm run release-desktop-web & npm run copy-fluent-icon & npm run release-electron & npm run electron", + "build-run-electron": "npm run build-desktop-web & npm run copy-fluent-icon & npm run copy-loading-page & npm run build-electron & npm run electron", + "release-run-electron": "npm run release-desktop-web & npm run copy-fluent-icon & npm run copy-loading-page & npm run release-electron & npm run electron", "copy-package-json": "fse mkdirp ./bundle/ & node ./config/electron.forge.config.js --out ./bundle", "copy-build-result": "fse mkdirp ./bundle/ & fse mkdirp ./build/ & fse copy ./build/ ./bundle/", "copy-electron-icon": "fse mkdirp ./bundle/ & fse copy ./assets/living-together.ico ./bundle/living-together.ico & fse copy ./assets/living-together.icns ./bundle/living-together.icns", diff --git a/source/Electron/Electron.ts b/source/Electron/Electron.ts index 3132ab1..4bad8d2 100644 --- a/source/Electron/Electron.ts +++ b/source/Electron/Electron.ts @@ -29,12 +29,38 @@ class ElectronApp { ); } + public loadingPage?: BrowserWindow; public simulatorWindow?: BrowserWindow; + public async showLoadingPage() { + return new Promise((r) => { + + this.loadingPage = new BrowserWindow({ + width: 603, + height: 432, + fullscreenable: false, + skipTaskbar: true, + resizable: false, + titleBarStyle: 'hidden', + frame: false, + show: false + }); + + this.loadingPage.loadFile(ENV.LIVING_TOGETHER_LOADING_PAGE ?? "./LoadingPage.html"); + + this.loadingPage.on("ready-to-show", () => { + this.loadingPage?.show(); + r(undefined); + }); + }); + } + public async runMainThread() { await app.whenReady(); + await this.showLoadingPage(); + await this.runService(); let preload = pathJoin(__dirname, "./SimulatorWindow.js"); @@ -50,11 +76,19 @@ class ElectronApp { frame: false, minWidth: 460, minHeight: 300, - webPreferences: { preload } + webPreferences: { preload }, + show: false, }); this.simulatorWindow.loadURL(this.serviceUrl + (ENV.LIVING_TOGETHER_WEB_PATH ?? "/resources/app.asar/")); + this.simulatorWindow.on("ready-to-show", () => { + setTimeout(() => { + this.loadingPage?.close(); + this.simulatorWindow?.show(); + }, 1220); + }); + this.handelSimulatorWindowBehavior(); this.handelFileChange();