|
|
@@ -3,13 +3,13 @@ |
|
|
<div class="input-search"> |
|
|
<div class="input-search"> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-input v-model="input" clearable :autofocus="true" @input="changeValue" id="topics_input" @keyup.enter.native="postTopic"> |
|
|
|
|
|
|
|
|
<el-input v-model="input" clearable :autofocus="true" @input="changeValue" id="topics_input" @keyup.enter.native="postTopic" placeholder="搜索或创建标签"> |
|
|
|
|
|
|
|
|
</el-input> |
|
|
</el-input> |
|
|
<div class="scrolling-menu"> |
|
|
<div class="scrolling-menu"> |
|
|
<div v-if="showSearchTopic" class="item-text" v-for="(arr,i) in array" @click="addTopics(i,arr)"> |
|
|
<div v-if="showSearchTopic" class="item-text" v-for="(arr,i) in array" @click="addTopics(i,arr)"> |
|
|
<div class="icon-wrapper"> |
|
|
<div class="icon-wrapper"> |
|
|
<i style="vertical-align: middle;color: #303643;" v-if="showInitTopic[i]" class="el-icon-check" ></i> |
|
|
|
|
|
|
|
|
<i style="line-height: 1.5;color: #303643;font-weight: 900;" v-if="showInitTopic[i]" class="el-icon-check" ></i> |
|
|
</div> |
|
|
</div> |
|
|
<div class="text">{{arr.topic_name}} </div> |
|
|
<div class="text">{{arr.topic_name}} </div> |
|
|
</div> |
|
|
</div> |
|
|
@@ -18,7 +18,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
<div v-if="showAddTopic" class="item-text" @click="addPostTopic"> |
|
|
<div v-if="showAddTopic" class="item-text" @click="addPostTopic"> |
|
|
<div class="icon-wrapper"> |
|
|
<div class="icon-wrapper"> |
|
|
<i style="vertical-align: middle;color: #303643;" v-if="showAddFlage" class="el-icon-check" ></i> |
|
|
|
|
|
|
|
|
<i style="line-height: 1.5;color: #303643;font-weight: 900;" v-if="showAddFlage" class="el-icon-check" ></i> |
|
|
</div> |
|
|
</div> |
|
|
<div class="text">{{input}}</div> |
|
|
<div class="text">{{input}}</div> |
|
|
</div> |
|
|
</div> |
|
|
@@ -72,6 +72,7 @@ export default { |
|
|
}) |
|
|
}) |
|
|
this.Post(data,topics) |
|
|
this.Post(data,topics) |
|
|
this.$set(this.showInitTopic,item,true) |
|
|
this.$set(this.showInitTopic,item,true) |
|
|
|
|
|
$('#repo-topics1').children('span').remove() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -91,6 +92,12 @@ export default { |
|
|
}) |
|
|
}) |
|
|
this.Post(data,topics) |
|
|
this.Post(data,topics) |
|
|
this.$set(this.showInitTopic,item,false) |
|
|
this.$set(this.showInitTopic,item,false) |
|
|
|
|
|
if(this.arrayTopics.length===0){ |
|
|
|
|
|
console.log("set empty") |
|
|
|
|
|
$('#repo-topics1').append('<span class="no-description text-italic">暂无标签</span>') |
|
|
|
|
|
}else{ |
|
|
|
|
|
$('#repo-topics1').children('span').remove() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@@ -190,21 +197,34 @@ export default { |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
postTopic(){ |
|
|
postTopic(){ |
|
|
|
|
|
const patter = /^[\u4e00-\u9fa5a-z0-9][\u4e00-\u9fa5a-zA-Z0-9-]{0,35}$/ |
|
|
|
|
|
let regexp = patter.test(this.input) |
|
|
|
|
|
console.log("regexp",regexp) |
|
|
|
|
|
if(!regexp){ |
|
|
|
|
|
this.$notify({ |
|
|
|
|
|
|
|
|
|
|
|
message: '主题必须以中文、字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符', |
|
|
|
|
|
duration: 3000, |
|
|
|
|
|
type:'error' |
|
|
|
|
|
}); |
|
|
|
|
|
return |
|
|
|
|
|
}else{ |
|
|
|
|
|
let topic = this.input |
|
|
|
|
|
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 topic = this.input |
|
|
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
this.showInputValue = false |
|
|
|
|
|
this.showAddTopic = true |
|
|
|
|
|
this.showAddFlage = true |
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
addPostTopic(){ |
|
|
addPostTopic(){ |
|
|
@@ -218,7 +238,13 @@ export default { |
|
|
topics:strTopics |
|
|
topics:strTopics |
|
|
}) |
|
|
}) |
|
|
this.Post(data,topics) |
|
|
this.Post(data,topics) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.arrayTopics.length===0){ |
|
|
|
|
|
console.log("add postTopic") |
|
|
|
|
|
$('#repo-topics1').append('<span class="no-description text-italic">暂无标签</span>') |
|
|
|
|
|
}else{ |
|
|
|
|
|
$('#repo-topics1').children('span').remove() |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else if(!this.showAddFlage){ |
|
|
else if(!this.showAddFlage){ |
|
|
let topic = this.input |
|
|
let topic = this.input |
|
|
@@ -231,6 +257,7 @@ export default { |
|
|
topics:strTopics |
|
|
topics:strTopics |
|
|
}) |
|
|
}) |
|
|
this.Post(data,topics) |
|
|
this.Post(data,topics) |
|
|
|
|
|
$('#repo-topics1').children('span').remove() |
|
|
} |
|
|
} |
|
|
this.showAddFlage = !this.showAddFlage |
|
|
this.showAddFlage = !this.showAddFlage |
|
|
}, |
|
|
}, |
|
|
@@ -245,6 +272,27 @@ export default { |
|
|
editDiv.css('display', ''); // show Semantic UI Grid |
|
|
editDiv.css('display', ''); // show Semantic UI Grid |
|
|
|
|
|
|
|
|
this.input = '' |
|
|
this.input = '' |
|
|
|
|
|
if (this.input === ''){ |
|
|
|
|
|
this.array = this.arrayTopics |
|
|
|
|
|
let data = [] |
|
|
|
|
|
this.showInitTopic = [] |
|
|
|
|
|
this.array.forEach((element,index) => { |
|
|
|
|
|
|
|
|
|
|
|
let item = {} |
|
|
|
|
|
item.topic_name = element |
|
|
|
|
|
|
|
|
|
|
|
data.push(item) |
|
|
|
|
|
this.showInitTopic.push(true) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.array = data |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.showInputValue = false |
|
|
|
|
|
this.showSearchTopic = true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
stopPropagation(e); |
|
|
stopPropagation(e); |
|
|
|
|
|
|
|
|
@@ -310,7 +358,10 @@ mounted() { |
|
|
|
|
|
|
|
|
context.arrayTopics.push($(this).text()) |
|
|
context.arrayTopics.push($(this).text()) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if(this.arrayTopics.length===0){ |
|
|
|
|
|
|
|
|
|
|
|
$('#repo-topics1').append('<span class="no-description text-italic">暂无标签</span>') |
|
|
|
|
|
} |
|
|
this.changeValue() |
|
|
this.changeValue() |
|
|
} , |
|
|
} , |
|
|
created(){ |
|
|
created(){ |
|
|
|