vue2-client 1.8.48 → 1.8.49

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.
@@ -1,201 +1,203 @@
1
- <template>
2
- <div class="dynamic-statistics">
3
- <div class="data-nav-card-back">
4
- <div class="data-nav-card">
5
- <a-row type="flex" align="middle" class="search-title-card">
6
- <img class="search-title-logo" src="@vue2-client/assets/img/logo.png"/>
7
- <span class="search-title-text">数据检索平台</span>
8
- </a-row>
9
- <div class="search-card">
10
- <div class="blue-overlay"></div>
11
- <div class="search-card-main">
12
- <!-- 搜索栏组件 -->
13
- <search-bar ref="searchBar" @search="handleSearch" @saveToFavorites="handleSaveToFavorites" @openFavorites="handleOpenFavorite"></search-bar>
14
- </div>
15
- </div>
16
- </div>
17
- </div>
18
- <div class="data-main-card">
19
- <!-- 数据展示Tabs -->
20
- <data-tabs
21
- ref="tabs"
22
- @tab-change="handleTabChange"
23
- @remove-cache="remove"
24
- ></data-tabs>
25
- </div>
26
- </div>
27
- </template>
28
-
29
- <script>
30
- import SearchBar from './SearchBar.vue'
31
- import DataTabs from './DataTabs.vue'
32
- import { indexedDB } from '@vue2-client/utils/indexedDB'
33
- import { post } from '@vue2-client/services/api'
34
- import { formatDate } from '@vue2-client/utils/util'
35
-
36
- export default {
37
- name: 'DynamicStatistics',
38
- components: {
39
- SearchBar,
40
- DataTabs
41
- },
42
- data () {
43
- return {
44
- cacheSearchArray: {},
45
- panes: []
46
- }
47
- },
48
- methods: {
49
- // 处理搜索逻辑,这里简化为直接赋值,实际应调用API
50
- handleSearch (value, callback) {
51
- if (!value) {
52
- this.$message.warn('请先输入查询的数据')
53
- return
54
- }
55
- const uuid = this.uuid()
56
- post('/ai/question/', {
57
- messages: [{
58
- content: value,
59
- role: 'user'
60
- }]
61
- }).then(res => {
62
- if (Array.isArray(res)) {
63
- this.addTab(uuid, value, res, false)
64
- } else {
65
- this.$message.warning(res)
66
- }
67
- }).finally(() => {
68
- callback()
69
- })
70
- },
71
- addTab (uuid, question, searchResults, isFavorite) {
72
- this.cacheSearchArray[uuid] = {
73
- uuid: uuid,
74
- question: question,
75
- data: searchResults,
76
- isFavorite: isFavorite
77
- }
78
- this.$refs.tabs.add(this.cacheSearchArray[uuid])
79
- this.$refs.searchBar.setObj(this.cacheSearchArray[uuid])
80
- },
81
- // 处理保存到收藏夹的逻辑
82
- handleSaveToFavorites (uuid) {
83
- if (!uuid) {
84
- this.$message.warn('请先输入查询的数据')
85
- return
86
- }
87
- const key = 'question-' + uuid
88
- if (!this.cacheSearchArray[uuid]) {
89
- indexedDB.get(key, (item) => {
90
- this.cacheSearchArray[uuid] = item
91
- this.setFavorite(key, uuid)
92
- delete this.cacheSearchArray[uuid]
93
- })
94
- } else {
95
- this.setFavorite(key, uuid)
96
- }
97
- },
98
- setFavorite (key, uuid) {
99
- const isFavorite = this.cacheSearchArray[uuid].isFavorite
100
- this.cacheSearchArray[uuid].isFavorite = !isFavorite
101
- if (isFavorite) {
102
- indexedDB.delete(key)
103
- this.$message.success('取消收藏成功')
104
- } else {
105
- indexedDB.add(key, Object.assign({
106
- date: formatDate('now')
107
- }, this.cacheSearchArray[uuid]))
108
- this.$message.success('收藏成功')
109
- }
110
- this.$refs.searchBar.setFavorite(uuid, !isFavorite)
111
- },
112
- // 处理Tab变更,可以在这里进行额外的逻辑处理
113
- handleTabChange (uuid) {
114
- if (uuid) {
115
- this.$refs.searchBar.setObj(this.cacheSearchArray[uuid])
116
- } else {
117
- this.cacheSearchArray = []
118
- this.$refs.searchBar.init()
119
- }
120
- },
121
- // 处理从收藏夹打开收藏项
122
- handleOpenFavorite (uuid) {
123
- if (this.cacheSearchArray[uuid]) {
124
- this.$message.success('已切换至搜索结果页')
125
- this.$refs.tabs.set(uuid)
126
- return
127
- }
128
- // 这里应根据data从indexedDB中查询数据并展示
129
- const key = 'question-' + uuid
130
- indexedDB.get(key, (item) => {
131
- this.addTab(uuid, item.question, item.data, item.isFavorite)
132
- })
133
- },
134
- uuid () {
135
- const tempUrl = URL.createObjectURL(new Blob())
136
- const uuid = tempUrl.toString() // blob:https://xxx.com/b250d159-e1b6-4a87-9002-885d90033be3
137
- URL.revokeObjectURL(tempUrl)
138
- return uuid.substr(uuid.lastIndexOf('/') + 1)
139
- },
140
- remove (uuid) {
141
- delete this.cacheSearchArray[uuid]
142
- }
143
- }
144
- }
145
- </script>
146
-
147
- <style lang="less" scoped>
148
- .dynamic-statistics {
149
- position: relative;
150
- overflow: auto;
151
- height: 100vh;
152
- background-color: #f5f7fb;
153
- min-width: 1400px;
154
- margin: 0 auto;
155
- .data-nav-card-back {
156
- width: 100%;
157
- height: 265px;
158
- }
159
- .data-nav-card {
160
- z-index: 999;
161
- position: fixed;
162
- width: 100%;
163
- top: 0;
164
- background: #fff;
165
- .search-title-card {
166
- height: 65px;
167
- width: 75%;
168
- margin: 0 auto;
169
- .search-title-logo {
170
- width: 60px;
171
- margin-right: 8px;
172
- }
173
- .search-title-text {
174
- font-size: 20px;
175
- font-weight: bold;
176
- }
177
- }
178
- .search-card {
179
- width: 100%;
180
- height: 200px;
181
- background-image: url('/public/img/dynamicStatistics/dynamicStatisticsBack.jpg');
182
- background-size: cover;
183
- position: relative;
184
- }
185
- }
186
- .data-main-card {
187
- width: 75%;
188
- padding: 20px;
189
- margin: 0 auto;
190
- background-color: #f5f7fb;
191
- }
192
- .blue-overlay {
193
- position: absolute;
194
- top: 0;
195
- left: 0;
196
- width: 100%;
197
- height: 100%;
198
- background-color: rgba(#4F93FE, 0.8) // 这里设置蓝色蒙版的颜色和透明度
199
- }
200
- }
201
- </style>
1
+ <template>
2
+ <div class="dynamic-statistics">
3
+ <div class="data-nav-card-back">
4
+ <div class="data-nav-card">
5
+ <a-row type="flex" align="middle" class="search-title-card">
6
+ <img class="search-title-logo" src="@vue2-client/assets/img/logo.png"/>
7
+ <span class="search-title-text">数据检索平台</span>
8
+ </a-row>
9
+ <div class="search-card">
10
+ <div class="blue-overlay"></div>
11
+ <div class="search-card-main">
12
+ <!-- 搜索栏组件 -->
13
+ <search-bar ref="searchBar" @search="handleSearch"></search-bar>
14
+ </div>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ <div class="data-main-card">
19
+ <a-row style="height:100%">
20
+ <a-col :span="6" style="height:100%">
21
+ <question-history-and-favorites
22
+ ref="qhaf"
23
+ @handleOpenFavorite="handleOpenFavorite"
24
+ :currentuuid="currentuuid"
25
+ @handleSearch="handleSearch">
26
+ </question-history-and-favorites>
27
+ </a-col>
28
+ <a-col :span="18" style="height:100%">
29
+ <a-spin :spinning="loading" tip="正在努力加载...">
30
+ <!-- 数据展示Tabs -->
31
+ <data-tabs
32
+ ref="tabs"
33
+ @tab-change="handleTabChange"
34
+ @remove-cache="remove"
35
+ ></data-tabs>
36
+ </a-spin>
37
+ </a-col>
38
+ </a-row>
39
+ </div>
40
+ </div>
41
+ </template>
42
+
43
+ <script>
44
+ import SearchBar from './SearchBar.vue'
45
+ import DataTabs from './DataTabs.vue'
46
+ // import { post } from '@vue2-client/services/api'
47
+ import { formatDate } from '@vue2-client/utils/util'
48
+ import QuestionHistoryAndFavorites from './QuestionHistoryAndFavorites.vue'
49
+ import { post } from '@/services/api'
50
+
51
+ export default {
52
+ name: 'DynamicStatistics',
53
+ components: {
54
+ SearchBar,
55
+ DataTabs,
56
+ QuestionHistoryAndFavorites
57
+ },
58
+ data () {
59
+ return {
60
+ cacheSearchArray: {},
61
+ loading: false,
62
+ // 当前选中的uuid
63
+ currentuuid: ''
64
+ }
65
+ },
66
+ methods: {
67
+ // 处理搜索逻辑,这里简化为直接赋值,实际应调用API
68
+ async handleSearch (value, callback, uuid) {
69
+ this.loading = true
70
+ if (!value) {
71
+ this.$message.warn('请先输入查询的数据')
72
+ callback()
73
+ return
74
+ }
75
+ if (!uuid) {
76
+ uuid = this.uuid()
77
+ }
78
+
79
+ this.$refs.qhaf.add({
80
+ uuid: uuid,
81
+ question: value,
82
+ isFavorite: false,
83
+ date: formatDate('now')
84
+ })
85
+ post('/ai/question/', {
86
+ messages: [{
87
+ content: value,
88
+ role: 'user'
89
+ }]
90
+ }).then(res => {
91
+ this.loading = false
92
+ if (Array.isArray(res)) {
93
+ this.addTab(uuid, value, res, false)
94
+ } else {
95
+ this.$message.warning(res)
96
+ }
97
+ }).finally(() => {
98
+ callback()
99
+ })
100
+ },
101
+ addTab (uuid, question, searchResults, isFavorite) {
102
+ this.cacheSearchArray[uuid] = {
103
+ uuid: uuid,
104
+ question: question,
105
+ data: searchResults,
106
+ isFavorite: isFavorite,
107
+ date: formatDate('now')
108
+ }
109
+ this.currentuuid = uuid
110
+ this.$refs.tabs.show(this.cacheSearchArray[uuid])
111
+ this.$refs.qhaf.add(this.cacheSearchArray[uuid])
112
+ this.$refs.searchBar.setObj(this.cacheSearchArray[uuid])
113
+ },
114
+ // 处理Tab变更,可以在这里进行额外的逻辑处理
115
+ handleTabChange (uuid) {
116
+ if (uuid) {
117
+ this.$refs.searchBar.setObj(this.cacheSearchArray[uuid])
118
+ } else {
119
+ this.cacheSearchArray = []
120
+ this.$refs.searchBar.init()
121
+ }
122
+ },
123
+ // 处理从对话历史/收藏夹打开收藏项
124
+ handleOpenFavorite (item) {
125
+ this.addTab(item.uuid, item.question, item.data, item.isFavorite)
126
+ },
127
+ uuid () {
128
+ const tempUrl = URL.createObjectURL(new Blob())
129
+ const uuid = tempUrl.toString() // blob:https://xxx.com/b250d159-e1b6-4a87-9002-885d90033be3
130
+ URL.revokeObjectURL(tempUrl)
131
+ return uuid.substr(uuid.lastIndexOf('/') + 1)
132
+ },
133
+ remove (uuid) {
134
+ delete this.cacheSearchArray[uuid]
135
+ }
136
+ }
137
+ }
138
+ </script>
139
+
140
+ <style lang="less" scoped>
141
+ .dynamic-statistics {
142
+ position: relative;
143
+ overflow: auto;
144
+ height: 100vh;
145
+ background-color: #f5f7fb;
146
+ margin: 0 auto;
147
+
148
+ .data-nav-card-back {
149
+ width: 100%;
150
+ height: 20%;
151
+ }
152
+
153
+ .data-nav-card {
154
+ z-index: 999;
155
+ position: fixed;
156
+ width: 100%;
157
+ height: 150px;
158
+ top: 0;
159
+ background: #fff;
160
+
161
+ .search-title-card {
162
+ height: 65px;
163
+ width: 75%;
164
+ margin: 0 auto;
165
+
166
+ .search-title-logo {
167
+ width: 60px;
168
+ margin-right: 8px;
169
+ }
170
+
171
+ .search-title-text {
172
+ font-size: 20px;
173
+ font-weight: bold;
174
+ }
175
+ }
176
+
177
+ .search-card {
178
+ width: 100%;
179
+ //height: 200px;
180
+ background-image: url('/public/img/dynamicStatistics/dynamicStatisticsBack.jpg');
181
+ background-size: cover;
182
+ position: relative;
183
+ }
184
+ }
185
+
186
+ .data-main-card {
187
+ //width: 75%;
188
+ height: 79%;
189
+ padding: 20px;
190
+ margin: 0 auto;
191
+ background-color: #f5f7fb;
192
+ }
193
+
194
+ .blue-overlay {
195
+ position: absolute;
196
+ top: 0;
197
+ left: 0;
198
+ width: 100%;
199
+ height: 100%;
200
+ background-color: rgba(#4F93FE, 0.8) // 这里设置蓝色蒙版的颜色和透明度
201
+ }
202
+ }
203
+ </style>