Skip to content

Commit daf391b

Browse files
committed
feat:optimize
1 parent 80d7604 commit daf391b

28 files changed

Lines changed: 540 additions & 321 deletions

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
22
"name": "hotpe-clientn",
33
"private": true,
4-
"version": "0.0.1",
4+
"version": "0.0.2",
55
"main": "dist/main/index.js",
66
"scripts": {
77
"dev": "vite",
88
"dev-main": "tsc -w --p ./src/main",
99
"dev-ele": "nodemon --watch ./dist/main/* --exec electron .",
10-
"build": "tsc && vite build && tsc -p ./src/main && electron-builder --ia32",
10+
"build": "tsc && vite build && tsc -p ./src/main && electron-builder --ia32 --dir",
1111
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1212
"preview": "vite preview"
1313
},
1414
"dependencies": {
1515
"electron-is-dev": "^2.0.0",
16+
"electron-log": "^4.4.8",
1617
"ini": "^4.1.1",
1718
"react-markdown": "^8.0.7",
1819
"react-virtualized": "^9.22.5",
@@ -33,7 +34,7 @@
3334
"@typescript-eslint/parser": "^5.60.1",
3435
"@vitejs/plugin-react-swc": "^3.3.2",
3536
"copyfiles": "^2.4.1",
36-
"electron": "^25.2.0",
37+
"electron": "^18.0.0",
3738
"electron-builder": "^24.4.0",
3839
"eslint": "^8.43.0",
3940
"eslint-plugin-react-hooks": "^4.6.0",

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=20230718
10+
ldate=20230720
1111
Lang=cn
1212
Ver=9.13.0

resources/tools/update/update.bat

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
1+
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
22

33
::{pack}为新客户端压缩包路径,{clientDir}为客户端路径:末带\
44
@echo off
55
chcp 65001
66
mode con cols=60 lines=20
77
color 03
8+
cd /d "%~dp0"
89
title HotPE客户端更新中,请稍等...
10+
taskkill /IM "HotPE Client.exe" /F > tmp
911
TIMEOUT /T 3
10-
cd /d "%~dp0"
12+
1113

1214
if "%1"=="h" GOTO exit
1315

@@ -29,7 +31,8 @@ del "{clientDir}resources\elevate.exe" /F /Q > tmp
2931
rd "{clientDir}resources\tools\" /S /Q > tmp
3032

3133
echo 替换文件
32-
xcopy "%~dp0updateTemp\" "{clientDir}" /E /C /Q /H /R /Y > tmp
34+
xcopy "%~dp0updateTemp\*" "{clientDir}*" /E /C /Q /H /R /Y > tmp
35+
3336

3437
echo 清理退出
3538
rd "%~dp0updateTemp\" /S /Q > tmp

src/main/index.ts

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
//import RunCmd from './function/runCmd'
21
import { app, BrowserWindow, ipcMain, shell } from 'electron'
32
import { dialog } from 'electron';
4-
//const { app, BrowserWindow, ipcMain, shell } =require('electron');
5-
//var path = require('path');
6-
const path = require('path');
3+
import path from 'path'
74

85
//是否为开发模式
9-
//const isDev = require('electron-is-dev');
106
import isDev from 'electron-is-dev'
117

8+
129
app.on('ready', () => {
1310
//创建一个窗口
1411
const mainWindow = new BrowserWindow({
@@ -29,57 +26,49 @@ app.on('ready', () => {
2926
}
3027
})
3128

32-
33-
//remote
34-
//require('@electron/remote/main').initialize()
35-
//require("@electron/remote/main").enable(mainWindow.webContents)
29+
//窗口加载html文件
30+
//mainWindow.loadFile('./src/main.html')
31+
mainWindow.loadURL(isDev ? 'http://localhost:5173' : `file://${path.join(__dirname, '../view/index.html')}`);
3632

3733
//去掉菜单栏
3834
mainWindow.removeMenu()
3935

40-
4136
//开发工具
4237
if (isDev == true) {
4338
mainWindow.webContents.openDevTools({ mode: 'right' })
44-
}
45-
46-
//mainWindow.webContents.openDevTools({ mode: 'right' })
39+
}
40+
ipcMain.on('windows:openDevTools', () => {
41+
mainWindow.webContents.openDevTools({ mode: 'right' })
42+
})
4743

48-
//窗口加载html文件
49-
//mainWindow.loadFile('./src/main.html')
50-
mainWindow.loadURL(isDev ? 'http://localhost:5173' : `file://${path.join(__dirname, '../view/index.html')}`);
5144

52-
5345
ipcMain.on('exitapp', () => {
5446
app.exit()//退出
5547
})
5648

5749
ipcMain.on('windows:mini', () => {
5850
mainWindow.minimize();//最小化
5951
})
60-
//console.log(RunCmd("dir"))
6152

6253
//拦截首页打开新窗口的链接用浏览器打开
54+
mainWindow.webContents.setWindowOpenHandler((details) => {
55+
shell.openExternal(details.url)
56+
return { action: 'deny' }//取消创建新窗口
57+
})
6358

64-
//test()
65-
66-
59+
//选择文件保存位置
6760
ipcMain.on('file:getSavePath', (event, message) => {
68-
console.log(`receive message from render: `)
6961
event.returnValue = dialog.showSaveDialogSync({
7062
title: "请选择文件保存位置",
7163
buttonLabel: "保存",
72-
defaultPath:message.toString(),
64+
defaultPath: message.toString(),
7365
filters: [
74-
{ name: '镜像文件', extensions: ['iso'] },
75-
]
66+
{ name: '镜像文件', extensions: ['iso'] },
67+
]
7668
})
77-
7869
})
7970

8071

72+
8173
})
8274

83-
async function test(){
84-
console.log();
85-
}

src/view/app.tsx

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,15 @@
1-
import React, { useState } from 'react';
1+
import React, { useState,useEffect,useReducer } from 'react';
22
import Header_ from './layout/header.tsx'
33
import Page from './page/page.tsx'
44

5-
import { Layout, Nav, Button, Notification } from '@douyinfe/semi-ui';
5+
import { Layout, Nav, Button, Notification, Badge } from '@douyinfe/semi-ui';
66
import { IconAppCenter, IconHelpCircle, IconPaperclip, IconHome, IconSetting } from '@douyinfe/semi-icons';
7+
import { HPMDLRender, HPMDlList } from './services/hpm.ts';
78

89
const { Header, Sider, Content } = Layout;
910

1011
export default function App() {
11-
const naviItems = [
12-
{ itemKey: 'Home', text: '首页', icon: <IconHome /> },
13-
{
14-
text: '安装',
15-
icon: <IconPaperclip />,
16-
itemKey: 'Setup',
17-
items: [{ itemKey: 'SetupToSys', text: '安装到系统' }, { itemKey: 'SetupToUDisk', text: '安装到U盘' }, { itemKey: 'MakeISO', text: '生成ISO镜像' }],
18-
},
19-
{
20-
text: '模块',
21-
icon: <IconAppCenter />,
22-
itemKey: 'HPM',
23-
items: [{ itemKey: 'HPMDl', text: '下载模块' }, { itemKey: 'HPMMgr', text: '模块管理' }, { itemKey: 'TaskMgr', text: '任务管理' }],
24-
},
25-
{ itemKey: 'Docs', text: '文档', icon: <IconHelpCircle /> },
26-
{ itemKey: 'Setting', text: '设置', icon: <IconSetting /> }
27-
];
12+
2813

2914
const [navKey, setNavKey] = useState('Home');
3015
const [lockMuen, setLockMuen] = useState(false);
@@ -51,15 +36,8 @@ export default function App() {
5136
</Header>
5237
<Layout style={{ width: '100%', height: 'calc(100vh - 41px)' }}>
5338
<Sider style={{ backgroundColor: 'var(--semi-color-bg-1)' }}>
54-
<Nav
55-
style={{ maxWidth: 170, height: '100%' }}
56-
selectedKeys={[navKey]}
57-
defaultSelectedKeys={['Home']}
58-
defaultOpenKeys={['Setup', 'HPM']}
59-
items={naviItems}
60-
onSelect={(e) => { upNavKey(e.itemKey.toString()) }}
61-
footer={{ collapseButton: true, }}
62-
/>
39+
<Navigation navKey={navKey} upNavKey={upNavKey}></Navigation>
40+
6341
</Sider>
6442
<Content style={{ backgroundColor: 'var(--semi-color-bg-0)', height: "100%" }}>
6543
<Page navKey={navKey} setNavKey={setNavKey} setLockMuen={setLockMuen}></Page>
@@ -69,4 +47,45 @@ export default function App() {
6947
</Layout>
7048

7149
)
72-
}
50+
}
51+
52+
function Navigation(props:any) {
53+
const [ignored, forceUpdate] = useReducer(x => x + 1, 0);//刷新组件
54+
55+
useEffect(() => {
56+
HPMDLRender.callRefreshNav = forceUpdate
57+
})
58+
59+
const naviItems = [
60+
{ itemKey: 'Home', text: '首页', icon: <IconHome /> },
61+
{
62+
text: '安装',
63+
icon: <IconPaperclip />,
64+
itemKey: 'Setup',
65+
items: [{ itemKey: 'SetupToSys', text: '安装到系统' }, { itemKey: 'SetupToUDisk', text: '安装到U盘' }, { itemKey: 'MakeISO', text: '生成ISO镜像' }],
66+
},
67+
{
68+
text: '模块',
69+
icon: <IconAppCenter />,
70+
itemKey: 'HPM',
71+
items: [{ itemKey: 'HPMDl', text: '下载模块' }, { itemKey: 'HPMMgr', text: '模块管理' }, {
72+
itemKey: 'TaskMgr', text: <>
73+
任务管理{HPMDlList.length > 0 ? <Badge count={HPMDlList.length} overflowCount={99} type='primary' /> : <></>}
74+
</>
75+
}],
76+
},
77+
{ itemKey: 'Docs', text: '文档', icon: <IconHelpCircle /> },
78+
{ itemKey: 'Setting', text: '设置', icon: <IconSetting /> }
79+
];
80+
81+
return <Nav
82+
style={{ maxWidth: 170, height: '100%' }}
83+
selectedKeys={[props.navKey]}
84+
defaultSelectedKeys={['Home']}
85+
defaultOpenKeys={['Setup', 'HPM']}
86+
items={naviItems}
87+
onSelect={(e) => { props.upNavKey(e.itemKey.toString()) }}
88+
footer={{ collapseButton: true, }}
89+
/>
90+
91+
}

src/view/controller/Install/makeISO.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Notification } from '@douyinfe/semi-ui';
22
import { config, roConfig } from '../../services/config';
33
import { runCmdAsync } from '../../utils/command';
4-
import { copyFiles, dealStrForCmd, delDir, isFileExisted, takeLeftStr, unZipFile } from '../../utils/utils';
4+
import { copyDir, copyFile, dealStrForCmd, delDir, isFileExisted, takeLeftStr, unZipFile } from '../../utils/utils';
55
import { checkIsReady } from './check';
66

77
const { shell, ipcRenderer } = require('electron')
@@ -26,11 +26,11 @@ export async function makeISOFile(setStep: Function, setStepStr: Function,setLoc
2626
isSucceed = isSucceed && await unZipFile(roConfig.path.resources.pe + config.resources.pe.new, tempPathSource)
2727

2828
setStepStr('正在复制HotPE文件')
29-
isSucceed = isSucceed && await copyFiles(tempPathSource + 'EFI\\*', tempPathISO)
30-
isSucceed = isSucceed && await copyFiles(tempPathSource + 'Data\\*', tempPathISO)
29+
isSucceed = isSucceed && await copyDir(tempPathSource + 'EFI\\', tempPathISO)
30+
isSucceed = isSucceed && await copyDir(tempPathSource + 'Data\\', tempPathISO)
3131

3232
setStepStr('正在生成ISO文件')
33-
await runCmdAsync(roConfig.path.tools + 'oscdimg\\oscdimg.exe -m -o -u2 -udfver102 -h -bootdata:2#p0,e,b' + dealStrForCmd(roConfig.path.tools + 'oscdimg\\Etfsboot.com') + '#pEF,e,b' + dealStrForCmd(roConfig.path.tools + 'oscdimg\\Efisys.bin') + ' -l HotPEToolBox ' + dealStrForCmd(tempPathISO) + ' ' + dealStrForCmd(ISOSavePath))
33+
await runCmdAsync(roConfig.path.tools + 'oscdimg\\oscdimg.exe -m -o -u2 -udfver102 -h -bootdata:2#p0,e,b' + dealStrForCmd(roConfig.path.tools + 'oscdimg\\Etfsboot.com') + '#pEF,e,b' + dealStrForCmd(roConfig.path.tools + 'oscdimg\\Efisys.bin') + ' -lHotPEToolBox ' + dealStrForCmd(tempPathISO) + ' ' + dealStrForCmd(ISOSavePath))
3434

3535
isSucceed = isSucceed && await isFileExisted(ISOSavePath)
3636

src/view/controller/Install/toSystem.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { config, roConfig } from "../../services/config";
22
import { runCmdAsync } from "../../utils/command";
3-
import { copyFiles, delDir, delFiles, isFileExisted, readHotPEConfig, takeLeftStr, unZipFile, writeHotPEConfig } from "../../utils/utils";
3+
import { copyDir, copyFile, delDir, delFiles, isFileExisted, readHotPEConfig, takeLeftStr, unZipFile, writeHotPEConfig } from "../../utils/utils";
44
import { Notification } from "@douyinfe/semi-ui";
55
import ini from 'ini'
66
import { checkPEDrive } from "../condition";
@@ -50,11 +50,12 @@ export async function installToSystem(setCurrentStep: Function, setStepStr: Func
5050
//await fs.mkdir(roConfig.environment.sysLetter + 'HotPEModule\\', (back: any) => { console.log(back) })
5151

5252
//复制文件
53-
await copyFiles(tempPath + 'EFI\\HotPE\\kernel.wim', roConfig.environment.sysLetter + 'HotPE\\kernel.wim')
54-
await copyFiles(tempPath + 'Data\\HotPE\\confi.ini', roConfig.environment.sysLetter + 'HotPE\\confi.ini')
55-
await copyFiles(tempPath + 'EFI\\HotPE\\HotPE.ini', roConfig.environment.sysLetter + 'HotPE\\HotPE.ini')
56-
await copyFiles(tempPath + 'EFI\\HotPE\\Data\\', roConfig.environment.sysLetter + 'HotPE\\Data\\')
57-
await copyFiles(tempPath + 'Data\\HotPEModule\\', roConfig.environment.sysLetter + 'HotPEModule\\')
53+
await copyFile(tempPath + 'EFI\\HotPE\\kernel.wim', roConfig.environment.sysLetter + 'HotPE\\kernel.wim')
54+
await copyFile(tempPath + 'EFI\\HotPE\\kernel.sdi', roConfig.environment.sysLetter + 'HotPE\\kernel.sdi')
55+
await copyFile(tempPath + 'Data\\HotPE\\confi.ini', roConfig.environment.sysLetter + 'HotPE\\confi.ini')
56+
await copyFile(tempPath + 'EFI\\HotPE\\HotPE.ini', roConfig.environment.sysLetter + 'HotPE\\HotPE.ini')
57+
await copyDir(tempPath + 'EFI\\HotPE\\Data\\', roConfig.environment.sysLetter + 'HotPE\\Data\\')
58+
await copyDir(tempPath + 'Data\\HotPEModule\\', roConfig.environment.sysLetter + 'HotPEModule\\')
5859

5960
//pe配置文件
6061
let HotPEConfig = readHotPEConfig(roConfig.environment.sysLetter)

src/view/controller/Install/toUDisk.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Modal, Notification } from "@douyinfe/semi-ui"
22
import { config, roConfig } from "../../services/config"
33
import { runCmdAsync } from "../../utils/command"
4-
import { copyFiles, delDir, delFiles, getUsableLetter, isHotPEDrive, letterIsExist, moveFiles, readHotPEConfig, takeLeftStr, unZipFile, writeHotPEConfig } from "../../utils/utils"
4+
import { copyDir, copyFile, delDir, delFiles, getUsableLetter, isHotPEDrive, letterIsExist, moveFiles, readHotPEConfig, takeLeftStr, unZipFile, writeHotPEConfig } from "../../utils/utils"
55
import { checkPEDrive } from "../condition"
66
import { checkIsReady } from "./check"
77
import { ReactNode } from "react"
@@ -76,7 +76,7 @@ export async function installToUDisk(diskIndex: string, setStep: Function, setSt
7676
await runCmdAsync(pecmdPath + ' DFMT ' + dataLetter + ',exFAT,HotPE工具箱')
7777

7878
//复制数据区文件
79-
await copyFiles(tempDataPath, dataLetter + '\\')
79+
await copyDir(tempDataPath, dataLetter + '\\')
8080

8181
//pe配置文件
8282
let HotPEConfig = readHotPEConfig(dataLetter + '\\')
@@ -227,7 +227,7 @@ export async function updatePEForUDisk(diskIndex: string, setStep: Function, set
227227

228228
//if (await letterIsExist(dataLetter)) {
229229
//复制数据区文件
230-
await copyFiles(tempDataPath, dataLetter + '\\')
230+
await copyDir(tempDataPath, dataLetter + '\\')
231231

232232
//pe配置文件
233233
let HotPEConfig = readHotPEConfig(dataLetter + '\\')

src/view/controller/condition.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { runCmdAsync } from "../utils/command";
66
import { isHotPEDrive, traverseFiles, readHotPEConfig } from "../utils/utils"
77
import { getHardwareInfo } from "../utils/hardwareInfo"
88
import { getEnvironment, updateState } from "./init";
9+
import { checkHPMFiles } from "./hpm/checkHpmFiles";
910

1011
//检查PE资源
1112
export async function checkPERes() {
@@ -79,6 +80,9 @@ export async function checkPEDrive() {
7980
//选择最后一个PE盘符
8081
if (config.environment.HotPEDrive.all.length > 0) {
8182
config.environment.HotPEDrive.new = config.environment.HotPEDrive.all[config.environment.HotPEDrive.all.length - 1]
83+
84+
//更新HPM列表本地
85+
checkHPMFiles()
8286
}
8387

8488
console.log('HotPEDrive:', config.environment.HotPEDrive);

0 commit comments

Comments
 (0)