fix the path of EditThisCookie zip file while run launch-bosszhipin-login-page-with-preload-extension from ui

This commit is contained in:
geekgeekrun
2024-03-03 07:04:17 +08:00
parent 2b78d3dbd5
commit f2a0ed7219
2 changed files with 18 additions and 3 deletions
@@ -14,6 +14,7 @@ import os from 'node:os'
import path from 'node:path'; import path from 'node:path';
import JSON5 from 'json5' import JSON5 from 'json5'
import url from 'url'; import url from 'url';
import packageJson from './package.json' assert {type: 'json'}
const __dirname = url.fileURLToPath(new URL('.', import.meta.url)) const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE) const isRunFromUi = Boolean(process.env.MAIN_BOSSGEEKGO_UI_RUN_MODE)
@@ -32,15 +33,28 @@ if (!fs.existsSync(
if (!fs.existsSync(extensionDir)) { if (!fs.existsSync(extensionDir)) {
fs.mkdirSync(extensionDir) fs.mkdirSync(extensionDir)
} }
const editThisCookieZipPath = path.join(__dirname, 'extensions', 'EditThisCookie.zip')
const editThisCookieExtensionPath = path.join(extensionDir, 'EditThisCookie') const editThisCookieExtensionPath = path.join(extensionDir, 'EditThisCookie')
let editThisCookieZipPath
async function getEditThisCookieZipPath () {
if (editThisCookieZipPath) {
return editThisCookieZipPath
}
if (isRunFromUi) {
const { app } = await import('electron')
editThisCookieZipPath = path.join(app.getAppPath(), './node_modules', packageJson.name, 'extensions', 'EditThisCookie.zip')
} else {
editThisCookieZipPath = path.join(__dirname, 'extensions', 'EditThisCookie.zip')
}
return editThisCookieZipPath
}
export async function main() { export async function main() {
if (!fs.existsSync( if (!fs.existsSync(
path.join(editThisCookieExtensionPath, 'manifest.json') path.join(editThisCookieExtensionPath, 'manifest.json')
)) { )) {
await extractZip( await extractZip(
editThisCookieZipPath, await getEditThisCookieZipPath(),
{ {
dir: extensionDir dir: extensionDir
} }
+2 -1
View File
@@ -10,7 +10,8 @@ files:
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}' - '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}' - '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}'
asarUnpack: asarUnpack:
- resources/** - 'resources/**'
- 'node_modules/@geekgeekrun/launch-bosszhipin-login-page-with-preload-extension/**'
extraResources: extraResources:
- external-node-runtime-dependencies/** - external-node-runtime-dependencies/**
win: win: