Skip to content

Commit 214870a

Browse files
committed
fix:optimize installation
1 parent 6d4a368 commit 214870a

11 files changed

Lines changed: 65 additions & 40 deletions

File tree

resources/config.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/tools/PACMDforUSB/cfg.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ Vdr=aomei
77
Spd=pa
88
ProductName=Windows 10 Enterprise x64
99
fdate=20220106
10-
ldate=20230723
10+
ldate=20230730
1111
Lang=cn
1212
Ver=9.13.0

src/main/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { app, BrowserWindow, ipcMain, shell } from 'electron'
22
import { dialog } from 'electron';
33
import path from 'path'
44

5+
56
//是否为开发模式
67
import isDev from 'electron-is-dev'
78

@@ -24,7 +25,6 @@ app.on('ready', () => {
2425
preload: path.join(__dirname, './preload.js')
2526
}
2627
})
27-
2828

2929
//窗口加载html文件
3030
//mainWindow.loadFile('./src/main.html')

src/view/controller/Install/check.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Notification } from "@douyinfe/semi-ui";
22
import { isClientReady } from "../init";
3+
import { config } from "../../services/config";
34

45

56

@@ -14,3 +15,29 @@ export function checkIsReady(){
1415
}
1516
return isReady
1617
}
18+
19+
//获取PE版本
20+
export function getHotPEDriveVer(diskIndex: Number) {
21+
//console.log(config.environment.HotPEDrive.all);
22+
23+
for (let i in config.environment.HotPEDrive.all) {
24+
if (config.environment.HotPEDrive.all[i].diskIndex == diskIndex) {
25+
return config.environment.HotPEDrive.all[i].version
26+
}
27+
}
28+
29+
return ''
30+
}
31+
32+
//获取PE数据分区盘符
33+
export function getHotPEDriveLetter(diskIndex: Number) {
34+
//console.log(config.environment.HotPEDrive.all);
35+
36+
for (let i in config.environment.HotPEDrive.all) {
37+
if (config.environment.HotPEDrive.all[i].diskIndex == diskIndex) {
38+
return config.environment.HotPEDrive.all[i].letter
39+
}
40+
}
41+
42+
return ''
43+
}

src/view/controller/Install/toSystem.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ export async function uninstallToSystem(setIsUninstalling: Function, setLockMuen
134134
await runCmdAsync(bcdeditPath + ' /delete ' + GUID1 + ' /f')
135135

136136
await delDir(roConfig.environment.sysLetter + 'HotPE\\')
137-
await delDir(roConfig.environment.sysLetter + 'HotPEModule\\')
137+
if (!isUpdate) {
138+
await delDir(roConfig.environment.sysLetter + 'HotPEModule\\')
139+
}
140+
138141

139142
//更新PE安装状态
140143
await checkPEDrive()

src/view/controller/Install/toUDisk.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { config, roConfig } from "../../services/config"
33
import { runCmdAsync } from "../../utils/command"
44
import { copyDir, copyFile, delDir, delFiles, getUsableLetter, isHotPEDrive, letterIsExist, moveFiles, readHotPEConfig, takeLeftStr, unZipFile, writeHotPEConfig } from "../../utils/utils"
55
import { checkPEDrive } from "../condition"
6-
import { checkIsReady } from "./check"
6+
import { checkIsReady, getHotPEDriveLetter } from "./check"
77
import { ReactNode } from "react"
88
const fs = window.require('fs')
99

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

209-
210-
211209
setStep(1)
212210

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

223221
setStepStr('正在更新数据分区')
222+
let dataLetter = getHotPEDriveLetter(Number(diskIndex))
223+
224+
//let dataLetter = (await getUsableLetter() as string).substring(0, 2)
225+
//await runPacmd(' /hd:' + diskIndex + ' /setletter:0 /letter:' + dataLetter)
226+
if (dataLetter != '') {
227+
//if (await letterIsExist(dataLetter)) {
228+
//复制数据区文件
229+
await copyDir(tempDataPath, dataLetter + '\\')
230+
231+
//pe配置文件
232+
let HotPEConfig = readHotPEConfig(dataLetter + '\\')
233+
HotPEConfig.information.Installation_Method = 'UDisk'
234+
HotPEConfig.information.ReleaseVersion = takeLeftStr(config.resources.pe.new, '.')
235+
writeHotPEConfig(dataLetter + '\\', HotPEConfig)
236+
237+
await runCmdAsync('attrib ' + dataLetter + '\\HotPE +S +H /S /D')
238+
await runCmdAsync('attrib ' + dataLetter + '\\HotPE\\* +S +H /S /D')
239+
await runCmdAsync('attrib ' + dataLetter + '\\AUTORUN.INF +S +H /S /D')
240+
await runCmdAsync('attrib ' + dataLetter + '\\HotPE.ico +S +H /S /D')
241+
//}
242+
}else{
243+
isSucceed = isSucceed && false
244+
}
224245

225-
let dataLetter = (await getUsableLetter() as string).substring(0, 2)
226-
await runPacmd(' /hd:' + diskIndex + ' /setletter:0 /letter:' + dataLetter)
227-
228-
//if (await letterIsExist(dataLetter)) {
229-
//复制数据区文件
230-
await copyDir(tempDataPath, dataLetter + '\\')
231-
232-
//pe配置文件
233-
let HotPEConfig = readHotPEConfig(dataLetter + '\\')
234-
HotPEConfig.information.Installation_Method = 'UDisk'
235-
HotPEConfig.information.ReleaseVersion = takeLeftStr(config.resources.pe.new, '.')
236-
writeHotPEConfig(dataLetter + '\\', HotPEConfig)
237246

238-
await runCmdAsync('attrib ' + dataLetter + '\\HotPE +S +H /S /D')
239-
await runCmdAsync('attrib ' + dataLetter + '\\HotPE\\* +S +H /S /D')
240-
await runCmdAsync('attrib ' + dataLetter + '\\AUTORUN.INF +S +H /S /D')
241-
await runCmdAsync('attrib ' + dataLetter + '\\HotPE.ico +S +H /S /D')
242-
//}
243247

244248
setStep(2)
245249
setStepStr('正在清理退出')

src/view/controller/condition.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function checkPERes() {
2121
config.resources.pe.new = ''
2222
}
2323

24+
2425
//删除旧的PE资源
2526
for (let i in config.resources.pe.all) {
2627
if (config.resources.pe.all[i] != config.resources.pe.new) {

src/view/controller/init.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ import { checkHPMFiles } from "./hpm/checkHpmFiles"
1111
import { errorDialog } from "./log"
1212
import { exitapp } from "../layout/header"
1313
import { HotPEDriveChoose } from "../page/setting"
14+
import { runCmdAsync } from "../utils/command"
1415

1516
let isInitDone = false
1617

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

1922

2023
await initDir()

src/view/page/setup/setupToSys.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function SetupToSys(props:any) {
3030
<h2 >已安装到系统</h2>
3131
<h3 style={{color:'var(--semi-color-text-1)'}}>你已将HotPE安装到系统中,你可以进行</h3>
3232
{//更新按钮
33-
config.state.setupToSys < Number(takeLeftStr(config.resources.pe.new, '.')) ? <Button onClick={() => { updatePEForSys(setIsUninstalling, setCurrentStep, setStepStr,props.setLockMuen) }} type='primary' style={{ marginLeft: 8 }}>更新</Button> : <></>}
33+
config.state.setupToSys < Number(takeLeftStr(config.resources.pe.new, '.')) ? <Button onClick={() => { updatePEForSys(setIsUninstalling, setCurrentStep, setStepStr,props.setLockMuen) }} type='primary' style={{ marginRight: 8 }}>更新</Button> : <></>}
3434
<Button onClick={() => { uninstallToSystem(setIsUninstalling,props.setLockMuen) }} type='danger'>卸载</Button>
3535
</div>
3636
: <div style={{ textAlign: "center", marginTop: "70px", width: "100%" }}>

src/view/page/setup/setupToUDisk.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { IconRefresh } from '@douyinfe/semi-icons';
88
import { getEnvironment } from '../../controller/init';
99
import { UnInstallToUDisk, installToUDisk, updatePEForUDisk } from '../../controller/Install/toUDisk';
1010
import { checkPEDrive } from '../../controller/condition';
11+
import { getHotPEDriveVer } from '../../controller/Install/check';
1112

1213

1314
//let uDiskRefreshing =false
@@ -29,19 +30,6 @@ async function UDiskRefres(steUDiskRefreshing: Function, setLockMuen: Function)
2930
setLockMuen(false)
3031
}
3132

32-
//获取PE版本
33-
function getHotPEDriveVer(diskIndex: Number) {
34-
//console.log(config.environment.HotPEDrive.all);
35-
36-
for (let i in config.environment.HotPEDrive.all) {
37-
if (config.environment.HotPEDrive.all[i].diskIndex == diskIndex) {
38-
return config.environment.HotPEDrive.all[i].version
39-
}
40-
}
41-
42-
return ''
43-
}
44-
4533
export default function SetupToUDisk(props: any) {
4634
const [ignored, forceUpdate] = useReducer(x => x + 1, 0);//刷新页面
4735
const [uDiskRefreshing, steUDiskRefreshing] = useState(false)

0 commit comments

Comments
 (0)