🐛 从用户主页离开提示用户不存在问题修复
This commit is contained in:
parent
ad73aab050
commit
4a69f4237c
@ -176,6 +176,7 @@ export default {
|
|||||||
language: state => state.global.language,
|
language: state => state.global.language,
|
||||||
isMobile: state => state.global.isMobile,
|
isMobile: state => state.global.isMobile,
|
||||||
user: state => state.auth.user,
|
user: state => state.auth.user,
|
||||||
|
loggedIn: state => state.auth.loggedIn,
|
||||||
avatar: state => state.auth.user?.avatarUrl
|
avatar: state => state.auth.user?.avatarUrl
|
||||||
}),
|
}),
|
||||||
isFetching() {
|
isFetching() {
|
||||||
@ -388,7 +389,7 @@ export default {
|
|||||||
async mounted() {
|
async mounted() {
|
||||||
let _ts = this;
|
let _ts = this;
|
||||||
_ts.$store.commit('setActiveMenu', 'post-article');
|
_ts.$store.commit('setActiveMenu', 'post-article');
|
||||||
if (_ts.user) {
|
if (_ts.loggedIn) {
|
||||||
const responseData = await _ts.$axios.$get('/api/upload/token');
|
const responseData = await _ts.$axios.$get('/api/upload/token');
|
||||||
if (responseData) {
|
if (responseData) {
|
||||||
_ts.$set(_ts, 'tokenURL', {
|
_ts.$set(_ts, 'tokenURL', {
|
||||||
|
@ -61,8 +61,8 @@
|
|||||||
</el-link>
|
</el-link>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="auth.user">
|
<div v-if="loggedIn">
|
||||||
<div v-if="auth.user.idUser !== user.idUser">
|
<div v-if="auth.idUser !== user.idUser">
|
||||||
<el-button type="primary" v-if="isFollow" @click="cancelFollowUser(user.idUser)" plain>取消关注</el-button>
|
<el-button type="primary" v-if="isFollow" @click="cancelFollowUser(user.idUser)" plain>取消关注</el-button>
|
||||||
<el-button type="primary" v-else @click="followUser(user.idUser)" plain>关注</el-button>
|
<el-button type="primary" v-else @click="followUser(user.idUser)" plain>关注</el-button>
|
||||||
<el-button v-show="false" @click="gotoChats" plain>聊天</el-button>
|
<el-button v-show="false" @click="gotoChats" plain>聊天</el-button>
|
||||||
@ -122,7 +122,8 @@ export default {
|
|||||||
validate({params, store}) {
|
validate({params, store}) {
|
||||||
return params.account
|
return params.account
|
||||||
},
|
},
|
||||||
fetch({store, params, query, error}) {
|
fetch() {
|
||||||
|
let {store, params, query, error} = this.$nuxt.context;
|
||||||
params.page = query.page || 1
|
params.page = query.page || 1
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
store
|
store
|
||||||
@ -138,6 +139,7 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
'$route.query': function () {
|
'$route.query': function () {
|
||||||
let _ts = this;
|
let _ts = this;
|
||||||
|
if (_ts.$route.params.account) {
|
||||||
let activeTab = _ts.$route.query.tab || '0'
|
let activeTab = _ts.$route.query.tab || '0'
|
||||||
_ts.$set(_ts, 'activeTab', activeTab)
|
_ts.$set(_ts, 'activeTab', activeTab)
|
||||||
switch (_ts.activeTab) {
|
switch (_ts.activeTab) {
|
||||||
@ -167,6 +169,7 @@ export default {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
@ -176,6 +179,7 @@ export default {
|
|||||||
portfolios: state => state.user.portfolios,
|
portfolios: state => state.user.portfolios,
|
||||||
followers: state => state.user.followers,
|
followers: state => state.user.followers,
|
||||||
followings: state => state.user.followings,
|
followings: state => state.user.followings,
|
||||||
|
loggedIn: state => state.auth.loggedIn,
|
||||||
auth: state => state.auth.user
|
auth: state => state.auth.user
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -215,8 +219,9 @@ export default {
|
|||||||
this.onRouter(key, 1)
|
this.onRouter(key, 1)
|
||||||
},
|
},
|
||||||
onRouter(key, page) {
|
onRouter(key, page) {
|
||||||
this.$router.push({
|
let _ts = this
|
||||||
path: `/user/${this.$route.params.account}?tab=${key}&page=${page}`
|
_ts.$router.push({
|
||||||
|
path: `/user/${_ts.$route.params.account}?tab=${key}&page=${page}`
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
gotoChats() {
|
gotoChats() {
|
||||||
@ -227,7 +232,7 @@ export default {
|
|||||||
},
|
},
|
||||||
followUser(idUser) {
|
followUser(idUser) {
|
||||||
let _ts = this;
|
let _ts = this;
|
||||||
if (_ts.auth) {
|
if (_ts.loggedIn) {
|
||||||
_ts.$axios.$post('/api/follow', {
|
_ts.$axios.$post('/api/follow', {
|
||||||
followingId: idUser,
|
followingId: idUser,
|
||||||
followingType: 0
|
followingType: 0
|
||||||
@ -241,7 +246,7 @@ export default {
|
|||||||
},
|
},
|
||||||
cancelFollowUser(idUser) {
|
cancelFollowUser(idUser) {
|
||||||
let _ts = this;
|
let _ts = this;
|
||||||
if (_ts.auth) {
|
if (_ts.loggedIn) {
|
||||||
_ts.$axios.$post('/api/follow/cancel-follow', {
|
_ts.$axios.$post('/api/follow/cancel-follow', {
|
||||||
followingId: idUser,
|
followingId: idUser,
|
||||||
followingType: 0
|
followingType: 0
|
||||||
@ -265,7 +270,7 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
let _ts = this;
|
let _ts = this;
|
||||||
this.$store.commit('setActiveMenu', 'user');
|
this.$store.commit('setActiveMenu', 'user');
|
||||||
if (_ts.auth) {
|
if (_ts.loggedIn) {
|
||||||
_ts.$axios.$get('/api/follow/is-follow', {
|
_ts.$axios.$get('/api/follow/is-follow', {
|
||||||
params: {
|
params: {
|
||||||
followingId: _ts.user.idUser,
|
followingId: _ts.user.idUser,
|
||||||
|
Loading…
Reference in New Issue
Block a user