vuepress-theme-uniapp-official 1.5.4 → 1.6.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/components/DcloudSearchPage/components/AIChat/SelectPlatform.vue +63 -0
- package/components/DcloudSearchPage/components/AIChat/index.vue +405 -0
- package/components/DcloudSearchPage/components/AIChat/markdown-loader.js +45 -0
- package/components/DcloudSearchPage/components/AIChat/skeleton.styl +39 -0
- package/components/DcloudSearchPage/components/Results.vue +1 -5
- package/components/DcloudSearchPage/index.styl +36 -1
- package/components/DcloudSearchPage/index.vue +115 -82
- package/components/DcloudSearchPage/utils/postDcloudServer.js +12 -3
- package/package.json +4 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { watch, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
currentCategory: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: false,
|
|
8
|
+
default: 'uni-app x'
|
|
9
|
+
},
|
|
10
|
+
platforms: {
|
|
11
|
+
type: Array,
|
|
12
|
+
required: false,
|
|
13
|
+
default: () => []
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const emit = defineEmits(['change'])
|
|
18
|
+
|
|
19
|
+
const platform = ref(
|
|
20
|
+
props.platforms.includes(props.currentCategory)
|
|
21
|
+
? props.currentCategory
|
|
22
|
+
: props.platforms[0] || ''
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
watch(platform, (v) => emit('change', v))
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<template>
|
|
29
|
+
<div class="select-platform">
|
|
30
|
+
<select name="select" v-model="platform">
|
|
31
|
+
<template v-for="value in props.platforms">
|
|
32
|
+
<option :key="value" :value="value">{{ value }}</option>
|
|
33
|
+
</template>
|
|
34
|
+
</select>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<style lang="stylus" scoped>
|
|
39
|
+
.select-platform
|
|
40
|
+
margin-left auto
|
|
41
|
+
|
|
42
|
+
select
|
|
43
|
+
color black
|
|
44
|
+
appearance none
|
|
45
|
+
padding 6px 12px
|
|
46
|
+
border 1px solid rgba(0,0,0,.12)
|
|
47
|
+
border-radius 8px
|
|
48
|
+
font-size 14px
|
|
49
|
+
background white
|
|
50
|
+
cursor pointer
|
|
51
|
+
outline none
|
|
52
|
+
transition border .2s
|
|
53
|
+
|
|
54
|
+
&:hover
|
|
55
|
+
border-color $accentColor
|
|
56
|
+
|
|
57
|
+
&:focus
|
|
58
|
+
border-color $accentColor
|
|
59
|
+
box-shadow 0 0 0 2px rgba($accentColor, .2)
|
|
60
|
+
|
|
61
|
+
&:active
|
|
62
|
+
border-color $accentColor
|
|
63
|
+
</style>
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="chat-wrapper">
|
|
3
|
+
<header class="chat-header">
|
|
4
|
+
<div class="title">DCloud 文档 AI 助手</div>
|
|
5
|
+
<SelectPlatform :currentCategory="currentCategory" :platforms="aiPlatforms" @change="platformChange" />
|
|
6
|
+
</header>
|
|
7
|
+
|
|
8
|
+
<main ref="msgList" class="chat-messages">
|
|
9
|
+
<transition-group name="fade-up" tag="div">
|
|
10
|
+
|
|
11
|
+
<div v-for="m in messages" :key="m.id" :class="['msg', m.role]">
|
|
12
|
+
|
|
13
|
+
<div class="bubble" v-html="m.rendered"></div>
|
|
14
|
+
|
|
15
|
+
<div class="meta">
|
|
16
|
+
<span class="time">{{ m.time }}</span>
|
|
17
|
+
|
|
18
|
+
<!-- <div class="actions" v-if="m.role === 'assistant'">
|
|
19
|
+
<span class="icon" :class="{ active: m.like === 1 }" @click="setLike(m, 1)">
|
|
20
|
+
👍
|
|
21
|
+
</span>
|
|
22
|
+
<span class="icon" :class="{ active: m.like === -1 }" @click="setLike(m, -1)">
|
|
23
|
+
👎
|
|
24
|
+
</span>
|
|
25
|
+
</div> -->
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
</transition-group>
|
|
30
|
+
|
|
31
|
+
<div v-if="sending" class="chat-skeleton chat-skeleton-left">
|
|
32
|
+
<div class="content">
|
|
33
|
+
<div class="line"></div>
|
|
34
|
+
<div class="line"></div>
|
|
35
|
+
<div class="line short"></div>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
</main>
|
|
40
|
+
|
|
41
|
+
<footer class="chat-input-bar">
|
|
42
|
+
<div class="input-container">
|
|
43
|
+
<textarea ref="input" v-model="inputText" class="chat-input" rows="1" placeholder="请输入内容…" @input="autoGrow"
|
|
44
|
+
@keydown.enter.exact.prevent="send" inputmode="text" enterkeyhint="newline"></textarea>
|
|
45
|
+
|
|
46
|
+
<button class="send-btn" :disabled="sending" @click="send">
|
|
47
|
+
发送
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
</footer>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script setup>
|
|
55
|
+
import { ref, nextTick, watchEffect, onMounted, onActivated, watch } from 'vue'
|
|
56
|
+
import { renderMarkdown } from "./markdown-loader";
|
|
57
|
+
import 'highlight.js/styles/github.min.css'
|
|
58
|
+
import SelectPlatform from './SelectPlatform.vue';
|
|
59
|
+
import { ajax } from '../../utils/postDcloudServer';
|
|
60
|
+
import searchPageConfig from '@theme-config/searchPage';
|
|
61
|
+
|
|
62
|
+
const { aiPlatforms = [], aiChatForDocSearch } = searchPageConfig;
|
|
63
|
+
|
|
64
|
+
const props = defineProps({
|
|
65
|
+
currentCategory: {
|
|
66
|
+
type: String,
|
|
67
|
+
required: false,
|
|
68
|
+
default: 'uni-app x'
|
|
69
|
+
},
|
|
70
|
+
visible: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
required: false,
|
|
73
|
+
default: true
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const messages = ref([])
|
|
78
|
+
const inputText = ref('')
|
|
79
|
+
const sending = ref(false)
|
|
80
|
+
const sendPlatform = ref(props.currentCategory)
|
|
81
|
+
|
|
82
|
+
const msgList = ref(null)
|
|
83
|
+
const input = ref(null)
|
|
84
|
+
|
|
85
|
+
function setSessionMessages(value) {
|
|
86
|
+
sessionStorage.setItem('__UNIDOC_MESSAGES__', JSON.stringify(value));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
onMounted(() => {
|
|
90
|
+
const savedMessages = sessionStorage.getItem('__UNIDOC_MESSAGES__')
|
|
91
|
+
if (savedMessages) {
|
|
92
|
+
messages.value = JSON.parse(savedMessages)
|
|
93
|
+
scrollToBottom()
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
watchEffect(() => {
|
|
98
|
+
if (props.visible) {
|
|
99
|
+
nextTick(() => {
|
|
100
|
+
scrollToBottom()
|
|
101
|
+
autoGrow(true)
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
function formatTime() {
|
|
107
|
+
const d = new Date()
|
|
108
|
+
return `${d.getHours().toString().padStart(2, '0')}:${d
|
|
109
|
+
.getMinutes()
|
|
110
|
+
.toString()
|
|
111
|
+
.padStart(2, '0')}`
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function autoGrow(clear) {
|
|
115
|
+
const el = input.value
|
|
116
|
+
el.style.height = 'auto'
|
|
117
|
+
scrollToBottom()
|
|
118
|
+
if (clear === true) {
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
el.style.height = el.scrollHeight + 'px'
|
|
122
|
+
el.scrollTo({ top: el.scrollHeight, behavior: 'smooth' })
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function scrollToBottom() {
|
|
126
|
+
nextTick(() => {
|
|
127
|
+
const el = msgList.value
|
|
128
|
+
if (!el) return
|
|
129
|
+
el.scrollTo({ top: el.scrollHeight, behavior: 'smooth' })
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function renderHTML(raw) {
|
|
134
|
+
const rendered = await renderMarkdown(raw)
|
|
135
|
+
return rendered
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function setLike(msg, val) {
|
|
139
|
+
msg.like = msg.like === val ? 0 : val
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function fakeAITyping(text, msgObj) {
|
|
143
|
+
return new Promise(resolve => {
|
|
144
|
+
let i = 0
|
|
145
|
+
const timer = setInterval(async () => {
|
|
146
|
+
if (i >= text.length) {
|
|
147
|
+
clearInterval(timer)
|
|
148
|
+
msgObj.raw = text
|
|
149
|
+
msgObj.rendered = await renderHTML(text)
|
|
150
|
+
msgObj.isTyping = false
|
|
151
|
+
resolve()
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
msgObj.raw += text[i]
|
|
156
|
+
msgObj.rendered = await renderHTML(msgObj.raw)
|
|
157
|
+
i++
|
|
158
|
+
scrollToBottom()
|
|
159
|
+
}, 25)
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function platformChange(newPlatform) {
|
|
164
|
+
sendPlatform.value = newPlatform
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function send() {
|
|
168
|
+
if (!inputText.value.trim() || sending.value) return
|
|
169
|
+
|
|
170
|
+
const userText = inputText.value.trim()
|
|
171
|
+
inputText.value = ''
|
|
172
|
+
autoGrow(true)
|
|
173
|
+
|
|
174
|
+
// 用户消息
|
|
175
|
+
messages.value.push({
|
|
176
|
+
id: Date.now(),
|
|
177
|
+
role: 'user',
|
|
178
|
+
raw: userText,
|
|
179
|
+
rendered: await renderHTML(userText),
|
|
180
|
+
time: formatTime(),
|
|
181
|
+
like: 0
|
|
182
|
+
})
|
|
183
|
+
scrollToBottom()
|
|
184
|
+
|
|
185
|
+
sending.value = true
|
|
186
|
+
|
|
187
|
+
let fakeReply = ''
|
|
188
|
+
try {
|
|
189
|
+
const res = await ajax(aiChatForDocSearch ? aiChatForDocSearch : 'https://ai-assist-api.dcloud.net.cn/tbox/chatForDocSearch', 'POST', {
|
|
190
|
+
"question": userText,
|
|
191
|
+
"group_name": sendPlatform.value
|
|
192
|
+
})
|
|
193
|
+
if (res.errorCode === 0) {
|
|
194
|
+
fakeReply = res.chunk
|
|
195
|
+
} else {
|
|
196
|
+
fakeReply = `抱歉,AI 助手出错了:${res.errorMessage || '未知错误'}`
|
|
197
|
+
}
|
|
198
|
+
} catch (error) {
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
sending.value = false
|
|
202
|
+
|
|
203
|
+
// AI 消息对象
|
|
204
|
+
const aiMsg = {
|
|
205
|
+
id: Date.now() + 1,
|
|
206
|
+
role: 'assistant',
|
|
207
|
+
raw: fakeReply,
|
|
208
|
+
rendered: await renderHTML(fakeReply),
|
|
209
|
+
time: formatTime(),
|
|
210
|
+
isTyping: false,
|
|
211
|
+
like: 0
|
|
212
|
+
}
|
|
213
|
+
messages.value.push(aiMsg)
|
|
214
|
+
|
|
215
|
+
// 动态打字
|
|
216
|
+
// await fakeAITyping(fakeReply, aiMsg)
|
|
217
|
+
setSessionMessages(messages.value)
|
|
218
|
+
|
|
219
|
+
scrollToBottom()
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
window.addEventListener('resize', scrollToBottom)
|
|
223
|
+
</script>
|
|
224
|
+
|
|
225
|
+
<style lang="stylus">
|
|
226
|
+
@import './skeleton.styl'
|
|
227
|
+
|
|
228
|
+
.chat-wrapper
|
|
229
|
+
display flex
|
|
230
|
+
flex-direction column
|
|
231
|
+
height calc(100vh - 56px - 40px)
|
|
232
|
+
background #f9fafb
|
|
233
|
+
overflow hidden
|
|
234
|
+
|
|
235
|
+
.chat-header
|
|
236
|
+
height 56px
|
|
237
|
+
display flex
|
|
238
|
+
align-items center
|
|
239
|
+
padding 0 16px
|
|
240
|
+
background white
|
|
241
|
+
border-bottom 1px solid #eee
|
|
242
|
+
|
|
243
|
+
.title
|
|
244
|
+
font-size 18px
|
|
245
|
+
font-weight 600
|
|
246
|
+
|
|
247
|
+
.chat-messages
|
|
248
|
+
flex 1
|
|
249
|
+
overflow-y auto
|
|
250
|
+
padding 16px
|
|
251
|
+
box-sizing border-box
|
|
252
|
+
|
|
253
|
+
.msg
|
|
254
|
+
display flex
|
|
255
|
+
flex-direction column
|
|
256
|
+
margin-bottom 14px
|
|
257
|
+
|
|
258
|
+
.msg.user
|
|
259
|
+
.bubble
|
|
260
|
+
background $accentColor
|
|
261
|
+
color white
|
|
262
|
+
margin-left auto
|
|
263
|
+
pre
|
|
264
|
+
background rgba(255,255,255,.9)
|
|
265
|
+
.meta
|
|
266
|
+
justify-content flex-end
|
|
267
|
+
.time
|
|
268
|
+
margin-right 10px
|
|
269
|
+
|
|
270
|
+
.msg.assistant
|
|
271
|
+
.bubble
|
|
272
|
+
max-width 80%
|
|
273
|
+
background white
|
|
274
|
+
border 1px solid #eee
|
|
275
|
+
margin-right auto
|
|
276
|
+
pre
|
|
277
|
+
background #f6f8fa
|
|
278
|
+
.time
|
|
279
|
+
margin-left 10px
|
|
280
|
+
|
|
281
|
+
.bubble
|
|
282
|
+
display inline-block
|
|
283
|
+
max-width 50%
|
|
284
|
+
padding 10px 14px
|
|
285
|
+
border-radius 14px
|
|
286
|
+
line-height 1.5
|
|
287
|
+
font-size 15px
|
|
288
|
+
word-break break-word
|
|
289
|
+
box-shadow 0 1px 3px rgba(0,0,0,0.08)
|
|
290
|
+
pre
|
|
291
|
+
border-radius 10px
|
|
292
|
+
& + pre
|
|
293
|
+
margin-top 8px
|
|
294
|
+
pre, code
|
|
295
|
+
white-space: pre-wrap; /* 允许换行 */
|
|
296
|
+
word-wrap: break-word; /* 允许长行断开 */
|
|
297
|
+
word-break: break-word;
|
|
298
|
+
h1, h2, h3, h4, h5, h6, p, ul, ol, dl, figure, blockquote, pre
|
|
299
|
+
margin: 0
|
|
300
|
+
padding: 0
|
|
301
|
+
ul, ol
|
|
302
|
+
list-style: none
|
|
303
|
+
|
|
304
|
+
.meta
|
|
305
|
+
font-size 12px
|
|
306
|
+
color #888
|
|
307
|
+
margin-top 4px
|
|
308
|
+
display flex
|
|
309
|
+
align-items center
|
|
310
|
+
|
|
311
|
+
.actions
|
|
312
|
+
display flex
|
|
313
|
+
gap 10px
|
|
314
|
+
|
|
315
|
+
.icon
|
|
316
|
+
cursor pointer
|
|
317
|
+
opacity .5
|
|
318
|
+
transition .2s
|
|
319
|
+
&.active
|
|
320
|
+
opacity 1
|
|
321
|
+
color $accentColor
|
|
322
|
+
|
|
323
|
+
.chat-input-bar
|
|
324
|
+
padding 10px
|
|
325
|
+
background white
|
|
326
|
+
border-top 1px solid #eee
|
|
327
|
+
display flex
|
|
328
|
+
align-items flex-end
|
|
329
|
+
justify-content center
|
|
330
|
+
|
|
331
|
+
.input-container
|
|
332
|
+
display flex
|
|
333
|
+
align-items flex-end
|
|
334
|
+
width 100%
|
|
335
|
+
background #fff
|
|
336
|
+
border 1px solid rgba(0,0,0,.1)
|
|
337
|
+
border-radius 20px
|
|
338
|
+
padding 8px 12px
|
|
339
|
+
box-shadow 0 2px 8px rgba(0,0,0,.06)
|
|
340
|
+
transition border-color .2s
|
|
341
|
+
&:focus-within
|
|
342
|
+
border-color $accentColor
|
|
343
|
+
box-shadow 0 0 0 2px rgba($accentColor, .2)
|
|
344
|
+
|
|
345
|
+
.chat-input
|
|
346
|
+
flex 1
|
|
347
|
+
resize none
|
|
348
|
+
outline none
|
|
349
|
+
border none
|
|
350
|
+
padding 8px 10px
|
|
351
|
+
line-height 1.5
|
|
352
|
+
max-height 160px
|
|
353
|
+
overflow-y auto
|
|
354
|
+
font-size 15px
|
|
355
|
+
transition: height 0.2s;
|
|
356
|
+
|
|
357
|
+
.send-btn
|
|
358
|
+
margin-left 8px
|
|
359
|
+
padding 8px 14px
|
|
360
|
+
border none
|
|
361
|
+
border-radius 8px
|
|
362
|
+
background $accentColor
|
|
363
|
+
color white
|
|
364
|
+
font-size 15px
|
|
365
|
+
cursor pointer
|
|
366
|
+
transition: background 0.2s, transform 0.15s;
|
|
367
|
+
&:hover
|
|
368
|
+
background: darken($accentColor, 10%)
|
|
369
|
+
&:active
|
|
370
|
+
transform: scale(0.95)
|
|
371
|
+
&:disabled
|
|
372
|
+
opacity .4
|
|
373
|
+
|
|
374
|
+
/* Skeleton shimmer animation */
|
|
375
|
+
@keyframes skeleton-loading
|
|
376
|
+
0%
|
|
377
|
+
background-position: -200px 0
|
|
378
|
+
100%
|
|
379
|
+
background-position: calc(200px + 100%) 0
|
|
380
|
+
|
|
381
|
+
.fade-up-enter-active, .fade-up-leave-active
|
|
382
|
+
transition all .25s ease
|
|
383
|
+
|
|
384
|
+
.fade-up-enter
|
|
385
|
+
opacity 0
|
|
386
|
+
transform translateY(6px)
|
|
387
|
+
|
|
388
|
+
&::-webkit-scrollbar
|
|
389
|
+
width 6px
|
|
390
|
+
height 6px
|
|
391
|
+
|
|
392
|
+
&::-webkit-scrollbar-track
|
|
393
|
+
background transparent
|
|
394
|
+
|
|
395
|
+
&::-webkit-scrollbar-thumb
|
|
396
|
+
background rgba(0,0,0,.25)
|
|
397
|
+
border-radius 6px
|
|
398
|
+
|
|
399
|
+
&::-webkit-scrollbar-thumb:hover
|
|
400
|
+
background rgba(0,0,0,.35)
|
|
401
|
+
|
|
402
|
+
/* Firefox */
|
|
403
|
+
scrollbar-width thin
|
|
404
|
+
scrollbar-color rgba(0,0,0,.25) transparent
|
|
405
|
+
</style>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// markdown-loader.js
|
|
2
|
+
let markedInstance = null;
|
|
3
|
+
let hljsInstance = null;
|
|
4
|
+
|
|
5
|
+
function transfromLang(lang) {
|
|
6
|
+
switch (lang) {
|
|
7
|
+
case 'uts':
|
|
8
|
+
return 'typescript';
|
|
9
|
+
case 'json5':
|
|
10
|
+
return 'json';
|
|
11
|
+
}
|
|
12
|
+
if (!hljsInstance) return 'plaintext';
|
|
13
|
+
return hljsInstance.getLanguage(lang) ? lang : 'plaintext';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function renderMarkdown(md) {
|
|
17
|
+
if (!markedInstance) {
|
|
18
|
+
const [{ Marked }, { markedHighlight }, hljs] = await Promise.all([
|
|
19
|
+
import('marked'),
|
|
20
|
+
import('marked-highlight'),
|
|
21
|
+
import('highlight.js'),
|
|
22
|
+
]);
|
|
23
|
+
|
|
24
|
+
const marked = new Marked(
|
|
25
|
+
markedHighlight({
|
|
26
|
+
emptyLangClass: 'hljs',
|
|
27
|
+
langPrefix: 'hljs language-',
|
|
28
|
+
highlight(code, lang, info) {
|
|
29
|
+
const language = transfromLang(lang);
|
|
30
|
+
return hljs.highlight(code, { language }).value;
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
marked.setOptions({
|
|
36
|
+
headerIds: false,
|
|
37
|
+
mangle: false,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
markedInstance = marked;
|
|
41
|
+
hljsInstance = hljs;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return markedInstance.parse(md || '');
|
|
45
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* Skeleton base style */
|
|
2
|
+
.skeleton
|
|
3
|
+
background: #eee
|
|
4
|
+
background-image: linear-gradient(
|
|
5
|
+
90deg,
|
|
6
|
+
#eee 0px,
|
|
7
|
+
#f5f5f5 40px,
|
|
8
|
+
#eee 80px
|
|
9
|
+
)
|
|
10
|
+
background-size: 200px 100%
|
|
11
|
+
animation: skeleton-loading 1.4s ease-in-out infinite
|
|
12
|
+
border-radius: 8px
|
|
13
|
+
|
|
14
|
+
/* 消息骨架 */
|
|
15
|
+
.chat-skeleton
|
|
16
|
+
display: flex
|
|
17
|
+
flex-direction: column
|
|
18
|
+
gap: 12px
|
|
19
|
+
padding: 12px 0
|
|
20
|
+
|
|
21
|
+
.chat-skeleton .line
|
|
22
|
+
height: 14px
|
|
23
|
+
width: 60%
|
|
24
|
+
border-radius: 6px
|
|
25
|
+
@extend .skeleton
|
|
26
|
+
|
|
27
|
+
.chat-skeleton .line.short
|
|
28
|
+
width: 40%
|
|
29
|
+
|
|
30
|
+
/* 左侧消息骨架(AI) */
|
|
31
|
+
.chat-skeleton-left
|
|
32
|
+
display: flex
|
|
33
|
+
flex-direction: row
|
|
34
|
+
gap: 10px
|
|
35
|
+
.content
|
|
36
|
+
flex: 1
|
|
37
|
+
display: flex
|
|
38
|
+
flex-direction: column
|
|
39
|
+
gap: 10px
|
|
@@ -200,4 +200,39 @@ $svg-hover-color = #9b9b9b
|
|
|
200
200
|
.search-result-aside
|
|
201
201
|
display none
|
|
202
202
|
.result-number
|
|
203
|
-
font-size 14px
|
|
203
|
+
font-size 14px
|
|
204
|
+
|
|
205
|
+
.tabs
|
|
206
|
+
display flex
|
|
207
|
+
position relative
|
|
208
|
+
width 100%
|
|
209
|
+
height 44px
|
|
210
|
+
background #fff
|
|
211
|
+
border-bottom 1px solid #e5e5e5
|
|
212
|
+
user-select none
|
|
213
|
+
justify-content: center
|
|
214
|
+
align-items: center
|
|
215
|
+
|
|
216
|
+
.tab
|
|
217
|
+
flex 1
|
|
218
|
+
display flex
|
|
219
|
+
justify-content center
|
|
220
|
+
align-items center
|
|
221
|
+
font-size 15px
|
|
222
|
+
color #666
|
|
223
|
+
cursor pointer
|
|
224
|
+
transition color .25s
|
|
225
|
+
|
|
226
|
+
.tab.active
|
|
227
|
+
color $accentColor
|
|
228
|
+
font-weight 600
|
|
229
|
+
|
|
230
|
+
.indicator
|
|
231
|
+
position absolute
|
|
232
|
+
bottom 0
|
|
233
|
+
left 0
|
|
234
|
+
width 50%
|
|
235
|
+
height 2px
|
|
236
|
+
background $accentColor
|
|
237
|
+
border-radius 2px
|
|
238
|
+
transition transform .25s ease
|
|
@@ -2,108 +2,126 @@
|
|
|
2
2
|
<transition name="fade">
|
|
3
3
|
<div v-if="openSearch" id="search-container" ref="pageContainer" @click.self="onSearchClose">
|
|
4
4
|
<!-- <div class="search-navbar">
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
<div class="search-navbar-header navbar">
|
|
6
|
+
<div class="main-navbar">
|
|
7
|
+
<NavbarLogo />
|
|
8
|
+
<div class="main-navbar-links can-hide">
|
|
9
|
+
<div class="main-navbar-item active"></div>
|
|
10
|
+
</div>
|
|
10
11
|
</div>
|
|
11
12
|
</div>
|
|
12
|
-
</div>
|
|
13
|
-
</div> -->
|
|
13
|
+
</div> -->
|
|
14
14
|
<div class="search-page-content">
|
|
15
|
-
<div class="
|
|
16
|
-
<div class="
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
<div v-if="enableAI" class="tabs">
|
|
16
|
+
<div class="tab" :class="{ active: !isAI }" @click="isAI = false">
|
|
17
|
+
搜索文档
|
|
18
|
+
</div>
|
|
19
|
+
<div class="divider" style="width: 1px;height: 80%; background-color: #ccc; margin: 0 10px;"></div>
|
|
20
|
+
<div class="tab" :class="{ active: isAI }" @click="isAI = true">
|
|
21
|
+
问 AI
|
|
22
|
+
</div>
|
|
23
|
+
<div class="indicator" :style="indicatorStyle"></div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div v-show="!isAI">
|
|
27
|
+
<div class="sub-navbar">
|
|
28
|
+
<div class="search-wrap">
|
|
29
|
+
<div class="input-wrap">
|
|
30
|
+
<input ref="searchInput" class="search-input" :placeholder="placeholder" type="text" @keydown.enter="
|
|
26
31
|
() => {
|
|
27
32
|
resetSearchPage();
|
|
28
33
|
search();
|
|
29
34
|
}
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
" v-model="searchValue" />
|
|
36
|
+
<span class="search-input-btn">
|
|
37
|
+
<button @click="
|
|
38
|
+
() => {
|
|
39
|
+
resetSearchPage();
|
|
40
|
+
search();
|
|
41
|
+
}
|
|
42
|
+
">
|
|
43
|
+
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
|
44
|
+
<path
|
|
45
|
+
d="M11.33 10.007l4.273 4.273a.502.502 0 0 1 .005.709l-.585.584a.499.499 0 0 1-.709-.004L10.046 11.3a6.278 6.278 0 1 1 1.284-1.294zm.012-3.729a5.063 5.063 0 1 0-10.127 0 5.063 5.063 0 0 0 10.127 0z">
|
|
46
|
+
</path>
|
|
47
|
+
</svg>
|
|
48
|
+
</button>
|
|
49
|
+
</span>
|
|
50
|
+
<a href="javascript:;" class="search-back__btn" @click="onSearchClose">
|
|
51
|
+
{{ buttonText }}
|
|
52
|
+
</a>
|
|
53
|
+
</div>
|
|
42
54
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
<div class="search-category">
|
|
56
|
+
<div class="navbar">
|
|
57
|
+
<div class="main-navbar">
|
|
58
|
+
<div class="main-navbar-links">
|
|
59
|
+
<template v-for="(item, index) in category">
|
|
60
|
+
<div :class="mainNavLinkClass(index)" :key="item.text">
|
|
61
|
+
<MainNavbarLink v-if="item.link" :key="item.text" :item="{
|
|
62
|
+
...item,
|
|
63
|
+
link: createLink(item),
|
|
64
|
+
}" />
|
|
65
|
+
<a v-else href="javascript:;" @click="switchCategory(index)">
|
|
66
|
+
{{ item.text }}
|
|
67
|
+
</a>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
</div>
|
|
58
71
|
</div>
|
|
59
72
|
</div>
|
|
60
73
|
</div>
|
|
61
74
|
</div>
|
|
62
75
|
</div>
|
|
63
|
-
</div>
|
|
64
76
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
<div class="result-number">
|
|
78
|
+
<span v-if="showLoading" class="uni-loading"></span>
|
|
79
|
+
<span v-else>{{ resultText }}</span>
|
|
80
|
+
</div>
|
|
69
81
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
82
|
+
<div class="search-result" ref="searchResult">
|
|
83
|
+
<div class="result-wrap">
|
|
84
|
+
<template v-if="isAlgolia">
|
|
85
|
+
<template v-for="item in resultList">
|
|
86
|
+
<Results :key="item.sourceId" :title="item.title" :results="item.items" :onSelect="item.onSelect" />
|
|
87
|
+
</template>
|
|
75
88
|
</template>
|
|
76
|
-
</template>
|
|
77
89
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
<template v-else>
|
|
91
|
+
<div class="markdown-section search-result-list" v-if="serverHtml" v-html="serverHtml"></div>
|
|
92
|
+
</template>
|
|
93
|
+
</div>
|
|
81
94
|
</div>
|
|
82
|
-
</div>
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
</a>
|
|
92
|
-
</div>
|
|
93
|
-
<div v-if="isAlgolia" class="algolia-logo">
|
|
94
|
-
<div class="DocSearch-Logo">
|
|
95
|
-
<a href="https://www.algolia.com/ref/docsearch/?utm_source=uniapp.dcloud.io&utm_medium=referral&utm_content=powered_by&utm_campaign=docsearch"
|
|
96
|
-
target="_blank" rel="noopener noreferrer">
|
|
97
|
-
<span class="DocSearch-Label">{{ searchBy }}</span>
|
|
98
|
-
<svg width="77" height="19" aria-label="Algolia" role="img">
|
|
99
|
-
<path
|
|
100
|
-
d="M2.5067 0h14.0245c1.384.001 2.5058 1.1205 2.5068 2.5017V16.5c-.0014 1.3808-1.1232 2.4995-2.5068 2.5H2.5067C1.1232 18.9995.0014 17.8808 0 16.5V2.4958A2.495 2.495 0 01.735.7294 2.505 2.505 0 012.5068 0zM37.95 15.0695c-3.7068.0168-3.7068-2.986-3.7068-3.4634L34.2372.3576 36.498 0v11.1794c0 .2715 0 1.9889 1.452 1.994v1.8961zm-9.1666-1.8388c.694 0 1.2086-.0397 1.5678-.1088v-2.2934a5.3639 5.3639 0 00-1.3303-.1679 4.8283 4.8283 0 00-.758.0582 2.2845 2.2845 0 00-.688.2024c-.2029.0979-.371.2362-.4919.4142-.1268.1788-.185.2826-.185.5533 0 .5297.185.8359.5205 1.0375.3355.2016.7928.3053 1.365.3053v-.0008zm-.1969-8.1817c.7463 0 1.3768.092 1.8856.2767.5088.1838.9195.4428 1.2204.7717.3068.334.5147.7777.6423 1.251.1327.4723.196.991.196 1.5603v5.798c-.5235.1036-1.05.192-1.5787.2649-.7048.1037-1.4976.156-2.3774.156-.5832 0-1.1215-.0582-1.6016-.167a3.385 3.385 0 01-1.2432-.5364 2.6034 2.6034 0 01-.8037-.9565c-.191-.3922-.29-.9447-.29-1.5208 0-.5533.11-.905.3246-1.2863a2.7351 2.7351 0 01.8849-.9329c.376-.242.8029-.415 1.2948-.5187a7.4517 7.4517 0 011.5381-.156 7.1162 7.1162 0 011.6667.2024V8.886c0-.259-.0296-.5061-.093-.7372a1.5847 1.5847 0 00-.3245-.6158 1.5079 1.5079 0 00-.6119-.4158 2.6788 2.6788 0 00-.966-.173c-.5206 0-.9948.0634-1.4283.1384a6.5481 6.5481 0 00-1.065.259l-.2712-1.849c.2831-.0986.7048-.1964 1.2491-.2943a9.2979 9.2979 0 011.752-.1501v.0008zm44.6597 8.1193c.6947 0 1.2086-.0405 1.567-.1097v-2.2942a5.3743 5.3743 0 00-1.3303-.1679c-.2485 0-.503.0177-.7573.0582a2.2853 2.2853 0 00-.688.2024 1.2333 1.2333 0 00-.4918.4142c-.1268.1788-.1843.2826-.1843.5533 0 .5297.1843.8359.5198 1.0375.3414.2066.7927.3053 1.365.3053v.0009zm-.191-8.1767c.7463 0 1.3768.0912 1.8856.2759.5087.1847.9195.4436 1.2204.7717.3.329.5147.7786.6414 1.251a5.7248 5.7248 0 01.197 1.562v5.7972c-.3466.0742-.874.1602-1.5788.2648-.7049.1038-1.4976.1552-2.3774.1552-.5832 0-1.1215-.0573-1.6016-.167a3.385 3.385 0 01-1.2432-.5356 2.6034 2.6034 0 01-.8038-.9565c-.191-.3922-.2898-.9447-.2898-1.5216 0-.5533.1098-.905.3245-1.2854a2.7373 2.7373 0 01.8849-.9338c.376-.2412.8029-.4141 1.2947-.5178a7.4545 7.4545 0 012.325-.1097c.2781.0287.5672.081.879.156v-.3686a2.7781 2.7781 0 00-.092-.738 1.5788 1.5788 0 00-.3246-.6166 1.5079 1.5079 0 00-.612-.415 2.6797 2.6797 0 00-.966-.1729c-.5205 0-.9947.0633-1.4282.1384a6.5608 6.5608 0 00-1.065.259l-.2712-1.8498c.283-.0979.7048-.1957 1.2491-.2935a9.8597 9.8597 0 011.752-.1494zm-6.79-1.072c-.7576.001-1.373-.6103-1.3759-1.3664 0-.755.6128-1.3664 1.376-1.3664.764 0 1.3775.6115 1.3775 1.3664s-.6195 1.3664-1.3776 1.3664zm1.1393 11.1507h-2.2726V5.3409l2.2734-.3568v10.0845l-.0008.0017zm-3.984 0c-3.707.0168-3.707-2.986-3.707-3.4642L59.7069.3576 61.9685 0v11.1794c0 .2715 0 1.9889 1.452 1.994V15.0703zm-7.3512-4.979c0-.975-.2138-1.7873-.6305-2.3516-.4167-.571-.9998-.852-1.747-.852-.7454 0-1.3302.281-1.7452.852-.4166.5702-.6195 1.3765-.6195 2.3516 0 .9851.208 1.6473.6254 2.2183.4158.576.9998.8587 1.7461.8587.7454 0 1.3303-.2885 1.747-.8595.4158-.5761.6237-1.2315.6237-2.2184v.0009zm2.3132-.006c0 .7609-.1099 1.3361-.3356 1.9654a4.654 4.654 0 01-.9533 1.6076A4.214 4.214 0 0155.613 14.69c-.579.2412-1.4697.3795-1.9143.3795-.4462-.005-1.3303-.1324-1.9033-.3795a4.307 4.307 0 01-1.474-1.0316c-.4115-.4445-.7293-.9801-.9609-1.6076a5.3423 5.3423 0 01-.3465-1.9653c0-.7608.104-1.493.3356-2.1155a4.683 4.683 0 01.9719-1.5958 4.3383 4.3383 0 011.479-1.0257c.5739-.242 1.2043-.3567 1.8864-.3567.6829 0 1.3125.1197 1.8906.3567a4.1245 4.1245 0 011.4816 1.0257 4.7587 4.7587 0 01.9592 1.5958c.2426.6225.3643 1.3547.3643 2.1155zm-17.0198 0c0 .9448.208 1.9932.6238 2.431.4166.4386.955.6579 1.6142.6579.3584 0 .6998-.0523 1.0176-.1502.3186-.0978.5721-.2134.775-.3517V7.0784a8.8706 8.8706 0 00-1.4926-.1906c-.8206-.0236-1.4452.312-1.8847.8468-.4335.5365-.6533 1.476-.6533 2.3516v-.0008zm6.2863 4.4485c0 1.5385-.3938 2.662-1.1866 3.3773-.791.7136-2.0005 1.0712-3.6308 1.0712-.5958 0-1.834-.1156-2.8228-.334l.3643-1.7865c.8282.173 1.9202.2193 2.4932.2193.9077 0 1.555-.1847 1.943-.5533.388-.3686.578-.916.578-1.643v-.3687a6.8289 6.8289 0 01-.8848.3349c-.3634.1096-.786.167-1.261.167-.6246 0-1.1917-.0979-1.7055-.2944a3.5554 3.5554 0 01-1.3244-.8645c-.3642-.3796-.6541-.8579-.8561-1.4289-.2028-.571-.3068-1.59-.3068-2.339 0-.7034.1099-1.5856.3245-2.1735.2198-.5871.5316-1.0949.9542-1.515.4167-.42.9255-.743 1.5213-.98a5.5923 5.5923 0 012.052-.3855c.7353 0 1.4114.092 2.0707.2024.6592.1088 1.2204.2236 1.6776.35v8.945-.0008zM11.5026 4.2418v-.6511c-.0005-.4553-.3704-.8241-.8266-.8241H8.749c-.4561 0-.826.3688-.8265.824v.669c0 .0742.0693.1264.1445.1096a6.0346 6.0346 0 011.6768-.2362 6.125 6.125 0 011.6202.2185.1116.1116 0 00.1386-.1097zm-5.2806.852l-.3296-.3282a.8266.8266 0 00-1.168 0l-.393.3922a.8199.8199 0 000 1.164l.3237.323c.0524.0515.1268.0397.1733-.0117.191-.259.3989-.507.6305-.7372.2374-.2362.48-.4437.7462-.6335.0575-.0354.0634-.1155.017-.1687zm3.5159 2.069v2.818c0 .081.0879.1392.1622.0987l2.5102-1.2964c.0574-.0287.0752-.0987.0464-.1552a3.1237 3.1237 0 00-2.603-1.574c-.0575 0-.115.0456-.115.1097l-.0008-.0009zm.0008 6.789c-2.0933.0005-3.7915-1.6912-3.7947-3.7804C5.9468 8.0821 7.6452 6.39 9.7387 6.391c2.0932-.0005 3.7911 1.6914 3.794 3.7804a3.7783 3.7783 0 01-1.1124 2.675 3.7936 3.7936 0 01-2.6824 1.1054h.0008zM9.738 4.8002c-1.9218 0-3.6975 1.0232-4.6584 2.6841a5.359 5.359 0 000 5.3683c.9609 1.661 2.7366 2.6841 4.6584 2.6841a5.3891 5.3891 0 003.8073-1.5725 5.3675 5.3675 0 001.578-3.7987 5.3574 5.3574 0 00-1.5771-3.797A5.379 5.379 0 009.7387 4.801l-.0008-.0008z"
|
|
101
|
-
fill="currentColor" fill-rule="evenodd"></path>
|
|
102
|
-
</svg>
|
|
96
|
+
<div class="search-footer">
|
|
97
|
+
<div class="search-pagination">
|
|
98
|
+
<pagination v-show="showPagination" @research="research" :totalPage="totalPage" :curPage="curPage"
|
|
99
|
+
:pageSize="pageSize" />
|
|
100
|
+
<a v-if="showMoreAsk" class="search-more" @click="moreAskResult">
|
|
101
|
+
<span v-if="showServerLoading" class="uni-loading"></span>
|
|
102
|
+
<span v-else>{{ hasNoMoreServerResult ? '没有更多了' : '更多...' }}</span>
|
|
103
103
|
</a>
|
|
104
104
|
</div>
|
|
105
|
+
<div v-if="isAlgolia" class="algolia-logo">
|
|
106
|
+
<div class="DocSearch-Logo">
|
|
107
|
+
<a href="https://www.algolia.com/ref/docsearch/?utm_source=uniapp.dcloud.io&utm_medium=referral&utm_content=powered_by&utm_campaign=docsearch"
|
|
108
|
+
target="_blank" rel="noopener noreferrer">
|
|
109
|
+
<span class="DocSearch-Label">{{ searchBy }}</span>
|
|
110
|
+
<svg width="77" height="19" aria-label="Algolia" role="img">
|
|
111
|
+
<path
|
|
112
|
+
d="M2.5067 0h14.0245c1.384.001 2.5058 1.1205 2.5068 2.5017V16.5c-.0014 1.3808-1.1232 2.4995-2.5068 2.5H2.5067C1.1232 18.9995.0014 17.8808 0 16.5V2.4958A2.495 2.495 0 01.735.7294 2.505 2.505 0 012.5068 0zM37.95 15.0695c-3.7068.0168-3.7068-2.986-3.7068-3.4634L34.2372.3576 36.498 0v11.1794c0 .2715 0 1.9889 1.452 1.994v1.8961zm-9.1666-1.8388c.694 0 1.2086-.0397 1.5678-.1088v-2.2934a5.3639 5.3639 0 00-1.3303-.1679 4.8283 4.8283 0 00-.758.0582 2.2845 2.2845 0 00-.688.2024c-.2029.0979-.371.2362-.4919.4142-.1268.1788-.185.2826-.185.5533 0 .5297.185.8359.5205 1.0375.3355.2016.7928.3053 1.365.3053v-.0008zm-.1969-8.1817c.7463 0 1.3768.092 1.8856.2767.5088.1838.9195.4428 1.2204.7717.3068.334.5147.7777.6423 1.251.1327.4723.196.991.196 1.5603v5.798c-.5235.1036-1.05.192-1.5787.2649-.7048.1037-1.4976.156-2.3774.156-.5832 0-1.1215-.0582-1.6016-.167a3.385 3.385 0 01-1.2432-.5364 2.6034 2.6034 0 01-.8037-.9565c-.191-.3922-.29-.9447-.29-1.5208 0-.5533.11-.905.3246-1.2863a2.7351 2.7351 0 01.8849-.9329c.376-.242.8029-.415 1.2948-.5187a7.4517 7.4517 0 011.5381-.156 7.1162 7.1162 0 011.6667.2024V8.886c0-.259-.0296-.5061-.093-.7372a1.5847 1.5847 0 00-.3245-.6158 1.5079 1.5079 0 00-.6119-.4158 2.6788 2.6788 0 00-.966-.173c-.5206 0-.9948.0634-1.4283.1384a6.5481 6.5481 0 00-1.065.259l-.2712-1.849c.2831-.0986.7048-.1964 1.2491-.2943a9.2979 9.2979 0 011.752-.1501v.0008zm44.6597 8.1193c.6947 0 1.2086-.0405 1.567-.1097v-2.2942a5.3743 5.3743 0 00-1.3303-.1679c-.2485 0-.503.0177-.7573.0582a2.2853 2.2853 0 00-.688.2024 1.2333 1.2333 0 00-.4918.4142c-.1268.1788-.1843.2826-.1843.5533 0 .5297.1843.8359.5198 1.0375.3414.2066.7927.3053 1.365.3053v.0009zm-.191-8.1767c.7463 0 1.3768.0912 1.8856.2759.5087.1847.9195.4436 1.2204.7717.3.329.5147.7786.6414 1.251a5.7248 5.7248 0 01.197 1.562v5.7972c-.3466.0742-.874.1602-1.5788.2648-.7049.1038-1.4976.1552-2.3774.1552-.5832 0-1.1215-.0573-1.6016-.167a3.385 3.385 0 01-1.2432-.5356 2.6034 2.6034 0 01-.8038-.9565c-.191-.3922-.2898-.9447-.2898-1.5216 0-.5533.1098-.905.3245-1.2854a2.7373 2.7373 0 01.8849-.9338c.376-.2412.8029-.4141 1.2947-.5178a7.4545 7.4545 0 012.325-.1097c.2781.0287.5672.081.879.156v-.3686a2.7781 2.7781 0 00-.092-.738 1.5788 1.5788 0 00-.3246-.6166 1.5079 1.5079 0 00-.612-.415 2.6797 2.6797 0 00-.966-.1729c-.5205 0-.9947.0633-1.4282.1384a6.5608 6.5608 0 00-1.065.259l-.2712-1.8498c.283-.0979.7048-.1957 1.2491-.2935a9.8597 9.8597 0 011.752-.1494zm-6.79-1.072c-.7576.001-1.373-.6103-1.3759-1.3664 0-.755.6128-1.3664 1.376-1.3664.764 0 1.3775.6115 1.3775 1.3664s-.6195 1.3664-1.3776 1.3664zm1.1393 11.1507h-2.2726V5.3409l2.2734-.3568v10.0845l-.0008.0017zm-3.984 0c-3.707.0168-3.707-2.986-3.707-3.4642L59.7069.3576 61.9685 0v11.1794c0 .2715 0 1.9889 1.452 1.994V15.0703zm-7.3512-4.979c0-.975-.2138-1.7873-.6305-2.3516-.4167-.571-.9998-.852-1.747-.852-.7454 0-1.3302.281-1.7452.852-.4166.5702-.6195 1.3765-.6195 2.3516 0 .9851.208 1.6473.6254 2.2183.4158.576.9998.8587 1.7461.8587.7454 0 1.3303-.2885 1.747-.8595.4158-.5761.6237-1.2315.6237-2.2184v.0009zm2.3132-.006c0 .7609-.1099 1.3361-.3356 1.9654a4.654 4.654 0 01-.9533 1.6076A4.214 4.214 0 0155.613 14.69c-.579.2412-1.4697.3795-1.9143.3795-.4462-.005-1.3303-.1324-1.9033-.3795a4.307 4.307 0 01-1.474-1.0316c-.4115-.4445-.7293-.9801-.9609-1.6076a5.3423 5.3423 0 01-.3465-1.9653c0-.7608.104-1.493.3356-2.1155a4.683 4.683 0 01.9719-1.5958 4.3383 4.3383 0 011.479-1.0257c.5739-.242 1.2043-.3567 1.8864-.3567.6829 0 1.3125.1197 1.8906.3567a4.1245 4.1245 0 011.4816 1.0257 4.7587 4.7587 0 01.9592 1.5958c.2426.6225.3643 1.3547.3643 2.1155zm-17.0198 0c0 .9448.208 1.9932.6238 2.431.4166.4386.955.6579 1.6142.6579.3584 0 .6998-.0523 1.0176-.1502.3186-.0978.5721-.2134.775-.3517V7.0784a8.8706 8.8706 0 00-1.4926-.1906c-.8206-.0236-1.4452.312-1.8847.8468-.4335.5365-.6533 1.476-.6533 2.3516v-.0008zm6.2863 4.4485c0 1.5385-.3938 2.662-1.1866 3.3773-.791.7136-2.0005 1.0712-3.6308 1.0712-.5958 0-1.834-.1156-2.8228-.334l.3643-1.7865c.8282.173 1.9202.2193 2.4932.2193.9077 0 1.555-.1847 1.943-.5533.388-.3686.578-.916.578-1.643v-.3687a6.8289 6.8289 0 01-.8848.3349c-.3634.1096-.786.167-1.261.167-.6246 0-1.1917-.0979-1.7055-.2944a3.5554 3.5554 0 01-1.3244-.8645c-.3642-.3796-.6541-.8579-.8561-1.4289-.2028-.571-.3068-1.59-.3068-2.339 0-.7034.1099-1.5856.3245-2.1735.2198-.5871.5316-1.0949.9542-1.515.4167-.42.9255-.743 1.5213-.98a5.5923 5.5923 0 012.052-.3855c.7353 0 1.4114.092 2.0707.2024.6592.1088 1.2204.2236 1.6776.35v8.945-.0008zM11.5026 4.2418v-.6511c-.0005-.4553-.3704-.8241-.8266-.8241H8.749c-.4561 0-.826.3688-.8265.824v.669c0 .0742.0693.1264.1445.1096a6.0346 6.0346 0 011.6768-.2362 6.125 6.125 0 011.6202.2185.1116.1116 0 00.1386-.1097zm-5.2806.852l-.3296-.3282a.8266.8266 0 00-1.168 0l-.393.3922a.8199.8199 0 000 1.164l.3237.323c.0524.0515.1268.0397.1733-.0117.191-.259.3989-.507.6305-.7372.2374-.2362.48-.4437.7462-.6335.0575-.0354.0634-.1155.017-.1687zm3.5159 2.069v2.818c0 .081.0879.1392.1622.0987l2.5102-1.2964c.0574-.0287.0752-.0987.0464-.1552a3.1237 3.1237 0 00-2.603-1.574c-.0575 0-.115.0456-.115.1097l-.0008-.0009zm.0008 6.789c-2.0933.0005-3.7915-1.6912-3.7947-3.7804C5.9468 8.0821 7.6452 6.39 9.7387 6.391c2.0932-.0005 3.7911 1.6914 3.794 3.7804a3.7783 3.7783 0 01-1.1124 2.675 3.7936 3.7936 0 01-2.6824 1.1054h.0008zM9.738 4.8002c-1.9218 0-3.6975 1.0232-4.6584 2.6841a5.359 5.359 0 000 5.3683c.9609 1.661 2.7366 2.6841 4.6584 2.6841a5.3891 5.3891 0 003.8073-1.5725 5.3675 5.3675 0 001.578-3.7987 5.3574 5.3574 0 00-1.5771-3.797A5.379 5.379 0 009.7387 4.801l-.0008-.0008z"
|
|
113
|
+
fill="currentColor" fill-rule="evenodd"></path>
|
|
114
|
+
</svg>
|
|
115
|
+
</a>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
105
118
|
</div>
|
|
106
119
|
</div>
|
|
120
|
+
|
|
121
|
+
<!-- AI 界面 -->
|
|
122
|
+
<div v-show="isAI" class="search-ai-content">
|
|
123
|
+
<AIChat :visible="isAI" :currentCategory="currentCategory.text" />
|
|
124
|
+
</div>
|
|
107
125
|
</div>
|
|
108
126
|
</div>
|
|
109
127
|
</transition>
|
|
@@ -113,6 +131,7 @@
|
|
|
113
131
|
import NavbarLogo from '../NavbarLogo.vue';
|
|
114
132
|
import Results from './components/Results.vue';
|
|
115
133
|
import pagination from './components/pagination.vue';
|
|
134
|
+
import AIChat from './components/AIChat/index.vue';
|
|
116
135
|
import MainNavbarLink from '../MainNavbarLink.vue';
|
|
117
136
|
import { search as searchClient } from './utils/searchClient';
|
|
118
137
|
import { postExt, postAsk } from './utils/postDcloudServer';
|
|
@@ -122,6 +141,7 @@ import searchPageConfig from '@theme-config/searchPage';
|
|
|
122
141
|
import Base64 from './utils/Base64';
|
|
123
142
|
|
|
124
143
|
const {
|
|
144
|
+
enableAI = true,
|
|
125
145
|
category,
|
|
126
146
|
translations: {
|
|
127
147
|
searchBox: { placeholder, buttonText, searchBy },
|
|
@@ -145,10 +165,12 @@ export default {
|
|
|
145
165
|
|
|
146
166
|
props: ['options'],
|
|
147
167
|
|
|
148
|
-
components: { NavbarLogo, Results, pagination, MainNavbarLink },
|
|
168
|
+
components: { NavbarLogo, Results, pagination, MainNavbarLink, AIChat },
|
|
149
169
|
|
|
150
170
|
data() {
|
|
151
171
|
return {
|
|
172
|
+
enableAI: enableAI,
|
|
173
|
+
isAI: enableAI && false,
|
|
152
174
|
openSearch: false,
|
|
153
175
|
placeholder,
|
|
154
176
|
buttonText,
|
|
@@ -195,6 +217,13 @@ export default {
|
|
|
195
217
|
? resultsText.replace('${resultHits}', this.curHits)
|
|
196
218
|
: askNoResultsText.replace('${categoryText}', this.currentCategory.text);
|
|
197
219
|
},
|
|
220
|
+
indicatorStyle() {
|
|
221
|
+
return {
|
|
222
|
+
transform: this.isAI
|
|
223
|
+
? 'translateX(100%)'
|
|
224
|
+
: 'translateX(0%)'
|
|
225
|
+
}
|
|
226
|
+
}
|
|
198
227
|
},
|
|
199
228
|
|
|
200
229
|
mounted() {
|
|
@@ -275,7 +304,7 @@ export default {
|
|
|
275
304
|
const searchPagination = 36 + 20; // pagination height + margin
|
|
276
305
|
|
|
277
306
|
if (searchResult) {
|
|
278
|
-
|
|
307
|
+
let height =
|
|
279
308
|
pageHeight -
|
|
280
309
|
searchNavbarHeight -
|
|
281
310
|
resultNumberHeight -
|
|
@@ -283,7 +312,11 @@ export default {
|
|
|
283
312
|
algoliaLogoHeight -
|
|
284
313
|
// 多余空间 mobile
|
|
285
314
|
20 -
|
|
286
|
-
60
|
|
315
|
+
60
|
|
316
|
+
if (this.isAI) {
|
|
317
|
+
height = height - 200
|
|
318
|
+
}
|
|
319
|
+
searchResult.style.height = height + 'px';;
|
|
287
320
|
}
|
|
288
321
|
},
|
|
289
322
|
|
|
@@ -2,17 +2,26 @@ const isProduction = process.env.NODE_ENV === "production"
|
|
|
2
2
|
const isMock = false
|
|
3
3
|
import mock from './mock'
|
|
4
4
|
|
|
5
|
-
function ajax(url = '', method = 'get',) {
|
|
5
|
+
export function ajax(url = '', method = 'get', data = {}) {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
7
|
if (!url) reject('url 不可为空')
|
|
8
8
|
const xhr = new XMLHttpRequest();
|
|
9
9
|
xhr.open(method, url);
|
|
10
10
|
xhr.onreadystatechange = function () {
|
|
11
11
|
if (this.readyState == 4 && this.status == 200) {
|
|
12
|
-
|
|
12
|
+
try {
|
|
13
|
+
resolve(JSON.parse(this.response))
|
|
14
|
+
} catch (error) {
|
|
15
|
+
resolve(this.response)
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
|
-
|
|
19
|
+
if (method.toLowerCase() === 'post') {
|
|
20
|
+
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
|
|
21
|
+
xhr.send(JSON.stringify(data));
|
|
22
|
+
} else {
|
|
23
|
+
xhr.send();
|
|
24
|
+
}
|
|
16
25
|
})
|
|
17
26
|
}
|
|
18
27
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuepress-theme-uniapp-official",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "uni-app official website theme for vuepress",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -35,9 +35,12 @@
|
|
|
35
35
|
"@vuepress/plugin-back-to-top": "^1.9.5",
|
|
36
36
|
"algoliasearch": "^4.13.1",
|
|
37
37
|
"clipboard": "^2.0.11",
|
|
38
|
+
"highlight.js": "^11.11.1",
|
|
38
39
|
"markdown-it-attrs": "^4.1.6",
|
|
39
40
|
"markdown-it-raw-table": "^1.0.0",
|
|
40
41
|
"markdown-it-task-lists": "^2.1.1",
|
|
42
|
+
"marked": "^5.1.2",
|
|
43
|
+
"marked-highlight": "^2.2.3",
|
|
41
44
|
"qr-code-with-logo": "^1.1.0",
|
|
42
45
|
"vuepress-plugin-juejin-style-copy": "^1.0.4",
|
|
43
46
|
"vuepress-plugin-mermaidjs": "1.9.1",
|