1
0
mirror of https://github.com/Dreamer-Paul/Pio.git synced 2025-03-27 12:30:34 +08:00
更换检测移动设备的方法
This commit is contained in:
奇趣保罗 2020-03-08 23:55:19 +08:00
parent 90e4531b22
commit deba457fbb
2 changed files with 11 additions and 8 deletions

View File

@ -2,7 +2,7 @@
# Pio Plugin
# By: Dreamer-Paul
# Last Update: 2020.02.10
# Last Update: 2020.3.8
一个支持更换 Live2D 模型的 Typecho 插件
@ -90,5 +90,4 @@
@media screen and (max-width: 768px){
#pio{ width: 8em }
.pio-container{ pointer-events: none }
.pio-container.hidden, .pio-action, .pio-dialog{ display: none }
}

View File

@ -2,7 +2,7 @@
# Pio Plugin
# By: Dreamer-Paul
# Last Update: 2020.02.10
# Last Update: 2020.3.8
一个支持更换 Live2D 模型的 Typecho 插件
@ -60,6 +60,13 @@ var Paul_Pio = function (prop) {
destroy: function () {
current.body.parentNode.removeChild(current.body);
localStorage.setItem("posterGirl", 0);
},
// 是否为移动设备
isMobile: function () {
var ua = window.navigator.userAgent.toLowerCase();
ua = ua.indexOf("mobile") || ua.indexOf("android") || ua.indexOf("ios");
return window.innerWidth < 500 || ua !== -1;
}
};
@ -241,12 +248,9 @@ var Paul_Pio = function (prop) {
// 运行
this.init = function (onlyText) {
current.body.classList.add("loaded");
if(!(prop.hidden && modules.isMobile())){
current.body.classList.add("loaded");
if(prop.hidden === true && window.innerWidth < 400){
current.body.classList.add("hidden");
}
else{
if(!onlyText){
action.welcome();
loadlive2d("pio", prop.model[0]);