save & save all

This commit is contained in:
zhandouxiaojiji committed 2020-11-04 10:32:39 +08:00
1 parent 3392630e6b
commit c4eb53ac68
5 files changed
+66 -5

No files matched your search

+14 -4
View File
@@ -1,17 +1,17 @@
import * as React from 'react';
import * as fs from 'fs';
import * as path from 'path';
import { Row, Col, message } from 'antd';
import NodePanel from './NodePanel';
import { INode } from '@antv/g6/lib/interface/item';
import G6, { TreeGraph, Util } from '@antv/g6';
import { TreeGraphData, IG6GraphEvent } from '@antv/g6/lib/types';
import G6, { TreeGraph } from '@antv/g6';
import { G6GraphEvent } from '@antv/g6/lib/interface/behavior';
import './Editor.css';
import * as Utils from '../../common/Utils';
import { BehaviorTreeModel, GraphNodeModel, BehaviorNodeModel } from '../../common/BehaviorTreeModel';
import TreePanel from './TreePanel';
import Settings from '../../main-process/Settings';
import './Editor.css';
export interface EditorProps {
filepath: string;
}
@@ -303,6 +303,16 @@ export default class Editor extends React.Component<EditorProps, EditorState> {
this.graph.set('animate', true);
}
save() {
const { filepath } = this.props;
const root = Utils.createFileData(this.graph.findDataById('1') as GraphNodeModel);
fs.writeFileSync(filepath, JSON.stringify({
name: path.basename(filepath).slice(0, -5),
root,
desc: root.desc,
}));
}
render() {
const { curNodeId, treeModel, settings } = this.state;
var curNode: any;