specify output directory when build

This commit is contained in:
codetypes committed 2024-03-12 09:46:56 +08:00
1 parent 8e43285089
commit 95689ec712
4 files changed
+49 -34

No files matched your search

+4 -9
View File
@@ -2,8 +2,8 @@ import { Tabs, message } from "antd";
import { ipcRenderer } from "electron";
import * as fs from "fs";
import * as path from "path";
import * as Utils from "../common/Utils";
import React, { Component } from "react";
import * as Utils from "../common/Utils";
import Editor from "./Editor";
import "antd/dist/antd.dark.css";
@@ -72,7 +72,7 @@ export default class TreeTabs extends Component<TreeTabsProps, TreeTabsState> {
message.success("已保存所有行为树");
});
ipcRenderer.on(MainEventType.BUILD, () => {
ipcRenderer.on(MainEventType.BUILD, async (event, buildDir) => {
for (let k in this.editors) {
let editor = this.editors[k];
editor.save();
@@ -80,21 +80,16 @@ export default class TreeTabs extends Component<TreeTabsProps, TreeTabsState> {
const settings = Utils.getRemoteSettings();
const workdir = settings.workdir;
if (!fs.existsSync(workdir)) {
console.log("workdir not found:", workdir);
return;
}
const files = fs.readdirSync(workdir).filter((f) => {
return f.endsWith(".json");
});
for (const path of files) {
const builddir = fs.realpathSync(workdir + "/../build", "utf-8");
fs.mkdirSync(builddir, { recursive: true });
const buildpath = builddir + "/" + path;
const buildpath = buildDir + "/" + path;
console.log("build:", buildpath);
const treeModel = Utils.createBuildData(path, settings);
fs.writeFileSync(buildpath, JSON.stringify(treeModel, null, 2));
}
message.success("已构建所有行为树");
});
ipcRenderer.on(MainEventType.UNDO, () => {
+32 -22
View File
@@ -5,7 +5,7 @@ import { Layout, message, Tabs } from "antd";
import * as Utils from "../common/Utils";
import MainEventType from "../common/MainEventType";
import Settings from "../main-process/Settings";
import {ipcRenderer} from "electron";
import { ipcRenderer } from "electron";
import "antd/dist/antd.dark.css";
import "./index.css";
import RegisterNode from "./RegisterNode";
@@ -53,20 +53,20 @@ export default class Main extends Component {
}
SyncRequest("POST", serverModel.host, {
body: JSON.stringify({
cmd:"btree.reload",
cmd: "btree.reload",
data: {
trees: this.tabs.getOpenTreesModel()
trees: this.tabs.getOpenTreesModel(),
},
session: this.session++,
timestamp: Date.now(),
})
}),
});
message.success("服务器已更新");
})
});
ipcRenderer.on(MainEventType.BATCH_EXEC, (event: any, path: string)=>{
ipcRenderer.on(MainEventType.BATCH_EXEC, (event: any, path: string) => {
BatchExec(path, this.state.workdir);
})
});
console.log("workdir", this.settings.curWorkspace.getWorkdir());
setTimeout(() => {
@@ -113,7 +113,7 @@ export default class Main extends Component {
sider.style.maxWidth = width + "px";
sider.style.minWidth = "0px";
sider.style.flex = "";
reSizer.style.left = (width - 5) + "px";
reSizer.style.left = width - 5 + "px";
content.style.width = window.innerWidth - width + "px";
}
@@ -122,16 +122,27 @@ export default class Main extends Component {
document.documentElement.removeEventListener("mouseup", stopDrag, false);
}
reSizer.addEventListener("mouseover", function() {
reSizer.style.opacity = "1";
reSizer.addEventListener("mousedown", initDrag, false);
reSizer.addEventListener("mouseout", function init() {
reSizer.style.opacity = "0";
}, false);
}, false);
reSizer.addEventListener(
"mouseover",
function () {
reSizer.style.opacity = "1";
reSizer.addEventListener("mousedown", initDrag, false);
reSizer.addEventListener(
"mouseout",
function init() {
reSizer.style.opacity = "0";
},
false
);
},
false
);
window.addEventListener("resize", function() {
const currentWidth = parseInt(document.defaultView.getComputedStyle(reSizerParent).width, 10);
window.addEventListener("resize", function () {
const currentWidth = parseInt(
document.defaultView.getComputedStyle(reSizerParent).width,
10
);
setWidth(currentWidth);
});
@@ -147,7 +158,7 @@ export default class Main extends Component {
const { workdir, workspace } = this.state;
document.title = `行为树编辑器 - ${workspace}`;
return (
<Layout className="body" style={{flexDirection: "column"}}>
<Layout className="body" style={{ flexDirection: "column" }}>
<Sider className="sider" width={250}>
{workdir !== "" ? (
<Explorer
@@ -166,16 +177,15 @@ export default class Main extends Component {
"Please Open Workspace"
)}
</Sider>
<div id="sizer-hint-bar"/>
<div id="sizer-hint-bar" />
<Content className="content">
<TreeTabs
ref={(ref) => {
this.tabs = ref;
}}
onTabSelected={(path)=>{
onTabSelected={(path) => {
this.explorer.selectNode(path);
}
}
}}
/>
</Content>
</Layout>