load file
This commit is contained in:
1 parent
001d122e5a
commit
3ed022af37
2 files changed
+10
-1
No files matched your search
@@ -17,7 +17,6 @@ export function initMenu(mainWindow: BrowserWindow) {
|
|||||||
{name: "Json", extensions:['json']}
|
{name: "Json", extensions:['json']}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
console.log("open res", res);
|
|
||||||
mainWindow.webContents.send(MainEventType.OPEN_FILE, res.filePaths[0]);
|
mainWindow.webContents.send(MainEventType.OPEN_FILE, res.filePaths[0]);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import { DatePicker } from 'antd';
|
import { DatePicker } from 'antd';
|
||||||
import { ipcRenderer } from 'electron';
|
import { ipcRenderer } from 'electron';
|
||||||
|
import * as fs from 'fs';
|
||||||
import MainEventType from "../../common/MainEventType";
|
import MainEventType from "../../common/MainEventType";
|
||||||
|
|
||||||
interface EditorState {
|
interface EditorState {
|
||||||
@@ -28,6 +29,14 @@ export default class Editor extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderJson() {
|
||||||
|
if(this.state.filepaths.length>0) {
|
||||||
|
const path = this.state.filepaths[0];
|
||||||
|
const str = fs.readFileSync(path, 'utf8');
|
||||||
|
return (<div>{str}</div>)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -37,6 +46,7 @@ export default class Editor extends Component {
|
|||||||
<div>
|
<div>
|
||||||
当前文件:{this.state.filepaths.join("\n")}
|
当前文件:{this.state.filepaths.join("\n")}
|
||||||
</div>
|
</div>
|
||||||
|
{this.renderJson()}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user