yuang-framework-ui-common 1.0.70 → 1.0.72
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.
- package/lib/hooks/framework/frameworkGroup.ts +1 -59
- package/lib/hooks/framework/frameworkSseClient.ts +8 -0
- package/lib/interface/component/componentParam.ts +15 -0
- package/lib/interface/sso/ssoUserTrace.ts +38 -0
- package/package.json +1 -1
- package/src/router/index.ts +1 -1
- package/src/views/hooks/framework/framework-sse-client.vue +51 -23
@@ -1,61 +1,3 @@
|
|
1
|
-
import { http } from '../../../lib/config/httpConfig';
|
2
|
-
import { application } from '../../../lib/config/applicationConfig';
|
3
1
|
|
4
|
-
import { getShortUuid } from '../../../lib/utils/uuidUtils';
|
5
2
|
|
6
|
-
|
7
|
-
return new Promise((resolve) => {
|
8
|
-
// prettier-ignore
|
9
|
-
http.post(`${application.gatewayServerBaseUrl}/uims-api/core/framework-group/selectPage`, { codeForEqual: frameworkGroupCode }).then((res) => {
|
10
|
-
if (res.data.data.records.length == 0) {
|
11
|
-
const formData = {
|
12
|
-
id: '',
|
13
|
-
name: '全部分组',
|
14
|
-
code: frameworkGroupCode,
|
15
|
-
parentId: ''
|
16
|
-
};
|
17
|
-
http
|
18
|
-
.post('/uims-api/core/framework-group/insertInfo', formData)
|
19
|
-
.then((res) => {
|
20
|
-
formData.id = res.data.data.id;
|
21
|
-
resolve(formData);
|
22
|
-
})
|
23
|
-
.catch(() => {
|
24
|
-
//
|
25
|
-
});
|
26
|
-
} else {
|
27
|
-
resolve(res.data.data.records[0]);
|
28
|
-
}
|
29
|
-
}).catch(() => {
|
30
|
-
//
|
31
|
-
});
|
32
|
-
});
|
33
|
-
};
|
34
|
-
|
35
|
-
const saveFrameworkGroup = ({ isAddForm, editForm }) => {
|
36
|
-
return new Promise((resolve, reject) => {
|
37
|
-
editForm.code = editForm.code || getShortUuid();
|
38
|
-
// prettier-ignore
|
39
|
-
http.post(`/uims-api/core/framework-group/${isAddForm ? 'insertInfo' : 'updateInfo'}`, editForm).then((res) => {
|
40
|
-
if (!editForm.id) {
|
41
|
-
editForm.id = res.data.data.id;
|
42
|
-
}
|
43
|
-
resolve({ group: editForm });
|
44
|
-
}).catch(() => {
|
45
|
-
reject();
|
46
|
-
});
|
47
|
-
});
|
48
|
-
};
|
49
|
-
const deleteFrameworkGroup = ({ editForm }) => {
|
50
|
-
return new Promise((resolve, reject) => {
|
51
|
-
// prettier-ignore
|
52
|
-
http.get(`/uims-api/core/framework-group/deleteInfo`, { params: { id: editForm.id } }).then((res) => {
|
53
|
-
res;
|
54
|
-
resolve({ group: editForm });
|
55
|
-
}).catch(() => {
|
56
|
-
reject();
|
57
|
-
});
|
58
|
-
});
|
59
|
-
};
|
60
|
-
|
61
|
-
export { initFrameworkGroup, saveFrameworkGroup, deleteFrameworkGroup };
|
3
|
+
export { };
|
@@ -51,6 +51,14 @@ export class FrameworkSseClient {
|
|
51
51
|
try {
|
52
52
|
this.eventSource = new EventSource(this.url);
|
53
53
|
|
54
|
+
// 监听服务端发送的 clientId 事件
|
55
|
+
this.eventSource.addEventListener('clientId', (event) => {
|
56
|
+
const clientId = event.data;
|
57
|
+
console.log('My clientId:', clientId);
|
58
|
+
// 保存到 localStorage 或内存中,用于后续业务请求
|
59
|
+
localStorage.setItem('sseClientId', clientId);
|
60
|
+
});
|
61
|
+
|
54
62
|
// 处理消息事件
|
55
63
|
this.eventSource.onmessage = (event) => {
|
56
64
|
this.messageHandler(event.data, event);
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import type { FrameworkBase, FrameworkBaseQueryParam } from '../framework/frameworkBase';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* sso用户踪迹
|
5
|
+
*/
|
6
|
+
export interface SsoUserTrace extends FrameworkBase {
|
7
|
+
account?: string;
|
8
|
+
status?: number;
|
9
|
+
|
10
|
+
loginTime?: Date;
|
11
|
+
logoutTime?: Date;
|
12
|
+
|
13
|
+
authCode?: string;
|
14
|
+
authCodeCreateTime?: Date;
|
15
|
+
authCodeExpireTime?: Date;
|
16
|
+
|
17
|
+
accessToken?: string;
|
18
|
+
accessTokenCreateTime?: Date;
|
19
|
+
accessTokenExpireTime?: Date;
|
20
|
+
|
21
|
+
|
22
|
+
refreshToken?: string;
|
23
|
+
refreshTokenCreateTime?: Date;
|
24
|
+
refreshTokenExpireTime?: Date;
|
25
|
+
|
26
|
+
tgt?: string;
|
27
|
+
tgtCreateTime?: Date;
|
28
|
+
tgtExpireTime?: Date;
|
29
|
+
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* sso用户踪迹搜索条件
|
34
|
+
*/
|
35
|
+
export interface SsoUserTraceQueryParam extends FrameworkBaseQueryParam {
|
36
|
+
accountForLike?: string;
|
37
|
+
statusForEqual?: string;
|
38
|
+
}
|
package/package.json
CHANGED
package/src/router/index.ts
CHANGED
@@ -1,41 +1,69 @@
|
|
1
1
|
<template>
|
2
|
-
<div
|
2
|
+
<div>
|
3
|
+
|
4
|
+
<el-button @click="connect">连接</el-button>
|
5
|
+
<el-button @click="sendMessage">发送消息</el-button>
|
6
|
+
接收到的消息:
|
7
|
+
<div id="messageContainer"></div>
|
8
|
+
</div>
|
3
9
|
</template>
|
4
10
|
|
5
11
|
<script setup lang="ts">
|
6
12
|
import { onMounted, ref } from 'vue';
|
13
|
+
import { ElMessage } from 'element-plus'
|
7
14
|
import { FrameworkSseClient } from '../../../../lib/hooks/framework/frameworkSseClient';
|
15
|
+
import { http } from '../../../../lib/config/httpConfig';
|
8
16
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
+
}
|
27
36
|
},
|
28
|
-
|
29
|
-
|
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
|
+
}
|
30
48
|
}
|
31
|
-
|
32
|
-
|
49
|
+
);
|
50
|
+
}
|
51
|
+
|
33
52
|
|
34
53
|
// 页面关闭时手动关闭连接
|
35
54
|
window.addEventListener('beforeunload', () => {
|
36
55
|
frameworkSseClient.close();
|
37
56
|
});
|
38
57
|
|
58
|
+
const sendMessage = ()=>{
|
59
|
+
http.post(`/framework-api/standard/framework-sse/sendMessage`, {
|
60
|
+
clientId: clientId,
|
61
|
+
message: "测试"
|
62
|
+
}).then((res) => {
|
63
|
+
|
64
|
+
});
|
65
|
+
}
|
66
|
+
|
39
67
|
</script>
|
40
68
|
|
41
69
|
<style scoped>
|