Skip to content

Commit

Permalink
fix:optimize installation
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtualHotBar committed Aug 1, 2023
1 parent 6d4a368 commit 214870a
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 40 deletions.
1 change: 0 additions & 1 deletion resources/config.json

This file was deleted.

2 changes: 1 addition & 1 deletion resources/tools/PACMDforUSB/cfg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Vdr=aomei
Spd=pa
ProductName=Windows 10 Enterprise x64
fdate=20220106
ldate=20230723
ldate=20230730
Lang=cn
Ver=9.13.0
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { app, BrowserWindow, ipcMain, shell } from 'electron'
import { dialog } from 'electron';
import path from 'path'


//是否为开发模式
import isDev from 'electron-is-dev'

Expand All @@ -24,7 +25,6 @@ app.on('ready', () => {
preload: path.join(__dirname, './preload.js')
}
})


//窗口加载html文件
//mainWindow.loadFile('./src/main.html')
Expand Down
27 changes: 27 additions & 0 deletions src/view/controller/Install/check.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Notification } from "@douyinfe/semi-ui";
import { isClientReady } from "../init";
import { config } from "../../services/config";



Expand All @@ -14,3 +15,29 @@ export function checkIsReady(){
}
return isReady
}

//获取PE版本
export function getHotPEDriveVer(diskIndex: Number) {
//console.log(config.environment.HotPEDrive.all);

for (let i in config.environment.HotPEDrive.all) {
if (config.environment.HotPEDrive.all[i].diskIndex == diskIndex) {
return config.environment.HotPEDrive.all[i].version
}
}

return ''
}

//获取PE数据分区盘符
export function getHotPEDriveLetter(diskIndex: Number) {
//console.log(config.environment.HotPEDrive.all);

for (let i in config.environment.HotPEDrive.all) {
if (config.environment.HotPEDrive.all[i].diskIndex == diskIndex) {
return config.environment.HotPEDrive.all[i].letter
}
}

return ''
}
5 changes: 4 additions & 1 deletion src/view/controller/Install/toSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ export async function uninstallToSystem(setIsUninstalling: Function, setLockMuen
await runCmdAsync(bcdeditPath + ' /delete ' + GUID1 + ' /f')

await delDir(roConfig.environment.sysLetter + 'HotPE\\')
await delDir(roConfig.environment.sysLetter + 'HotPEModule\\')
if (!isUpdate) {
await delDir(roConfig.environment.sysLetter + 'HotPEModule\\')
}


//更新PE安装状态
await checkPEDrive()
Expand Down
44 changes: 24 additions & 20 deletions src/view/controller/Install/toUDisk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { config, roConfig } from "../../services/config"
import { runCmdAsync } from "../../utils/command"
import { copyDir, copyFile, delDir, delFiles, getUsableLetter, isHotPEDrive, letterIsExist, moveFiles, readHotPEConfig, takeLeftStr, unZipFile, writeHotPEConfig } from "../../utils/utils"
import { checkPEDrive } from "../condition"
import { checkIsReady } from "./check"
import { checkIsReady, getHotPEDriveLetter } from "./check"
import { ReactNode } from "react"
const fs = window.require('fs')

Expand Down Expand Up @@ -206,8 +206,6 @@ export async function updatePEForUDisk(diskIndex: string, setStep: Function, set
setStepStr('正在解压文件')
await unZipFile(roConfig.path.resources.pe + config.resources.pe.new, tempPath)



setStep(1)

//清理EFI分区
Expand All @@ -221,25 +219,31 @@ export async function updatePEForUDisk(diskIndex: string, setStep: Function, set
isSucceed = isSucceed && await runPacmd(' /hd:' + diskIndex + ' /whide:1 /src:' + roConfig.path.execDir + tempEFIPath.substring(2, tempEFIPath.length - 1))//去路径末'\'

setStepStr('正在更新数据分区')
let dataLetter = getHotPEDriveLetter(Number(diskIndex))

//let dataLetter = (await getUsableLetter() as string).substring(0, 2)
//await runPacmd(' /hd:' + diskIndex + ' /setletter:0 /letter:' + dataLetter)
if (dataLetter != '') {
//if (await letterIsExist(dataLetter)) {
//复制数据区文件
await copyDir(tempDataPath, dataLetter + '\\')

//pe配置文件
let HotPEConfig = readHotPEConfig(dataLetter + '\\')
HotPEConfig.information.Installation_Method = 'UDisk'
HotPEConfig.information.ReleaseVersion = takeLeftStr(config.resources.pe.new, '.')
writeHotPEConfig(dataLetter + '\\', HotPEConfig)

await runCmdAsync('attrib ' + dataLetter + '\\HotPE +S +H /S /D')
await runCmdAsync('attrib ' + dataLetter + '\\HotPE\\* +S +H /S /D')
await runCmdAsync('attrib ' + dataLetter + '\\AUTORUN.INF +S +H /S /D')
await runCmdAsync('attrib ' + dataLetter + '\\HotPE.ico +S +H /S /D')
//}
}else{
isSucceed = isSucceed && false
}

let dataLetter = (await getUsableLetter() as string).substring(0, 2)
await runPacmd(' /hd:' + diskIndex + ' /setletter:0 /letter:' + dataLetter)

//if (await letterIsExist(dataLetter)) {
//复制数据区文件
await copyDir(tempDataPath, dataLetter + '\\')

//pe配置文件
let HotPEConfig = readHotPEConfig(dataLetter + '\\')
HotPEConfig.information.Installation_Method = 'UDisk'
HotPEConfig.information.ReleaseVersion = takeLeftStr(config.resources.pe.new, '.')
writeHotPEConfig(dataLetter + '\\', HotPEConfig)

await runCmdAsync('attrib ' + dataLetter + '\\HotPE +S +H /S /D')
await runCmdAsync('attrib ' + dataLetter + '\\HotPE\\* +S +H /S /D')
await runCmdAsync('attrib ' + dataLetter + '\\AUTORUN.INF +S +H /S /D')
await runCmdAsync('attrib ' + dataLetter + '\\HotPE.ico +S +H /S /D')
//}

setStep(2)
setStepStr('正在清理退出')
Expand Down
1 change: 1 addition & 0 deletions src/view/controller/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export async function checkPERes() {
config.resources.pe.new = ''
}


//删除旧的PE资源
for (let i in config.resources.pe.all) {
if (config.resources.pe.all[i] != config.resources.pe.new) {
Expand Down
3 changes: 3 additions & 0 deletions src/view/controller/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import { checkHPMFiles } from "./hpm/checkHpmFiles"
import { errorDialog } from "./log"
import { exitapp } from "../layout/header"
import { HotPEDriveChoose } from "../page/setting"
import { runCmdAsync } from "../utils/command"

let isInitDone = false

export async function initClient(setStartStr: Function) {
//结束傲慢
await runCmdAsync('taskkill /IM PartAssist.exe /F')


await initDir()
Expand Down
2 changes: 1 addition & 1 deletion src/view/page/setup/setupToSys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function SetupToSys(props:any) {
<h2 >已安装到系统</h2>
<h3 style={{color:'var(--semi-color-text-1)'}}>你已将HotPE安装到系统中,你可以进行</h3>
{//更新按钮
config.state.setupToSys < Number(takeLeftStr(config.resources.pe.new, '.')) ? <Button onClick={() => { updatePEForSys(setIsUninstalling, setCurrentStep, setStepStr,props.setLockMuen) }} type='primary' style={{ marginLeft: 8 }}>更新</Button> : <></>}
config.state.setupToSys < Number(takeLeftStr(config.resources.pe.new, '.')) ? <Button onClick={() => { updatePEForSys(setIsUninstalling, setCurrentStep, setStepStr,props.setLockMuen) }} type='primary' style={{ marginRight: 8 }}>更新</Button> : <></>}
<Button onClick={() => { uninstallToSystem(setIsUninstalling,props.setLockMuen) }} type='danger'>卸载</Button>
</div>
: <div style={{ textAlign: "center", marginTop: "70px", width: "100%" }}>
Expand Down
14 changes: 1 addition & 13 deletions src/view/page/setup/setupToUDisk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IconRefresh } from '@douyinfe/semi-icons';
import { getEnvironment } from '../../controller/init';
import { UnInstallToUDisk, installToUDisk, updatePEForUDisk } from '../../controller/Install/toUDisk';
import { checkPEDrive } from '../../controller/condition';
import { getHotPEDriveVer } from '../../controller/Install/check';


//let uDiskRefreshing =false
Expand All @@ -29,19 +30,6 @@ async function UDiskRefres(steUDiskRefreshing: Function, setLockMuen: Function)
setLockMuen(false)
}

//获取PE版本
function getHotPEDriveVer(diskIndex: Number) {
//console.log(config.environment.HotPEDrive.all);

for (let i in config.environment.HotPEDrive.all) {
if (config.environment.HotPEDrive.all[i].diskIndex == diskIndex) {
return config.environment.HotPEDrive.all[i].version
}
}

return ''
}

export default function SetupToUDisk(props: any) {
const [ignored, forceUpdate] = useReducer(x => x + 1, 0);//刷新页面
const [uDiskRefreshing, steUDiskRefreshing] = useState(false)
Expand Down
4 changes: 2 additions & 2 deletions src/view/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const fs = window.require('fs')

//只读配置read only=======================================================================================
const roConfig = {
id: '230725',
clientVer: 'V0.2.230725_bate',
id: '230730',
clientVer: 'V0.2.230730_bate',
url: {
home: 'https://www.hotpe.top/',
github: 'https://github.com/VirtualHotBar/HotPE_Client',
Expand Down

0 comments on commit 214870a

Please sign in to comment.