fix(global): 设备端判断问题修复
fix(global): 设备端判断问题修复
This commit is contained in:
commit
c5310cd0fd
@ -183,7 +183,6 @@ export default {
|
|||||||
// isPostingComment: state => state.comment.posting,
|
// isPostingComment: state => state.comment.posting,
|
||||||
constants: state => state.global.constants,
|
constants: state => state.global.constants,
|
||||||
language: state => state.global.language,
|
language: state => state.global.language,
|
||||||
isMobile: state => state.global.isMobile,
|
|
||||||
user: state => state.auth.user,
|
user: state => state.auth.user,
|
||||||
loggedIn: state => state.auth.loggedIn,
|
loggedIn: state => state.auth.loggedIn,
|
||||||
avatar: state => state.auth.user?.avatarUrl
|
avatar: state => state.auth.user?.avatarUrl
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<body >
|
<div>
|
||||||
<pc-main-view v-if="!isMobile" />
|
<pc-main-view v-if="$device.isDesktop"/>
|
||||||
<mobile-main-view v-else/>
|
<mobile-main-view v-else/>
|
||||||
</body>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
@ -19,10 +19,7 @@ export default Vue.extend({
|
|||||||
computed: {
|
computed: {
|
||||||
theme() {
|
theme() {
|
||||||
return this.$store.state.global.theme
|
return this.$store.state.global.theme
|
||||||
},
|
}
|
||||||
isMobile() {
|
|
||||||
return this.$store.state.global.isMobile
|
|
||||||
},
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -71,7 +71,8 @@ export default {
|
|||||||
modules: [
|
modules: [
|
||||||
'@nuxtjs/axios',
|
'@nuxtjs/axios',
|
||||||
'@nuxtjs/proxy',
|
'@nuxtjs/proxy',
|
||||||
'@nuxtjs/auth-next'
|
'@nuxtjs/auth-next',
|
||||||
|
'@nuxtjs/device',
|
||||||
],
|
],
|
||||||
auth: {
|
auth: {
|
||||||
redirect: {
|
redirect: {
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"@commitlint/cli": "^17.4.0",
|
"@commitlint/cli": "^17.4.0",
|
||||||
"@commitlint/config-conventional": "^17.4.0",
|
"@commitlint/config-conventional": "^17.4.0",
|
||||||
"@nuxt/types": "~2.16.0",
|
"@nuxt/types": "~2.16.0",
|
||||||
|
"@nuxtjs/device": "^2.1.0",
|
||||||
"@nuxtjs/proxy": "^2.1.0",
|
"@nuxtjs/proxy": "^2.1.0",
|
||||||
"conventional-changelog-cli": "^2.2.2",
|
"conventional-changelog-cli": "^2.2.2",
|
||||||
"cz-git": "^1.4.1",
|
"cz-git": "^1.4.1",
|
||||||
|
@ -191,7 +191,6 @@ export default {
|
|||||||
...mapState({
|
...mapState({
|
||||||
article: state => state.article.detail.data,
|
article: state => state.article.detail.data,
|
||||||
isFetching: state => state.article.detail.fetching,
|
isFetching: state => state.article.detail.fetching,
|
||||||
isMobile: state => state.global.isMobile,
|
|
||||||
loggedIn: state => state.auth.loggedIn,
|
loggedIn: state => state.auth.loggedIn,
|
||||||
user: state => state.auth.user,
|
user: state => state.auth.user,
|
||||||
avatar: state => state.auth.user?.avatarUrl
|
avatar: state => state.auth.user?.avatarUrl
|
||||||
|
@ -87,7 +87,6 @@
|
|||||||
...mapState({
|
...mapState({
|
||||||
article: state => state.draft.detail.data,
|
article: state => state.draft.detail.data,
|
||||||
isFetching: state => state.draft.detail.fetching,
|
isFetching: state => state.draft.detail.fetching,
|
||||||
isMobile: state => state.global.isMobile,
|
|
||||||
user: state => state.auth.user,
|
user: state => state.auth.user,
|
||||||
avatar: state => state.auth.user?.avatarURL
|
avatar: state => state.auth.user?.avatarURL
|
||||||
}),
|
}),
|
||||||
|
@ -82,7 +82,6 @@ export default {
|
|||||||
portfolio: state => state.portfolio.detail.data,
|
portfolio: state => state.portfolio.detail.data,
|
||||||
articles: state => state.portfolio.articles,
|
articles: state => state.portfolio.articles,
|
||||||
isFetching: state => state.portfolio.detail.fetching,
|
isFetching: state => state.portfolio.detail.fetching,
|
||||||
isMobile: state => state.global.isMobile,
|
|
||||||
user: state => state.auth.user,
|
user: state => state.auth.user,
|
||||||
avatar: state => state.auth.user?.avatarURL
|
avatar: state => state.auth.user?.avatarURL
|
||||||
}),
|
}),
|
||||||
|
@ -26,29 +26,7 @@ export const mutations = {
|
|||||||
export const actions = {
|
export const actions = {
|
||||||
nuxtServerInit(store, {req}) {
|
nuxtServerInit(store, {req}) {
|
||||||
// 初始化时的全局任务
|
// 初始化时的全局任务
|
||||||
const userAgent = isServer ? req.headers['user-agent'] : navigator.userAgent
|
const initFetchAppData = [
|
||||||
const browser = {
|
|
||||||
versions: function() {
|
|
||||||
return { //移动终端浏览器版本信息
|
|
||||||
trident: userAgent.indexOf('Trident') > -1, //IE内核
|
|
||||||
presto: userAgent.indexOf('Presto') > -1, //opera内核
|
|
||||||
webKit: userAgent.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
|
|
||||||
gecko: userAgent.indexOf('Gecko') > -1 && userAgent.indexOf('KHTML') == -1, //火狐内核
|
|
||||||
mobile: !!userAgent.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
|
|
||||||
ios: !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
|
|
||||||
android: userAgent.indexOf('Android') > -1 || userAgent.indexOf('Linux') > -1, //android终端或uc浏览器
|
|
||||||
iPhone: userAgent.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
|
|
||||||
iPad: userAgent.indexOf('iPad') > -1, //是否iPad
|
|
||||||
webApp: userAgent.indexOf('Safari') == -1 //是否web应用程序,没有头部与底部
|
|
||||||
};
|
|
||||||
} ()
|
|
||||||
}
|
|
||||||
if (browser.versions.mobile) {
|
|
||||||
// 移动端
|
|
||||||
store.commit('global/updateMobileState', true)
|
|
||||||
}
|
|
||||||
|
|
||||||
const initFetchAppData = [
|
|
||||||
// 内容数据
|
// 内容数据
|
||||||
store.dispatch('topic/fetchNavList'),
|
store.dispatch('topic/fetchNavList'),
|
||||||
store.dispatch('article/fetchList')
|
store.dispatch('article/fetchList')
|
||||||
|
Loading…
Reference in New Issue
Block a user