Commit 1370f76b authored by rocosen's avatar rocosen

fix:写入文件

parent 364b555d
......@@ -134,25 +134,24 @@ ipcMain.on('resize-home', (event) => {
});
});
// 主进程
// path.join(__dirname, '../renderer/data/data.json'),
ipcMain.on('asynchronous-message', function (event, arg) {
// arg是从渲染进程返回来的数据
fs.writeFile(
resolveHtmlPath('/data/roco.json'),
JSON.stringify(arg),
'utf8',
(err: any) => {
if (err) {
event.sender.send('asynchronous-reply', '写入失败');
// alert('222222');
} else {
event.sender.send('asynchronous-reply', '写入成功');
// alert('111111');
const USER_HOME =( process.env.HOME || process.env.USERPROFILE) + '\\.bkunyun\\'
fs.mkdir(USER_HOME,{recursive:true},(err: any) => {
if(err) return
fs.writeFile(
USER_HOME + 'roco.json' ,
JSON.stringify(arg),
'utf8',
(err: any) => {
if (err) {
event.sender.send('asynchronous-reply', '写入失败');
} else {
event.sender.send('asynchronous-reply', '写入成功');
}
}
}
);
);
})
});
ipcMain.on('window-close', (event) => {
......
......@@ -110,10 +110,11 @@ export default (props) => {
case '1':
return;
case '2':
console.log('2222222222222222222222');
const USER_HOME = process.env.HOME || process.env.USERPROFILE
console.log('USER_HOME: ', USER_HOME);
electron.ipcRenderer.send(
'asynchronous-message',
'传递回去ping'
'11111'
);
return;
case '4':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment