vuepress-theme-uniapp-official 1.6.9 → 1.6.10
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.
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
import { ref, nextTick, watchEffect, onMounted, computed } from 'vue'
|
|
60
60
|
import searchPageConfig from '@theme-config/searchPage';
|
|
61
61
|
import { renderMarkdown } from "./markdown-loader";
|
|
62
|
-
import { MAX_AI_ANSWER_LENGTH } from '../constants';
|
|
62
|
+
import { MAX_AI_ANSWER_LENGTH, AI_CHAT_FOR_DOC_SEARCH_URL } from '../constants';
|
|
63
63
|
import { ajax } from '../utils/postDcloudServer';
|
|
64
64
|
import SelectPlatform from '../components/SelectPlatform.vue';
|
|
65
65
|
import LikeButton from '../components/LikeButton.vue';
|
|
66
66
|
import Skeleton from '../components/Skeleton.vue';
|
|
67
67
|
|
|
68
|
-
const { aiPlatforms = [], aiChatForDocSearch =
|
|
68
|
+
const { aiPlatforms = [], aiChatForDocSearch = AI_CHAT_FOR_DOC_SEARCH_URL } = searchPageConfig;
|
|
69
69
|
|
|
70
70
|
const props = defineProps({
|
|
71
71
|
currentCategory: {
|
|
@@ -92,7 +92,8 @@ const footer = ref(null)
|
|
|
92
92
|
const hasMessage = computed(() => messages.value.length > 0)
|
|
93
93
|
const inputError = computed(() => {
|
|
94
94
|
const inputTextTrimmed = inputText.value.trim();
|
|
95
|
-
|
|
95
|
+
if (inputTextTrimmed.length === 0) return false
|
|
96
|
+
return inputTextTrimmed.length < MAX_AI_ANSWER_LENGTH || !/[\u4e00-\u9fa5]/.test(inputTextTrimmed);
|
|
96
97
|
})
|
|
97
98
|
|
|
98
99
|
const notSupportBackdrop = ref(false);
|
|
@@ -202,7 +203,7 @@ function platformChange(newPlatform) {
|
|
|
202
203
|
|
|
203
204
|
// 限制只取最近 6 条消息
|
|
204
205
|
function getChatHistory() {
|
|
205
|
-
return messages.value.slice(-
|
|
206
|
+
return messages.value.slice(-5).map(m => ({
|
|
206
207
|
role: m.role,
|
|
207
208
|
contentType: 'text',
|
|
208
209
|
content: m.raw
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export const DEFAULT_ENABLE_AI = true; // 默认启用 AI 助手
|
|
2
|
-
export const MAX_AI_ANSWER_LENGTH = 6; // AI 消息最小长度
|
|
2
|
+
export const MAX_AI_ANSWER_LENGTH = 6; // AI 消息最小长度
|
|
3
|
+
export const AI_CHAT_FOR_DOC_SEARCH_URL = 'https://ai-assist-api-p.dcloud.net.cn/http/tbox/chatForDocSearch'
|
|
4
|
+
export const AI_ERROR_MSG = '很抱歉,AI 助手未能找到相关答案。请尝试更换关键词进行搜索。'
|
|
@@ -148,7 +148,7 @@ import { removeHighlightTags, isEditingContent } from './utils/searchUtils';
|
|
|
148
148
|
import Base64 from './utils/Base64';
|
|
149
149
|
import { ajax } from './utils/postDcloudServer';
|
|
150
150
|
import { renderMarkdown } from "./AIChat/markdown-loader";
|
|
151
|
-
import { DEFAULT_ENABLE_AI, MAX_AI_ANSWER_LENGTH } from './constants';
|
|
151
|
+
import { DEFAULT_ENABLE_AI, MAX_AI_ANSWER_LENGTH, AI_CHAT_FOR_DOC_SEARCH_URL, AI_ERROR_MSG } from './constants';
|
|
152
152
|
import 'highlight.js/styles/github.min.css'
|
|
153
153
|
|
|
154
154
|
const {
|
|
@@ -159,10 +159,9 @@ const {
|
|
|
159
159
|
resultsScreen: { resultsText, noResultsText, askNoResultsText },
|
|
160
160
|
},
|
|
161
161
|
extraFacetFilters = [],
|
|
162
|
-
aiChatForDocSearch =
|
|
162
|
+
aiChatForDocSearch = AI_CHAT_FOR_DOC_SEARCH_URL
|
|
163
163
|
} = searchPageConfig;
|
|
164
164
|
const crawlerUrl = 'https://zh.uniapp.dcloud.io/'
|
|
165
|
-
const AIErrorMsg = '很抱歉,AI 助手未能找到相关答案。请尝试更换关键词进行搜索。'
|
|
166
165
|
|
|
167
166
|
const resolveRoutePathFromUrl = (url, base = '/') => {
|
|
168
167
|
if (url.indexOf(crawlerUrl) === 0) {
|
|
@@ -452,7 +451,7 @@ export default {
|
|
|
452
451
|
if (res.errorCode === 0) {
|
|
453
452
|
return renderMarkdown(res.chunk)
|
|
454
453
|
} else {
|
|
455
|
-
this.aiMessage.msg = res.errorMsg ||
|
|
454
|
+
this.aiMessage.msg = res.errorMsg || AI_ERROR_MSG;
|
|
456
455
|
return ''
|
|
457
456
|
}
|
|
458
457
|
})
|
|
@@ -461,11 +460,11 @@ export default {
|
|
|
461
460
|
return ''
|
|
462
461
|
})
|
|
463
462
|
.then(msg => {
|
|
464
|
-
this.aiMessage.msg = msg ||
|
|
463
|
+
this.aiMessage.msg = msg || AI_ERROR_MSG;
|
|
465
464
|
})
|
|
466
465
|
} catch (err) {
|
|
467
466
|
console.log('err :>> ', err);
|
|
468
|
-
this.aiMessage.msg = err.message ||
|
|
467
|
+
this.aiMessage.msg = err.message || AI_ERROR_MSG;
|
|
469
468
|
return ''
|
|
470
469
|
}
|
|
471
470
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuepress-theme-uniapp-official",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.10",
|
|
4
4
|
"description": "uni-app official website theme for vuepress",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"vuepress-plugin-mermaidjs": "1.9.1",
|
|
46
46
|
"vuepress-plugin-named-chunks": "^1.1.4",
|
|
47
47
|
"vuepress-plugin-zooming": "^1.1.8",
|
|
48
|
-
"vuepress-plugin-check-md2": "^1.0.5",
|
|
49
48
|
"vuepress-plugin-expandable-row": "^1.0.10",
|
|
50
|
-
"vuepress-plugin-noscript-code": "^1.0.2"
|
|
49
|
+
"vuepress-plugin-noscript-code": "^1.0.2",
|
|
50
|
+
"vuepress-plugin-check-md2": "^1.0.5"
|
|
51
51
|
},
|
|
52
52
|
"resolutions": {
|
|
53
53
|
"terser-webpack-plugin": "1.4.6",
|