File tree Expand file tree Collapse file tree
blog-consumer/src/main/resources Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,3 +57,17 @@ function topFunction() {
5757 document . documentElement . scrollTop = 0 ;
5858}
5959// ------------------------------------回到顶部 NED ------------------------------------
60+
61+ // ------------------------------------检查客户端的类型 NED ------------------------------------
62+ function clientType ( ) {
63+ if ( / ( i P h o n e | i P a d | i P o d | i O S ) / i. test ( navigator . userAgent ) ) {
64+ //alert("iPhone")
65+ return "iPhone"
66+ } else if ( / ( A n d r o i d ) / i. test ( navigator . userAgent ) ) {
67+ //alert("Android")
68+ return "Android"
69+ } else {
70+ return "PC"
71+ }
72+ }
73+ // ------------------------------------检查客户端的类型 NED ------------------------------------
Original file line number Diff line number Diff line change 6464< body >
6565 < div th:replace ="components/nav "> </ div >
6666
67- < div class ="face article-meta-container ">
67+ < div class ="face article-meta-container " id =" articleMetaDiv " >
6868 < h1 th:text ="${articleVo.title} "> title</ h1 >
6969
7070 < p >
@@ -83,7 +83,7 @@ <h1 th:text="${articleVo.title}">title</h1>
8383 </ div >
8484 </ div >
8585
86- < div class ="face ">
86+ < div class ="face " id =" articleMainDiv " >
8787 <!--左侧导航栏-->
8888 < aside >
8989 </ aside >
@@ -105,7 +105,7 @@ <h1 th:text="${articleVo.title}">title</h1>
105105 </ div >
106106
107107 <!--评论区-->
108- < div class ="face article-comment-container ">
108+ < div class ="face article-comment-container " id =" articleCommentDiv " >
109109 <!--评论-->
110110 < div class ="add-comment-container " th:if ="${articleVo.commented != null && articleVo.commented} ">
111111 < p style ="text-align: center; font-size: x-large "> 留下你的评论</ p >
@@ -192,6 +192,16 @@ <h1 th:text="${articleVo.title}">title</h1>
192192< script src ="/js/common.js "> </ script >
193193< script >
194194 $ ( function ( ) {
195+ //检查浏览器类型,移除仅在PC端才会显示的元素
196+ let type = clientType ( )
197+ if ( "PC" !== type ) {
198+ $ ( "#articleMetaDiv" ) . removeClass ( "face" )
199+ $ ( "#articleMainDiv" ) . removeClass ( "face" )
200+ $ ( "#articleCommentDiv" ) . removeClass ( "face" )
201+
202+ $ ( "aside" ) . remove ( )
203+ }
204+
195205 //当出现滚动时,就检测一下,是否需要显示回到顶部按钮
196206 window . onscroll = function ( ) {
197207 scrollFunction ( ) ;
You can’t perform that action at this time.
0 commit comments