2024-06-22 10:54:02 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import {useMainLayoutStore} from "~/strores/UseMainLayoutStore";
|
|
|
|
import {useSessionSignalRStore} from "~/strores/HubStore";
|
|
|
|
import {POSITION, useToast} from 'vue-toastification'
|
|
|
|
|
|
|
|
const toast = useToast()
|
|
|
|
const mainLayoutStore = useMainLayoutStore()
|
|
|
|
const signalRStore = useSessionSignalRStore()
|
|
|
|
const currentUserId = ref("")
|
|
|
|
const sendMessageModel = ref(false)
|
|
|
|
const message = ref("")
|
|
|
|
const items = ref([
|
|
|
|
{
|
|
|
|
label: '发送消息', command: () => {
|
|
|
|
sendMessageModel.value = true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{label: '通知',}
|
|
|
|
]);
|
|
|
|
const sendMessage = () => {
|
|
|
|
signalRStore.sendMessage("SendMessage", mainLayoutStore.UserInfo.id, currentUserId.value, message.value)
|
|
|
|
sendMessageModel.value = false
|
|
|
|
}
|
|
|
|
const onRightClick = (event: MouseEvent, userId: string) => {
|
|
|
|
menu.value.show(event);
|
|
|
|
currentUserId.value = userId;
|
|
|
|
};
|
|
|
|
const menu = ref();
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="online-user-layout">
|
|
|
|
<Dialog v-model:visible="sendMessageModel" header="发送消息" modal>
|
|
|
|
<Textarea v-model="message" cols="30" rows="5"/>
|
|
|
|
<template #footer>
|
|
|
|
<Button autofocus label="取消" severity="secondary" text @click="sendMessageModel = false"/>
|
|
|
|
<Button autofocus label="发送" outlined severity="secondary" @click="sendMessage"/>
|
|
|
|
</template>
|
|
|
|
</Dialog>
|
2024-07-22 18:41:15 +08:00
|
|
|
<n-modal v-model:show="sendMessageModel">
|
|
|
|
123123
|
|
|
|
</n-modal>
|
2024-06-22 10:54:02 +08:00
|
|
|
<ContextMenu ref="menu" :model="items"/>
|
|
|
|
<div v-for="user in mainLayoutStore.OnlineUsers" class="user-item" @click="onRightClick($event,user.id)">
|
2024-07-22 18:41:15 +08:00
|
|
|
<n-avatar
|
|
|
|
:size="50"
|
|
|
|
:src="user.avatar"
|
|
|
|
lazy
|
|
|
|
fallback-src="https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg"
|
|
|
|
/>
|
2024-06-22 10:54:02 +08:00
|
|
|
<div class="user-info">
|
|
|
|
<h4>{{ user.nickName }}</h4>
|
|
|
|
<div>
|
2024-07-22 18:41:15 +08:00
|
|
|
<n-tag type="info" :bordered="false">
|
|
|
|
{{user.posts}}
|
|
|
|
</n-tag>
|
2024-06-22 10:54:02 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import 'base';
|
|
|
|
|
|
|
|
.online-user-layout {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
gap: $gap*1.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
.user-item {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
gap: $gap*3;
|
2024-07-22 18:41:15 +08:00
|
|
|
padding: $padding*.25 $padding;
|
2024-06-22 10:54:02 +08:00
|
|
|
border-radius: $radius;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: rgba(212, 212, 212, 0.45);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .user-info {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
2024-07-22 18:41:15 +08:00
|
|
|
gap: $gap*.2;
|
2024-06-22 10:54:02 +08:00
|
|
|
flex: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|