vue2-client 1.8.102 → 1.8.104

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/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Change Log
2
2
  > 所有关于本项目的变化都在该文档里。
3
3
 
4
+ **1.8.103-1.8.104 -2024-3-14 @张振宇**
5
+ - 增加对话库功能
6
+ - 修复xbadge不更新展示问题
7
+
4
8
  **1.8.102 -2024-3-14 @张振宇**
5
9
  - microapp环境下使用 replace 跳转路由
6
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.8.102",
3
+ "version": "1.8.104",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -22,11 +22,11 @@ export default {
22
22
  props: {
23
23
  badgeKey: {
24
24
  type: String,
25
- required: true
25
+ required: true,
26
26
  },
27
27
  value: {
28
28
  type: [Number, String],
29
- required: true
29
+ required: true,
30
30
  },
31
31
  replaceText: {
32
32
  type: String,
@@ -38,22 +38,34 @@ export default {
38
38
  }
39
39
  },
40
40
  computed: {},
41
+ watch: {
42
+ badgeKey (newVal, oldVal) {
43
+ this.updateDictionary()
44
+ },
45
+ value (newVal, oldVal) {
46
+ this.updateDictionary()
47
+ }
48
+ },
41
49
  data () {
42
50
  return {
43
51
  dictionary: undefined
44
52
  }
45
53
  },
46
54
  created () {
47
- const result = this.$appdata.getParam(this.badgeKey, this.value)
48
- if (result) {
49
- this.dictionary = result
50
- return
51
- }
52
- this.$appdata.getDictValue(this.badgeKey, this.value, res => {
53
- this.dictionary = res
54
- })
55
+ this.updateDictionary()
55
56
  },
56
57
  methods: {
58
+ // todo 修改方式 想办法不使用回调方式
59
+ updateDictionary () {
60
+ const result = this.$appdata.getParam(this.badgeKey, this.value)
61
+ if (result) {
62
+ this.dictionary = result
63
+ return
64
+ }
65
+ this.$appdata.getDictValue(this.badgeKey, this.value, undefined, res => {
66
+ this.dictionary = res
67
+ })
68
+ },
57
69
  badgeFilter (key, value) {
58
70
  return this.$appdata.getParam(key, value)
59
71
  }
@@ -53,19 +53,19 @@ const GetAppDataService = {
53
53
  const object = JSON.parse(str)
54
54
  return object[key]
55
55
  },
56
- getDictValue (dictKey, value, callback) {
56
+ getDictValue (dictKey, value, func) {
57
57
  getConfigByName(dictKey, undefined, result => {
58
58
  for (const item of result.value) {
59
59
  if (item.value == value) {
60
- callback({
60
+ func({
61
61
  status: item.status || 'none',
62
62
  text: item.label
63
63
  })
64
64
  }
65
65
  }
66
- callback({
66
+ func({
67
67
  status: 'none',
68
- text: item.label
68
+ text: value
69
69
  })
70
70
  })
71
71
  },
@@ -6,7 +6,7 @@
6
6
  <a-row>
7
7
  <ChartSelector :rawData="pane.content" v-if="pane?.content?.length"/>
8
8
  </a-row>
9
- <EvaluationArea :uuid="pane.key" v-if="pane.key && pane.content"/>
9
+ <EvaluationArea :uuid="pane.key" v-if="pane.key && pane.content" @submitEvaluationLib="submitEvaluationLib"/>
10
10
  </a-row>
11
11
  </template>
12
12
 
@@ -33,6 +33,9 @@ export default {
33
33
  this.pane = {}
34
34
  },
35
35
  methods: {
36
+ submitEvaluationLib (value, uuid) {
37
+ this.$emit('submitEvaluationLib', value, uuid)
38
+ },
36
39
  show (obj) {
37
40
  const { uuid, question, data } = obj
38
41
  this.pane = { title: question, content: data, key: uuid }
@@ -32,7 +32,11 @@ export default {
32
32
  methods: {
33
33
  submitEvaluation (result) {
34
34
  const key = 'question-' + this.uuid
35
+ let flag = true
35
36
  indexedDB.get(key, (item) => {
37
+ flag = false
38
+ // 收藏状态不存储到库里
39
+ delete item.isFavorite
36
40
  const content = Object.assign(item, {
37
41
  evaluation: result
38
42
  })
@@ -48,6 +52,10 @@ export default {
48
52
  indexedDB.add(key, content)
49
53
  })
50
54
  })
55
+ // 如果 indexedDB 没有获取到说明是对话库的数据
56
+ if (flag) {
57
+ this.$emit('submitEvaluationLib', result, this.uuid)
58
+ }
51
59
  }
52
60
  }
53
61
  }
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <a-card class="question-history" id="question-history" size="small" :bordered="false" :bodyStyle="{ height:'100%', overflowY: 'auto'}">
2
+ <a-card
3
+ class="question-history"
4
+ id="question-history"
5
+ size="small"
6
+ :bordered="false"
7
+ :bodyStyle="{ height:'100%', overflowY: 'auto'}">
3
8
  <a-tabs v-model="activeKey" :tabBarStyle="{ textAlign: 'center',height:'100%' }" tabPosition="top">
4
9
  <a-tab-pane key="1" tab="对话历史">
5
10
  <a-list item-layout="horizontal" :data-source="questions">
@@ -32,7 +37,7 @@
32
37
  <a-icon
33
38
  type="star"
34
39
  :class="renderItem.isFavorite ? 'startActive' : 'startInactive'"
35
- @click.stop="toFavorites(renderItem,index)"
40
+ @click.stop="toFavorites(renderItem,index,'lib')"
36
41
  :theme=" renderItem.isFavorite ? 'filled': 'twoTone'"
37
42
  two-tone-color="#FFD700"/>
38
43
  </a-tooltip>
@@ -76,6 +81,61 @@
76
81
  </a-list-item>
77
82
  </a-list>
78
83
  </a-tab-pane>
84
+ <a-tab-pane key="3" tab="对话库">
85
+ <a-button type="dashed" class="pullQuestion" :loading="pullQuestionLoading" @click="pullQuestion">
86
+ 拉取对话
87
+ </a-button>
88
+ <a-list item-layout="horizontal" :data-source="questionsLib">
89
+ <a-list-item
90
+ slot="renderItem"
91
+ class="questionItem"
92
+ :class="[renderItem.sql ? (renderItem.uuid === currentuuid ? 'question-history-active' : 'question-history-inactive') : (renderItem.uuid === currentuuid ? 'question-history-active-bug' : 'question-history-inactive-bug'),
93
+ index===0 || questionsLib[index].date !== questionsLib[index-1].date ? 'mgtop-20' : '']"
94
+ slot-scope="renderItem,index"
95
+ @click="handleOnlyOpen(renderItem)">
96
+ <a-divider v-if="index===0 || questionsLib[index].date !== questionsLib[index-1].date" class="questionItemDivider">
97
+ {{ timeAgo(renderItem.date) }}
98
+ </a-divider>
99
+ <a-list-item-meta
100
+ :description="renderItem.date"
101
+ >
102
+ <span slot="title">
103
+ {{ renderItem.question }}
104
+ <br/>
105
+ <span class="evaluation" v-if="icons[renderItem.evaluation]">
106
+ <a-icon
107
+ :type="icons[renderItem.evaluation].icon"
108
+ theme="twoTone"
109
+ style="font-size: 1rem"
110
+ :two-tone-color="icons[renderItem.evaluation].color"/>
111
+ 【{{ icons[renderItem.evaluation].text }}】
112
+ </span>
113
+ <span class="evaluation" v-else>
114
+ <a-icon type="message" style="font-size: 1rem" theme="twoTone" two-tone-color="#999"/>
115
+ 未评价
116
+ </span>
117
+ </span>
118
+ </a-list-item-meta>
119
+ <a-space>
120
+ <a-tooltip :title="renderItem.isFavorite ? '取消收藏' : '收藏'" v-if="renderItem.sql">
121
+ <a-icon
122
+ type="star"
123
+ :class="renderItem.isFavorite ? 'startActive' : 'startInactive'"
124
+ @click.stop="libToFavorites(renderItem,index)"
125
+ :theme=" renderItem.isFavorite ? 'filled': 'twoTone'"
126
+ two-tone-color="#FFD700"/>
127
+ </a-tooltip>
128
+ <a-tooltip title="重新查询" v-else>
129
+ <a-icon
130
+ @click.stop="reTrySearch(renderItem, index)"
131
+ type="sync"
132
+ class="reSearch"
133
+ title="重新查询"/>
134
+ </a-tooltip>
135
+ </a-space>
136
+ </a-list-item>
137
+ </a-list>
138
+ </a-tab-pane>
79
139
  </a-tabs>
80
140
  <a-modal
81
141
  width="1200px"
@@ -122,6 +182,7 @@
122
182
  <script>
123
183
  import { indexedDB } from '@vue2-client/utils/indexedDB'
124
184
  import { formatDate } from '@vue2-client/utils/util'
185
+ import { post } from '@/services/api'
125
186
 
126
187
  export default {
127
188
  props: {
@@ -133,37 +194,135 @@ export default {
133
194
  data () {
134
195
  return {
135
196
  activeKey: '1',
197
+ actions: [
198
+ { type: 'star-o', text: '156' },
199
+ { type: 'like-o', text: '156' },
200
+ { type: 'message', text: '2' },
201
+ ],
136
202
  questions: [], // 你的问题历史
137
203
  favorites: [], // 你的收藏问题
204
+ questionsLib: [], // 对话库
205
+ icons: {
206
+ 0: {
207
+ icon: 'like',
208
+ text: '满意'
209
+ },
210
+ 1: {
211
+ icon: 'dislike',
212
+ text: '不满意',
213
+ color: '#FF4F53'
214
+ },
215
+ 2: {
216
+ icon: 'frown',
217
+ text: '待改进',
218
+ color: '#52c41a'
219
+ }
220
+ }, // 对话库
138
221
  // 元数据窗口
139
222
  metaDataModalVisible: false,
140
- item: {}
223
+ item: {},
224
+ pullQuestionLoading: false
141
225
  }
142
226
  },
143
227
  mounted () {
144
228
  this.loadData()
145
229
  },
146
230
  methods: {
231
+ // 根据时间yyyy-mm-dd hh24:mi:ss判断是刚刚?今天?昨天?还是更早?
232
+ timeAgo (time) {
233
+ const now = new Date()
234
+ const date = new Date(time)
235
+ const diff = now - date
236
+ const day = 24 * 60 * 60 * 1000
237
+ if (diff < 60 * 60 * 1000) {
238
+ return '刚刚'
239
+ } else if (diff < day) {
240
+ return '今天'
241
+ } else if (diff < day * 2) {
242
+ return '昨天'
243
+ } else {
244
+ return time.substring(0, 10)
245
+ }
246
+ },
247
+ pullQuestion () {
248
+ this.pullQuestionLoading = true
249
+ post('/api/af-system/logic/openapi/getCommonData', {
250
+ type: 'ai-question',
251
+ content: ''
252
+ }).then(res => {
253
+ res.forEach(item => {
254
+ const _item = JSON.parse(item.f_json)
255
+ if (_item.data && _item.data.length) {
256
+ if (!this.questionsLib.some(_ => _.uuid === _item.uuid)) {
257
+ _item.date = formatDate('now')
258
+ this.questionsLib.push(_item)
259
+ indexedDB.add('question-lib-' + _item.uuid, _item)
260
+ }
261
+ }
262
+ })
263
+ this.pullQuestionLoading = false
264
+ }).catch(e => {
265
+ this.pullQuestionLoading = false
266
+ })
267
+ },
147
268
  loadData () {
148
269
  this.questions = []
149
270
  this.favorites = []
150
271
  indexedDB.getAll((data) => {
151
272
  // 遍历data,将question和favorites分别赋值给questions和favorites
152
273
  for (const datum of data) {
153
- if (datum.key.includes('question')) {
154
- this.questions.push(datum.data)
274
+ if (datum.key.includes('question-lib')) {
275
+ this.questionsLib.push(datum.data)
155
276
  } else if (datum.key.includes('favorites')) {
156
277
  this.favorites.push(datum.data)
278
+ } else if (datum.key.includes('question')) {
279
+ this.favorites.push(datum.data)
157
280
  }
158
281
  }
159
282
  this.questions.sort((a, b) => new Date(b.date) - new Date(a.date))
160
283
  this.favorites.sort((a, b) => new Date(b.date) - new Date(a.date))
284
+ this.questionsLib.sort((a, b) => new Date(b.date) - new Date(a.date))
161
285
  }
162
286
  )
163
287
  },
164
288
  handleOpenFavorite (item) {
165
289
  this.$emit('handleOpenFavorite', item)
166
290
  },
291
+ handleOnlyOpen (item) {
292
+ this.$emit('handleOnlyOpen', item)
293
+ },
294
+ submitEvaluationLib (value, uuid) {
295
+ // 根据uuid 在 questionslib里卖弄找到这个对象
296
+ const item = this.questionsLib.find(item => item.uuid === uuid)
297
+ const key = 'question-lib-' + uuid
298
+ // 收藏状态不存储到库里
299
+ delete item.isFavorite
300
+ const content = Object.assign(item, {
301
+ evaluation: value
302
+ })
303
+ // 使用 content 替换 item
304
+ this.questionsLib = this.questionsLib.map(_item => {
305
+ if (_item.uuid === uuid) {
306
+ _item = content
307
+ }
308
+ return _item
309
+ })
310
+ if (content.sql) {
311
+ // 处理sql的单引号
312
+ content.sql = content.sql.replaceAll(/'/g, "''")
313
+ }
314
+ console.log(content)
315
+ // 保存到数据库中
316
+ post('/api/af-system/logic/openapi/updateCommonData', {
317
+ type: 'ai-question',
318
+ content: uuid,
319
+ newContent: content
320
+ }).then(res => {
321
+ this.$message.success('评论成功')
322
+ indexedDB.delete(key)
323
+ indexedDB.add(key, content)
324
+ })
325
+ },
167
326
  reTrySearch (item, index) {
168
327
  this.delQuestion(item, index)
169
328
  this.$emit('handleSearch', item.question, null, item.uuid)
@@ -215,6 +374,29 @@ export default {
215
374
  }
216
375
  this.updateQuestion(question)
217
376
  },
377
+ libToFavorites (question, index) {
378
+ this.questionsLib[index].isFavorite = !this.questionsLib[index].isFavorite
379
+ this.questionsLib = JSON.parse(JSON.stringify(this.questionsLib))
380
+ if (this.questionsLib[index].isFavorite) {
381
+ const key = 'favorites-' + question.uuid
382
+ question.isFavorite = true
383
+ // 避免从其他地方收藏了这个 uuid
384
+ indexedDB.delete(key)
385
+ indexedDB.add(key, question)
386
+ this.favorites.push(Object.assign({}, question, { date: formatDate('now') }))
387
+ this.$message.success('收藏成功')
388
+ } else {
389
+ // 根据 uuid 删除 favorites 中的对应项
390
+ this.favorites = this.favorites.filter(item => item.uuid !== question.uuid).sort((a, b) => new Date(b.date) - new Date(a.date))
391
+ // 删除收藏的储存
392
+ const key = 'favorites-' + question.uuid
393
+ indexedDB.delete(key)
394
+ }
395
+
396
+ const questionKey = 'question-lib-' + question.uuid
397
+ indexedDB.delete(questionKey)
398
+ indexedDB.add(questionKey, this.questionsLib[index])
399
+ },
218
400
  delQuestion (item, index) {
219
401
  // 删除对话历史
220
402
  this.questions.splice(index, 1)
@@ -271,13 +453,13 @@ export default {
271
453
 
272
454
  .question-history-inactive-bug {
273
455
  border-radius: 4px;
274
- padding : 18px;
456
+ padding: 18px;
275
457
  background-color: rgba(#ff0000, 0.04);
276
458
  }
277
459
 
278
460
  .question-history-inactive {
279
461
  border-radius: 4px;
280
- padding : 18px;
462
+ padding: 18px;
281
463
  }
282
464
 
283
465
  .ant-list-item-meta /deep/ {
@@ -357,6 +539,27 @@ export default {
357
539
  transform: rotate(0deg);
358
540
  }
359
541
  }
542
+
543
+ .pullQuestion {
544
+ width: 100%;
545
+ margin-bottom: 10px;
546
+ }
547
+
548
+ .evaluation {
549
+
550
+ }
551
+ .mgtop-20{
552
+ margin-top: 20px;
553
+ }
554
+
555
+ .questionItemDivider {
556
+ position: absolute;
557
+ top:-25px
558
+ }
559
+
560
+ .questionItem {
561
+ position: relative;
562
+ }
360
563
  }
361
564
 
362
565
  </style>
@@ -21,6 +21,7 @@
21
21
  <question-history-and-favorites
22
22
  ref="qhaf"
23
23
  @handleOpenFavorite="handleOpenFavorite"
24
+ @handleOnlyOpen="handleOnlyOpen"
24
25
  :currentuuid="currentuuid"
25
26
  @handleSearch="handleSearch">
26
27
  </question-history-and-favorites>
@@ -32,6 +33,7 @@
32
33
  v-show="!loading"
33
34
  ref="tabs"
34
35
  @tab-change="handleTabChange"
36
+ @submitEvaluationLib="submitEvaluationLib"
35
37
  @remove-cache="remove"
36
38
  ></data-tabs>
37
39
  </a-spin>
@@ -77,7 +79,7 @@ export default {
77
79
  indexedDB.getAll((data) => {
78
80
  let evaluation = true
79
81
  for (const datum of data) {
80
- if (datum.key.includes('question')) {
82
+ if (datum.key.includes('question') && !datum.key.includes('question-lib')) {
81
83
  const item = datum.data
82
84
  console.warn(item)
83
85
  if (item.evaluation === undefined && item.sql) {
@@ -169,6 +171,15 @@ export default {
169
171
  handleOpenFavorite (item) {
170
172
  this.addTab(item)
171
173
  },
174
+ // 处理从对话历史/收藏夹打开收藏项
175
+ handleOnlyOpen (item) {
176
+ this.$refs.tabs.show(item)
177
+ },
178
+ submitEvaluationLib (value, uuid) {
179
+ console.log(value, uuid)
180
+ this.currentuuid = uuid
181
+ this.$refs.qhaf.submitEvaluationLib(value, uuid)
182
+ },
172
183
  uuid () {
173
184
  const tempUrl = URL.createObjectURL(new Blob())
174
185
  const uuid = tempUrl.toString() // blob:https://xxx.com/b250d159-e1b6-4a87-9002-885d90033be3
package/vue.config.js CHANGED
@@ -12,7 +12,7 @@ const isProd = process.env.NODE_ENV === 'production'
12
12
 
13
13
  // v4 产品演示
14
14
  const v3Server = 'http://121.36.106.17:8400'
15
- const gateway = 'http://192.168.50.67:31567'
15
+ const gateway = 'http://192.168.50.67:31467'
16
16
  // v3 铜川
17
17
  // const v3Server = 'http://61.134.55.234:8405'
18
18
  // const gateway = 'http://61.134.55.234:8456/webmeter'