function createTray () {
const menubarPic = process.platform === 'darwin' ? `${__static}/menubar.png` : `${__static}/menubar-nodarwin.png`
tray = new Tray(menubarPic)
const contextMenu =
tray.on('right-click', () => {
window.hide()
tray.popUpContextMenu(contextMenu)
})
tray.on('click', () => {
if (process.platform === 'darwin') {
toggleWindow()
} else {
window.hide()
if (settingWindow === null) {
createSettingWindow()
settingWindow.show()
} else {
settingWindow.show()
settingWindow.focus()
}
}
})
}
export default {
mounted () {
t his.disableDragEvent()
},
methods: {
disableDragEvent () {
window.addEventListener('dragenter', this.disableDrag, false)
window.addEventListener('dragover', this.disableDrag)
window.addEventListener('drop', this.disableDrag)
},
disableDrag (e) {
const dropzone = document.getElementById('upload-area')
if (dropzone === null || !dropzone.contains(e.target)) {
e.preventDefault()
e.dataTransfer.effectAllowed = 'none'
e.dataTransfer.dropEffect = 'none'
}
}
},
beforeDestroy () {
window.removeEventListener('dragenter', this.disableDrag, false)
window.removeEventListener('dragover', this.disableDrag)
window.removeEventListener('drop', this.disableDrag)
}
}
this.$electron.remote.xxx
this.$electron.remote.shell.openExternal('https://github.com/Molunerfinn/PicGo')
openDialog () {
this.$electron.remote.dialog.showMessageBox({
title: 'PicGo',
message: 'PicGo',
detail: `Version: ${pkg.version}\nAuthor: Molunerfinn\nGithub: https://github.com/Molunerfinn/PicGo`
})
}
if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
聊天编辑器光标处插入表情
function handleCaptureScreen() {
return new Promise((resolve) => {
const { execFile } = require('child_process')
var screenWin = execFile('./static/PrintScr.exe')
screenWin.on('exit', function(code) {
let pngs = require('electron').clipboard.readImage().toPNG()
let imgData = new Buffer.from(pngs, 'base64')
let imgs = 'data:image/png;base64,' + btoa(new Uint8Array(imgData).reduce((data, byte) => data + String.fromCharCode(byte), ''))
resolve(imgs)
})
})
}
function minimizeWindow () {
const window = BrowserWindow.getFocusedWindow()
window.minimize()
}
function closeWindow () {
const window = BrowserWindow.getFocusedWindow()
window.close()
}