From f24bdbb1dc2830c475cd5a8c8c59758538510466 Mon Sep 17 00:00:00 2001 From: Zeeland <287017217@qq.com> Date: Tue, 1 Nov 2022 02:27:57 +0800 Subject: [PATCH 1/6] :fix: the preference button does not render correctly in time. --- pages/admin/articles.vue | 18 ++++++------------ pages/admin/dashboard.vue | 18 ++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/pages/admin/articles.vue b/pages/admin/articles.vue index bb5b231..de12a55 100644 --- a/pages/admin/articles.vue +++ b/pages/admin/articles.vue @@ -157,18 +157,12 @@ export default { idArticle: idArticle, articlePerfect: '1' }).then(function (res) { - if (res) { - if (res.success) { - _ts.$store.commit('admin/updateArticlePreference', { - index: index, - idArticle: idArticle, - articlePerfect: '1' - }) - _ts.$message.success("设置成功!"); - } else { - _ts.$message.error(_ts.message); - } - } + _ts.$store.commit('admin/updateArticlePreference', { + index: index, + idArticle: idArticle, + articlePerfect: '1' + }) + _ts.$message.success("设置成功!"); }) }, cancelPreference(index, idArticle) { diff --git a/pages/admin/dashboard.vue b/pages/admin/dashboard.vue index 5228568..45fc794 100644 --- a/pages/admin/dashboard.vue +++ b/pages/admin/dashboard.vue @@ -503,18 +503,12 @@ export default { idArticle: idArticle, articlePerfect: '1' }).then(function (res) { - if (res) { - if (res.success) { - _ts.$store.commit('admin/updateArticlePreference', { - index: index, - idArticle: idArticle, - articlePerfect: '1' - }) - _ts.$message.success("设置成功!"); - } else { - _ts.$message.error(_ts.message); - } - } + _ts.$store.commit('admin/updateArticlePreference', { + index: index, + idArticle: idArticle, + articlePerfect: '1' + }) + _ts.$message.success("设置成功!"); }) }, cancelPreference(index, idArticle) { From 3d7562a4da1ca04fc1263296bb3c91926d74a627 Mon Sep 17 00:00:00 2001 From: Zeeland <287017217@qq.com> Date: Tue, 1 Nov 2022 02:57:34 +0800 Subject: [PATCH 2/6] :fix: the preference button in article page does not render correctly in time. --- pages/article/_article_id.vue | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/pages/article/_article_id.vue b/pages/article/_article_id.vue index 2f53a9d..eacbc05 100644 --- a/pages/article/_article_id.vue +++ b/pages/article/_article_id.vue @@ -341,14 +341,8 @@ export default { idArticle: _ts.article.idArticle, articlePerfect: '1', }).then(function (res) { - if (res) { - if (res.success) { - _ts.$set(_ts, 'isPerfect', false); - _ts.$message.success("设置成功!"); - } else { - _ts.$message.error(_ts.message); - } - } + _ts.isPerfect = !_ts.isPerfect; + _ts.$message.success("设置成功!"); }) }, cancelPreference() { @@ -357,14 +351,8 @@ export default { idArticle: _ts.article.idArticle, articlePerfect: '0', }).then(function (res) { - if (res) { - if (res.success) { - _ts.$set(_ts, 'isPerfect', true); - _ts.$message.success("取消成功!"); - } else { - _ts.$message.error(_ts.message); - } - } + _ts.isPerfect = !_ts.isPerfect; + _ts.$message.success("设置成功!"); }) }, thumbsUp() { From 55de0b557ae32c7a4863fc715be305e6814a44a3 Mon Sep 17 00:00:00 2001 From: Zeeland <287017217@qq.com> Date: Tue, 1 Nov 2022 02:59:22 +0800 Subject: [PATCH 3/6] :fix: the preference button does not render correctly in time. --- pages/admin/articles.vue | 18 ++++++------------ pages/admin/dashboard.vue | 18 ++++++------------ 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/pages/admin/articles.vue b/pages/admin/articles.vue index de12a55..0a0cfb3 100644 --- a/pages/admin/articles.vue +++ b/pages/admin/articles.vue @@ -171,18 +171,12 @@ export default { idArticle: idArticle, articlePerfect: '0' }).then(function (res) { - if (res) { - if (res.success) { - _ts.$store.commit('admin/updateArticlePreference', { - index: index, - idArticle: idArticle, - articlePerfect: '0' - }) - _ts.$message.success("取消成功!"); - } else { - _ts.$message.error(_ts.message); - } - } + _ts.$store.commit('admin/updateArticlePreference', { + index: index, + idArticle: idArticle, + articlePerfect: '0' + }) + _ts.$message.success("取消成功!"); }) }, updateTags(index, article) { diff --git a/pages/admin/dashboard.vue b/pages/admin/dashboard.vue index 45fc794..71090e1 100644 --- a/pages/admin/dashboard.vue +++ b/pages/admin/dashboard.vue @@ -517,18 +517,12 @@ export default { idArticle: idArticle, articlePerfect: '0' }).then(function (res) { - if (res) { - if (res.success) { - _ts.$store.commit('admin/updateArticlePreference', { - index: index, - idArticle: idArticle, - articlePerfect: '0' - }) - _ts.$message.success("取消成功!"); - } else { - _ts.$message.error(_ts.message); - } - } + _ts.$store.commit('admin/updateArticlePreference', { + index: index, + idArticle: idArticle, + articlePerfect: '0' + }) + _ts.$message.success("取消成功!"); }) }, updateTags(index, article) { From c61b7cea5d6106c725cd18eac3717be38eba37eb Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 1 Nov 2022 07:38:52 +0800 Subject: [PATCH 4/6] Update articles.vue --- pages/admin/articles.vue | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/pages/admin/articles.vue b/pages/admin/articles.vue index 0a0cfb3..2a75f49 100644 --- a/pages/admin/articles.vue +++ b/pages/admin/articles.vue @@ -157,12 +157,16 @@ export default { idArticle: idArticle, articlePerfect: '1' }).then(function (res) { - _ts.$store.commit('admin/updateArticlePreference', { - index: index, - idArticle: idArticle, - articlePerfect: '1' - }) - _ts.$message.success("设置成功!"); + if (res) { + _ts.$store.commit('admin/updateArticlePreference', { + index: index, + idArticle: idArticle, + articlePerfect: '1' + }) + _ts.$message.success("设置成功!"); + } else { + _ts.$message.error("设置失败!"); + } }) }, cancelPreference(index, idArticle) { @@ -171,12 +175,16 @@ export default { idArticle: idArticle, articlePerfect: '0' }).then(function (res) { - _ts.$store.commit('admin/updateArticlePreference', { - index: index, - idArticle: idArticle, - articlePerfect: '0' - }) - _ts.$message.success("取消成功!"); + if (res) { + _ts.$store.commit('admin/updateArticlePreference', { + index: index, + idArticle: idArticle, + articlePerfect: '0' + }) + _ts.$message.success("取消成功!"); + } else { + _ts.$message.error("取消失败!"); + } }) }, updateTags(index, article) { From e50613586d0357888d0a1370fc6d6a3ae2f60811 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 1 Nov 2022 07:40:27 +0800 Subject: [PATCH 5/6] Update dashboard.vue --- pages/admin/dashboard.vue | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/pages/admin/dashboard.vue b/pages/admin/dashboard.vue index 71090e1..3729487 100644 --- a/pages/admin/dashboard.vue +++ b/pages/admin/dashboard.vue @@ -503,12 +503,16 @@ export default { idArticle: idArticle, articlePerfect: '1' }).then(function (res) { - _ts.$store.commit('admin/updateArticlePreference', { - index: index, - idArticle: idArticle, - articlePerfect: '1' - }) - _ts.$message.success("设置成功!"); + if (res) { + _ts.$store.commit('admin/updateArticlePreference', { + index: index, + idArticle: idArticle, + articlePerfect: '1' + }) + _ts.$message.success("设置成功!"); + } else { + _ts.$message.error("设置失败!"); + } }) }, cancelPreference(index, idArticle) { @@ -517,12 +521,16 @@ export default { idArticle: idArticle, articlePerfect: '0' }).then(function (res) { - _ts.$store.commit('admin/updateArticlePreference', { - index: index, - idArticle: idArticle, - articlePerfect: '0' - }) - _ts.$message.success("取消成功!"); + if (res) { + _ts.$store.commit('admin/updateArticlePreference', { + index: index, + idArticle: idArticle, + articlePerfect: '0' + }) + _ts.$message.success("取消成功!"); + } else { + _ts.$message.error("取消失败!"); + } }) }, updateTags(index, article) { From 66784c40cc1ff21b00bb516bbba3cc62a46f6147 Mon Sep 17 00:00:00 2001 From: ronger Date: Tue, 1 Nov 2022 07:46:34 +0800 Subject: [PATCH 6/6] Update _article_id.vue --- pages/article/_article_id.vue | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pages/article/_article_id.vue b/pages/article/_article_id.vue index eacbc05..1a99618 100644 --- a/pages/article/_article_id.vue +++ b/pages/article/_article_id.vue @@ -335,14 +335,18 @@ export default { _ts.gotoLogin(); } }, - setPreference() { + setPreference() { let _ts = this; _ts.$axios.$patch("/api/admin/article/update-perfect", { idArticle: _ts.article.idArticle, articlePerfect: '1', }).then(function (res) { - _ts.isPerfect = !_ts.isPerfect; - _ts.$message.success("设置成功!"); + if (res) { + _ts.$set(_ts, 'isPerfect', true); + _ts.$message.success("设置成功!"); + } else { + _ts.$message.error("设置失败!"); + } }) }, cancelPreference() { @@ -351,8 +355,12 @@ export default { idArticle: _ts.article.idArticle, articlePerfect: '0', }).then(function (res) { - _ts.isPerfect = !_ts.isPerfect; - _ts.$message.success("设置成功!"); + if (res) { + _ts.$set(_ts, 'isPerfect', false); + _ts.$message.success("取消成功!"); + } else { + _ts.$message.error("设置失败!"); + } }) }, thumbsUp() {