From 7222753d0af642eb8b2bca820504a994bc0ec912 Mon Sep 17 00:00:00 2001 From: ronger Date: Sat, 29 Oct 2022 22:18:17 +0800 Subject: [PATCH 1/3] :sparkles: nuxt/auth --- nuxt.config.js | 2 +- pages/article/_article_id.vue | 2 +- pages/article/post/_article_id.vue | 2 +- pages/login.vue | 15 +++++++++------ pages/topic/_topic_uri.vue | 3 ++- store/open-data.js | 3 ++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/nuxt.config.js b/nuxt.config.js index f23eb4f..44f13f8 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -76,7 +76,7 @@ export default { redirect: { login: '/login', logout: false, - home: false + home: '/' }, strategies: { local: { diff --git a/pages/article/_article_id.vue b/pages/article/_article_id.vue index a3d7ee1..66ef8f4 100644 --- a/pages/article/_article_id.vue +++ b/pages/article/_article_id.vue @@ -194,7 +194,7 @@ export default { isMobile: state => state.global.isMobile, loggedIn: state => state.auth.loggedIn, user: state => state.auth.user, - avatar: state => state.auth.user.avatarUrl + avatar: state => state.auth.user?.avatarUrl }), hasPermissions() { let account = this.$store.state.auth.user?.nickname; diff --git a/pages/article/post/_article_id.vue b/pages/article/post/_article_id.vue index 823a57d..feb3626 100644 --- a/pages/article/post/_article_id.vue +++ b/pages/article/post/_article_id.vue @@ -91,7 +91,7 @@ return true; } } - return this.$auth.hasScope('blog_admin'); + return this.$auth.hasScope('blog_admin') || this.$auth.hasScope('admin'); } }, data() { diff --git a/pages/login.vue b/pages/login.vue index 8347005..5f65c03 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -57,6 +57,7 @@ import {mapState} from 'vuex'; export default { name: "login", middleware: 'auth', + auth: 'guest', data() { return { user: { @@ -93,10 +94,6 @@ export default { _ts.$auth.setUserToken(response.data.token, response.data.refreshToken); if (_ts.historyUrl) { window.location.href = _ts.historyUrl - } else { - _ts.$router.push({ - name: 'index' - }) } } _ts.$set(_ts, 'loginLoading', false); @@ -144,8 +141,14 @@ export default { } }, mounted() { - this.$store.commit('setActiveMenu', 'login'); - this.$set(this, 'historyUrl', this.$route.query.historyUrl || ''); + let _ts = this + _ts.$store.commit('setActiveMenu', 'login'); + _ts.$set(_ts, 'historyUrl', _ts.$route.query.historyUrl || ''); + // if (_ts.$auth.loggedIn) { + // _ts.$router.push({ + // name: 'index' + // }) + // } } } diff --git a/pages/topic/_topic_uri.vue b/pages/topic/_topic_uri.vue index 95e224f..05e62ec 100644 --- a/pages/topic/_topic_uri.vue +++ b/pages/topic/_topic_uri.vue @@ -22,7 +22,8 @@ export default { topic => topic.topicUri === params.topic_uri ) }, - fetch({store, params, query}) { + fetch() { + let {store, params, query} = this.$nuxt.context params.page = query.page || 1 return Promise.all([ store.dispatch('article/fetchList', params) diff --git a/store/open-data.js b/store/open-data.js index 2d168f2..db0c8fb 100644 --- a/store/open-data.js +++ b/store/open-data.js @@ -8,7 +8,8 @@ export const OPEN_DATA_API_PATH = '/api/open-data' const getDefaultDashboardData = () => { return { - dashboard: {} + countUserNum: 0, + countArticleNum: 0 } } From ad73aab0501c639ecee3715523b9f760c3df7c70 Mon Sep 17 00:00:00 2001 From: ronger Date: Sat, 29 Oct 2022 22:48:52 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:art:=20=E8=AF=84=E8=AE=BA=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/comment/main.vue | 624 ++++++++++++++--------------- pages/article/_article_id.vue | 8 +- plugins/axios.js | 2 - 3 files changed, 315 insertions(+), 319 deletions(-) diff --git a/components/common/comment/main.vue b/components/common/comment/main.vue index d96dc02..f6bc25b 100644 --- a/components/common/comment/main.vue +++ b/components/common/comment/main.vue @@ -44,14 +44,16 @@ - {{ comment.commenter.userNickname }} 回复了 {{ comment.commentOriginalAuthorNickname }} - 查看原评论 @@ -63,7 +65,8 @@ - {{ comment.commenter.userNickname }} @@ -92,7 +95,8 @@ - {{ comment.commenter.userNickname }} @@ -115,7 +119,7 @@ -

@@ -133,330 +137,324 @@