From 4bc1654b4e2928b02bc1234dad39611f448314a3 Mon Sep 17 00:00:00 2001 From: song_xiao_lin Date: Tue, 7 Jan 2025 14:29:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=E5=BD=93=E5=89=8D=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BD=8E=E4=BA=8E=E5=86=85=E7=BD=AE=E7=89=88=E6=9C=AC=EF=BC=8C?= =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E6=9B=B4=E6=96=B0=E4=B8=8B=E8=BD=BD=E5=86=85?= =?UTF-8?q?=E7=BD=AE=E7=89=88=E6=9C=AC&=E5=BC=95=E6=93=8E=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=89=8D=E6=8F=90=E7=A4=BA=E5=85=88=E6=9B=B4=E6=96=B0?= =?UTF-8?q?yakit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CheckEngineVersion.module.scss | 6 +- .../main/src/components/layout/FuncDomain.tsx | 53 +++++++++++---- .../main/src/components/layout/UILayout.tsx | 65 ++++++++++++++----- 3 files changed, 91 insertions(+), 33 deletions(-) diff --git a/app/renderer/src/main/src/components/layout/CheckEngineVersion/CheckEngineVersion.module.scss b/app/renderer/src/main/src/components/layout/CheckEngineVersion/CheckEngineVersion.module.scss index 809c1d84f8..8b13789179 100644 --- a/app/renderer/src/main/src/components/layout/CheckEngineVersion/CheckEngineVersion.module.scss +++ b/app/renderer/src/main/src/components/layout/CheckEngineVersion/CheckEngineVersion.module.scss @@ -1,5 +1 @@ -.check-engine-version-checkbox { - height: 100%; - display: flex; - align-items: center; -} + diff --git a/app/renderer/src/main/src/components/layout/FuncDomain.tsx b/app/renderer/src/main/src/components/layout/FuncDomain.tsx index 09174f54e5..174140d554 100644 --- a/app/renderer/src/main/src/components/layout/FuncDomain.tsx +++ b/app/renderer/src/main/src/components/layout/FuncDomain.tsx @@ -96,6 +96,7 @@ import {randomString} from "@/utils/randomUtil" import {ExpandAndRetractExcessiveState} from "@/pages/plugins/operator/expandAndRetract/ExpandAndRetract" import {YakitSpin} from "../yakitUI/YakitSpin/YakitSpin" import {PluginExecuteResult} from "@/pages/plugins/operator/pluginExecuteResult/PluginExecuteResult" +import {YakitHint} from "../yakitUI/YakitHint/YakitHint" const {ipcRenderer} = window.require("electron") @@ -1193,6 +1194,7 @@ interface UIOpUpdateProps { updateContent?: string onDownload: (type: "yakit" | "yaklang") => any onUpdateEdit?: (type: "yakit" | "yaklang") => any + isUpdate: boolean /** yakit属性 */ isUpdateWait?: boolean // 是否已下载未安装 @@ -1200,14 +1202,14 @@ interface UIOpUpdateProps { /** yaklang属性 */ localVersion?: string // 本地引擎文件版本 moreYaklangVersionList?: string[] // 更多引擎版本列表 - lowerYaklangLastVersion?: boolean // 引擎是否有更新 isRemoteMode?: boolean // 是否为远程模式 onNoticeShow?: (visible: boolean) => void + isUpdateYakit?: boolean // 下载引擎之前判断yakit是否需要先更新 } /** @name Yakit版本以及更新内容 */ const UIOpUpdateYakit: React.FC = React.memo((props) => { - const {version, lastVersion, isUpdateWait, onDownload, role, updateContent = "", onUpdateEdit} = props + const {version, lastVersion, isUpdate, isUpdateWait, onDownload, role, updateContent = "", onUpdateEdit} = props // 是否可编辑 const isShowModify = useMemo(() => { @@ -1216,8 +1218,6 @@ const UIOpUpdateYakit: React.FC = React.memo((props) => { return false }, [role]) - const isUpdate = lastVersion !== "" && removePrefixV(lastVersion) !== removePrefixV(version) - const content: string[] = useMemo(() => { if (updateContent) { const strs = updateContent.split("\n") @@ -1305,21 +1305,18 @@ const UIOpUpdateYaklang: React.FC = React.memo((props) => { lastVersion, localVersion = "", moreYaklangVersionList = [], - lowerYaklangLastVersion = false, isRemoteMode = false, onDownload, role, updateContent = "", onUpdateEdit, - onNoticeShow = () => {} + onNoticeShow = () => {}, + isUpdate, + isUpdateYakit } = props + const [updateHint, setUpdateHint] = useState(false) const [moreVersionPopShow, setMoreVersionPopShow] = useState(false) - - /** 是否存在更新 */ - const isUpdate = useMemo(() => { - return lowerYaklangLastVersion - }, [lowerYaklangLastVersion]) /** 判断连接引擎版本和本地引擎文件版本是否相同,不同提示是否重新启动引擎 */ const isKillEngine = useMemo(() => { return ( @@ -1404,11 +1401,36 @@ const UIOpUpdateYaklang: React.FC = React.memo((props) => {
更多版本
{isUpdate && ( -
onDownload("yaklang")}> +
{ + if (isUpdateYakit) { + onNoticeShow(false) + setUpdateHint(true) + } else { + onDownload("yaklang") + } + }} + > 立即更新
)} + { + setUpdateHint(false) + onDownload("yakit") + }} + onCancel={() => { + setUpdateHint(false) + onDownload("yaklang") + }} + /> {isKillEngine && ( ipcRenderer.invoke("kill-old-engine-process")} @@ -1893,6 +1915,9 @@ const UIOpNotice: React.FC = React.memo((props) => { }) const notice = useMemo(() => { + const isUpdateYakit = yakitLastVersion !== "" && removePrefixV(yakitLastVersion) !== removePrefixV(yakitVersion) + const isUpdateYaklang = lowerYaklangLastVersion + return (
@@ -1969,19 +1994,21 @@ const UIOpNotice: React.FC = React.memo((props) => { role={userInfo.role} updateContent={communityYakit} onUpdateEdit={UpdateContentEdit} + isUpdate={isUpdateYakit} />
diff --git a/app/renderer/src/main/src/components/layout/UILayout.tsx b/app/renderer/src/main/src/components/layout/UILayout.tsx index d3eebaeff7..e2ed9b318e 100644 --- a/app/renderer/src/main/src/components/layout/UILayout.tsx +++ b/app/renderer/src/main/src/components/layout/UILayout.tsx @@ -82,7 +82,7 @@ import {grpcFetchLatestYakVersion, grpcFetchYakInstallResult} from "@/apiUtils/g import {NetWorkApi} from "@/services/fetch" import {API} from "@/services/swagger/resposeType" import {visitorsStatisticsFun} from "@/utils/visitorsStatistics" -import { setYakitEngineMode } from "@/constants/software" +import {setYakitEngineMode} from "@/constants/software" const {ipcRenderer} = window.require("electron") @@ -201,16 +201,17 @@ const UILayout: React.FC = (props) => { NetWorkApi({ method: "get", url: "system/config" - }).then((config) => { - const data = config.data || [] - setEeSystemConfig([...data]) - }).catch(() => { - setEeSystemConfig([]) }) + .then((config) => { + const data = config.data || [] + setEeSystemConfig([...data]) + }) + .catch(() => { + setEeSystemConfig([]) + }) } }, [engineLink]) - /** ---------- 引擎状态和连接相关逻辑 Start ---------- */ /** 插件漏洞信息库自检 */ const handleBuiltInCheck = useMemoizedFn(() => { @@ -799,7 +800,7 @@ const UILayout: React.FC = (props) => { const [killOldEngine, setKillOldEngine] = useState(false) const [killLoading, setKillLoading] = useState(false) - const killOldProcess = useMemoizedFn(() => { + const killOldProcess = useMemoizedFn((callback?: () => void) => { let isFailed: boolean = false let port: number = 0 let pid: number = 0 @@ -850,6 +851,7 @@ const UILayout: React.FC = (props) => { info(`KILL yak PROCESS: ${pid}`) setKillOldEngine(false) setLinkLocalEngine() + callback && callback() }) .catch((e) => { failed(`PS | GREP yak failed ${e}`) @@ -885,16 +887,39 @@ const UILayout: React.FC = (props) => { const [builtInVersion, setBuiltInVersion] = useState("") const [currentVersion, setCurrentVersion] = useState("") + const compareVersions = (version1: string, version2: string) => { + // 用正则表达式将版本号分解成数字部分和beta后面的部分 + const parseVersion = (version) => { + const parts = version.split("-") // 分割 beta 部分 + const versionNumbers = parts[0].split(".").map((num) => parseInt(num)) // 获取数字部分 + const betaPart = parts[1] ? parseInt(parts[1].replace("beta", "")) : null // 如果有beta,提取beta后的数字 + return {versionNumbers, betaPart} + } + + const v1 = parseVersion(version1) + const v2 = parseVersion(version2) + + // 比较数字部分 + for (let i = 0; i < Math.min(v1.versionNumbers.length, v2.versionNumbers.length); i++) { + if (v1.versionNumbers[i] > v2.versionNumbers[i]) return 1 + if (v1.versionNumbers[i] < v2.versionNumbers[i]) return -1 + } + + // 如果数字部分相同,比较beta部分 + if (v1.betaPart !== null && v2.betaPart !== null) { + if (v1.betaPart > v2.betaPart) return 1 + if (v1.betaPart < v2.betaPart) return -1 + } + + // 如果没有beta部分,或者beta部分相同,则返回0 + return 0 + } + const showCheckVersion = useMemo(() => { if (isDev.current) return false if (!builtInVersion) return false if (!currentVersion) return false - if (!yakEngineVersionList.length) return false - const index1 = yakEngineVersionList.indexOf(currentVersion) - const index2 = yakEngineVersionList.indexOf(builtInVersion) - if (index1 === -1 || index2 === -1) return false - if (index1 > index2) return true - return false + return compareVersions(currentVersion, builtInVersion) === -1 }, [builtInVersion, currentVersion, yakEngineVersionList]) useEffect(() => { @@ -936,7 +961,17 @@ const UILayout: React.FC = (props) => { const onCheckVersionCancel = useMemoizedFn((flag: boolean) => { if (flag) { if (yaklangKillPss) return - emiter.emit("downYaklangSpecifyVersion", JSON.stringify({version: yaklangLastVersionRef.current})) + killOldProcess(() => { + ipcRenderer + .invoke("InitBuildInEngine", {}) + .then(() => { + yakitNotify("info", "解压内置引擎成功,即将重启软件") + ipcRenderer.invoke("relaunch") + }) + .catch((e) => { + yakitNotify("error", `解压内置引擎失败:${e}`) + }) + }) } setCurrentVersion("") }) From d93f2cdb6128e0bfe433a4fb148fa9a87afe5004 Mon Sep 17 00:00:00 2001 From: song_xiao_lin Date: Fri, 10 Jan 2025 10:58:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CheckEngineVersion/CheckEngineVersion.module.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/renderer/src/main/src/components/layout/CheckEngineVersion/CheckEngineVersion.module.scss b/app/renderer/src/main/src/components/layout/CheckEngineVersion/CheckEngineVersion.module.scss index 8b13789179..a30045f18c 100644 --- a/app/renderer/src/main/src/components/layout/CheckEngineVersion/CheckEngineVersion.module.scss +++ b/app/renderer/src/main/src/components/layout/CheckEngineVersion/CheckEngineVersion.module.scss @@ -1 +1,5 @@ - +.check-engine-version-checkbox { + height: 100%; + display: flex; + align-items: center; +} \ No newline at end of file From 616ab6bdb66ba6a7f32a99d09f79a52b0e5ed033 Mon Sep 17 00:00:00 2001 From: song_xiao_lin Date: Fri, 10 Jan 2025 14:22:09 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E5=8F=96=E6=B6=88=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/src/components/layout/FuncDomain.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/renderer/src/main/src/components/layout/FuncDomain.tsx b/app/renderer/src/main/src/components/layout/FuncDomain.tsx index 174140d554..0a06f28b99 100644 --- a/app/renderer/src/main/src/components/layout/FuncDomain.tsx +++ b/app/renderer/src/main/src/components/layout/FuncDomain.tsx @@ -1422,6 +1422,17 @@ const UIOpUpdateYaklang: React.FC = React.memo((props) => { content='更新Yakit可同步更新引擎,建议先更新Yakit' okButtonText='更新Yakit' cancelButtonText='更新引擎' + footerExtra={ + { + setUpdateHint(false) + }} + > + 取消 + + } onOk={() => { setUpdateHint(false) onDownload("yakit")