File tree Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,35 @@ var OS = (function () {
2222 phone : a
2323 }
2424} ( ) )
25- if ( OS . phone || OS . ipad ) {
26- const url = `${ location . origin } ${ location . pathname . replace ( '/vue-blog' , '/blogNuxtM' ) } ${ location . search } ${ location . hash } `
27- location . href = url
25+
26+ // 有些页面只有PC端有,移动端没有,不需要跳转移动端的页面
27+ const PCPathname = [
28+ 'signIn' , // 登录页
29+ 'editor' , // 写文章页面
30+ 'admin' // 个人中心相关页面
31+ ]
32+
33+ /**
34+ * 是否属于PC端独有页面
35+ * @param {* } PCPathname PC端独有页面的特殊标识字段数组
36+ * @param {* } location 当前location
37+ */
38+ function isBelongPCPathname ( PCPathname , location ) {
39+ let flag = false
40+ const pathname = location . pathname
41+ for ( let index = 0 ; index < PCPathname . length ; index ++ ) {
42+ const element = PCPathname [ index ]
43+ if ( pathname . indexOf ( element ) !== - 1 ) {
44+ flag = true
45+ break
46+ }
47+ }
48+ return flag
49+ }
50+
51+ if ( process . env . NODE_ENV === 'production' && ( OS . phone || OS . ipad ) ) {
52+ if ( ! isBelongPCPathname ( PCPathname , location ) ) {
53+ const url = `${ location . origin } ${ location . pathname . replace ( '/vue-blog' , '/blogNuxtM' ) } ${ location . search } ${ location . hash } `
54+ location . href = url
55+ }
2856}
You can’t perform that action at this time.
0 commit comments