1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
| <script setup lang="ts">
| import { Page, useVbenModal } from '@vben/common-ui';
|
| import { Space } from 'ant-design-vue';
|
| import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
|
| import { sseList } from './api';
| import sendMsgModal from './send-msg-modal.vue';
|
| const gridOptions: VxeGridProps = {
| columns: [
| {
| title: '用户ID',
| field: 'userId',
| },
| {
| title: '用户账号',
| field: 'userName',
| },
| {
| title: '用户昵称',
| field: 'nickName',
| },
| {
| title: '用户部门',
| field: 'deptName',
| },
| {
| field: 'action',
| fixed: 'right',
| slots: { default: 'action' },
| title: '操作',
| width: 180,
| },
| ],
| height: 'auto',
| keepSource: true,
| pagerConfig: {},
| proxyConfig: {
| ajax: {
| query: async () => {
| const list = await sseList();
| return {
| rows: list,
| };
| },
| },
| },
| rowConfig: {
| isHover: false,
| keyField: 'userId',
| height: 48,
| },
| id: 'sse-index',
| };
|
| const [BasicTable] = useVbenVxeGrid({
| gridOptions,
| });
|
| const [SendMsgModal, modalApi] = useVbenModal({
| connectedComponent: sendMsgModal,
| });
|
| function handleSendAll() {
| modalApi.setData({});
| modalApi.open();
| }
|
| function handleSendSingle(userId: string) {
| modalApi.setData({ userId });
| modalApi.open();
| }
| </script>
|
| <template>
| <Page
| :auto-content-height="true"
| description="这这里可以进行[Server-sent events]测试 非官方功能"
| title="SSE测试"
| >
| <BasicTable>
| <template #toolbar-actions>
| <span class="pl-[7px] text-[16px]">在线用户列表</span>
| </template>
| <template #toolbar-tools>
| <Space>
| <a-button @click="handleSendAll">发送全体消息</a-button>
| </Space>
| </template>
| <template #action="{ row }">
| <ghost-button @click="handleSendSingle(row.userId)">
| 发送消息
| </ghost-button>
| </template>
| </BasicTable>
| <SendMsgModal />
| </Page>
| </template>
|
|