From 328291a4a61c6f5d814e0fea92b16c410134cd61 Mon Sep 17 00:00:00 2001 From: song_xiao_lin Date: Fri, 19 Jul 2024 12:02:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E9=A1=B9=E7=9B=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E7=BC=96=E8=BE=91=E8=B5=B0=E6=96=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3&=E5=85=8D=E9=85=8D=E7=BD=AE=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E8=B7=AF=E5=BE=84=E4=B8=8D=E9=99=90=E5=88=B6=E5=90=8E?= =?UTF-8?q?=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main/handlers/project.js | 18 +- app/protos/grpc.proto | 1 + .../configNetwork/ConfigNetworkPage.tsx | 10 -- .../pages/softwareSettings/ProjectManage.tsx | 160 ++++++++---------- .../src/main/src/utils/ConfigSystemProxy.tsx | 10 -- 5 files changed, 93 insertions(+), 106 deletions(-) diff --git a/app/main/handlers/project.js b/app/main/handlers/project.js index 773a287068..5dde2627ee 100644 --- a/app/main/handlers/project.js +++ b/app/main/handlers/project.js @@ -1,4 +1,4 @@ -const {ipcMain} = require("electron"); +const { ipcMain } = require("electron"); module.exports = (win, getClient) => { // asyncSetCurrentProject wrapper @@ -65,6 +65,22 @@ module.exports = (win, getClient) => { return await asyncNewProject(params) }) + // asyncUpdateProject wrapper + const asyncUpdateProject = (params) => { + return new Promise((resolve, reject) => { + getClient().UpdateProject(params, (err, data) => { + if (err) { + reject(err) + return + } + resolve(data) + }) + }) + } + ipcMain.handle("UpdateProject", async (e, params) => { + return await asyncUpdateProject(params) + }) + // asyncIsProjectNameValid wrapper const asyncIsProjectNameValid = (params) => { return new Promise((resolve, reject) => { diff --git a/app/protos/grpc.proto b/app/protos/grpc.proto index 602a5038fb..180aacc90c 100644 --- a/app/protos/grpc.proto +++ b/app/protos/grpc.proto @@ -568,6 +568,7 @@ service Yak { rpc GetCurrentProject(Empty) returns (ProjectDescription); rpc GetProjects(GetProjectsRequest) returns (GetProjectsResponse); rpc NewProject(NewProjectRequest) returns (NewProjectResponse); + rpc UpdateProject(NewProjectRequest) returns(NewProjectResponse); rpc IsProjectNameValid(IsProjectNameValidRequest) returns (Empty); rpc RemoveProject(RemoveProjectRequest) returns (Empty); diff --git a/app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx b/app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx index 30478f9978..e6af4d5458 100644 --- a/app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx +++ b/app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx @@ -456,10 +456,6 @@ export const ConfigNetworkPage: React.FC = (props) => { } }) }, []) - const suffixFun = (file_name: string) => { - let file_index = file_name.lastIndexOf(".") - return file_name.slice(file_index, file_name.length) - } const onSetChromePath = useMemoizedFn((value?: string) => { setRemoteValue(RemoteGV.GlobalChromePath, JSON.stringify(value || chromePath)) }) @@ -771,17 +767,11 @@ export const ConfigNetworkPage: React.FC = (props) => { onChange={(e) => setChromePath(e.target.value)} /> { const file_name = f.name - const suffix = suffixFun(file_name) - if (![".exe"].includes(suffix)) { - warn("上传文件格式错误,请重新上传") - return false - } // @ts-ignore const path: string = f?.path || "" if (path.length > 0) { diff --git a/app/renderer/src/main/src/pages/softwareSettings/ProjectManage.tsx b/app/renderer/src/main/src/pages/softwareSettings/ProjectManage.tsx index 5790c75581..f72eabc519 100644 --- a/app/renderer/src/main/src/pages/softwareSettings/ProjectManage.tsx +++ b/app/renderer/src/main/src/pages/softwareSettings/ProjectManage.tsx @@ -2,7 +2,7 @@ import React, {memo, ReactNode, useEffect, useImperativeHandle, useMemo, useRef, import {useDebounceEffect, useGetState, useMemoizedFn, useScroll, useVirtualList} from "ahooks" import {YakitInput} from "@/components/yakitUI/YakitInput/YakitInput" import {QueryGeneralRequest} from "../invoker/schema" -import {failed, info, yakitFailed,warn} from "@/utils/notification" +import {failed, info, yakitFailed, warn} from "@/utils/notification" import { ChevronDownIcon, ChevronRightIcon, @@ -53,7 +53,7 @@ import styles from "./ProjectManage.module.scss" import {useTemporaryProjectStore} from "@/store/temporaryProject" import emiter from "@/utils/eventBus/eventBus" import YakitCollapse from "@/components/yakitUI/YakitCollapse/YakitCollapse" -import { AutoTextarea } from "../fuzzer/components/AutoTextarea/AutoTextarea" +import {AutoTextarea} from "../fuzzer/components/AutoTextarea/AutoTextarea" const {ipcRenderer} = window.require("electron") const {YakitPanel} = YakitCollapse @@ -297,22 +297,23 @@ const ProjectManage: React.FC = memo((props) => { ) } }, - { - key: "Description", - name: "备注", + { + key: "Description", + name: "备注", width: "30%", - render:(data)=>{ + render: (data) => { try { - const arr:{Key:string,Value:string}[] = JSON.parse(data.Description) + const arr: {Key: string; Value: string}[] = JSON.parse(data.Description) let str = "" - arr.forEach((item)=>{ + arr.forEach((item) => { str += `${item.Key}:${item.Value}; ` }) return str } catch (error) { return data.Description } - }}, + } + }, { key: "DatabasePath", name: "存储路径", @@ -775,22 +776,20 @@ const ProjectManage: React.FC = memo((props) => { ChildFolderId: projectInfo.ChildFolderId ? +projectInfo.ChildFolderId : 0, Type: "project" } - if (newProject.ProjectName === projectInfo.oldName) { - if (projectInfo.Id) newProject.Id = +projectInfo.Id + if (projectInfo.Id) { + newProject.Id = +projectInfo.Id ipcRenderer - .invoke("NewProject", newProject) + .invoke("UpdateProject", newProject) .then((res) => { - info(projectInfo.Id ? "编辑项目成功" : "创建新项目成功") + info("编辑项目成功") setModalInfo({visible: false}) - setParams({...params, Pagination: {...params.Pagination, Page: 1}}) setNewProjectInfo(res) setTimeout(() => { - setInquireIntoProjectVisible(true) update() }, 300) }) .catch((e) => { - failed(`${projectInfo.Id ? "编辑" : "创建新"}项目失败:${e}`) + failed(`编辑项目失败:${e}`) }) .finally(() => { setTimeout(() => { @@ -799,38 +798,26 @@ const ProjectManage: React.FC = memo((props) => { }) } else { ipcRenderer - .invoke("IsProjectNameValid", newProject) - .then((e) => { - if (projectInfo.Id) newProject.Id = +projectInfo.Id - ipcRenderer - .invoke("NewProject", newProject) - .then((res) => { - info(projectInfo.Id ? "编辑项目成功" : "创建新项目成功") - setModalInfo({visible: false}) - setParams({...params, Pagination: {...params.Pagination, Page: 1}}) - setNewProjectInfo(res) - setTimeout(() => { - setInquireIntoProjectVisible(true) - update() - }, 300) - }) - .catch((e) => { - failed(`${projectInfo.Id ? "编辑" : "创建新"}项目失败:${e}`) - }) - .finally(() => { - setTimeout(() => { - setModalLoading(false) - }, 300) - }) + .invoke("NewProject", newProject) + .then((res) => { + info("创建新项目成功") + setModalInfo({visible: false}) + setParams({...params, Pagination: {...params.Pagination, Page: 1}}) + setNewProjectInfo(res) + setTimeout(() => { + setInquireIntoProjectVisible(true) + update() + }, 300) }) .catch((e) => { - info(`${projectInfo.Id ? "编辑" : "创建新"}项目失败,项目名校验不通过:${e}`) + failed(`${projectInfo.Id ? "编辑" : "创建新"}项目失败:${e}`) + }) + .finally(() => { setTimeout(() => { setModalLoading(false) }, 300) }) } - return case "isNewFolder": let folderInfo: ProjectFolderInfoProps = {...(value as any)} @@ -1628,19 +1615,18 @@ export const NewProjectAndFolder: React.FC = memo((pro if (visible && isNew && project) { try { const firstDescribe = JSON.parse(project.Description) - if(Array.isArray(firstDescribe)){ + if (Array.isArray(firstDescribe)) { onReset({ Description: firstDescribe }) - } - else{ + } else { onReset({ - Description: [{Key: '系统', Value: ''}] + Description: [{Key: "系统", Value: ""}] }) } } catch (error) { onReset({ - Description: [{Key: '系统', Value: ''}] + Description: [{Key: "系统", Value: ""}] }) } setInfo({ @@ -1730,15 +1716,15 @@ export const NewProjectAndFolder: React.FC = memo((pro visible: false }) - const validateArray = useMemoizedFn((arr)=>{ - return arr.every(item => item.Key.trim() !== '' && item.Value.trim() !== ''); + const validateArray = useMemoizedFn((arr) => { + return arr.every((item) => item.Key.trim() !== "" && item.Value.trim() !== "") }) const onSubmit = useMemoizedFn(() => { const v = form.getFieldsValue() const isHasDescription = Array.isArray(v?.Description) && v.Description.length > 0 - - if(isHasDescription && !validateArray(v.Description)){ + + if (isHasDescription && !validateArray(v.Description)) { warn("请将备注信息填写完整") return } @@ -1772,8 +1758,8 @@ export const NewProjectAndFolder: React.FC = memo((pro } const type = isFolder ? "isNewFolder" : "isNewProject" - data.Description = isHasDescription?JSON.stringify(v?.Description):"" - + data.Description = isHasDescription ? JSON.stringify(v?.Description) : "" + onModalSubmit(type, {...data}) } if (isExport) { @@ -1902,7 +1888,7 @@ export const NewProjectAndFolder: React.FC = memo((pro ) => { e.stopPropagation() onReset({ - [field]: [{Key: '系统', Value: ''}] + [field]: [{Key: "系统", Value: ""}] }) ref.current.setVariableActiveKey(["0"]) } @@ -2015,37 +2001,41 @@ export const NewProjectAndFolder: React.FC = memo((pro /> )} -
-
备注 :
+
+
备注 :
{/* 添加额外的元素 */} - - { - handleReset(e, "Description", describeRef) - }} - size='small' - > - 重置 - - - { - handleAdd(e, "Description", describeRef) - }} - className={styles["btn-padding-right-0"]} - size='small' - > - 添加 - - + + { + handleReset(e, "Description", describeRef) + }} + size='small' + > + 重置 + + + { + handleAdd(e, "Description", describeRef) + }} + className={styles["btn-padding-right-0"]} + size='small' + > + 添加 + +
- { - handleRemove(i, "Description") - }}/> + { + handleRemove(i, "Description") + }} + /> {/* = React.forwardRef((props,ref) => { - const {field,onDel,collapseWrapperClassName,extra} = props +const VariableProjectList: React.FC = React.forwardRef((props, ref) => { + const {field, onDel, collapseWrapperClassName, extra} = props const [variableActiveKey, setVariableActiveKey] = useState(["0"]) useImperativeHandle( @@ -2456,8 +2446,8 @@ const VariableProjectList: React.FC = React.forwardRef setVariableActiveKey(key as string[]) }) - return( -
+ return ( +
{(fields, {add}) => { return ( diff --git a/app/renderer/src/main/src/utils/ConfigSystemProxy.tsx b/app/renderer/src/main/src/utils/ConfigSystemProxy.tsx index 647fd2bd1a..fd57cebcbe 100644 --- a/app/renderer/src/main/src/utils/ConfigSystemProxy.tsx +++ b/app/renderer/src/main/src/utils/ConfigSystemProxy.tsx @@ -168,10 +168,6 @@ export const ConfigChromePath: React.FC = (props) => { onClose() }) - const suffixFun = (file_name: string) => { - let file_index = file_name.lastIndexOf(".") - return file_name.slice(file_index, file_name.length) - } return (
@@ -191,17 +187,11 @@ export const ConfigChromePath: React.FC = (props) => { onChange={(e) => setChromePath(e.target.value)} /> { const file_name = f.name - const suffix = suffixFun(file_name) - if (![".exe"].includes(suffix)) { - warn("上传文件格式错误,请重新上传") - return false - } // @ts-ignore const path: string = f?.path || "" if (path.length > 0) { From 9148245d98b16a48e180d7728ca690b0af019ee4 Mon Sep 17 00:00:00 2001 From: Youngster_yj <907985037@qq.com> Date: Fri, 26 Jul 2024 11:18:32 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E5=A4=87=E6=B3=A8=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8C=BA=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/softwareSettings/ProjectManage.tsx | 128 ++++++++++-------- 1 file changed, 70 insertions(+), 58 deletions(-) diff --git a/app/renderer/src/main/src/pages/softwareSettings/ProjectManage.tsx b/app/renderer/src/main/src/pages/softwareSettings/ProjectManage.tsx index f72eabc519..b530d8b509 100644 --- a/app/renderer/src/main/src/pages/softwareSettings/ProjectManage.tsx +++ b/app/renderer/src/main/src/pages/softwareSettings/ProjectManage.tsx @@ -54,6 +54,7 @@ import {useTemporaryProjectStore} from "@/store/temporaryProject" import emiter from "@/utils/eventBus/eventBus" import YakitCollapse from "@/components/yakitUI/YakitCollapse/YakitCollapse" import {AutoTextarea} from "../fuzzer/components/AutoTextarea/AutoTextarea" +import {isCommunityEdition} from "@/utils/envfile" const {ipcRenderer} = window.require("electron") const {YakitPanel} = YakitCollapse @@ -1613,21 +1614,23 @@ export const NewProjectAndFolder: React.FC = memo((pro fetchFirstList() } if (visible && isNew && project) { - try { - const firstDescribe = JSON.parse(project.Description) - if (Array.isArray(firstDescribe)) { - onReset({ - Description: firstDescribe - }) - } else { + if (!isCommunityEdition()) { + try { + const firstDescribe = JSON.parse(project.Description) + if (Array.isArray(firstDescribe)) { + onReset({ + Description: firstDescribe + }) + } else { + onReset({ + Description: [{Key: "系统", Value: ""}] + }) + } + } catch (error) { onReset({ Description: [{Key: "系统", Value: ""}] }) } - } catch (error) { - onReset({ - Description: [{Key: "系统", Value: ""}] - }) } setInfo({ Id: +project.Id, @@ -1724,7 +1727,7 @@ export const NewProjectAndFolder: React.FC = memo((pro const v = form.getFieldsValue() const isHasDescription = Array.isArray(v?.Description) && v.Description.length > 0 - if (isHasDescription && !validateArray(v.Description)) { + if (isHasDescription && !validateArray(v.Description) && !isCommunityEdition()) { warn("请将备注信息填写完整") return } @@ -1758,7 +1761,9 @@ export const NewProjectAndFolder: React.FC = memo((pro } const type = isFolder ? "isNewFolder" : "isNewProject" - data.Description = isHasDescription ? JSON.stringify(v?.Description) : "" + if(!isCommunityEdition()){ + data.Description = isHasDescription ? JSON.stringify(v?.Description) : "" + } onModalSubmit(type, {...data}) } @@ -2001,51 +2006,58 @@ export const NewProjectAndFolder: React.FC = memo((pro /> )} -
-
备注 :
- {/* 添加额外的元素 */} - - { - handleReset(e, "Description", describeRef) - }} - size='small' - > - 重置 - - - { - handleAdd(e, "Description", describeRef) - }} - className={styles["btn-padding-right-0"]} - size='small' - > - 添加 - - - -
- { - handleRemove(i, "Description") - }} - /> - {/* - setInfo({...info, Description: e.target.value})} - /> - */} + <> + {isCommunityEdition() ? ( + + setInfo({...info, Description: e.target.value})} + /> + + ) : ( + <> +
+
备注 :
+ {/* 添加额外的元素 */} + + { + handleReset(e, "Description", describeRef) + }} + size='small' + > + 重置 + + + { + handleAdd(e, "Description", describeRef) + }} + className={styles["btn-padding-right-0"]} + size='small' + > + 添加 + + + +
+ { + handleRemove(i, "Description") + }} + /> + + )} + )} {isExport && ( From 9d4eadbc62bebc92db10870a467df637558f573c Mon Sep 17 00:00:00 2001 From: song_xiao_lin Date: Fri, 26 Jul 2024 15:43:21 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E9=A1=B9=E7=9B=AE=E5=8D=A0=E7=94=A8?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/renderer/src/main/src/components/layout/UILayout.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/app/renderer/src/main/src/components/layout/UILayout.tsx b/app/renderer/src/main/src/components/layout/UILayout.tsx index 6925fb1519..80936ebb8b 100644 --- a/app/renderer/src/main/src/components/layout/UILayout.tsx +++ b/app/renderer/src/main/src/components/layout/UILayout.tsx @@ -992,6 +992,7 @@ const UILayout: React.FC = (props) => { }) const onOkEnterProjectMag = () => { + ipcRenderer.invoke("SetCurrentProject", {}) setYakitMode("soft") setShowProjectManage(true) setCurrentProject(undefined)