From f0cb5ddc972a127ede1ea59bbf30b6ef68f433d7 Mon Sep 17 00:00:00 2001 From: zhoupzh Date: Thu, 14 Oct 2021 10:07:39 +0800 Subject: [PATCH] fix issue #487 --- web_src/js/components/EditTopics.vue | 59 +++++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/web_src/js/components/EditTopics.vue b/web_src/js/components/EditTopics.vue index 5c452d76a..5aa5e6e7a 100644 --- a/web_src/js/components/EditTopics.vue +++ b/web_src/js/components/EditTopics.vue @@ -61,18 +61,23 @@ export default { if(!this.showInitTopic[item]){ - - this.arrayTopics.push(array.topic_name) + if(this.arrayTopics.includes(array.topic_name)){ + return + } + else{ + this.arrayTopics.push(array.topic_name) + + let topics = this.arrayTopics + let strTopics = topics.join(',') + let data = this.qs.stringify({ + _csrf:csrf, + topics:strTopics + }) + this.Post(data,topics) + this.$set(this.showInitTopic,item,true) + $('#repo-topics1').children('span').remove() + } - let topics = this.arrayTopics - let strTopics = topics.join(',') - let data = this.qs.stringify({ - _csrf:csrf, - topics:strTopics - }) - this.Post(data,topics) - this.$set(this.showInitTopic,item,true) - $('#repo-topics1').children('span').remove() @@ -93,7 +98,6 @@ export default { this.Post(data,topics) this.$set(this.showInitTopic,item,false) if(this.arrayTopics.length===0){ - console.log("set empty") $('#repo-topics1').append('暂无标签') }else{ $('#repo-topics1').children('span').remove() @@ -199,7 +203,6 @@ export default { postTopic(){ const patter = /^[\u4e00-\u9fa5a-zA-Z0-9][\u4e00-\u9fa5a-zA-Z0-9-]{0,34}$/ let regexp = patter.test(this.input) - console.log("regexp",regexp) if(!regexp){ this.$notify({ @@ -210,19 +213,25 @@ export default { return }else{ let topic = this.input - this.arrayTopics.push(topic) + if(this.arrayTopics.includes(topic)){ + return + } + else{ + this.arrayTopics.push(topic) + + let topics = this.arrayTopics + let strTopics = topics.join(',') + let data = this.qs.stringify({ + _csrf:csrf, + topics:strTopics + }) + this.Post(data,topics) + $('#repo-topics1').children('span').remove() + this.showInputValue = false + this.showAddTopic = true + this.showAddFlage = true + } - let topics = this.arrayTopics - let strTopics = topics.join(',') - let data = this.qs.stringify({ - _csrf:csrf, - topics:strTopics - }) - this.Post(data,topics) - $('#repo-topics1').children('span').remove() - this.showInputValue = false - this.showAddTopic = true - this.showAddFlage = true }