1 Star 0 Fork 4

zhujiajian/flow-cat-public

forked from JackWhh/flow-cat-public 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
renderer.js 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
JackWhh 提交于 2022-11-18 18:03 . init
const Flower = require('./Flower')
const {getDirFileNum} = require("./util");
let openSrc = 'img/张嘴1.png'
let closeSrc = 'img/闭嘴1.png'
const imgElement = document.getElementById('imgAvatar');
imgElement.addEventListener("mousedown", ev => {
if (ev.button === 2) {
const string = imgElement.src.substring(imgElement.src.length - 5, imgElement.src.length).split('.')[0];
let index = parseInt(string);
if (index) {
getDirFileNum(`${__dirname}/img`).then(res=>{
console.log(res)
if (index < (res/2)) {
index++
openSrc = `img/张嘴${index}.png`
closeSrc = `img/闭嘴${index}.png`
} else {
openSrc = 'img/张嘴1.png'
closeSrc = 'img/闭嘴1.png'
}
imgElement.src = closeSrc
})
}
}
})
window.onGlobalKeyBoard = (type, value) => {
if (1 === type) {
const imgElement = document.getElementById('imgAvatar');
if (imgElement.src.concat('闭嘴')) {
imgElement.src = openSrc
imgElement.offsetTop
imgElement.offsetLeft
}
for (let i = 0; i < 6; i++) {
const number = parseInt((Math.random() * 21) + '')
document.body.appendChild(new Flower(`flower_${number + 1}.png`).img)
}
}
if (2 === type) {
const imgElement = document.getElementById('imgAvatar');
if (imgElement.src.concat('张嘴')) {
imgElement.src = closeSrc
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhujjjamie/flow-cat-public.git
git@gitee.com:zhujjjamie/flow-cat-public.git
zhujjjamie
flow-cat-public
flow-cat-public
main

搜索帮助