diff --git a/electron/main/index.ts b/electron/main/index.ts index a4101db..5cbd79e 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -103,6 +103,8 @@ async function createWindow(projectPath?: string) { nextWin.focus(); nextWin.webContents.send("refresh-app-men"); } + + win.focus(); }); win.on("closed", () => { diff --git a/package-lock.json b/package-lock.json index fa1060c..d9ae150 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "behavior3editor", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "behavior3editor", - "version": "1.1.0", + "version": "1.1.1", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 7324795..3cbd577 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "behavior3editor", - "version": "1.1.0", + "version": "1.1.1", "main": "dist-electron/main/index.js", "description": "行为树编辑器", "author": "zhandouxiaojiji & codetypes", diff --git a/src/components/editor.tsx b/src/components/editor.tsx index 570098e..08401d4 100644 --- a/src/components/editor.tsx +++ b/src/components/editor.tsx @@ -451,18 +451,22 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . return; } setTimeout(() => { - const subpath = dialog.showSaveDialogSync({ + let subpath = dialog.showSaveDialogSync({ defaultPath: workspace.workdir, properties: ["showOverwriteConfirmation"], filters: [{ name: "Json", extensions: ["json"] }], }); + if (!subpath) { return; } + + subpath = subpath.replaceAll(Path.sep, "/"); if (subpath.indexOf(workspace.workdir) == -1) { message.warning(t("node.subtreePathError")); return; } + const data = findDataById(editor.selectedId!); const subroot = b3util.createFileData(data); const subtreeModel = { @@ -471,7 +475,7 @@ export const Editor: FC = ({ onUpdate: updateState, data: editor, . desc: data.desc, } as TreeModel; fs.writeFileSync(subpath, JSON.stringify(subtreeModel, null, 2)); - data.path = subpath.substring(workspace.workdir.length + 1); + data.path = Path.relative(workspace.workdir, subpath).replaceAll(Path.sep, "/"); reload(); pushHistory(); onChange();