This repository has been archived on 2025-01-09. You can view files and clone it, but cannot push or open issues or pull requests.

26 lines
982 B
JavaScript
Raw Permalink Normal View History

2025-01-09 18:30:49 +08:00
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('自定义标题', '当前错误内容')
})
}