fix save subtree error on windows

This commit is contained in:
codetypes committed 2024-04-19 10:56:15 +08:00
1 parent 5dab8220a5
commit cd22671a3a
4 files changed
+11 -5

No files matched your search

+2
View File
@@ -103,6 +103,8 @@ async function createWindow(projectPath?: string) {
nextWin.focus();
nextWin.webContents.send("refresh-app-men");
}
win.focus();
});
win.on("closed", () => {
+2 -2
View File
@@ -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": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "behavior3editor",
"version": "1.1.0",
"version": "1.1.1",
"main": "dist-electron/main/index.js",
"description": "行为树编辑器",
"author": "zhandouxiaojiji & codetypes",
+6 -2
View File
@@ -451,18 +451,22 @@ export const Editor: FC<EditorProps> = ({ 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<EditorProps> = ({ 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();