mirror of
https://github.com/Buriburizaem0n/live2d.git
synced 2026-02-04 03:20:02 +00:00
new autoload.js
This commit is contained in:
44
live2d/dist/auto.js
vendored
44
live2d/dist/auto.js
vendored
@@ -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,26 +36,28 @@ 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"),
|
||||||
loadExternalResource(live2d_path + "/dist/waifu-tips.js", "js"),
|
loadExternalResource(live2d_path + "/dist/waifu-tips.js", "js"),
|
||||||
loadExternalResource("https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css", "css"),
|
loadExternalResource("https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css", "css"),
|
||||||
loadExternalResource("https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js", "js"),
|
loadExternalResource("https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js", "js"),
|
||||||
loadExternalResource("https://cdn.jsdelivr.net/npm/live2dcubismcore@1.0.2/live2dcubismcore.min.js", "js"),
|
loadExternalResource("https://cdn.jsdelivr.net/npm/live2dcubismcore@1.0.2/live2dcubismcore.min.js", "js"),
|
||||||
]).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;
|
|
||||||
Object.defineProperty(document.querySelector('meting-js'), "aplayer", {
|
ap = null;
|
||||||
set: function(aplayer) {
|
Object.defineProperty(document.querySelector('meting-js'), "aplayer", {
|
||||||
ap = aplayer;
|
set: function (aplayer) {
|
||||||
ap_init();
|
ap = aplayer;
|
||||||
initWidget();
|
ap_init();
|
||||||
}
|
initWidget();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`
|
console.log(`
|
||||||
く__,.ヘヽ. / ,ー、 〉
|
く__,.ヘヽ. / ,ー、 〉
|
||||||
\ ', !-─‐-i / /´
|
\ ', !-─‐-i / /´
|
||||||
|
|||||||
Reference in New Issue
Block a user