♻️ 个人中心路径 /user/nickname -> /user/account
This commit is contained in:
parent
cd95f0f9a0
commit
b53ee9dc41
@ -31,7 +31,7 @@
|
||||
</el-col>
|
||||
<el-col :xs="16" :sm="16" :xl="16">
|
||||
<div>
|
||||
<el-link rel="nofollow" @click="onRouter('user', article.articleAuthorName)" :underline="false"
|
||||
<el-link rel="nofollow" @click="onRouter('user', article.articleAuthor.userAccount)" :underline="false"
|
||||
class="text-default">
|
||||
{{ article.articleAuthorName }}
|
||||
</el-link>
|
||||
|
@ -7,7 +7,7 @@
|
||||
</el-col>
|
||||
<el-col :span="21">
|
||||
<div>
|
||||
<el-link rel="nofollow" @click="onRouter(user.nickname)" :underline="false" class="text-default">
|
||||
<el-link rel="nofollow" @click="onRouter(user.account)" :underline="false" class="text-default">
|
||||
{{ user.nickname }}
|
||||
</el-link>
|
||||
<small class="d-block text-muted">{{ user.signature }}</small>
|
||||
|
@ -106,6 +106,18 @@
|
||||
}
|
||||
return _ts.$store.state.userInfo?.nickname;
|
||||
},
|
||||
account() {
|
||||
let _ts = this;
|
||||
if (isBrowser) {
|
||||
if (!_ts.$store.state.userInfo) {
|
||||
let user = localStorage.getItem('user');
|
||||
if (user) {
|
||||
_ts.$store.commit('setUser', JSON.parse(user))
|
||||
}
|
||||
}
|
||||
}
|
||||
return _ts.$store.state.userInfo?.account;
|
||||
},
|
||||
hasPermissions() {
|
||||
return this.$store.getters.hasPermissions('blog_admin');
|
||||
}
|
||||
@ -154,7 +166,7 @@
|
||||
switch (item) {
|
||||
case 'user':
|
||||
_ts.$router.push({
|
||||
path: '/user/' + _ts.nickname
|
||||
path: '/user/' + _ts.account
|
||||
})
|
||||
break;
|
||||
case 'user-info':
|
||||
|
@ -142,6 +142,18 @@ export default {
|
||||
}
|
||||
return _ts.$store.state.userInfo?.nickname;
|
||||
},
|
||||
account() {
|
||||
let _ts = this;
|
||||
if (isBrowser) {
|
||||
if (!_ts.$store.state.userInfo) {
|
||||
let user = localStorage.getItem('user');
|
||||
if (user) {
|
||||
_ts.$store.commit('setUser', JSON.parse(user))
|
||||
}
|
||||
}
|
||||
}
|
||||
return _ts.$store.state.userInfo?.account;
|
||||
},
|
||||
hasPermissions() {
|
||||
return this.$store.getters.hasPermissions('blog_admin');
|
||||
}
|
||||
@ -219,7 +231,7 @@ export default {
|
||||
switch (item) {
|
||||
case 'user':
|
||||
_ts.$router.push({
|
||||
path: '/user/' + _ts.nickname
|
||||
path: '/user/' + _ts.account
|
||||
})
|
||||
break;
|
||||
case 'user-info':
|
||||
|
@ -29,7 +29,7 @@
|
||||
width="180"
|
||||
prop="nickname">
|
||||
<template slot-scope="scope">
|
||||
<el-link type="primary" :href="getUserPath(scope.row.nickname)" :underline="false">
|
||||
<el-link type="primary" :href="getUserPath(scope.row.account)" :underline="false">
|
||||
{{ scope.row.nickname }}
|
||||
</el-link>
|
||||
</template>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</el-col>
|
||||
<el-col :xs="9" :sm="11" :xl="11">
|
||||
<div style="margin-left: 1rem;">
|
||||
<el-link rel="nofollow" @click="onRouter('user', article.articleAuthorName)" :underline="false"
|
||||
<el-link rel="nofollow" @click="onRouter('user', article.articleAuthor.userAccount)" :underline="false"
|
||||
class="text-default">{{ article.articleAuthorName }}
|
||||
</el-link>
|
||||
<small class="d-block text-muted">{{ article.timeAgo }}</small>
|
||||
|
@ -48,7 +48,6 @@
|
||||
<script>
|
||||
import Vue from 'vue';
|
||||
import {mapState} from 'vuex';
|
||||
import { isBrowser } from '~/environment'
|
||||
|
||||
export default {
|
||||
name: "PostArticle",
|
||||
|
@ -9,7 +9,7 @@
|
||||
</el-col>
|
||||
<el-col style="margin-top: 2rem;" id="messagesContent">
|
||||
<el-col v-for="message in Array.prototype.reverse.call(messages)" :key="message.dataId">
|
||||
<el-col v-if="message.from === user.nickname">
|
||||
<el-col v-if="message.from === user.account">
|
||||
<el-col :span="22" style="text-align: right;">
|
||||
<div class="from-message">
|
||||
<div v-html="message.content"></div>
|
||||
@ -156,8 +156,8 @@ export default {
|
||||
async send() {
|
||||
let _ts = this;
|
||||
const message = {
|
||||
to: _ts.to.nickname,
|
||||
from: _ts.user.nickname,
|
||||
to: _ts.to.account,
|
||||
from: _ts.user.account,
|
||||
dataType: 1,
|
||||
dataId: new Date().getTime(),
|
||||
content: await _ts.contentEditor.getHTML()
|
||||
@ -172,7 +172,7 @@ export default {
|
||||
_ts.$store.commit('setActiveMenu', 'post-article');
|
||||
|
||||
let to = {
|
||||
nickname: _ts.$route.params?.nickname
|
||||
account: _ts.$route.params?.account
|
||||
}
|
||||
|
||||
_ts.$set(_ts, 'to', to);
|
@ -108,7 +108,8 @@ export default {
|
||||
|
||||
let user = {
|
||||
nickname: res.user.nickname,
|
||||
avatarURL: res.user.avatarUrl
|
||||
avatarURL: res.user.avatarUrl,
|
||||
account: res.user.account
|
||||
}
|
||||
_ts.$store.commit('setAuth', auth) // mutating to store for client rendering
|
||||
localStorage.setItem('user', JSON.stringify(user))
|
||||
|
@ -7,7 +7,7 @@
|
||||
</el-col>
|
||||
<el-col style="margin-bottom: .5rem;">
|
||||
<span class="text-default" style="padding-right: 1rem;">作者</span>
|
||||
<el-link rel="nofollow" @click="onRouter('user', portfolio.portfolioAuthorName)" :underline="false" class="text-default">
|
||||
<el-link rel="nofollow" @click="onRouter('user', portfolio.portfolioAuthor.userAccount)" :underline="false" class="text-default">
|
||||
<el-avatar :src="portfolio.portfolioAuthorAvatarUrl" :size="16"></el-avatar>
|
||||
{{ portfolio.portfolioAuthorName }}
|
||||
</el-link>
|
||||
|
@ -35,7 +35,7 @@
|
||||
<div v-if="oauth.idUser !== user.idUser">
|
||||
<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 @click="gotoChats" plain>聊天</el-button>
|
||||
<el-button v-show="false" @click="gotoChats" plain>聊天</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
@ -89,7 +89,7 @@ export default {
|
||||
name: "User",
|
||||
components: {ArticleList, PortfolioList, UserList},
|
||||
validate({params, store}) {
|
||||
return params.nickname
|
||||
return params.account
|
||||
},
|
||||
fetch({store, params, query, error}) {
|
||||
params.page = query.page || 1
|
||||
@ -112,25 +112,25 @@ export default {
|
||||
switch (_ts.activeTab) {
|
||||
case "0":
|
||||
_ts.$store.dispatch('user/fetchArticleList', {
|
||||
nickname: _ts.$route.params.nickname,
|
||||
account: _ts.$route.params.account,
|
||||
page: _ts.$route.query.page || 1
|
||||
})
|
||||
break;
|
||||
case "1":
|
||||
_ts.$store.dispatch('user/fetchPortfolioList', {
|
||||
nickname: _ts.$route.params.nickname,
|
||||
account: _ts.$route.params.account,
|
||||
page: _ts.$route.query.page || 1
|
||||
})
|
||||
break;
|
||||
case "2":
|
||||
_ts.$store.dispatch('user/fetchFollowerList', {
|
||||
nickname: _ts.$route.params.nickname,
|
||||
account: _ts.$route.params.account,
|
||||
page: _ts.$route.query.page || 1
|
||||
})
|
||||
break;
|
||||
default:
|
||||
_ts.$store.dispatch('user/fetchFollowingList', {
|
||||
nickname: _ts.$route.params.nickname,
|
||||
account: _ts.$route.params.account,
|
||||
page: _ts.$route.query.page || 1
|
||||
})
|
||||
break
|
||||
@ -181,14 +181,14 @@ export default {
|
||||
},
|
||||
onRouter(key, page) {
|
||||
this.$router.push({
|
||||
path: `/user/${this.$route.params.nickname}?tab=${key}&page=${page}`
|
||||
path: `/user/${this.$route.params.account}?tab=${key}&page=${page}`
|
||||
})
|
||||
|
||||
},
|
||||
gotoChats() {
|
||||
let _ts = this;
|
||||
_ts.$router.push({
|
||||
path: `/chats/${_ts.user.nickname}`
|
||||
path: `/chats/${_ts.user.account}`
|
||||
})
|
||||
},
|
||||
followUser(idUser) {
|
@ -25,14 +25,14 @@ export default {
|
||||
}, _ts.headers);
|
||||
_ts.stompClient.subscribe('/topic/greening', (msg) => {
|
||||
console.log('pub', JSON.parse(msg.body));
|
||||
});
|
||||
}, _ts.headers);
|
||||
},
|
||||
initSocket: function (user) {
|
||||
let _ts = this;
|
||||
_ts.socket = new SockJS(apiConfig.SOCKET);
|
||||
_ts.stompClient = Stomp.over(_ts.socket);
|
||||
let headers = {
|
||||
id: user.nickname
|
||||
id: user.account
|
||||
}
|
||||
_ts.headers = headers;
|
||||
_ts.stompClient.connect(_ts.headers, () => {
|
||||
|
@ -58,7 +58,7 @@ export const actions = {
|
||||
fetchDetail({ commit }, params) {
|
||||
commit('updateFetching', true);
|
||||
return this.$axios
|
||||
.$get(`${USER_API_PATH}/${params.nickname}`)
|
||||
.$get(`${USER_API_PATH}/${params.account}`)
|
||||
.then(response => {
|
||||
commit('updateDetailData', response)
|
||||
commit('updateFetching', false)
|
||||
@ -70,7 +70,7 @@ export const actions = {
|
||||
fetchUserExtend({ commit }, params) {
|
||||
commit('updateFetching', true);
|
||||
return this.$axios
|
||||
.$get(`${USER_API_PATH}/${params.nickname}/user-extend`)
|
||||
.$get(`${USER_API_PATH}/${params.account}/user-extend`)
|
||||
.then(response => {
|
||||
commit('updateUserExtendData', response)
|
||||
commit('updateFetching', false)
|
||||
@ -82,7 +82,7 @@ export const actions = {
|
||||
fetchArticleList({commit}, params) {
|
||||
commit('updateFetching', true);
|
||||
return this.$axios
|
||||
.$get(`${USER_API_PATH}/${params.nickname}/articles`, {
|
||||
.$get(`${USER_API_PATH}/${params.account}/articles`, {
|
||||
params: {
|
||||
page: params.page
|
||||
}
|
||||
@ -98,7 +98,7 @@ export const actions = {
|
||||
fetchPortfolioList({commit}, params) {
|
||||
commit('updateFetching', true);
|
||||
return this.$axios
|
||||
.$get(`${USER_API_PATH}/${params.nickname}/portfolios`, {
|
||||
.$get(`${USER_API_PATH}/${params.account}/portfolios`, {
|
||||
params: {
|
||||
page: params.page
|
||||
}
|
||||
@ -118,7 +118,7 @@ export const actions = {
|
||||
pagination: {}
|
||||
})
|
||||
return this.$axios
|
||||
.$get(`${USER_API_PATH}/${params.nickname}/followers`, {
|
||||
.$get(`${USER_API_PATH}/${params.account}/followers`, {
|
||||
params: {
|
||||
page: params.page
|
||||
}
|
||||
@ -138,7 +138,7 @@ export const actions = {
|
||||
pagination: {}
|
||||
})
|
||||
return this.$axios
|
||||
.$get(`${USER_API_PATH}/${params.nickname}/followings`, {
|
||||
.$get(`${USER_API_PATH}/${params.account}/followings`, {
|
||||
params: {
|
||||
page: params.page
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user