yuang-framework-ui-common 1.0.121 → 1.0.122
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getLocalStorageItem, setLocalStorageItem } from "../../utils/storageUtils";
|
|
2
|
+
import { getIsDebug } from '../../utils/htmlUtils';
|
|
2
3
|
|
|
3
4
|
// 🔥 1. 优化常量:支持模块隔离的存储键
|
|
4
5
|
export const getSseClientIdKey = (moduleCode?: string) => {
|
|
@@ -138,11 +139,11 @@ export class FrameworkSseClient {
|
|
|
138
139
|
// 兼容非标准消息格式
|
|
139
140
|
if (!cleanMessage.startsWith('data:') && !cleanMessage.startsWith('event:')) {
|
|
140
141
|
console.log('[SSE] 兼容非标准消息格式:', cleanMessage);
|
|
141
|
-
const
|
|
142
|
+
const messageEvent = {
|
|
142
143
|
data: cleanMessage,
|
|
143
144
|
type: 'message'
|
|
144
145
|
} as MessageEvent;
|
|
145
|
-
this.messageHandler(cleanMessage,
|
|
146
|
+
this.messageHandler(cleanMessage, messageEvent);
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
149
|
|
|
@@ -178,16 +179,17 @@ export class FrameworkSseClient {
|
|
|
178
179
|
return;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
182
|
+
if (eventType === 'sseMessage') {
|
|
183
|
+
// 生成标准 MessageEvent
|
|
184
|
+
const messageEvent = new MessageEvent(eventType, {
|
|
185
|
+
data,
|
|
186
|
+
lastEventId: messageId,
|
|
187
|
+
origin: new URL(this.url).origin,
|
|
188
|
+
source: null,
|
|
189
|
+
ports: []
|
|
190
|
+
});
|
|
191
|
+
this.messageHandler(data, messageEvent);
|
|
192
|
+
}
|
|
191
193
|
}
|
|
192
194
|
|
|
193
195
|
private handleReconnectSse(): void {
|
|
@@ -307,7 +309,9 @@ export function useSse(
|
|
|
307
309
|
|
|
308
310
|
// 🔥 核心修复3:clientId 更新回调(即时同步响应式变量)
|
|
309
311
|
const onSseClientIdUpdate = (clientId: string) => {
|
|
310
|
-
|
|
312
|
+
if(getIsDebug()) {
|
|
313
|
+
console.log(`[SSE Hook] [${moduleCode}] 同步 sseClientId:`, clientId);
|
|
314
|
+
}
|
|
311
315
|
sseClientId.value = clientId; // 即时更新响应式变量
|
|
312
316
|
};
|
|
313
317
|
|