Skip to content

Commit

Permalink
Merge pull request #1857 from yaklang/song/fix/projectMag
Browse files Browse the repository at this point in the history
Song/fix/project mag
  • Loading branch information
youngster-yj authored Jul 26, 2024
2 parents 3d2e6e4 + 9d4eadb commit c7ed419
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 127 deletions.
18 changes: 17 additions & 1 deletion app/main/handlers/project.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {ipcMain} = require("electron");
const { ipcMain } = require("electron");

module.exports = (win, getClient) => {
// asyncSetCurrentProject wrapper
Expand Down Expand Up @@ -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) => {
Expand Down
1 change: 1 addition & 0 deletions app/protos/grpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,6 @@ export const ConfigNetworkPage: React.FC<ConfigNetworkPageProp> = (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))
})
Expand Down Expand Up @@ -771,17 +767,11 @@ export const ConfigNetworkPage: React.FC<ConfigNetworkPageProp> = (props) => {
onChange={(e) => setChromePath(e.target.value)}
/>
<Upload
accept={".exe"}
multiple={false}
maxCount={1}
showUploadList={false}
beforeUpload={(f) => {
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) {
Expand Down
1 change: 1 addition & 0 deletions app/renderer/src/main/src/components/layout/UILayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ const UILayout: React.FC<UILayoutProp> = (props) => {
})

const onOkEnterProjectMag = () => {
ipcRenderer.invoke("SetCurrentProject", {})
setYakitMode("soft")
setShowProjectManage(true)
setCurrentProject(undefined)
Expand Down
Loading

0 comments on commit c7ed419

Please sign in to comment.