|
|
@@ -2449,6 +2449,33 @@ const checkIsCreator = () => {
|
|
|
* 初始化消息监听
|
|
|
*/
|
|
|
const messageInit = () => {
|
|
|
+ // 如果是创建者,清空所有同步状态
|
|
|
+ if (isCreator.value && docSocket.value) {
|
|
|
+ console.log('🧹 创建者进入,清空所有同步状态')
|
|
|
+ docSocket.value.transact(() => {
|
|
|
+ // 清空消息
|
|
|
+ const messageArray = docSocket.value?.getArray?.('message')
|
|
|
+ if (messageArray) {
|
|
|
+ messageArray.delete(0, messageArray.length)
|
|
|
+ }
|
|
|
+ // 清空计时器状态
|
|
|
+ const timerStateMap = docSocket.value?.getMap?.('timerState')
|
|
|
+ if (timerStateMap) {
|
|
|
+ timerStateMap.clear()
|
|
|
+ }
|
|
|
+ // 清空激光笔状态
|
|
|
+ const laserStateMap = docSocket.value?.getMap?.('laserState')
|
|
|
+ if (laserStateMap) {
|
|
|
+ laserStateMap.clear()
|
|
|
+ }
|
|
|
+ // 清空画图状态
|
|
|
+ const writingBoardStateMap = docSocket.value?.getMap?.('writingBoardState')
|
|
|
+ if (writingBoardStateMap) {
|
|
|
+ writingBoardStateMap.clear()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
if (docSocket.value && !yMessage.value) {
|
|
|
console.log('获取message', docSocket.value, yMessage.value)
|
|
|
yMessage.value = docSocket.value.getArray('message')
|