26 lines
982 B
JavaScript
26 lines
982 B
JavaScript
const { remote } = require('electron')
|
|
|
|
window.onload = () => {
|
|
let oBtn = document.getElementById('btn')
|
|
let oBtnErr = document.getElementById('btnErr')
|
|
|
|
oBtn.addEventListener('click', () => {
|
|
remote.dialog.showOpenDialog({
|
|
defaultPath: __dirname, // 默认打开目录
|
|
buttonLabel: '请选择', // 按钮上的文字
|
|
title: '啦啦啦啦', // 对话框标题
|
|
properties: ['openFiles', 'multiSelections'], // 文件类型
|
|
filters: [ // 文件类型过滤
|
|
{'name': '代码文件', extensions: ['js', 'json', 'html']},
|
|
{'name': '图片文件', extensions: ['ico', 'jpeg', 'png']},
|
|
{'name': '媒体类型', extensions: ['avi', 'mp4', 'mp3']},
|
|
],
|
|
}).then(ret => {
|
|
alert(ret)
|
|
})
|
|
})
|
|
|
|
oBtnErr.addEventListener('click', () => {
|
|
remote.dialog.showErrorBox('自定义标题', '当前错误内容')
|
|
})
|
|
} |