websocket默认用户列表改为真实获取
This commit is contained in:
parent
ae30219b8b
commit
e899c7c181
|
|
@ -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({
|
||||||
});
|
});
|
||||||
|
|
||||||
// 固定用户ID列表(只需要ID,不需要姓名)
|
// 固定用户ID列表(只需要ID,不需要姓名)
|
||||||
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]];
|
||||||
|
|
|
||||||
|
|
@ -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 });
|
||||||
|
|
||||||
Loading…
Reference in New Issue