diff --git a/.electron-builder.config.js b/.electron-builder.config.js index 852f87c..e74b135 100644 --- a/.electron-builder.config.js +++ b/.electron-builder.config.js @@ -11,7 +11,7 @@ module.exports = async function () { const {getVersion} = await import('./version/getVersion.mjs'); return { - productName: 'chrome-power', + productName: 'chrome-power-alpha', directories: { output: 'dist', buildResources: 'buildResources', @@ -46,7 +46,7 @@ module.exports = async function () { allowToChangeInstallationDirectory: true, createDesktopShortcut: true, createStartMenuShortcut: true, - shortcutName: 'chrome-power', + shortcutName: 'chrome-power-alpha', }, win: { diff --git a/packages/main/src/fingerprint/device.ts b/packages/main/src/fingerprint/device.ts index 7db097c..16f54f6 100644 --- a/packages/main/src/fingerprint/device.ts +++ b/packages/main/src/fingerprint/device.ts @@ -2,6 +2,7 @@ import {execSync} from 'child_process'; import * as os from 'os'; import {createLogger} from '../../../shared/utils/logger'; import {APP_LOGGER_LABEL} from '../constants'; +import {parse} from 'path'; const logger = createLogger(APP_LOGGER_LABEL); @@ -56,3 +57,11 @@ export function getChromePath() { } return chromePath; } + +export function getRootDir() { + const installationPath = process.resourcesPath; + const parsedPath = parse(installationPath); + // 获取根目录 + const rootDirectory = parsedPath.root; + return rootDirectory; +} diff --git a/packages/main/src/fingerprint/index.ts b/packages/main/src/fingerprint/index.ts index 7b9fb3b..63ef3ba 100644 --- a/packages/main/src/fingerprint/index.ts +++ b/packages/main/src/fingerprint/index.ts @@ -113,12 +113,8 @@ export async function openFingerprintWindow(id: number) { const proxyType = proxyData?.proxy_type?.toLowerCase(); const settings = getSettings(); - let cachePath; - if (settings.profileCachePath) { - cachePath = settings.profileCachePath; - } else { - cachePath = join(process.resourcesPath, 'chromePowerCache'); - } + const cachePath = settings.profileCachePath; + const win = BrowserWindow.getAllWindows()[0]; const windowDataDir = join( cachePath, @@ -193,6 +189,7 @@ export async function openFingerprintWindow(id: number) { if (!chromeInstance) { return; } + await sleep(1); await WindowDB.update(id, { status: 2, port: chromePort, diff --git a/packages/main/src/services/common-service.ts b/packages/main/src/services/common-service.ts index d9b3a84..42c0ea7 100644 --- a/packages/main/src/services/common-service.ts +++ b/packages/main/src/services/common-service.ts @@ -84,6 +84,7 @@ export const initCommonService = () => { ); ipcMain.handle('common-save-settings', async (_, values: SettingOptions) => { + const configFilePath = join(process.resourcesPath, 'chrome-power-config.json'); try { diff --git a/packages/main/src/utils/get-settings.ts b/packages/main/src/utils/get-settings.ts index 3d779cc..f90b863 100644 --- a/packages/main/src/utils/get-settings.ts +++ b/packages/main/src/utils/get-settings.ts @@ -1,12 +1,12 @@ import {existsSync, readFileSync, writeFileSync} from 'fs'; import {join} from 'path'; import type {SettingOptions} from '../../../shared/types/common'; -import {getChromePath} from '../fingerprint/device'; +import {getChromePath, getRootDir} from '../fingerprint/device'; export const getSettings = (): SettingOptions => { const configFilePath = join(process.resourcesPath, 'chrome-power-config.json'); let settings = { - profileCachePath: join(process.resourcesPath, 'chromePowerCache'), + profileCachePath: join(getRootDir(), 'chromePowerCache'), useLocalChrome: true, localChromePath: '', chromiumBinPath: '', diff --git a/scripts/uninstall.nsis b/scripts/uninstall.nsis new file mode 100644 index 0000000..e69de29