yuang-framework-ui-common 1.0.71 → 1.0.73

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.
@@ -0,0 +1,15 @@
1
+ export interface ComponentParam {
2
+ /** id */
3
+ id?: string;
4
+ /** 类型 */
5
+ type?: string;
6
+
7
+ mode?: string;
8
+ }
9
+
10
+
11
+ export interface FrameworkAttachmentComponentParam extends ComponentParam {
12
+
13
+ maxCount?: number;
14
+ maxSize?: number;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuang-framework-ui-common",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -60,7 +60,7 @@ const router = createRouter({
60
60
  path: '/hooks/framework/framework-sse-client',
61
61
  component: () => import('@/views/hooks/framework/framework-sse-client.vue'),
62
62
  meta: {
63
- isSsoExcluded: true
63
+ isSsoExcluded: false
64
64
  }
65
65
  },
66
66
 
@@ -1,42 +1,54 @@
1
1
  <template>
2
2
  <div>
3
3
 
4
- <div id="messageContainer"></div>
4
+ <el-button @click="connect">连接</el-button>
5
5
  <el-button @click="sendMessage">发送消息</el-button>
6
+ 接收到的消息:
7
+ <div id="messageContainer"></div>
6
8
  </div>
7
9
  </template>
8
10
 
9
11
  <script setup lang="ts">
10
12
  import { onMounted, ref } from 'vue';
13
+ import { ElMessage } from 'element-plus'
11
14
  import { FrameworkSseClient } from '../../../../lib/hooks/framework/frameworkSseClient';
12
15
  import { http } from '../../../../lib/config/httpConfig';
13
16
 
14
- // 初始化 SSE 客户端
15
- const frameworkSseClient = new FrameworkSseClient (
16
- '/framework-api/standard/framework-sse/connect',
17
- (data) => {
18
- debugger
19
- console.log('data', data);
20
- // 处理接收到的消息
21
- const container = document.getElementById('messageContainer');
22
- if (container) {
23
- const messageDiv = document.createElement('div');
24
- messageDiv.className = 'message';
25
- messageDiv.textContent = `[${new Date().toLocaleTimeString()}] ${data}`;
26
- container.appendChild(messageDiv);
27
- }
28
- },
29
- {
30
- reconnectInterval: 5000, // 重连间隔 5 秒
31
- maxReconnectAttempts: 15, // 最大重连 15 次
32
- openHandler: () => {
33
- console.log('SSE 连接成功回调');
17
+ let frameworkSseClient = null;
18
+
19
+ let clientId = '';
20
+ let connect = () => {
21
+ // 初始化 SSE 客户端
22
+ frameworkSseClient = new FrameworkSseClient (
23
+ '/framework-api/standard/framework-sse/connect',
24
+ (data) => {
25
+
26
+ console.log('data', data);
27
+ clientId = localStorage.getItem('sseClientId');
28
+ // 处理接收到的消息
29
+ const container = document.getElementById('messageContainer');
30
+ if (container) {
31
+ const messageDiv = document.createElement('div');
32
+ messageDiv.className = 'message';
33
+ messageDiv.textContent = `[${new Date().toLocaleTimeString()}] ${data}`;
34
+ container.appendChild(messageDiv);
35
+ }
34
36
  },
35
- errorHandler: (error) => {
36
- console.error('自定义错误处理:', error);
37
+ {
38
+ reconnectInterval: 5000, // 重连间隔 5 秒
39
+ maxReconnectAttempts: 15, // 最大重连 15 次
40
+ openHandler: () => {
41
+ console.log('SSE 连接成功回调');
42
+ ElMessage.success('连接成功');
43
+ },
44
+ errorHandler: (error) => {
45
+ console.error('自定义错误处理:', error);
46
+ ElMessage.success('出错了');
47
+ }
37
48
  }
38
- }
39
- );
49
+ );
50
+ }
51
+
40
52
 
41
53
  // 页面关闭时手动关闭连接
42
54
  window.addEventListener('beforeunload', () => {
@@ -44,7 +56,10 @@ window.addEventListener('beforeunload', () => {
44
56
  });
45
57
 
46
58
  const sendMessage = ()=>{
47
- http.post(`/framework-api/standard/framework-sse/send/3220bfd9-050e-435d-88d7-77b4a1dbf7cf`, { message: "测试" }).then((res) => {
59
+ http.post(`/framework-api/standard/framework-sse/sendMessage`, {
60
+ clientId: clientId,
61
+ message: "测试"
62
+ }).then((res) => {
48
63
 
49
64
  });
50
65
  }