Use destructuring assignment

This commit is contained in:
Mimi 2020-07-31 15:13:35 +08:00
parent b6f9613eca
commit 26dfd56fc3
2 changed files with 13 additions and 11 deletions

View File

@ -135,7 +135,9 @@ https://github.com/xiaoski/live2d_models_collection
除此之外,还有桌面版本:
https://github.com/amorist/platelet
https://github.com/akiroz/Live2D-Widget
https://github.com/akiroz/Live2D-Widget
https://github.com/zenghongtu/PPet
https://github.com/LikeNeko/L2dPetForMac
## 许可证 License

View File

@ -170,29 +170,29 @@ function loadWidget(config) {
.then(response => response.json())
.then(result => {
window.addEventListener("mouseover", event => {
for (let tips of result.mouseover) {
if (!event.target.matches(tips.selector)) continue;
let text = randomSelection(tips.text);
for (let { selector, text } of result.mouseover) {
if (!event.target.matches(selector)) continue;
text = randomSelection(text);
text = text.replace("{text}", event.target.innerText);
showMessage(text, 4000, 8);
return;
}
});
window.addEventListener("click", event => {
for (let tips of result.click) {
if (!event.target.matches(tips.selector)) continue;
let text = randomSelection(tips.text);
for (let { selector, text } of result.click) {
if (!event.target.matches(selector)) continue;
text = randomSelection(text);
text = text.replace("{text}", event.target.innerText);
showMessage(text, 4000, 8);
return;
}
});
result.seasons.forEach(tips => {
result.seasons.forEach(({ date, text }) => {
const now = new Date(),
after = tips.date.split("-")[0],
before = tips.date.split("-")[1] || after;
after = date.split("-")[0],
before = date.split("-")[1] || after;
if ((after.split("/")[0] <= now.getMonth() + 1 && now.getMonth() + 1 <= before.split("/")[0]) && (after.split("/")[1] <= now.getDate() && now.getDate() <= before.split("/")[1])) {
let text = randomSelection(tips.text);
text = randomSelection(text);
text = text.replace("{year}", now.getFullYear());
//showMessage(text, 7000, true);
messageArray.push(text);