first commit

This commit is contained in:
编码猿
2024-09-27 01:07:59 +08:00
commit 6cd216628a
162 changed files with 21879 additions and 0 deletions

40
static/page-script/pexels.js Executable file
View File

@@ -0,0 +1,40 @@
const { ipcRenderer } = require('electron')
const { render } = require('./render')
const isImg = target => target.tagName === 'IMG' && ['photo-item__img'].includes(target.className)
const mouseoverFn = function (e){
const { target } = e
if (isImg(target)){
const imgParent = target.parentNode
if (!imgParent.addChild){
const options = {
width: target.getAttribute('data-image-width'),
height: target.getAttribute('data-image-height'),
url: target.getAttribute('data-large-src'),
downloadUrl: target.getAttribute('data-big-src').split('?')[0]
}
imgParent.addChild = render(options)
imgParent.appendChild(imgParent.addChild)
}
}
}
const mouseoutFn = function (e){
const { target } = e
if (isImg(target)){
const imgParent = target.parentNode
if (imgParent.addChild){
window.setTimeout(() => {
if (!imgParent.addChild.mouseoverFlag){
imgParent.removeChild(imgParent.addChild)
imgParent.addChild = null
}
}, 40)
}
}
}
ipcRenderer.on('dom-ready', () => {
document.querySelector('body').addEventListener('mouseover', mouseoverFn, false)
document.querySelector('body').addEventListener('mouseout', mouseoutFn, false)
})