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 mockEvent = {
142
+ const messageEvent = {
142
143
  data: cleanMessage,
143
144
  type: 'message'
144
145
  } as MessageEvent;
145
- this.messageHandler(cleanMessage, mockEvent);
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
- // 生成标准 MessageEvent
182
- const mockEvent = new MessageEvent(eventType, {
183
- data,
184
- lastEventId: messageId,
185
- origin: new URL(this.url).origin,
186
- source: null,
187
- ports: []
188
- });
189
-
190
- this.messageHandler(data, mockEvent);
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
- console.log(`[SSE Hook] [${moduleCode}] 同步 sseClientId:`, clientId);
312
+ if(getIsDebug()) {
313
+ console.log(`[SSE Hook] [${moduleCode}] 同步 sseClientId:`, clientId);
314
+ }
311
315
  sseClientId.value = clientId; // 即时更新响应式变量
312
316
  };
313
317
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-common",
3
- "version": "1.0.121",
3
+ "version": "1.0.122",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {