+
@@ -17,9 +17,9 @@
{{ contact.nickname }}
- @{{ contact.username }}
+ @{{ contact.username }}
已关注
@@ -62,11 +62,23 @@ import { NIcon, useDialog, DropdownOption } from 'naive-ui';
import { formatDate } from '@/utils/formatTime';
import { MoreHorizFilled } from '@vicons/material';
import { PaperPlaneOutline, BodyOutline, WalkOutline } from '@vicons/ionicons5';
-import { Api } from '@/utils/request';
import UserAction from '@/composables/useUserAction';
const dialog = useDialog();
+const props = withDefaults(
+ defineProps<{
+ contact: Item.ContactItemProps;
+ type?: 'contact' | 'follow';
+ }>(),
+ {
+ type: 'contact',
+ },
+);
+
+const showFollowingTag = computed(() => props.type === 'follow');
+const enableFollowAction = computed(() => props.type === 'follow');
+
const emit = defineEmits<{
(e: 'send-whisper', user: Item.UserInfo): void;
(e: 'unfollow-success'): void;
@@ -85,7 +97,6 @@ const handleFollowUser = () => {
UserAction.followAction(dialog, props.contact.user_id, props.contact.username, props.contact.is_following)
.then(_action => {
props.contact.is_following = _action;
- // 如果是取消关注操作,触发事件
if (wasFollowing && !_action) {
emit('unfollow-success');
}
@@ -95,13 +106,6 @@ const handleFollowUser = () => {
});
};
-const props = withDefaults(
- defineProps<{
- contact: Item.ContactItemProps;
- }>(),
- {},
-);
-
const actionOpts = computed(() => {
let options: DropdownOption[] = [
{
@@ -110,19 +114,23 @@ const actionOpts = computed(() => {
icon: renderIcon(PaperPlaneOutline),
},
];
- if (props.contact.is_following) {
- options.push({
- label: '取消关注 @' + props.contact.username,
- key: 'unfollow',
- icon: renderIcon(WalkOutline),
- });
- } else {
- options.push({
- label: '关注 @' + props.contact.username,
- key: 'follow',
- icon: renderIcon(BodyOutline),
- });
+
+ if (enableFollowAction.value) {
+ if (props.contact.is_following) {
+ options.push({
+ label: '取消关注 @' + props.contact.username,
+ key: 'unfollow',
+ icon: renderIcon(WalkOutline),
+ });
+ } else {
+ options.push({
+ label: '关注 @' + props.contact.username,
+ key: 'follow',
+ icon: renderIcon(BodyOutline),
+ });
+ }
}
+
return options;
});
@@ -155,13 +163,10 @@ const handleAction = (item: 'follow' | 'unfollow' | 'whisper') => {
\ No newline at end of file
+
diff --git a/web/src/views/Contacts.vue b/web/src/views/Contacts.vue
index 7a48f85e..01cfdd4b 100644
--- a/web/src/views/Contacts.vue
+++ b/web/src/views/Contacts.vue
@@ -12,38 +12,33 @@
-
+