optimize topics ui and logic (70%)

pull/273/head
Michael Li 1 year 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"`
QuoteNum int64 `json:"quote_num"`
IsFollowing int8 `json:"is_following"`
IsTop int8 `json:"is_top"`
}
func (t *Tag) Format() *TagFormated {
@ -36,7 +37,8 @@ func (t *Tag) Format() *TagFormated {
User: &UserFormated{},
Tag: t.Tag,
QuoteNum: t.QuoteNum,
IsFollowing: 0,
IsFollowing: 1,
IsTop: 0,
}
}

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

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

Loading…
Cancel
Save