open file & workspace path
This commit is contained in:
1 parent
84e1e376b9
commit
001d122e5a
5 files changed
+46
-16
No files matched your search
@@ -1,26 +1,43 @@
|
||||
import React, { Component } from "react";
|
||||
import { DatePicker } from 'antd';
|
||||
import { ipcRenderer } from 'electron';
|
||||
import EventType from "../../common/EventType";
|
||||
import MainEventType from "../../common/MainEventType";
|
||||
|
||||
interface EditorState {
|
||||
workspace: string;
|
||||
filepaths: string[];
|
||||
}
|
||||
|
||||
export default class Editor extends Component {
|
||||
state: EditorState = {
|
||||
workspace: ''
|
||||
workspace: '',
|
||||
filepaths: [],
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
ipcRenderer.on(EventType.MAIN_OPEN_FILE, (event: any, path: any) => {
|
||||
console.log("on", event, path);
|
||||
})
|
||||
ipcRenderer.on(MainEventType.OPEN_FILE, (event: any, path: any) => {
|
||||
console.log("on open file", path);
|
||||
const filepaths = this.state.filepaths;
|
||||
filepaths.push(path);
|
||||
this.setState({filepaths});
|
||||
});
|
||||
|
||||
ipcRenderer.on(MainEventType.OPEN_WORKSPACE, (event: any, workspace: any) => {
|
||||
console.log("on open workspace", workspace);
|
||||
this.setState({workspace});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DatePicker />
|
||||
<div>
|
||||
<div>
|
||||
当前目录:{this.state.workspace}
|
||||
</div>
|
||||
<div>
|
||||
当前文件:{this.state.filepaths.join("\n")}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user