cnhis-design-vue 3.3.3-release.12 → 3.3.3-release.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -87
- package/es/components/button-print/index.d.ts +60 -0
- package/es/components/button-print/src/ButtonPrint.vue.d.ts +60 -0
- package/es/components/button-print/src/ButtonPrint.vue2.js +6 -0
- package/es/components/button-print/src/components/NewPrintComponent.vue.d.ts +18 -0
- package/es/components/button-print/src/components/NewPrintComponent.vue2.js +8 -0
- package/es/components/button-print/src/components/OldPrintComponent.vue.d.ts +18 -0
- package/es/components/button-print/src/components/OldPrintComponent.vue2.js +8 -0
- package/es/components/button-print/src/utils/print.d.ts +4 -2
- package/es/components/button-print/src/utils/print.js +165 -4
- package/es/components/classification/src/components/table-modal/index.vue.d.ts +0 -3
- package/es/components/field-set/src/FieldColor.vue.d.ts +4 -4
- package/es/components/field-set/src/FieldFilter.vue.d.ts +4 -4
- package/es/components/field-set/src/FieldSet.vue.d.ts +5 -5
- package/es/components/field-set/src/components/table-row.vue.d.ts +4 -4
- package/es/components/field-set/src/types/index.d.ts +1 -1
- package/es/components/form-render/src/components/renderer/radio_checkbox.js +2 -1
- package/es/components/iho-chat/index.d.ts +40 -49
- package/es/components/iho-chat/src/Index.vue.d.ts +40 -49
- package/es/components/iho-chat/src/components/ChatFooter.vue2.js +6 -2
- package/es/components/iho-chat/src/components/ChatMain.vue2.js +1 -1
- package/es/components/iho-chat/src/components/ImageLightbox.vue2.js +1 -1
- package/es/components/iho-chat/src/components/MultipleVideo.vue.d.ts +29 -28
- package/es/components/iho-chat/src/components/MultipleVideo.vue2.js +240 -93
- package/es/components/iho-chat/src/components/PersonProfile.vue2.js +1 -1
- package/es/components/iho-chat/src/components/Video.vue.d.ts +14 -24
- package/es/components/iho-chat/src/components/Video.vue2.js +35 -40
- package/es/components/iho-chat/src/hooks/useVideo.d.ts +54 -10
- package/es/components/iho-chat/src/hooks/useVideo.js +422 -44
- package/es/components/iho-chat/src/utils/index.d.ts +1 -0
- package/es/components/iho-chat/src/utils/index.js +7 -1
- package/es/components/iho-chat/style/index.css +1 -1
- package/es/components/index.css +1 -1
- package/es/components/index.d.ts +2 -0
- package/es/components/index.js +1 -0
- package/es/components/keyboard/index.d.ts +8 -0
- package/es/components/keyboard/src/Keyboard.vue.d.ts +8 -0
- package/es/components/keyboard/src/Keyboard.vue2.js +33 -9
- package/es/components/keyboard/src/components/NumberPanel.vue.d.ts +3 -0
- package/es/components/keyboard/src/components/NumberPanel.vue2.js +27 -7
- package/es/components/keyboard/src/types.d.ts +17 -0
- package/es/components/keyboard/src/types.js +1 -0
- package/es/components/scale-view/index.d.ts +13 -0
- package/es/components/scale-view/src/ScaleView.vue.d.ts +13 -0
- package/es/components/scale-view/src/hooks/scaleview-computed.js +2 -1
- package/es/components/scale-view/src/hooks/scaleview-props.d.ts +4 -0
- package/es/components/scale-view/src/hooks/scaleview-props.js +4 -0
- package/es/components/table-filter/src/components/render-widget/helpers/dateExtraMap.js +32 -4
- package/es/components/table-filter/src/tool/baseOptions.js +8 -1
- package/es/components/vertify/index.d.ts +1 -0
- package/es/components/vertify/index.js +1 -0
- package/es/components/vertify/src/components/IdentityVerification.vue.d.ts +89 -0
- package/es/components/vertify/src/components/IdentityVerification.vue.js +6 -0
- package/es/components/vertify/src/components/IdentityVerification.vue2.js +256 -0
- package/es/components/vertify/src/utils/dialog.d.ts +7 -0
- package/es/components/vertify/src/utils/dialog.js +73 -0
- package/es/components/vertify/src/utils/index.d.ts +11 -0
- package/es/components/vertify/src/utils/index.js +24 -0
- package/es/components/vod-chunk-upload/index.d.ts +13 -0
- package/es/components/vod-chunk-upload/src/chunk-upload-new.vue.d.ts +19 -2
- package/es/components/vod-chunk-upload/src/chunk-upload-new.vue2.js +104 -75
- package/es/components/vod-chunk-upload/src/hooks/upload-computed.d.ts +1 -0
- package/es/components/vod-chunk-upload/src/hooks/upload-computed.js +20 -3
- package/es/components/vod-chunk-upload/src/hooks/upload-data.d.ts +4 -0
- package/es/components/vod-chunk-upload/src/hooks/upload-data.js +6 -2
- package/es/components/vod-chunk-upload/src/vod-chunk-upload/vod-chunk-upload.vue.d.ts +13 -0
- package/es/components/vod-chunk-upload/src/vod-chunk-upload/vod-chunk-upload.vue2.js +6 -1
- package/es/components/vod-chunk-upload/style/index.css +1 -1
- package/es/env.d.ts +25 -25
- package/es/shared/assets/img/defaultCover/10review_successful.png.js +1 -1
- package/es/shared/assets/img/defaultCover/11review_fail.png.js +1 -1
- package/es/shared/assets/img/defaultCover/12no_setting.png.js +1 -1
- package/es/shared/assets/img/defaultCover/13no_menu_setting.png.js +1 -1
- package/es/shared/assets/img/defaultCover/14no_call_setting.png.js +1 -1
- package/es/shared/assets/img/defaultCover/15no_use_tag.png.js +1 -1
- package/es/shared/assets/img/defaultCover/16no_table_data.png.js +1 -1
- package/es/shared/assets/img/defaultCover/1location.png.js +1 -1
- package/es/shared/assets/img/defaultCover/2notfound.png.js +1 -1
- package/es/shared/assets/img/defaultCover/3loading.png.js +1 -1
- package/es/shared/assets/img/defaultCover/4no_permission.png.js +1 -1
- package/es/shared/assets/img/defaultCover/5no_data.png.js +1 -1
- package/es/shared/assets/img/defaultCover/6no_network.png.js +1 -1
- package/es/shared/assets/img/defaultCover/7no_doctor.png.js +1 -1
- package/es/shared/assets/img/defaultCover/8system_error.png.js +1 -1
- package/es/shared/assets/img/defaultCover/9system_upgrade.png.js +1 -1
- package/es/shared/components/InputNumberSlash/InputNumberSlash.js +1 -1
- package/es/shared/package.json.js +1 -1
- package/es/shared/utils/fabricjs/index.js +1 -1
- package/package.json +2 -2
@@ -1,14 +1,14 @@
|
|
1
|
-
import { ref, computed, onBeforeUnmount } from 'vue';
|
1
|
+
import { ref, computed, onBeforeUnmount, nextTick } from 'vue';
|
2
2
|
import { useData } from './useData.js';
|
3
3
|
import 'stompjs';
|
4
4
|
import 'sockjs-client/dist/sockjs.min.js';
|
5
5
|
import { MESSAGE_TYPE } from '../constants/index.js';
|
6
6
|
import '../api/index.js';
|
7
|
-
import { formatSeconds } from '../utils/index.js';
|
7
|
+
import { formatSeconds, $message } from '../utils/index.js';
|
8
8
|
import 'lodash-es';
|
9
9
|
import TRTC from 'trtc-sdk-v5';
|
10
10
|
|
11
|
-
function useVideo() {
|
11
|
+
function useVideo(config = {}) {
|
12
12
|
const time = {
|
13
13
|
timer: null,
|
14
14
|
seconds: 0
|
@@ -21,6 +21,11 @@ function useVideo() {
|
|
21
21
|
const timing = ref("");
|
22
22
|
const voiceClose = ref(false);
|
23
23
|
const videocamClose = ref(false);
|
24
|
+
const isConnect = ref(false);
|
25
|
+
const remoteUsers = ref([]);
|
26
|
+
const videoRefs = ref(/* @__PURE__ */ new Map());
|
27
|
+
const retryTimers = ref(/* @__PURE__ */ new Map());
|
28
|
+
const retryCount = ref(/* @__PURE__ */ new Map());
|
24
29
|
const isAudio = computed(() => state.currentAVMsg.chatMessageType === MESSAGE_TYPE.AUDIO);
|
25
30
|
const isCall = computed(() => state.currentAVMsg.callMode === "call");
|
26
31
|
const messageTypeText = computed(() => isAudio.value ? function() {
|
@@ -39,6 +44,7 @@ function useVideo() {
|
|
39
44
|
}
|
40
45
|
}());
|
41
46
|
const trtc = TRTC.create();
|
47
|
+
const MAIN_STREAM_TYPE = TRTC.TYPE.STREAM_TYPE_MAIN;
|
42
48
|
function startTimer() {
|
43
49
|
resetTimer();
|
44
50
|
time.timer = setInterval(() => {
|
@@ -52,50 +58,401 @@ function useVideo() {
|
|
52
58
|
time.timer = null;
|
53
59
|
time.seconds = 0;
|
54
60
|
}
|
55
|
-
async function
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
61
|
+
async function checkTRTCSupport() {
|
62
|
+
try {
|
63
|
+
const checkResult = await TRTC.isSupported();
|
64
|
+
if (!checkResult.result) {
|
65
|
+
$message.error("\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u89C6\u9891\u901A\u8BDD\uFF0C\u8BF7\u4F7F\u7528\u6700\u65B0\u7248Chrome\u6D4F\u89C8\u5668");
|
66
|
+
return false;
|
67
|
+
}
|
68
|
+
if (!checkResult.detail.isH264EncodeSupported) {
|
69
|
+
$message.error("\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u89C6\u9891\u7F16\u7801");
|
70
|
+
return false;
|
71
|
+
}
|
72
|
+
if (!checkResult.detail.isH264DecodeSupported) {
|
73
|
+
$message.error("\u60A8\u7684\u6D4F\u89C8\u5668\u4E0D\u652F\u6301\u89C6\u9891\u89E3\u7801");
|
74
|
+
return false;
|
75
|
+
}
|
76
|
+
return true;
|
77
|
+
} catch (error) {
|
78
|
+
console.error("Error checking TRTC support:", error);
|
79
|
+
$message.error("\u68C0\u67E5\u6D4F\u89C8\u5668\u652F\u6301\u65F6\u51FA\u9519");
|
80
|
+
return false;
|
81
|
+
}
|
60
82
|
}
|
61
|
-
|
62
|
-
|
63
|
-
|
83
|
+
function findUser(userId) {
|
84
|
+
return remoteUsers.value.find((user) => user.id === userId);
|
85
|
+
}
|
86
|
+
function findUserIndex(userId) {
|
87
|
+
return remoteUsers.value.findIndex((user) => user.id === userId);
|
88
|
+
}
|
89
|
+
function addOrUpdateUser(userId, updates) {
|
90
|
+
const userIndex = findUserIndex(userId);
|
91
|
+
if (userIndex !== -1) {
|
92
|
+
const oldUser = {
|
93
|
+
...remoteUsers.value[userIndex]
|
94
|
+
};
|
95
|
+
Object.assign(remoteUsers.value[userIndex], updates);
|
96
|
+
console.log(`Updated user ${userId}:`, {
|
97
|
+
old: oldUser,
|
98
|
+
new: remoteUsers.value[userIndex]
|
99
|
+
});
|
100
|
+
} else {
|
101
|
+
const newUser = {
|
102
|
+
id: userId,
|
103
|
+
name: updates.name || userId,
|
104
|
+
hasVideo: updates.hasVideo || false,
|
105
|
+
hasAudio: updates.hasAudio || false
|
106
|
+
};
|
107
|
+
remoteUsers.value.push(newUser);
|
108
|
+
console.log(`Added new user ${userId}:`, newUser);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
function removeUser(userId) {
|
112
|
+
console.log("Removing user:", userId);
|
113
|
+
const userIndex = findUserIndex(userId);
|
114
|
+
if (userIndex !== -1) {
|
115
|
+
remoteUsers.value.splice(userIndex, 1);
|
116
|
+
}
|
117
|
+
videoRefs.value.delete(userId);
|
118
|
+
clearRetryTimer(userId);
|
119
|
+
stopRemoteVideo(userId).catch((error) => {
|
120
|
+
console.warn("Error stopping remote video during user removal:", error);
|
64
121
|
});
|
65
|
-
|
66
|
-
}
|
67
|
-
function
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
122
|
+
console.log("User removed and cleaned up:", userId);
|
123
|
+
}
|
124
|
+
function clearRetryTimer(userId) {
|
125
|
+
const timer = retryTimers.value.get(userId);
|
126
|
+
if (timer) {
|
127
|
+
clearTimeout(timer);
|
128
|
+
retryTimers.value.delete(userId);
|
129
|
+
}
|
130
|
+
retryCount.value.delete(userId);
|
131
|
+
}
|
132
|
+
async function tryRenderRemoteVideo(userId) {
|
133
|
+
var _a, _b;
|
134
|
+
const videoElement = videoRefs.value.get(userId);
|
135
|
+
const user = findUser(userId);
|
136
|
+
console.log("tryRenderRemoteVideo called for user:", userId);
|
137
|
+
console.log("Video element:", videoElement);
|
138
|
+
console.log("User data:", user);
|
139
|
+
console.log("Is connected:", isConnect.value);
|
140
|
+
if (!videoElement) {
|
141
|
+
console.log("Video element not found for user:", userId, "Available refs:", Array.from(videoRefs.value.keys()));
|
79
142
|
return;
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
handleRemoteVideoAvailable
|
88
|
-
}) {
|
89
|
-
trtc.off(TRTC.EVENT.ERROR, handleError);
|
90
|
-
trtc.off(TRTC.EVENT.REMOTE_USER_ENTER, handleRemoteUserEnter);
|
91
|
-
trtc.off(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, handleRemoteAudioAvailable);
|
92
|
-
trtc.off(TRTC.EVENT.REMOTE_USER_EXIT, handleRemoteUserExit);
|
93
|
-
if (isAudio.value)
|
143
|
+
}
|
144
|
+
if (!isConnect.value) {
|
145
|
+
console.log("Not connected, skipping video render for user:", userId);
|
146
|
+
return;
|
147
|
+
}
|
148
|
+
if (!(user == null ? void 0 : user.hasVideo)) {
|
149
|
+
console.log("User has no video stream:", userId, "User hasVideo:", user == null ? void 0 : user.hasVideo);
|
94
150
|
return;
|
95
|
-
|
151
|
+
}
|
152
|
+
try {
|
153
|
+
const existingVideo = videoElement.querySelector("video");
|
154
|
+
if (existingVideo) {
|
155
|
+
console.log("Video already playing for user:", userId);
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
console.log("Starting remote video for user:", userId, "with element:", videoElement);
|
159
|
+
await trtc.startRemoteVideo({
|
160
|
+
userId,
|
161
|
+
streamType: MAIN_STREAM_TYPE,
|
162
|
+
view: videoElement
|
163
|
+
});
|
164
|
+
console.log("Successfully rendered video for user:", userId);
|
165
|
+
clearRetryTimer(userId);
|
166
|
+
} catch (error) {
|
167
|
+
console.warn("Failed to render video for user:", userId, error);
|
168
|
+
if (error.code === "INVALID_OPERATION" && (((_a = error.message) == null ? void 0 : _a.includes("does not publishing stream")) || ((_b = error.message) == null ? void 0 : _b.includes("not exist"))) || error.code === "OPERATION_ABORT") {
|
169
|
+
console.log("User no longer exists or not publishing, removing from retry:", userId);
|
170
|
+
clearRetryTimer(userId);
|
171
|
+
addOrUpdateUser(userId, {
|
172
|
+
hasVideo: false
|
173
|
+
});
|
174
|
+
}
|
175
|
+
}
|
96
176
|
}
|
97
|
-
|
177
|
+
async function stopRemoteVideo(userId) {
|
178
|
+
var _a;
|
179
|
+
try {
|
180
|
+
await trtc.stopRemoteVideo({
|
181
|
+
userId,
|
182
|
+
streamType: MAIN_STREAM_TYPE
|
183
|
+
});
|
184
|
+
console.log("Stopped remote video for user:", userId);
|
185
|
+
} catch (error) {
|
186
|
+
if (error.code === "INVALID_OPERATION" && ((_a = error.message) == null ? void 0 : _a.includes("does not exist"))) {
|
187
|
+
console.log("User already exited, no need to stop video:", userId);
|
188
|
+
} else {
|
189
|
+
console.warn("Error stopping remote video for user:", userId, error);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
}
|
193
|
+
function isUserValid(userId) {
|
194
|
+
const user = findUser(userId);
|
195
|
+
return user !== void 0;
|
196
|
+
}
|
197
|
+
function cleanupInvalidUsers() {
|
198
|
+
const validUserIds = remoteUsers.value.map((user) => user.id);
|
199
|
+
const retryUserIds = Array.from(retryTimers.value.keys());
|
200
|
+
retryUserIds.forEach((userId) => {
|
201
|
+
if (!validUserIds.includes(userId)) {
|
202
|
+
console.log("Cleaning up retry timer for invalid user:", userId);
|
203
|
+
clearRetryTimer(userId);
|
204
|
+
}
|
205
|
+
});
|
206
|
+
}
|
207
|
+
let userConnectionCheckInterval = null;
|
208
|
+
function startUserConnectionMonitoring() {
|
209
|
+
if (userConnectionCheckInterval)
|
210
|
+
return;
|
211
|
+
console.log("Starting user connection monitoring...");
|
212
|
+
userConnectionCheckInterval = setInterval(() => {
|
213
|
+
if (!isConnect.value) {
|
214
|
+
stopUserConnectionMonitoring();
|
215
|
+
return;
|
216
|
+
}
|
217
|
+
remoteUsers.value.forEach((user) => {
|
218
|
+
if (!user.hasVideo && !user.hasAudio) {
|
219
|
+
console.log(`User ${user.id} has no streams for extended period, checking...`);
|
220
|
+
}
|
221
|
+
});
|
222
|
+
}, 1e4);
|
223
|
+
}
|
224
|
+
function stopUserConnectionMonitoring() {
|
225
|
+
if (userConnectionCheckInterval) {
|
226
|
+
clearInterval(userConnectionCheckInterval);
|
227
|
+
userConnectionCheckInterval = null;
|
228
|
+
console.log("Stopped user connection monitoring");
|
229
|
+
}
|
230
|
+
}
|
231
|
+
function checkAndRenderAllVideos() {
|
232
|
+
console.log("Checking and rendering all videos...");
|
233
|
+
cleanupInvalidUsers();
|
234
|
+
const currentUsers = remoteUsers.value.filter((user) => user.hasVideo);
|
235
|
+
console.log("Current users with video:", currentUsers.map((u) => u.id));
|
236
|
+
currentUsers.forEach((user) => {
|
237
|
+
const videoElement = videoRefs.value.get(user.id);
|
238
|
+
if (videoElement) {
|
239
|
+
const hasExistingVideo = videoElement.querySelector("video");
|
240
|
+
console.log(`User ${user.id}: hasVideo=${user.hasVideo}, hasElement=${!!videoElement}, hasExistingVideo=${!!hasExistingVideo}`);
|
241
|
+
if (user.hasVideo && !hasExistingVideo) {
|
242
|
+
console.log(`Attempting to render video for user: ${user.id}`);
|
243
|
+
tryRenderRemoteVideo(user.id);
|
244
|
+
}
|
245
|
+
} else {
|
246
|
+
console.log(`No video element found for user: ${user.id}`);
|
247
|
+
}
|
248
|
+
});
|
249
|
+
}
|
250
|
+
async function forceRenderAllVideos() {
|
251
|
+
var _a;
|
252
|
+
console.log("Force rendering all available videos...");
|
253
|
+
const usersWithVideo = remoteUsers.value.filter((user) => user.hasVideo);
|
254
|
+
console.log("Users with video to force render:", usersWithVideo.map((u) => u.id));
|
255
|
+
for (const user of usersWithVideo) {
|
256
|
+
const videoElement = videoRefs.value.get(user.id);
|
257
|
+
if (videoElement && user.hasVideo) {
|
258
|
+
try {
|
259
|
+
const existingVideo = videoElement.querySelector("video");
|
260
|
+
if (existingVideo) {
|
261
|
+
existingVideo.remove();
|
262
|
+
}
|
263
|
+
await trtc.startRemoteVideo({
|
264
|
+
userId: user.id,
|
265
|
+
streamType: MAIN_STREAM_TYPE,
|
266
|
+
view: videoElement
|
267
|
+
});
|
268
|
+
console.log(`Force rendered video for user: ${user.id}`);
|
269
|
+
} catch (error) {
|
270
|
+
console.error(`Failed to force render video for user ${user.id}:`, error);
|
271
|
+
if (error.code === "INVALID_OPERATION" && ((_a = error.message) == null ? void 0 : _a.includes("does not publishing stream"))) {
|
272
|
+
console.log("User not publishing stream, updating status:", user.id);
|
273
|
+
addOrUpdateUser(user.id, {
|
274
|
+
hasVideo: false
|
275
|
+
});
|
276
|
+
}
|
277
|
+
}
|
278
|
+
}
|
279
|
+
}
|
280
|
+
}
|
281
|
+
function cleanupAllResources() {
|
282
|
+
retryTimers.value.forEach((timer) => clearTimeout(timer));
|
283
|
+
retryTimers.value.clear();
|
284
|
+
retryCount.value.clear();
|
285
|
+
videoRefs.value.clear();
|
286
|
+
remoteUsers.value = [];
|
287
|
+
isConnect.value = false;
|
98
288
|
resetTimer();
|
289
|
+
stopUserConnectionMonitoring();
|
290
|
+
}
|
291
|
+
async function toggleAudio() {
|
292
|
+
try {
|
293
|
+
await trtc.updateLocalAudio({
|
294
|
+
mute: !voiceClose.value
|
295
|
+
});
|
296
|
+
voiceClose.value = !voiceClose.value;
|
297
|
+
} catch (error) {
|
298
|
+
console.error("Error toggling audio:", error);
|
299
|
+
$message.error("\u5207\u6362\u97F3\u9891\u5931\u8D25");
|
300
|
+
}
|
301
|
+
}
|
302
|
+
async function toggleVideo() {
|
303
|
+
try {
|
304
|
+
await trtc.updateLocalVideo({
|
305
|
+
mute: !videocamClose.value
|
306
|
+
});
|
307
|
+
videocamClose.value = !videocamClose.value;
|
308
|
+
} catch (error) {
|
309
|
+
console.error("Error toggling video:", error);
|
310
|
+
$message.error("\u5207\u6362\u89C6\u9891\u5931\u8D25");
|
311
|
+
}
|
312
|
+
}
|
313
|
+
async function enterRoom() {
|
314
|
+
if (isConnect.value) {
|
315
|
+
console.log("Already connected");
|
316
|
+
return true;
|
317
|
+
}
|
318
|
+
const isSupported = await checkTRTCSupport();
|
319
|
+
if (!isSupported) {
|
320
|
+
return false;
|
321
|
+
}
|
322
|
+
try {
|
323
|
+
console.log("Entering TRTC room...");
|
324
|
+
await trtc.enterRoom({
|
325
|
+
strRoomId: state.currentAVMsg.strRoomId,
|
326
|
+
sdkAppId: parseInt(state.userInfo.sdkAppID),
|
327
|
+
userId: state.userInfo.id,
|
328
|
+
userSig: state.userInfo.userSig,
|
329
|
+
proxy: trtcProxy.value
|
330
|
+
});
|
331
|
+
isConnect.value = true;
|
332
|
+
console.log("Successfully entered TRTC room");
|
333
|
+
startUserConnectionMonitoring();
|
334
|
+
return true;
|
335
|
+
} catch (error) {
|
336
|
+
console.error("Failed to enter TRTC room:", error);
|
337
|
+
$message.error(`\u8FDB\u5165\u623F\u95F4\u5931\u8D25: ${error.message || "\u672A\u77E5\u9519\u8BEF"}`);
|
338
|
+
isConnect.value = false;
|
339
|
+
return false;
|
340
|
+
}
|
341
|
+
}
|
342
|
+
async function exitRoom() {
|
343
|
+
try {
|
344
|
+
console.log("Exiting TRTC room...");
|
345
|
+
const stopPromises = [];
|
346
|
+
stopPromises.push(trtc.stopLocalAudio().catch((error) => {
|
347
|
+
console.warn("Error stopping local audio:", error);
|
348
|
+
}));
|
349
|
+
if (!isAudio.value) {
|
350
|
+
stopPromises.push(trtc.stopLocalVideo().catch((error) => {
|
351
|
+
console.warn("Error stopping local video:", error);
|
352
|
+
}));
|
353
|
+
}
|
354
|
+
await Promise.allSettled(stopPromises);
|
355
|
+
if (isConnect.value) {
|
356
|
+
await trtc.exitRoom().catch((error) => {
|
357
|
+
console.warn("Error exiting room:", error);
|
358
|
+
});
|
359
|
+
}
|
360
|
+
cleanupAllResources();
|
361
|
+
console.log("Successfully exited TRTC room");
|
362
|
+
} catch (error) {
|
363
|
+
console.error("Error during exit:", error);
|
364
|
+
}
|
365
|
+
}
|
366
|
+
async function startLocalMedia(selfVideoRef) {
|
367
|
+
try {
|
368
|
+
await trtc.startLocalAudio({
|
369
|
+
mute: voiceClose.value
|
370
|
+
});
|
371
|
+
if (!isAudio.value && selfVideoRef) {
|
372
|
+
await trtc.startLocalVideo({
|
373
|
+
view: selfVideoRef,
|
374
|
+
mute: videocamClose.value
|
375
|
+
});
|
376
|
+
}
|
377
|
+
} catch (error) {
|
378
|
+
console.error("Error starting local media:", error);
|
379
|
+
throw error;
|
380
|
+
}
|
381
|
+
}
|
382
|
+
function installEventHandlers(handlers) {
|
383
|
+
console.log("Installing TRTC event handlers...");
|
384
|
+
const wrappedHandlers = {
|
385
|
+
handleError: (error) => {
|
386
|
+
console.log("TRTC EVENT: ERROR", error);
|
387
|
+
handlers.handleError(error);
|
388
|
+
},
|
389
|
+
handleRemoteUserEnter: (event) => {
|
390
|
+
console.log("TRTC EVENT: REMOTE_USER_ENTER", event);
|
391
|
+
handlers.handleRemoteUserEnter(event);
|
392
|
+
},
|
393
|
+
handleRemoteAudioAvailable: (event) => {
|
394
|
+
console.log("TRTC EVENT: REMOTE_AUDIO_AVAILABLE", event);
|
395
|
+
handlers.handleRemoteAudioAvailable(event);
|
396
|
+
},
|
397
|
+
handleRemoteUserExit: (event) => {
|
398
|
+
console.log("TRTC EVENT: REMOTE_USER_EXIT", event);
|
399
|
+
handlers.handleRemoteUserExit(event);
|
400
|
+
},
|
401
|
+
handleRemoteVideoAvailable: (event) => {
|
402
|
+
console.log("TRTC EVENT: REMOTE_VIDEO_AVAILABLE", event);
|
403
|
+
handlers.handleRemoteVideoAvailable(event);
|
404
|
+
},
|
405
|
+
handleRemoteVideoUnavailable: (event) => {
|
406
|
+
console.log("TRTC EVENT: REMOTE_VIDEO_UNAVAILABLE", event);
|
407
|
+
if (handlers.handleRemoteVideoUnavailable) {
|
408
|
+
handlers.handleRemoteVideoUnavailable(event);
|
409
|
+
}
|
410
|
+
}
|
411
|
+
};
|
412
|
+
trtc.on(TRTC.EVENT.ERROR, wrappedHandlers.handleError);
|
413
|
+
trtc.on(TRTC.EVENT.REMOTE_USER_ENTER, wrappedHandlers.handleRemoteUserEnter);
|
414
|
+
trtc.on(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, wrappedHandlers.handleRemoteAudioAvailable);
|
415
|
+
trtc.on(TRTC.EVENT.REMOTE_USER_EXIT, wrappedHandlers.handleRemoteUserExit);
|
416
|
+
if (!isAudio.value) {
|
417
|
+
trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, wrappedHandlers.handleRemoteVideoAvailable);
|
418
|
+
trtc.on(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, wrappedHandlers.handleRemoteVideoUnavailable);
|
419
|
+
console.log("REMOTE_VIDEO_UNAVAILABLE event listener added");
|
420
|
+
}
|
421
|
+
}
|
422
|
+
function uninstallEventHandlers(handlers) {
|
423
|
+
trtc.off(TRTC.EVENT.ERROR, handlers.handleError);
|
424
|
+
trtc.off(TRTC.EVENT.REMOTE_USER_ENTER, handlers.handleRemoteUserEnter);
|
425
|
+
trtc.off(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, handlers.handleRemoteAudioAvailable);
|
426
|
+
trtc.off(TRTC.EVENT.REMOTE_USER_EXIT, handlers.handleRemoteUserExit);
|
427
|
+
if (!isAudio.value) {
|
428
|
+
trtc.off(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, handlers.handleRemoteVideoAvailable);
|
429
|
+
trtc.off(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, handlers.handleRemoteVideoUnavailable || handlers.handleRemoteVideoAvailable);
|
430
|
+
}
|
431
|
+
}
|
432
|
+
function setVideoRef(userId, el) {
|
433
|
+
if (el) {
|
434
|
+
videoRefs.value.set(userId, el);
|
435
|
+
console.log("Video ref set for user:", userId, "Element:", el);
|
436
|
+
if (isConnect.value) {
|
437
|
+
const user = findUser(userId);
|
438
|
+
console.log("User found:", user);
|
439
|
+
if (user == null ? void 0 : user.hasVideo) {
|
440
|
+
console.log("User has video, attempting to render");
|
441
|
+
nextTick(() => {
|
442
|
+
tryRenderRemoteVideo(userId);
|
443
|
+
});
|
444
|
+
} else {
|
445
|
+
console.log("User has no video stream yet, will render when available");
|
446
|
+
}
|
447
|
+
}
|
448
|
+
} else {
|
449
|
+
videoRefs.value.delete(userId);
|
450
|
+
clearRetryTimer(userId);
|
451
|
+
console.log("Video ref removed for user:", userId);
|
452
|
+
}
|
453
|
+
}
|
454
|
+
onBeforeUnmount(() => {
|
455
|
+
cleanupAllResources();
|
99
456
|
});
|
100
457
|
return {
|
101
458
|
state,
|
@@ -105,16 +462,37 @@ function useVideo() {
|
|
105
462
|
timing,
|
106
463
|
voiceClose,
|
107
464
|
videocamClose,
|
465
|
+
isConnect,
|
108
466
|
isAudio,
|
109
467
|
isCall,
|
468
|
+
messageTypeText,
|
469
|
+
time,
|
470
|
+
remoteUsers,
|
471
|
+
videoRefs,
|
110
472
|
startTimer,
|
111
473
|
resetTimer,
|
112
474
|
toggleAudio,
|
113
475
|
toggleVideo,
|
114
|
-
|
115
|
-
|
476
|
+
enterRoom,
|
477
|
+
exitRoom,
|
478
|
+
startLocalMedia,
|
479
|
+
checkTRTCSupport,
|
480
|
+
findUser,
|
481
|
+
addOrUpdateUser,
|
482
|
+
removeUser,
|
483
|
+
tryRenderRemoteVideo,
|
484
|
+
stopRemoteVideo,
|
485
|
+
setVideoRef,
|
116
486
|
installEventHandlers,
|
117
|
-
uninstallEventHandlers
|
487
|
+
uninstallEventHandlers,
|
488
|
+
cleanupAllResources,
|
489
|
+
checkAndRenderAllVideos,
|
490
|
+
forceRenderAllVideos,
|
491
|
+
cleanupInvalidUsers,
|
492
|
+
isUserValid,
|
493
|
+
startUserConnectionMonitoring,
|
494
|
+
stopUserConnectionMonitoring,
|
495
|
+
MAIN_STREAM_TYPE
|
118
496
|
};
|
119
497
|
}
|
120
498
|
|
@@ -22,3 +22,4 @@ export declare function getDetail(item: AnyObject, isShowSize?: boolean): string
|
|
22
22
|
export declare function showAudioAndVideoRecord(chatMessageType: string): "语音通话" | "视频通话";
|
23
23
|
export declare function formatJsonstr(obj: AnyObject | string, type: string): any;
|
24
24
|
export declare function removeImgBySrc(htmlString: string, targetSrc: string): string;
|
25
|
+
export declare function ensureLeadingSlashIfRelative(str?: string): string;
|
@@ -308,5 +308,11 @@ function removeImgBySrc(htmlString, targetSrc) {
|
|
308
308
|
function escapeRegExp(str) {
|
309
309
|
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
310
310
|
}
|
311
|
+
function ensureLeadingSlashIfRelative(str = "") {
|
312
|
+
if (!/^[a-z]+:\/\//i.test(str) && !str.startsWith("/")) {
|
313
|
+
return "/" + str;
|
314
|
+
}
|
315
|
+
return str;
|
316
|
+
}
|
311
317
|
|
312
|
-
export { $message, base64ToFile, downloadFile, formatJsonstr, formatSeconds, formatTime, getAVTime, getDetail, getFileType, getForwardTitle, getRoleName, isAudioOrVideoMessage, isDoctorRole, isGroup, listSort, removeImgBySrc, showAudioAndVideoRecord, simplifyMessage, transformMessage };
|
318
|
+
export { $message, base64ToFile, downloadFile, ensureLeadingSlashIfRelative, formatJsonstr, formatSeconds, formatTime, getAVTime, getDetail, getFileType, getForwardTitle, getRoleName, isAudioOrVideoMessage, isDoctorRole, isGroup, listSort, removeImgBySrc, showAudioAndVideoRecord, simplifyMessage, transformMessage };
|