From 4a69f4237cde48dd4402233b44640f497bcb2321 Mon Sep 17 00:00:00 2001 From: ronger Date: Sun, 30 Oct 2022 01:02:30 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BB=8E=E7=94=A8=E6=88=B7=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E7=A6=BB=E5=BC=80=E6=8F=90=E7=A4=BA=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/comment/main.vue | 3 +- pages/user/_account.vue | 75 ++++++++++++++++-------------- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/components/common/comment/main.vue b/components/common/comment/main.vue index f6bc25b..6e1f978 100644 --- a/components/common/comment/main.vue +++ b/components/common/comment/main.vue @@ -176,6 +176,7 @@ export default { language: state => state.global.language, isMobile: state => state.global.isMobile, user: state => state.auth.user, + loggedIn: state => state.auth.loggedIn, avatar: state => state.auth.user?.avatarUrl }), isFetching() { @@ -388,7 +389,7 @@ export default { async mounted() { let _ts = this; _ts.$store.commit('setActiveMenu', 'post-article'); - if (_ts.user) { + if (_ts.loggedIn) { const responseData = await _ts.$axios.$get('/api/upload/token'); if (responseData) { _ts.$set(_ts, 'tokenURL', { diff --git a/pages/user/_account.vue b/pages/user/_account.vue index 6c8c3a8..6626a04 100644 --- a/pages/user/_account.vue +++ b/pages/user/_account.vue @@ -61,8 +61,8 @@ -
-
+
+
取消关注 关注 聊天 @@ -122,7 +122,8 @@ export default { validate({params, store}) { return params.account }, - fetch({store, params, query, error}) { + fetch() { + let {store, params, query, error} = this.$nuxt.context; params.page = query.page || 1 return Promise.all([ store @@ -138,33 +139,35 @@ export default { watch: { '$route.query': function () { let _ts = this; - let activeTab = _ts.$route.query.tab || '0' - _ts.$set(_ts, 'activeTab', activeTab) - switch (_ts.activeTab) { - case "0": - _ts.$store.dispatch('user/fetchArticleList', { - account: _ts.$route.params.account, - page: _ts.$route.query.page || 1 - }) - break; - case "1": - _ts.$store.dispatch('user/fetchPortfolioList', { - account: _ts.$route.params.account, - page: _ts.$route.query.page || 1 - }) - break; - case "2": - _ts.$store.dispatch('user/fetchFollowingList', { - account: _ts.$route.params.account, - page: _ts.$route.query.page || 1 - }) - break; - default: - _ts.$store.dispatch('user/fetchFollowerList', { - account: _ts.$route.params.account, - page: _ts.$route.query.page || 1 - }) - break + if (_ts.$route.params.account) { + let activeTab = _ts.$route.query.tab || '0' + _ts.$set(_ts, 'activeTab', activeTab) + switch (_ts.activeTab) { + case "0": + _ts.$store.dispatch('user/fetchArticleList', { + account: _ts.$route.params.account, + page: _ts.$route.query.page || 1 + }) + break; + case "1": + _ts.$store.dispatch('user/fetchPortfolioList', { + account: _ts.$route.params.account, + page: _ts.$route.query.page || 1 + }) + break; + case "2": + _ts.$store.dispatch('user/fetchFollowingList', { + account: _ts.$route.params.account, + page: _ts.$route.query.page || 1 + }) + break; + default: + _ts.$store.dispatch('user/fetchFollowerList', { + account: _ts.$route.params.account, + page: _ts.$route.query.page || 1 + }) + break + } } } }, @@ -176,6 +179,7 @@ export default { portfolios: state => state.user.portfolios, followers: state => state.user.followers, followings: state => state.user.followings, + loggedIn: state => state.auth.loggedIn, auth: state => state.auth.user }) }, @@ -215,8 +219,9 @@ export default { this.onRouter(key, 1) }, onRouter(key, page) { - this.$router.push({ - path: `/user/${this.$route.params.account}?tab=${key}&page=${page}` + let _ts = this + _ts.$router.push({ + path: `/user/${_ts.$route.params.account}?tab=${key}&page=${page}` }) }, gotoChats() { @@ -227,7 +232,7 @@ export default { }, followUser(idUser) { let _ts = this; - if (_ts.auth) { + if (_ts.loggedIn) { _ts.$axios.$post('/api/follow', { followingId: idUser, followingType: 0 @@ -241,7 +246,7 @@ export default { }, cancelFollowUser(idUser) { let _ts = this; - if (_ts.auth) { + if (_ts.loggedIn) { _ts.$axios.$post('/api/follow/cancel-follow', { followingId: idUser, followingType: 0 @@ -265,7 +270,7 @@ export default { mounted() { let _ts = this; this.$store.commit('setActiveMenu', 'user'); - if (_ts.auth) { + if (_ts.loggedIn) { _ts.$axios.$get('/api/follow/is-follow', { params: { followingId: _ts.user.idUser,