import * as ReactDOM from "react-dom"; import Editor from "./Editor"; import React, { Component } from "react"; import { Layout, Tabs } from "antd"; import { ipcRenderer, remote } from "electron"; import * as path from "path"; import * as fs from "fs"; import * as Utils from "../common/Utils"; import MainEventType from "../common/MainEventType"; import Properties from "./Properties"; import Settings from "../main-process/Settings"; import G6 from "@antv/g6"; import "antd/dist/antd.dark.css"; import "./index.css"; import { ModelConfig, Item } from "@antv/g6/lib/types"; import RegisterNode from "./RegisterNode"; import TreeTabs from "./TreeTabs"; const { Header, Sider, Content, Footer } = Layout; const { TabPane } = Tabs; interface MainState { workdir: string; workspace: string; } export default class Main extends Component { state: MainState = { workdir: "", workspace: "", }; settings: Settings; tabs: TreeTabs; componentWillMount() { this.updateSettings(); RegisterNode(this.settings); } componentDidMount() { ipcRenderer.on(MainEventType.OPEN_FILE, (event: any, path: any) => { this.setState({ curPath: path }); }); ipcRenderer.on(MainEventType.OPEN_DIR, (event: any, workdir: any, workspace: string) => { console.log("on open workspace", workspace); document.title = workspace; this.setState({ workdir, workspace }); }); console.log("workdir", this.settings.curWorkspace.getWorkdir()); this.setState({ workdir: this.settings.curWorkspace.getWorkdir(), workspace: this.settings.curWorkspace.getFilepath(), }); } updateSettings() { this.settings = Utils.getRemoteSettings(); } render() { console.log("render main"); const { workdir, workspace } = this.state; document.title = `行为树编辑器 - ${workspace}`; return ( { this.tabs.openFile(path); }} /> { this.tabs = ref; }} /> ); } } ReactDOM.render(
, document.getElementById("root") as HTMLElement);