|
|
@@ -4050,6 +4050,34 @@ onMounted(() => {
|
|
|
forceLogout,
|
|
|
forceLogout2,
|
|
|
setCan,
|
|
|
+ // Yjs 诊断函数:控制台调用 PPTistStudent.diagnoseYjs()
|
|
|
+ diagnoseYjs: () => {
|
|
|
+ const doc = docSocket.value
|
|
|
+ if (!doc) {
|
|
|
+ console.log('════════ Yjs 诊断 ════════\ndocSocket.value 为 null')
|
|
|
+ return null
|
|
|
+ }
|
|
|
+ const ymap = doc.getMap('message')
|
|
|
+ const msgType = doc.share.get('message')
|
|
|
+ const report = {
|
|
|
+ '1. doc.guid': doc.guid,
|
|
|
+ '2. yMessage.value === doc.getMap("message")': yMessage.value === ymap,
|
|
|
+ '3. yMessage.value?.doc?.guid': yMessage.value?.doc?.guid,
|
|
|
+ '4. doc.store.clients.size': doc.store.clients.size,
|
|
|
+ '5. doc.share.get("message") 类型': msgType?.constructor?.name,
|
|
|
+ '6. doc.getMap("message").size': ymap.size,
|
|
|
+ '7. doc.getMap("message").get("latest")': ymap.get('latest'),
|
|
|
+ '8. yMessage.value?.get("latest")': yMessage.value?.get('latest'),
|
|
|
+ '9. doc 里所有顶层 key': Array.from(doc.share.entries()).map(([k, v]: [string, any]) => k + ':' + v.constructor.name),
|
|
|
+ '10. provider synced': providerSocket.value?.synced,
|
|
|
+ '11. ws.readyState': providerSocket.value?.ws?.readyState,
|
|
|
+ }
|
|
|
+ console.log('════════ Yjs 诊断 ════════')
|
|
|
+ for (const [k, v] of Object.entries(report)) {
|
|
|
+ console.log(k + ':', typeof v === 'object' ? JSON.stringify(v) : v)
|
|
|
+ }
|
|
|
+ return report
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
console.log('PPTist Student View 已加载,可通过 window.PPTistStudent 访问功能')
|
|
|
@@ -4356,6 +4384,9 @@ const createWebSocketConnection = async (type = 1) => {
|
|
|
if (docSocket.value) {
|
|
|
initializeYjsData()
|
|
|
}
|
|
|
+ if(type == 1){
|
|
|
+ createWebSocketConnection(2)
|
|
|
+ }
|
|
|
}
|
|
|
else if (event.status === 'disconnected') {
|
|
|
console.log('👉 连接断开,等待自动重连...')
|
|
|
@@ -4419,6 +4450,9 @@ const createWebSocketConnection = async (type = 1) => {
|
|
|
if (props.type === '2') {
|
|
|
sendMessage({ type: 'class_begin', courseid: props.courseid })
|
|
|
}
|
|
|
+
|
|
|
+ // 自动运行 Yjs 诊断
|
|
|
+ ;(window as any).PPTistStudent?.diagnoseYjs?.()
|
|
|
})
|
|
|
// 监听连接错误
|
|
|
// providerSocket.value.on('connection-error', (error: any) => {
|