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