mirror of
https://github.com/pompurin404/mihomo-party.git
synced 2024-11-16 03:32:17 +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_arch: ${{ matrix.arch }}
|
||||||
npm_config_target_arch: ${{ matrix.arch }}
|
npm_config_target_arch: ${{ matrix.arch }}
|
||||||
run: pnpm build:win --${{ 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
|
- name: Generate checksums
|
||||||
run: pnpm checksum setup.exe portable.7z
|
run: pnpm checksum setup.exe portable.7z
|
||||||
- name: Upload Artifacts
|
- name: Upload Artifacts
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
### New Features
|
### New Features
|
||||||
|
|
||||||
- MacOS 支持自动设置系统DNS
|
- 便携版默认开启便携模式,不再需要手动开启
|
||||||
- 调整UI细节
|
- 不再允许修改是否开启便携模式
|
||||||
|
- 便携版更新时自动下载7z文件
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ export async function downloadAndInstallUpdate(version: string): Promise<void> {
|
||||||
'darwin-x64': `mihomo-party-macos-${version}-x64.dmg`,
|
'darwin-x64': `mihomo-party-macos-${version}-x64.dmg`,
|
||||||
'darwin-arm64': `mihomo-party-macos-${version}-arm64.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()) {
|
if (isPortable()) {
|
||||||
throw new Error('便携模式不支持自动更新')
|
file = file.replace('-setup.exe', '-portable.7z')
|
||||||
}
|
}
|
||||||
if (!file) {
|
if (!file) {
|
||||||
throw new Error('不支持自动更新,请手动下载更新')
|
throw new Error('不支持自动更新,请手动下载更新')
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { is } from '@electron-toolkit/utils'
|
import { is } from '@electron-toolkit/utils'
|
||||||
import { app } from 'electron'
|
|
||||||
import { existsSync, mkdirSync } from 'fs'
|
import { existsSync, mkdirSync } from 'fs'
|
||||||
import { rm, writeFile } from 'fs/promises'
|
import { app } from 'electron'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
export const homeDir = app.getPath('home')
|
export const homeDir = app.getPath('home')
|
||||||
|
@ -10,14 +9,6 @@ export function isPortable(): boolean {
|
||||||
return existsSync(path.join(exeDir(), 'PORTABLE'))
|
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 {
|
export function dataDir(): string {
|
||||||
if (isPortable()) {
|
if (isPortable()) {
|
||||||
return path.join(exeDir(), 'data')
|
return path.join(exeDir(), 'data')
|
||||||
|
|
|
@ -58,7 +58,6 @@ import {
|
||||||
setupFirewall
|
setupFirewall
|
||||||
} from '../sys/misc'
|
} from '../sys/misc'
|
||||||
import { getRuntimeConfig, getRuntimeConfigStr } from '../core/factory'
|
import { getRuntimeConfig, getRuntimeConfigStr } from '../core/factory'
|
||||||
import { isPortable, setPortable } from './dirs'
|
|
||||||
import { listWebdavBackups, webdavBackup, webdavDelete, webdavRestore } from '../resolve/backup'
|
import { listWebdavBackups, webdavBackup, webdavDelete, webdavRestore } from '../resolve/backup'
|
||||||
import { getInterfaces } from '../sys/interface'
|
import { getInterfaces } from '../sys/interface'
|
||||||
import { copyEnv } from '../resolve/tray'
|
import { copyEnv } from '../resolve/tray'
|
||||||
|
@ -167,8 +166,6 @@ export function registerIpcMainHandlers(): void {
|
||||||
ipcMain.handle('openUWPTool', ipcErrorWrapper(openUWPTool))
|
ipcMain.handle('openUWPTool', ipcErrorWrapper(openUWPTool))
|
||||||
ipcMain.handle('setupFirewall', ipcErrorWrapper(setupFirewall))
|
ipcMain.handle('setupFirewall', ipcErrorWrapper(setupFirewall))
|
||||||
ipcMain.handle('getInterfaces', getInterfaces)
|
ipcMain.handle('getInterfaces', getInterfaces)
|
||||||
ipcMain.handle('setPortable', (_e, portable) => ipcErrorWrapper(setPortable)(portable))
|
|
||||||
ipcMain.handle('isPortable', isPortable)
|
|
||||||
ipcMain.handle('webdavBackup', ipcErrorWrapper(webdavBackup))
|
ipcMain.handle('webdavBackup', ipcErrorWrapper(webdavBackup))
|
||||||
ipcMain.handle('webdavRestore', (_e, filename) => ipcErrorWrapper(webdavRestore)(filename))
|
ipcMain.handle('webdavRestore', (_e, filename) => ipcErrorWrapper(webdavRestore)(filename))
|
||||||
ipcMain.handle('listWebdavBackups', ipcErrorWrapper(listWebdavBackups))
|
ipcMain.handle('listWebdavBackups', ipcErrorWrapper(listWebdavBackups))
|
||||||
|
|
|
@ -9,10 +9,8 @@ import {
|
||||||
copyEnv,
|
copyEnv,
|
||||||
disableAutoRun,
|
disableAutoRun,
|
||||||
enableAutoRun,
|
enableAutoRun,
|
||||||
isPortable,
|
|
||||||
relaunchApp,
|
relaunchApp,
|
||||||
restartCore,
|
restartCore
|
||||||
setPortable
|
|
||||||
} from '@renderer/utils/ipc'
|
} from '@renderer/utils/ipc'
|
||||||
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
import { useAppConfig } from '@renderer/hooks/use-app-config'
|
||||||
import { platform } from '@renderer/utils/init'
|
import { platform } from '@renderer/utils/init'
|
||||||
|
@ -20,7 +18,6 @@ import { useTheme } from 'next-themes'
|
||||||
|
|
||||||
const GeneralConfig: React.FC = () => {
|
const GeneralConfig: React.FC = () => {
|
||||||
const { data: enable, mutate: mutateEnable } = useSWR('checkAutoRun', checkAutoRun)
|
const { data: enable, mutate: mutateEnable } = useSWR('checkAutoRun', checkAutoRun)
|
||||||
const { data: portable, mutate: mutatePortable } = useSWR('isPortable', isPortable)
|
|
||||||
const { appConfig, patchAppConfig } = useAppConfig()
|
const { appConfig, patchAppConfig } = useAppConfig()
|
||||||
const { setTheme } = useTheme()
|
const { setTheme } = useTheme()
|
||||||
const {
|
const {
|
||||||
|
@ -157,28 +154,6 @@ const GeneralConfig: React.FC = () => {
|
||||||
</SettingItem>
|
</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>
|
<SettingItem title="使用系统标题栏" divider>
|
||||||
<Switch
|
<Switch
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|
|
@ -267,14 +267,6 @@ export async function getInterfaces(): Promise<Record<string, NetworkInterfaceIn
|
||||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('getInterfaces'))
|
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> {
|
export async function webdavBackup(): Promise<boolean> {
|
||||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('webdavBackup'))
|
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('webdavBackup'))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user