websocket默认用户列表改为真实获取

This commit is contained in:
1378012178@qq.com 2026-01-13 10:22:35 +08:00
parent ae30219b8b
commit e899c7c181
2 changed files with 25 additions and 10 deletions

View File

@ -446,6 +446,7 @@
import { ref, reactive, computed, onMounted, onBeforeUnmount, watch, nextTick } from 'vue'; import { ref, reactive, computed, onMounted, onBeforeUnmount, watch, nextTick } from 'vue';
import { message, Modal } from 'ant-design-vue'; import { message, Modal } from 'ant-design-vue';
import { UserOutlined, ReloadOutlined } from '@ant-design/icons-vue'; import { UserOutlined, ReloadOutlined } from '@ant-design/icons-vue';
import { userList } from './test.api';
// WebSocket // WebSocket
const ws = ref({}); // WebSocket const ws = ref({}); // WebSocket
@ -461,15 +462,7 @@ const wsConfig = reactive({
}); });
// IDID // IDID
const fixedUsers = ref([ const fixedUsers = ref([]);
'1990230015776468901',
'1990230015776468902',
'1990230015776468905',
'1990230015776468903',
'1990230015776468906',
'1990230015776468993',
'1990230015776468904'
]);
// //
const userRealnameCache = ref({}); const userRealnameCache = ref({});
@ -1056,6 +1049,8 @@ const broadcastToSelectedUsers = () => {
// //
const sendMessageToUser = (userId, msg) => { const sendMessageToUser = (userId, msg) => {
console.log("🌊 ~ sendMessageToUser ~ msg:", msg)
console.log("🌊 ~ sendMessageToUser ~ userId:", userId)
if (!isConnected.value) { if (!isConnected.value) {
message.warning('WebSocket未连接'); message.warning('WebSocket未连接');
return false; return false;
@ -1645,7 +1640,12 @@ onBeforeUnmount(() => {
}); });
// //
onMounted(() => { onMounted(async () => {
let users = await userList()
users.forEach(item => {
return fixedUsers.value.push(item.id);
})
// //
if (fixedUsers.value.length > 0) { if (fixedUsers.value.length > 0) {
selectedConnectUsers.value = [fixedUsers.value[0]]; selectedConnectUsers.value = [fixedUsers.value[0]];

View File

@ -0,0 +1,15 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
userList = '/api/pad/employee/queryEmpList',
}
/**
*
* @param params
*/
export const userList = () => defHttp.get({ url: Api.userList });