diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index efc1a7e..69559c1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,12 @@ jobs: npm_config_arch: ${{ matrix.arch }} npm_config_target_arch: ${{ matrix.arch }} run: pnpm build:win --${{ matrix.arch }} + - name: Add Portable Flag + run: | + New-Item -Path "PORTABLE" -ItemType File + Get-ChildItem dist/*portable.7z | ForEach-Object { + 7z a $_.FullName PORTABLE + } - name: Generate checksums run: pnpm checksum setup.exe portable.7z - name: Upload Artifacts diff --git a/changelog.md b/changelog.md index d21fa55..21f6013 100644 --- a/changelog.md +++ b/changelog.md @@ -4,8 +4,9 @@ ### New Features -- MacOS 支持自动设置系统DNS -- 调整UI细节 +- 便携版默认开启便携模式,不再需要手动开启 +- 不再允许修改是否开启便携模式 +- 便携版更新时自动下载7z文件 ### Bug Fixes diff --git a/src/main/resolve/autoUpdater.ts b/src/main/resolve/autoUpdater.ts index 3197a57..77e2ee7 100644 --- a/src/main/resolve/autoUpdater.ts +++ b/src/main/resolve/autoUpdater.ts @@ -39,9 +39,9 @@ export async function downloadAndInstallUpdate(version: string): Promise { 'darwin-x64': `mihomo-party-macos-${version}-x64.dmg`, 'darwin-arm64': `mihomo-party-macos-${version}-arm64.dmg` } - const file = fileMap[`${process.platform}-${process.arch}`] + let file = fileMap[`${process.platform}-${process.arch}`] if (isPortable()) { - throw new Error('便携模式不支持自动更新') + file = file.replace('-setup.exe', '-portable.7z') } if (!file) { throw new Error('不支持自动更新,请手动下载更新') diff --git a/src/main/utils/dirs.ts b/src/main/utils/dirs.ts index 21cbd83..b213ceb 100644 --- a/src/main/utils/dirs.ts +++ b/src/main/utils/dirs.ts @@ -1,7 +1,6 @@ import { is } from '@electron-toolkit/utils' -import { app } from 'electron' import { existsSync, mkdirSync } from 'fs' -import { rm, writeFile } from 'fs/promises' +import { app } from 'electron' import path from 'path' export const homeDir = app.getPath('home') @@ -10,14 +9,6 @@ export function isPortable(): boolean { return existsSync(path.join(exeDir(), 'PORTABLE')) } -export async function setPortable(portable: boolean): Promise { - if (portable) { - await writeFile(path.join(exeDir(), 'PORTABLE'), '') - } else { - await rm(path.join(exeDir(), 'PORTABLE')) - } -} - export function dataDir(): string { if (isPortable()) { return path.join(exeDir(), 'data') diff --git a/src/main/utils/ipc.ts b/src/main/utils/ipc.ts index e3abb08..e9d35b7 100644 --- a/src/main/utils/ipc.ts +++ b/src/main/utils/ipc.ts @@ -58,7 +58,6 @@ import { setupFirewall } from '../sys/misc' import { getRuntimeConfig, getRuntimeConfigStr } from '../core/factory' -import { isPortable, setPortable } from './dirs' import { listWebdavBackups, webdavBackup, webdavDelete, webdavRestore } from '../resolve/backup' import { getInterfaces } from '../sys/interface' import { copyEnv } from '../resolve/tray' @@ -167,8 +166,6 @@ export function registerIpcMainHandlers(): void { ipcMain.handle('openUWPTool', ipcErrorWrapper(openUWPTool)) ipcMain.handle('setupFirewall', ipcErrorWrapper(setupFirewall)) ipcMain.handle('getInterfaces', getInterfaces) - ipcMain.handle('setPortable', (_e, portable) => ipcErrorWrapper(setPortable)(portable)) - ipcMain.handle('isPortable', isPortable) ipcMain.handle('webdavBackup', ipcErrorWrapper(webdavBackup)) ipcMain.handle('webdavRestore', (_e, filename) => ipcErrorWrapper(webdavRestore)(filename)) ipcMain.handle('listWebdavBackups', ipcErrorWrapper(listWebdavBackups)) diff --git a/src/renderer/src/components/settings/general-config.tsx b/src/renderer/src/components/settings/general-config.tsx index 092a662..e4c8aa4 100644 --- a/src/renderer/src/components/settings/general-config.tsx +++ b/src/renderer/src/components/settings/general-config.tsx @@ -9,10 +9,8 @@ import { copyEnv, disableAutoRun, enableAutoRun, - isPortable, relaunchApp, - restartCore, - setPortable + restartCore } from '@renderer/utils/ipc' import { useAppConfig } from '@renderer/hooks/use-app-config' import { platform } from '@renderer/utils/init' @@ -20,7 +18,6 @@ import { useTheme } from 'next-themes' const GeneralConfig: React.FC = () => { const { data: enable, mutate: mutateEnable } = useSWR('checkAutoRun', checkAutoRun) - const { data: portable, mutate: mutatePortable } = useSWR('isPortable', isPortable) const { appConfig, patchAppConfig } = useAppConfig() const { setTheme } = useTheme() const { @@ -157,28 +154,6 @@ const GeneralConfig: React.FC = () => { )} - {platform === 'win32' && ( - - - - )} { - return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('setPortable', portable)) -} - -export async function isPortable(): Promise { - return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('isPortable')) -} - export async function webdavBackup(): Promise { return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('webdavBackup')) }