From 54de0e5122a2c9786c0ec98c531c47532210b929 Mon Sep 17 00:00:00 2001 From: Alex <49969959+alexzhang1030@users.noreply.github.com> Date: Fri, 5 Jan 2024 17:12:21 +0800 Subject: [PATCH] fix(electron): compatible with windows (#153) --- packages/electron/package.json | 1 + packages/electron/scripts/build.ts | 2 +- packages/electron/src/app.ts | 1 + packages/electron/src/cli.ts | 4 +++- pnpm-lock.yaml | 13 ++++++++----- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/electron/package.json b/packages/electron/package.json index 39f7b4b4f..c016d5fca 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -36,6 +36,7 @@ "execa": "^8.0.1", "h3": "^1.9.0", "ip": "^1.1.8", + "pathe": "^1.1.1", "socket.io": "^4.7.2", "socket.io-client": "^4.7.2" }, diff --git a/packages/electron/scripts/build.ts b/packages/electron/scripts/build.ts index 2d1eda85f..09ccf5dd6 100644 --- a/packages/electron/scripts/build.ts +++ b/packages/electron/scripts/build.ts @@ -1,4 +1,4 @@ -import { resolve as _resolve } from 'node:path' +import { resolve as _resolve } from 'pathe' import type { Options } from 'tsup' import { build } from 'tsup' import { build as unbuild } from 'unbuild' diff --git a/packages/electron/src/app.ts b/packages/electron/src/app.ts index 1a8bdac01..15d442861 100644 --- a/packages/electron/src/app.ts +++ b/packages/electron/src/app.ts @@ -21,6 +21,7 @@ function createWindow() { }) const appEntryPath = path.join(__dirname, '../app.html') const url = new URL(`file://${appEntryPath}`).toString() + mainWindow.setMenu(null) mainWindow.loadURL(new URL(url).toString()) mainWindow.on('closed', () => { diff --git a/packages/electron/src/cli.ts b/packages/electron/src/cli.ts index e2e15c8d0..e1a279abd 100644 --- a/packages/electron/src/cli.ts +++ b/packages/electron/src/cli.ts @@ -1,11 +1,13 @@ import { execaSync } from 'execa' import electron from 'electron' +import { resolve } from 'pathe' -const appPath = new URL('../dist/app.cjs', import.meta.url).pathname +const appPath = resolve(new URL('../dist/app.cjs', import.meta.url).pathname) const argv = process.argv.slice(2) const result = execaSync(electron as unknown as string, [appPath].concat(argv), { stdio: 'ignore', + windowsHide: false, }) process.exit(result.exitCode) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 274fa9d13..079e18dd6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: devDependencies: '@antfu/eslint-config': specifier: 2.4.2 - version: 2.4.2(@unocss/eslint-plugin@0.58.3)(@vue/compiler-sfc@3.4.0)(eslint-plugin-format@0.1.0)(eslint-ts-patch@8.55.0-1)(typescript@5.3.3)(vitest@1.1.1) + version: 2.4.2(@unocss/eslint-plugin@0.58.3)(@vue/compiler-sfc@3.4.4)(eslint-plugin-format@0.1.0)(eslint-ts-patch@8.55.0-1)(typescript@5.3.3)(vitest@1.1.1) '@antfu/ni': specifier: ^0.21.12 version: 0.21.12 @@ -363,6 +363,9 @@ importers: ip: specifier: ^1.1.8 version: 1.1.8 + pathe: + specifier: ^1.1.1 + version: 1.1.1 socket.io: specifier: ^4.7.2 version: 4.7.2 @@ -748,7 +751,7 @@ packages: '@jridgewell/gen-mapping': 0.3.3 '@jridgewell/trace-mapping': 0.3.20 - /@antfu/eslint-config@2.4.2(@unocss/eslint-plugin@0.58.3)(@vue/compiler-sfc@3.4.0)(eslint-plugin-format@0.1.0)(eslint-ts-patch@8.55.0-1)(typescript@5.3.3)(vitest@1.1.1): + /@antfu/eslint-config@2.4.2(@unocss/eslint-plugin@0.58.3)(@vue/compiler-sfc@3.4.4)(eslint-plugin-format@0.1.0)(eslint-ts-patch@8.55.0-1)(typescript@5.3.3)(vitest@1.1.1): resolution: {integrity: sha512-19l69ER3GS0yHHTS65tRkuawJKndeGv9wmr5wYV3QNmzBXQeXsmt8CW7hUC1qfQ1eb1nLn/zMa+krqIWqdclbw==} hasBin: true peerDependencies: @@ -798,7 +801,7 @@ packages: eslint-plugin-vitest: 0.3.10(@typescript-eslint/eslint-plugin@6.13.2)(eslint-ts-patch@8.55.0-1)(typescript@5.3.3)(vitest@1.1.1) eslint-plugin-vue: 9.19.2(eslint-ts-patch@8.55.0-1) eslint-plugin-yml: 1.10.0(eslint-ts-patch@8.55.0-1) - eslint-processor-vue-blocks: 0.1.1(@vue/compiler-sfc@3.4.0)(eslint-ts-patch@8.55.0-1) + eslint-processor-vue-blocks: 0.1.1(@vue/compiler-sfc@3.4.4)(eslint-ts-patch@8.55.0-1) globals: 13.24.0 jsonc-eslint-parser: 2.4.0 local-pkg: 0.5.0 @@ -5365,13 +5368,13 @@ packages: - supports-color dev: true - /eslint-processor-vue-blocks@0.1.1(@vue/compiler-sfc@3.4.0)(eslint-ts-patch@8.55.0-1): + /eslint-processor-vue-blocks@0.1.1(@vue/compiler-sfc@3.4.4)(eslint-ts-patch@8.55.0-1): resolution: {integrity: sha512-9+dU5lU881log570oBwpelaJmOfOzSniben7IWEDRYQPPWwlvaV7NhOtsTuUWDqpYT+dtKKWPsgz4OkOi+aZnA==} peerDependencies: '@vue/compiler-sfc': ^3.3.0 eslint: ^8.50.0 dependencies: - '@vue/compiler-sfc': 3.4.0 + '@vue/compiler-sfc': 3.4.4 eslint: /eslint-ts-patch@8.55.0-1 dev: true