mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-15 19:22:31 +08:00
fix portable
This commit is contained in:
parent
ea728d3399
commit
408f445c73
6
.github/workflows/build.yml
vendored
6
.github/workflows/build.yml
vendored
|
@ -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
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
### New Features
|
||||
|
||||
- MacOS 支持自动设置系统DNS
|
||||
- 调整UI细节
|
||||
- 便携版默认开启便携模式,不再需要手动开启
|
||||
- 不再允许修改是否开启便携模式
|
||||
- 便携版更新时自动下载7z文件
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ export async function downloadAndInstallUpdate(version: string): Promise<void> {
|
|||
'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('不支持自动更新,请手动下载更新')
|
||||
|
|
|
@ -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<void> {
|
||||
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')
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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 = () => {
|
|||
</SettingItem>
|
||||
</>
|
||||
)}
|
||||
{platform === 'win32' && (
|
||||
<SettingItem title="数据存储路径" divider>
|
||||
<Select
|
||||
className="w-[150px]"
|
||||
size="sm"
|
||||
selectedKeys={new Set([portable ? 'portable' : 'data'])}
|
||||
onSelectionChange={async (v) => {
|
||||
try {
|
||||
await setPortable(v.currentKey === 'portable')
|
||||
await relaunchApp()
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
} finally {
|
||||
mutatePortable()
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectItem key="data">AppData</SelectItem>
|
||||
<SelectItem key="portable">安装目录</SelectItem>
|
||||
</Select>
|
||||
</SettingItem>
|
||||
)}
|
||||
<SettingItem title="使用系统标题栏" divider>
|
||||
<Switch
|
||||
size="sm"
|
||||
|
|
|
@ -267,14 +267,6 @@ export async function getInterfaces(): Promise<Record<string, NetworkInterfaceIn
|
|||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('getInterfaces'))
|
||||
}
|
||||
|
||||
export async function setPortable(portable: boolean): Promise<void> {
|
||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('setPortable', portable))
|
||||
}
|
||||
|
||||
export async function isPortable(): Promise<boolean> {
|
||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('isPortable'))
|
||||
}
|
||||
|
||||
export async function webdavBackup(): Promise<boolean> {
|
||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('webdavBackup'))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user