mirror of
https://github.com/stevenjoezhang/live2d-widget.git
synced 2024-11-22 20:59:59 +08:00
Update autoload.js
This commit is contained in:
parent
eaaf4a9e5f
commit
269dde43a6
25
autoload.js
25
autoload.js
@ -24,10 +24,20 @@ function loadExternalResource(url, type) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//判断移动端用户方法
|
||||||
|
function isMobile() {
|
||||||
|
var userAgent = navigator.userAgent || window.opera;
|
||||||
|
|
||||||
|
if (/android/i.test(userAgent) || /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 加载 waifu.css live2d.min.js waifu-tips.js
|
// 加载 waifu.css live2d.min.js waifu-tips.js
|
||||||
if (screen.width >= 768) {
|
if (isMobile()) {
|
||||||
|
//移动端用户
|
||||||
Promise.all([
|
Promise.all([
|
||||||
loadExternalResource(live2d_path + "waifu.css", "css"),
|
loadExternalResource(live2d_path + "waifu-mobie.css", "css"),
|
||||||
loadExternalResource(live2d_path + "live2d.min.js", "js"),
|
loadExternalResource(live2d_path + "live2d.min.js", "js"),
|
||||||
loadExternalResource(live2d_path + "waifu-tips.js", "js")
|
loadExternalResource(live2d_path + "waifu-tips.js", "js")
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
@ -35,20 +45,17 @@ if (screen.width >= 768) {
|
|||||||
initWidget({
|
initWidget({
|
||||||
waifuPath: live2d_path + "waifu-tips.json",
|
waifuPath: live2d_path + "waifu-tips.json",
|
||||||
//apiPath: "https://live2d.fghrsh.net/api/",
|
//apiPath: "https://live2d.fghrsh.net/api/",
|
||||||
cdnPath: "https://fastly.jsdelivr.net/gh/fghrsh/live2d_api/",
|
cdnPath: "/live2djs/",
|
||||||
tools: ["hitokoto", "asteroids", "switch-model", "switch-texture", "photo", "info", "quit"]
|
tools: ["hitokoto", "asteroids", "switch-model", "switch-texture", "photo", "info", "quit"]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
|
//pc端用户
|
||||||
// 加载 waifu.css live2d.min.js waifu-tips-.js,适配移动端
|
|
||||||
if (screen.width < 768) {
|
|
||||||
Promise.all([
|
Promise.all([
|
||||||
loadExternalResource(live2d_path + "waifu-mobie.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 + "waifu-tips.js", "js")
|
loadExternalResource(live2d_path + "waifu-tips.js", "js")
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
// 配置选项的具体用法见 README.md
|
|
||||||
initWidget({
|
initWidget({
|
||||||
waifuPath: live2d_path + "waifu-tips.json",
|
waifuPath: live2d_path + "waifu-tips.json",
|
||||||
//apiPath: "https://live2d.fghrsh.net/api/",
|
//apiPath: "https://live2d.fghrsh.net/api/",
|
||||||
|
Loading…
Reference in New Issue
Block a user