fix:【infra 基础设施】websocket 推送,无法选中所有人

pull/210/head
YunaiV 2025-09-06 21:21:43 +08:00
parent 4cbbad4d40
commit 74ffefb09f
2 changed files with 14 additions and 17 deletions

View File

@ -99,7 +99,7 @@ watchEffect(() => {
/** 发送消息 */
const sendText = ref(''); //
const sendUserId = ref(''); //
const sendUserId = ref('all'); //
function handlerSend() {
if (!sendText.value.trim()) {
message.warning('消息内容不能为空');
@ -109,7 +109,7 @@ function handlerSend() {
// 1.1 JSON message
const messageContent = JSON.stringify({
text: sendText.value,
toUserId: sendUserId.value,
toUserId: sendUserId.value === 'all' ? undefined : sendUserId.value,
});
// 1.2 JSON
const jsonMessage = JSON.stringify({

View File

@ -99,8 +99,8 @@ watchEffect(() => {
/** 发送消息 */
const sendText = ref(''); //
const sendUserId = ref(''); //
const handlerSend = () => {
const sendUserId = ref('all'); //
function handlerSend() {
if (!sendText.value.trim()) {
ElMessage.warning('消息内容不能为空');
return;
@ -109,7 +109,7 @@ const handlerSend = () => {
// 1.1 JSON message
const messageContent = JSON.stringify({
text: sendText.value,
toUserId: sendUserId.value,
toUserId: sendUserId.value === 'all' ? undefined : sendUserId.value,
});
// 1.2 JSON
const jsonMessage = JSON.stringify({
@ -119,19 +119,19 @@ const handlerSend = () => {
// 2.
send(jsonMessage);
sendText.value = '';
};
}
/** 切换 websocket 连接状态 */
const toggleConnectStatus = () => {
function toggleConnectStatus() {
if (getIsOpen.value) {
close();
} else {
open();
}
};
}
/** 获取消息类型的徽标颜色 */
const getMessageBadgeType = (type?: string) => {
function getMessageBadgeType(type?: string) {
switch (type) {
case 'group': {
return 'success';
@ -146,10 +146,10 @@ const getMessageBadgeType = (type?: string) => {
return 'info';
}
}
};
}
/** 获取消息类型的文本 */
const getMessageTypeText = (type?: string) => {
function getMessageTypeText(type?: string) {
switch (type) {
case 'group': {
return '群发';
@ -164,7 +164,7 @@ const getMessageTypeText = (type?: string) => {
return '未知';
}
}
};
}
/** 初始化 */
const userList = ref<SystemUserApi.User[]>([]); //
@ -227,8 +227,7 @@ onMounted(async () => {
placeholder="请选择接收人"
:disabled="!getIsOpen"
>
<!-- TODO @puhui999所有人选择不上 -->
<ElOption key="" value="" label="所有人">
<ElOption key="" value="all" label="所有人">
<div class="flex items-center">
<ElAvatar size="small"></ElAvatar>
<span class="ml-2">所有人</span>
@ -295,9 +294,7 @@ onMounted(async () => {
>
<div class="mb-1 flex items-center justify-between">
<div class="flex items-center">
<div>
<ElBadge :type="getMessageBadgeType(msg.type)" dot />
</div>
<ElBadge :type="getMessageBadgeType(msg.type)" is-dot />
<span class="ml-1 font-medium text-gray-600">
{{ getMessageTypeText(msg.type) }}
</span>