vue2-client 1.10.33 → 1.11.1
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/package.json +107 -107
- package/src/App.vue +196 -196
- package/src/base-client/components/common/XAddNativeForm/demo.vue +43 -43
- package/src/base-client/components/common/XAddReport/XAddReport.vue +207 -207
- package/src/base-client/components/common/XConversation/XConversation.vue +275 -263
- package/src/base-client/components/common/XForm/XForm.vue +393 -393
- package/src/base-client/components/common/XForm/XFormItem.vue +1248 -1248
- package/src/base-client/components/common/XFormCol/XFormCol.vue +157 -157
- package/src/base-client/components/common/XFormTable/XFormTable.vue +868 -856
- package/src/base-client/components/common/XIntervalPicker/XIntervalPicker.vue +121 -121
- package/src/base-client/components/common/XReportDrawer/XReportDrawer.vue +201 -201
- package/src/base-client/components/common/XReportGrid/XReport.vue +1079 -1070
- package/src/base-client/components/common/XReportGrid/XReportDemo.vue +46 -47
- package/src/base-client/components/common/XReportGrid/XReportDesign.vue +628 -628
- package/src/base-client/components/common/XReportGrid/XReportJsonRender.vue +380 -380
- package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +1104 -1104
- package/src/base-client/components/common/XReportGrid/print.js +184 -184
- package/src/base-client/components/common/XTab/XTab.vue +233 -201
- package/src/base-client/components/common/XTable/XTable.vue +114 -195
- package/src/base-client/components/common/XTable/XTableWrapper.vue +240 -0
- package/src/base-client/components/layout/XPageView/RenderRow.vue +12 -11
- package/src/components/STable/index.js +12 -12
- package/src/components/cache/AKeepAlive.js +179 -179
- package/src/layouts/BlankView.vue +78 -78
- package/src/pages/ReportGrid/index.vue +76 -76
- package/src/router/async/router.map.js +148 -95
- package/src/utils/indexedDB.js +167 -216
- package/src/utils/microAppUtils.js +49 -49
- package/vue.config.js +6 -5
|
@@ -1,263 +1,275 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div class="chat-container" v-if="loading">
|
|
4
|
-
<!-- 对话展示区域 -->
|
|
5
|
-
<div class="chat-content">
|
|
6
|
-
<div
|
|
7
|
-
v-for="(message, index) in messages"
|
|
8
|
-
:key="index"
|
|
9
|
-
:class="['chat-message', message.type]"
|
|
10
|
-
>
|
|
11
|
-
<span class="chat-avatar">{{ message.type === 'user' ? '👤' : '🤖' }}</span>
|
|
12
|
-
<div class="chat-text" v-if="message.text" v-html="renderMarkdown(message.text)"></div>
|
|
13
|
-
<div class="chat-text" v-else-if="message.state === 'loading'">
|
|
14
|
-
<a-spin :spinning="true"/>
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
<!-- 输入框和发送按钮 -->
|
|
20
|
-
<div class="chat-input">
|
|
21
|
-
<a-input
|
|
22
|
-
v-model="inputMessage"
|
|
23
|
-
placeholder="Type your message..."
|
|
24
|
-
@pressEnter="sendMessage"
|
|
25
|
-
/>
|
|
26
|
-
<a-button type="primary" @click="sendMessage">发送</a-button>
|
|
27
|
-
</div>
|
|
28
|
-
</div>
|
|
29
|
-
<a-spin :spinning="!loading"/>
|
|
30
|
-
</div>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<script>
|
|
34
|
-
import { runLogic } from '@vue2-client/services/api/common'
|
|
35
|
-
import { postByServiceName, startEventStreamPOST } from '@vue2-client/services/api/restTools'
|
|
36
|
-
import moment from 'moment/moment'
|
|
37
|
-
import { marked } from 'marked'
|
|
38
|
-
|
|
39
|
-
export default {
|
|
40
|
-
inject: {
|
|
41
|
-
getSelectedId: {
|
|
42
|
-
default: () => () => {
|
|
43
|
-
console.warn('getSelectedId is not provided.')
|
|
44
|
-
return null
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
default: () => () => {
|
|
49
|
-
console.warn('
|
|
50
|
-
return null
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
default: () => () => {
|
|
55
|
-
console.warn('
|
|
56
|
-
return
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
default: () => () => {
|
|
61
|
-
console.warn('
|
|
62
|
-
return
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
default: () => () => {
|
|
67
|
-
console.warn('
|
|
68
|
-
return {}
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
margin:
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.chat-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.chat-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.chat-
|
|
246
|
-
|
|
247
|
-
padding: 8px;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.chat-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="chat-container" v-if="loading">
|
|
4
|
+
<!-- 对话展示区域 -->
|
|
5
|
+
<div class="chat-content">
|
|
6
|
+
<div
|
|
7
|
+
v-for="(message, index) in messages"
|
|
8
|
+
:key="index"
|
|
9
|
+
:class="['chat-message', message.type]"
|
|
10
|
+
>
|
|
11
|
+
<span class="chat-avatar">{{ message.type === 'user' ? '👤' : '🤖' }}</span>
|
|
12
|
+
<div class="chat-text" v-if="message.text" v-html="renderMarkdown(message.text)"></div>
|
|
13
|
+
<div class="chat-text" v-else-if="message.state === 'loading'">
|
|
14
|
+
<a-spin :spinning="true"/>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
<!-- 输入框和发送按钮 -->
|
|
20
|
+
<div class="chat-input">
|
|
21
|
+
<a-input
|
|
22
|
+
v-model="inputMessage"
|
|
23
|
+
placeholder="Type your message..."
|
|
24
|
+
@pressEnter="sendMessage"
|
|
25
|
+
/>
|
|
26
|
+
<a-button type="primary" @click="sendMessage">发送</a-button>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
<a-spin :spinning="!loading"/>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script>
|
|
34
|
+
import { runLogic } from '@vue2-client/services/api/common'
|
|
35
|
+
import { postByServiceName, startEventStreamPOST } from '@vue2-client/services/api/restTools'
|
|
36
|
+
import moment from 'moment/moment'
|
|
37
|
+
import { marked } from 'marked'
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
inject: {
|
|
41
|
+
getSelectedId: {
|
|
42
|
+
default: () => () => {
|
|
43
|
+
console.warn('getSelectedId is not provided.')
|
|
44
|
+
return null
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
setGlobalData: {
|
|
48
|
+
default: () => () => {
|
|
49
|
+
console.warn('setGlobalData is not provided.')
|
|
50
|
+
return null
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
getGlobalData: {
|
|
54
|
+
default: () => () => {
|
|
55
|
+
console.warn('getGlobalData is not provided.')
|
|
56
|
+
return null
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
getSelectedData: {
|
|
60
|
+
default: () => () => {
|
|
61
|
+
console.warn('getSelectedData is not provided.')
|
|
62
|
+
return null
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
getMixinData: {
|
|
66
|
+
default: () => () => {
|
|
67
|
+
console.warn('getMixinData is not provided.')
|
|
68
|
+
return {}
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
getOutEnv: {
|
|
72
|
+
default: () => () => {
|
|
73
|
+
console.warn('getOutEnv is not provided.')
|
|
74
|
+
return {}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
currUser: {
|
|
78
|
+
default: () => () => {
|
|
79
|
+
console.warn('currUser is not provided.')
|
|
80
|
+
return {}
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
name: 'XConversation',
|
|
85
|
+
props: {
|
|
86
|
+
prompt: {
|
|
87
|
+
type: String,
|
|
88
|
+
default: undefined
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
data () {
|
|
92
|
+
return {
|
|
93
|
+
serviceName: undefined,
|
|
94
|
+
// 组件加载状态
|
|
95
|
+
loading: false,
|
|
96
|
+
// 配置内容
|
|
97
|
+
renderConfig: {
|
|
98
|
+
// 请求logic 名称
|
|
99
|
+
logicName: '',
|
|
100
|
+
// 请求api 地址
|
|
101
|
+
api: '',
|
|
102
|
+
// 请求流式api 地址
|
|
103
|
+
streamApi: '',
|
|
104
|
+
// 聊天室id 当type为AI 时必传
|
|
105
|
+
chatId: '',
|
|
106
|
+
// ai 模型 当type为AI 时必传
|
|
107
|
+
aiModel: '',
|
|
108
|
+
type: ''
|
|
109
|
+
},
|
|
110
|
+
// 用户输入的内容
|
|
111
|
+
inputMessage: '',
|
|
112
|
+
additionalInfo: {},
|
|
113
|
+
stopConnection: undefined,
|
|
114
|
+
messages: [ // 消息列表
|
|
115
|
+
{ type: 'bot', text: '你好! 今天有什么能帮到您的?' },
|
|
116
|
+
],
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
methods: {
|
|
120
|
+
renderMarkdown (text) {
|
|
121
|
+
const markdownPatterns = [
|
|
122
|
+
/(^|\s)(#{1,6})\s/, // 标题 (# 到 ######)
|
|
123
|
+
/(\*\*|__)(.*?)\1/, // 加粗 (** 或 __)
|
|
124
|
+
/(\*|_)(.*?)\1/, // 斜体 (* 或 _)
|
|
125
|
+
/\[([^\]]+)\]\([^\)]+\)/, // 链接 [text](url)
|
|
126
|
+
/`{1,3}[^`]+`{1,3}/, // 行内代码 (`text`)
|
|
127
|
+
/\n{2,}([^\n]+)\n{2,}/, // 段落之间的换行
|
|
128
|
+
/\n{3,}([^\n]+)\n{3,}/, // 多行代码块
|
|
129
|
+
/[-\*\+]\s+/, // 无序列表 (- 或 * 或 +)
|
|
130
|
+
/\d+\.\s+/, // 有序列表 (1. 或 2. 或 3.)
|
|
131
|
+
]
|
|
132
|
+
if (markdownPatterns.some(pattern => pattern.test(text))) {
|
|
133
|
+
return marked(text)
|
|
134
|
+
} else {
|
|
135
|
+
return text
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
setAddtionalInfo (params) {
|
|
139
|
+
this.additionalInfo = params
|
|
140
|
+
},
|
|
141
|
+
init (params) {
|
|
142
|
+
this.renderConfig = params
|
|
143
|
+
this.loading = true
|
|
144
|
+
this.serviceName = params.serviceName || process.env.VUE_APP_SERVICE_NAME
|
|
145
|
+
},
|
|
146
|
+
async sendMessage () {
|
|
147
|
+
if (this.renderConfig.type === 'AI') {
|
|
148
|
+
// 验证 chatId 和 aiModel
|
|
149
|
+
if (!this.renderConfig.chatId || !this.renderConfig.aiModel) {
|
|
150
|
+
this.$message.error('chatId 和 aiModel 不能为空,请检查调用逻辑')
|
|
151
|
+
return
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (!this.inputMessage.trim()) return
|
|
155
|
+
|
|
156
|
+
// 添加用户消息
|
|
157
|
+
this.messages.push({ type: 'user', text: this.inputMessage })
|
|
158
|
+
|
|
159
|
+
// 清空输入框
|
|
160
|
+
const userMessage = this.inputMessage
|
|
161
|
+
this.inputMessage = ''
|
|
162
|
+
// 模拟机器人的回复
|
|
163
|
+
// 通过logic获取消息
|
|
164
|
+
if (this.renderConfig.logicName) {
|
|
165
|
+
const response = await runLogic(this.renderConfig.logicName, {
|
|
166
|
+
question: userMessage,
|
|
167
|
+
additionalInfo: this.additionalInfo
|
|
168
|
+
}, this.serviceName)
|
|
169
|
+
this.messages.push({ type: 'bot', text: response.value })
|
|
170
|
+
} else if (this.renderConfig.api) {
|
|
171
|
+
// 通过api获取消息
|
|
172
|
+
this.messages.push({ type: 'bot', state: 'loading' })
|
|
173
|
+
this.messages[this.messages.length - 1].text = await postByServiceName(this.renderConfig.api, {
|
|
174
|
+
userMessage,
|
|
175
|
+
model: this.renderConfig.aiModel,
|
|
176
|
+
chatId: this.renderConfig.chatId || moment().format('YYYYMMDDHHmmss'),
|
|
177
|
+
prompt: this.prompt
|
|
178
|
+
}, this.serviceName)
|
|
179
|
+
this.$forceUpdate()
|
|
180
|
+
} else if (this.renderConfig.streamApi) {
|
|
181
|
+
// 通过流式api 获取消息
|
|
182
|
+
this.messages.push({ type: 'bot', state: 'loading' })
|
|
183
|
+
this.stopConnection = startEventStreamPOST(
|
|
184
|
+
this.renderConfig.streamApi,
|
|
185
|
+
{
|
|
186
|
+
userMessage,
|
|
187
|
+
model: this.renderConfig.aiModel,
|
|
188
|
+
chatId: this.renderConfig.chatId || moment().format('YYYYMMDDHHmmss'),
|
|
189
|
+
prompt: this.prompt
|
|
190
|
+
}, {},
|
|
191
|
+
(data) => {
|
|
192
|
+
this.messages[this.messages.length - 1].text = `${this.messages[this.messages.length - 1]?.text || ''}${data}`
|
|
193
|
+
this.$forceUpdate()
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
mounted () {
|
|
200
|
+
this.setAddtionalInfo(this.getMixinData())
|
|
201
|
+
},
|
|
202
|
+
beforeDestroy () {
|
|
203
|
+
if (this.stopConnection) {
|
|
204
|
+
this.stopConnection()
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
</script>
|
|
209
|
+
|
|
210
|
+
<style scoped>
|
|
211
|
+
.chat-container {
|
|
212
|
+
display: flex;
|
|
213
|
+
flex-direction: column;
|
|
214
|
+
height: 500px;
|
|
215
|
+
border: 1px solid #d9d9d9;
|
|
216
|
+
border-radius: 4px;
|
|
217
|
+
overflow: hidden;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.chat-content {
|
|
221
|
+
flex: 1;
|
|
222
|
+
padding: 16px;
|
|
223
|
+
overflow-y: auto;
|
|
224
|
+
background: #f5f5f5;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.chat-message {
|
|
228
|
+
display: flex;
|
|
229
|
+
align-items: flex-start;
|
|
230
|
+
margin-bottom: 10px;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.chat-message.user {
|
|
234
|
+
justify-content: flex-end;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.chat-message.bot {
|
|
238
|
+
justify-content: flex-start;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.chat-avatar {
|
|
242
|
+
margin: 0 8px;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.chat-text {
|
|
246
|
+
max-width: 70%;
|
|
247
|
+
padding: 8px 12px;
|
|
248
|
+
border-radius: 4px;
|
|
249
|
+
background-color: #fff;
|
|
250
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.chat-message.user .chat-text {
|
|
254
|
+
background-color: #e6f7ff;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.chat-input {
|
|
258
|
+
display: flex;
|
|
259
|
+
padding: 8px;
|
|
260
|
+
background: #fff;
|
|
261
|
+
border-top: 1px solid #d9d9d9;
|
|
262
|
+
gap: 10px;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.chat-input a-input {
|
|
266
|
+
flex: 1;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
code {
|
|
270
|
+
background-color: #f5f5f5;
|
|
271
|
+
border-radius: 4px;
|
|
272
|
+
padding: 2px 4px;
|
|
273
|
+
font-size: 90%;
|
|
274
|
+
}
|
|
275
|
+
</style>
|