mirror of
https://github.com/caojiezi2003/live2d-widget.git
synced 2024-11-10 04:49:47 +00:00
Skip script loading when screen width is narrow
This commit is contained in:
parent
7c604ae5b7
commit
e4037cdcd6
16
autoload.js
16
autoload.js
@ -25,13 +25,15 @@ function loadExternalResource(url, type) {
|
||||
}
|
||||
|
||||
// 加载 waifu.css live2d.min.js waifu-tips.js
|
||||
Promise.all([
|
||||
loadExternalResource(live2d_path + "waifu.css", "css"),
|
||||
loadExternalResource(live2d_path + "live2d.min.js", "js"),
|
||||
loadExternalResource(live2d_path + "waifu-tips.js", "js")
|
||||
]).then(() => {
|
||||
initWidget(live2d_path + "waifu-tips.json", "https://live2d.fghrsh.net/api");
|
||||
});
|
||||
if (screen.width >= 768) {
|
||||
Promise.all([
|
||||
loadExternalResource(live2d_path + "waifu.css", "css"),
|
||||
loadExternalResource(live2d_path + "live2d.min.js", "js"),
|
||||
loadExternalResource(live2d_path + "waifu-tips.js", "js")
|
||||
]).then(() => {
|
||||
initWidget(live2d_path + "waifu-tips.json", "https://live2d.fghrsh.net/api");
|
||||
});
|
||||
}
|
||||
// initWidget 第一个参数为 waifu-tips.json 的路径,第二个参数为 API 地址
|
||||
// API 后端可自行搭建,参考 https://github.com/fghrsh/live2d_api
|
||||
// 初始化看板娘会自动加载指定目录下的 waifu-tips.json
|
||||
|
@ -221,7 +221,6 @@ function loadWidget(waifuPath, apiPath) {
|
||||
}
|
||||
|
||||
function initWidget(waifuPath = "/waifu-tips.json", apiPath = "") {
|
||||
if (screen.width <= 768) return;
|
||||
document.body.insertAdjacentHTML("beforeend", `<div id="waifu-toggle">
|
||||
<span>看板娘</span>
|
||||
</div>`);
|
||||
|
@ -7,7 +7,7 @@
|
||||
"text": ["猜猜我要说些什么?", "我从青蛙王子那里听到了不少人生经验。"]
|
||||
}, {
|
||||
"selector": "#waifu-tool .fa-paper-plane",
|
||||
"text": ["要不要来玩飞机大战?", "这个按钮上写着“不要点击”。", "怎么,你想来和我玩个游戏?", "听说这样可以蹦迪!"]
|
||||
"text": ["要不要来玩飞机大战?", "这个按钮上写着「不要点击」。", "怎么,你想来和我玩个游戏?", "听说这样可以蹦迪!"]
|
||||
}, {
|
||||
"selector": "#waifu-tool .fa-user-circle",
|
||||
"text": ["你是不是不爱人家了呀,呜呜呜~", "要见见我的姐姐嘛?", "想要看我妹妹嘛?", "要切换看板娘吗?"]
|
||||
|
Loading…
Reference in New Issue
Block a user