代码拉取完成,页面将自动刷新
const { app, BrowserWindow, ipcMain, dialog } = require('electron')
//复用创建窗口得方法
class AppWindow extends BrowserWindow {
constructor(config, fileLocation) {
const basicConfig = {
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true
}
}
//这段代码啥意思
const finalConfig = { ...basicConfig, ...config }
super(finalConfig)
this.loadFile(fileLocation)
this.once('ready-to-show', () => {
this.show()
})
}
}
app.on('ready', () => {
const mainWindow = new AppWindow({}, './renderer/index.html')
ipcMain.on('add-music-window', () => {
console.log('333333')
const addWindow = new AppWindow({
width: 500,
height: 400,
parent: mainWindow
}, './renderer/add.html')
})
mainWindow.webContents.openDevTools();
ipcMain.on('open-music-file', (event,arg) => {
console.log('sdfsdgdfhg33333')
const files= dialog.showOpenDialog({
properties: ['openFile', 'multiSelections'],
filters: [{ name: 'Music', extensions: ['mp3'] }]
})
console.log(files);
if (files) {
console.log('=======');
event.sender.send('selected-file', files)
}
console.log('88888');
})
})
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。