From deba457fbbe6b7c9398fe94d9eb5d571f5ba775e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=87=E8=B6=A3=E4=BF=9D=E7=BD=97?= <dreamer_paul@126.com> Date: Sun, 8 Mar 2020 23:55:19 +0800 Subject: [PATCH] Fix #11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更换检测移动设备的方法 --- static/pio.css | 3 +-- static/pio.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/static/pio.css b/static/pio.css index 58cfad9..05a3e8b 100644 --- a/static/pio.css +++ b/static/pio.css @@ -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 } } \ No newline at end of file diff --git a/static/pio.js b/static/pio.js index 3163089..d74ee22 100644 --- a/static/pio.js +++ b/static/pio.js @@ -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]);