Browse Source

bugfix: 修复 `MacOS` 启动报错 `Error: Cannot found module '@natmri/platform-napi-darwin-x64'` 的问题

1.x
王良 2 weeks ago
parent
commit
2710f200d6
  1. 2
      packages/gui/package.json
  2. 10
      packages/gui/src/background.js
  3. 20
      packages/gui/vue.config.js

2
packages/gui/package.json

@ -24,7 +24,7 @@
"@docmirror/dev-sidecar": "^1.8.9",
"@docmirror/mitmproxy": "^1.8.9",
"@mihomo-party/sysproxy": "^2.0.4",
"@natmri/platform-napi": "0.0.7",
"@natmri/platform-napi": "^0.0.7",
"adm-zip": "^0.5.5",
"ant-design-vue": "^1.6.5",
"compressing": "^1.5.1",

10
packages/gui/src/background.js

@ -1,8 +1,7 @@
'use strict'
/* global __static */
import path from 'path'
import { app, protocol, BrowserWindow, Menu, Tray, ipcMain, dialog, nativeImage, nativeTheme, globalShortcut } from 'electron'
import { powerMonitor } from './background/powerMonitor'
import { app, protocol, BrowserWindow, Menu, Tray, ipcMain, dialog, powerMonitor, nativeImage, nativeTheme, globalShortcut } from 'electron'
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
import backend from './bridge/backend'
import DevSidecar from '@docmirror/dev-sidecar'
@ -15,6 +14,9 @@ const isMac = process.platform === 'darwin'
// import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
const isDevelopment = process.env.NODE_ENV !== 'production'
// 避免其他系统出现异常,只有 Windows 使用 './background/powerMonitor'
const _powerMonitor = isWindows ? require('./background/powerMonitor').powerMonitor : powerMonitor
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win
@ -192,7 +194,7 @@ function createWindow (startHideWindow) {
// !!IMPORTANT
if (isWindows) {
powerMonitor.setupMainWindow(win)
_powerMonitor.setupMainWindow(win)
}
if (process.env.WEBPACK_DEV_SERVER_URL) {
@ -450,7 +452,7 @@ if (!isFirstInstance) {
log.info('error:', err)
}
powerMonitor.on('shutdown', async (e) => {
_powerMonitor.on('shutdown', async (e) => {
if (e) {
e.preventDefault()
}

20
packages/gui/vue.config.js

@ -42,16 +42,16 @@ module.exports = {
'@mihomo-party/sysproxy-darwin-x64',
'@mihomo-party/sysproxy-darwin-arm64',
'@natmri/platform-napi',
"@natmri/platform-napi-win32-x64-msvc",
"@natmri/platform-napi-darwin-x64",
"@natmri/platform-napi-linux-x64-gnu",
"@natmri/platform-napi-darwin-arm64",
"@natmri/platform-napi-linux-arm64-gnu",
"@natmri/platform-napi-linux-arm64-musl",
"@natmri/platform-napi-win32-arm64-msvc",
"@natmri/platform-napi-linux-arm-gnueabihf",
"@natmri/platform-napi-linux-x64-musl",
"@natmri/platform-napi-win32-ia32-msvc"
'@natmri/platform-napi-win32-ia32-msvc',
'@natmri/platform-napi-win32-x64-msvc',
'@natmri/platform-napi-win32-arm64-msvc',
'@natmri/platform-napi-linux-x64-gnu',
'@natmri/platform-napi-linux-x64-musl',
'@natmri/platform-napi-linux-arm64-gnu',
'@natmri/platform-napi-linux-arm64-musl',
'@natmri/platform-napi-linux-arm-gnueabihf',
'@natmri/platform-napi-darwin-x64',
'@natmri/platform-napi-darwin-arm64'
],
nodeIntegration: true,
// Provide an array of files that, when changed, will recompile the main process and restart Electron

Loading…
Cancel
Save