yuang-framework-ui-common 1.0.120 → 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 {
@@ -256,6 +258,7 @@ import { application } from '../../../lib/config/applicationConfig';
256
258
  export interface UseSseResult {
257
259
  sseClientId: Ref<string>;
258
260
  sseMessageList: Ref<Object[]>;
261
+ sseMessage: Ref<Object>;
259
262
  isSseConnected: Ref<boolean>;
260
263
  connectSse: (options?: FrameworkSseClientOptions) => void;
261
264
  disconnectSse: () => void;
@@ -277,6 +280,7 @@ export function useSse(
277
280
  // 🔥 核心修复2:初始化时读取模块专属的 sseClientId
278
281
  const sseClientId = ref<string>(getLocalStorageItem(getSseClientIdKey(moduleCode)) || '');
279
282
  const sseMessageList = ref<Object[]>([]);
283
+ const sseMessage = ref<Object>({});
280
284
  const isSseConnected = ref<boolean>(false);
281
285
  let sseClient: FrameworkSseClient | null = null;
282
286
 
@@ -286,6 +290,7 @@ export function useSse(
286
290
  // 业务消息才加入列表,避免 clientId 事件混入
287
291
  if (event?.type !== 'sseClientId') {
288
292
  sseMessageList.value.push(data);
293
+ sseMessage.value = data;
289
294
  }
290
295
  };
291
296
 
@@ -304,7 +309,9 @@ export function useSse(
304
309
 
305
310
  // 🔥 核心修复3:clientId 更新回调(即时同步响应式变量)
306
311
  const onSseClientIdUpdate = (clientId: string) => {
307
- console.log(`[SSE Hook] [${moduleCode}] 同步 sseClientId:`, clientId);
312
+ if(getIsDebug()) {
313
+ console.log(`[SSE Hook] [${moduleCode}] 同步 sseClientId:`, clientId);
314
+ }
308
315
  sseClientId.value = clientId; // 即时更新响应式变量
309
316
  };
310
317
 
@@ -431,6 +438,7 @@ export function useSse(
431
438
  return {
432
439
  sseClientId,
433
440
  sseMessageList,
441
+ sseMessage,
434
442
  isSseConnected,
435
443
  connectSse,
436
444
  disconnectSse,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-common",
3
- "version": "1.0.120",
3
+ "version": "1.0.122",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,7 @@ import { ElMessage } from 'element-plus/es';
13
13
 
14
14
  const sendRequest = () => {
15
15
  // 测试
16
- http.get("/framework-api/core/framework-captcha/getSliderCaptcha", { params: {} }).then((res) => {
16
+ http.post("/framework-api/core/framework-captcha/createSliderCaptcha", { }).then((res) => {
17
17
  ElMessage.success('发送成功');
18
18
  });
19
19
  }