optimize topics ui and logic (70%)

pull/273/head
Michael Li 2 years ago
parent 49a624b2c0
commit 7e85a9a5a1
No known key found for this signature in database

@ -23,6 +23,7 @@ type TagFormated struct {
Tag string `json:"tag"` Tag string `json:"tag"`
QuoteNum int64 `json:"quote_num"` QuoteNum int64 `json:"quote_num"`
IsFollowing int8 `json:"is_following"` IsFollowing int8 `json:"is_following"`
IsTop int8 `json:"is_top"`
} }
func (t *Tag) Format() *TagFormated { func (t *Tag) Format() *TagFormated {
@ -36,7 +37,8 @@ func (t *Tag) Format() *TagFormated {
User: &UserFormated{}, User: &UserFormated{},
Tag: t.Tag, Tag: t.Tag,
QuoteNum: t.QuoteNum, QuoteNum: t.QuoteNum,
IsFollowing: 0, IsFollowing: 1,
IsTop: 0,
} }
} }

@ -68,12 +68,23 @@ const props = withDefaults(
const tagOptions = computed(() => { const tagOptions = computed(() => {
let options: DropdownOption[] = []; let options: DropdownOption[] = [];
if (props.tag.is_following == 0) { if (props.tag.is_following === 0) {
options.push({ options.push({
label: '', label: '',
key: 'follow', key: 'follow',
}); });
} else { } else {
if (props.tag.is_top === 0) {
options.push({
label: '',
key: 'stick',
});
} else {
options.push({
label: '',
key: 'unstick',
});
}
options.push({ options.push({
label: '', label: '',
key: 'unfollow', key: 'unfollow',
@ -83,14 +94,24 @@ const tagOptions = computed(() => {
}); });
const handleTagAction = ( const handleTagAction = (
item: 'follow' | 'unfollow' item: 'follow' | 'unfollow' | 'stick' | 'unstick'
) => { ) => {
switch (item) { switch (item) {
case 'follow': case 'follow':
window.$message.success(`关注话题 - ${props.tag.tag}`); // TODO
window.$message.success(`关注成功`);
break; break;
case 'unfollow': case 'unfollow':
window.$message.success(`取消关注话题 - ${props.tag.tag}`); // TODO
window.$message.success(`取消关注`);
break;
case 'stick':
// TODO
window.$message.success(`置顶成功`);
break;
case 'unstick':
// TODO
window.$message.success(`取消置顶`);
break; break;
default: default:
break; break;

@ -292,6 +292,8 @@ declare module Item {
deleted_on?: number; deleted_on?: number;
/** 是否关注0为未关注1为已关注 */ /** 是否关注0为未关注1为已关注 */
is_following?: 0 | 1; is_following?: 0 | 1;
/** 是否置顶0为未置顶1为已置顶 */
is_top?: 0 | 1;
/** 是否删除0为未删除1为已删除 */ /** 是否删除0为未删除1为已删除 */
is_del?: 0 | 1; is_del?: 0 | 1;
} }

Loading…
Cancel
Save