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