new autoload.js

This commit is contained in:
2024-09-20 15:15:08 +02:00
parent 2c59afc055
commit 419f5ae02e

8
live2d/dist/auto.js vendored
View File

@@ -1,9 +1,10 @@
const live2d_path = "https://www.luoyangdonghui.de/wp-content/uploads/live2d_test34/live2d/"; const live2d_path = "https://www.luoyangdonghui.de/wp-content/uploads/live2d_test35/live2d/";
//封装异步加载资源的方法 //封装异步加载资源的方法
function loadExternalResource(url, type) { function loadExternalResource(url, type) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let tag; let tag;
if (type === "css") { if (type === "css") {
tag = document.createElement("link"); tag = document.createElement("link");
tag.rel = "stylesheet"; tag.rel = "stylesheet";
@@ -13,6 +14,7 @@ function loadExternalResource(url, type) {
tag.src = url; tag.src = url;
tag.async = true; // 确保脚本是异步加载的 tag.async = true; // 确保脚本是异步加载的
} }
if (tag) { if (tag) {
tag.onload = () => { tag.onload = () => {
resolve(`Resource loaded: ${url}`); resolve(`Resource loaded: ${url}`);
@@ -34,7 +36,7 @@ function loadExternalResource(url, type) {
}); });
} }
if (screen.width >= 768) { if (screen.width >= 600) {
Promise.all([ Promise.all([
loadExternalResource(live2d_path + "waifu.css", "css"), loadExternalResource(live2d_path + "waifu.css", "css"),
loadExternalResource(live2d_path + "live2d.min.js", "js"), loadExternalResource(live2d_path + "live2d.min.js", "js"),
@@ -45,6 +47,7 @@ if (screen.width >= 768) {
]).then(() => { ]).then(() => {
loadExternalResource("https://cdn.jsdelivr.net/npm/meting@2.0.1/dist/Meting.min.js", "js"); loadExternalResource("https://cdn.jsdelivr.net/npm/meting@2.0.1/dist/Meting.min.js", "js");
}); });
ap = null; ap = null;
Object.defineProperty(document.querySelector('meting-js'), "aplayer", { Object.defineProperty(document.querySelector('meting-js'), "aplayer", {
set: function (aplayer) { set: function (aplayer) {
@@ -54,6 +57,7 @@ if (screen.width >= 768) {
} }
}); });
} }
console.log(` console.log(`
く__,.ヘヽ. / ,ー、 〉 く__,.ヘヽ. / ,ー、 〉
', !-─‐-i / /´ ', !-─‐-i / /´