vuepress-theme-uniapp-official 1.6.5 → 1.6.7

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.
@@ -57,13 +57,13 @@
57
57
 
58
58
  <script setup>
59
59
  import { ref, nextTick, watchEffect, onMounted, computed } from 'vue'
60
- import { renderMarkdown } from "./markdown-loader";
61
60
  import searchPageConfig from '@theme-config/searchPage';
61
+ import { renderMarkdown } from "./markdown-loader";
62
62
  import { MAX_AI_ANSWER_LENGTH } from '../constants';
63
+ import { ajax } from '../utils/postDcloudServer';
63
64
  import SelectPlatform from '../components/SelectPlatform.vue';
64
65
  import LikeButton from '../components/LikeButton.vue';
65
66
  import Skeleton from '../components/Skeleton.vue';
66
- import { ajax } from '../utils/postDcloudServer';
67
67
 
68
68
  const { aiPlatforms = [], aiChatForDocSearch = 'https://ai-assist-api.dcloud.net.cn/tbox/chatForDocSearch' } = searchPageConfig;
69
69
 
@@ -287,6 +287,8 @@ window.addEventListener('resize', scrollToBottom)
287
287
  </script>
288
288
 
289
289
  <style lang="stylus">
290
+ @import '../ai-answer-style-reset.styl'
291
+
290
292
  .__backdrop-filter__
291
293
  backdrop-filter blur(15px)
292
294
  .__not-support-backdrop-filter__
@@ -309,7 +311,7 @@ window.addEventListener('resize', scrollToBottom)
309
311
  border-bottom 1px solid #eee */
310
312
 
311
313
  .title
312
- margin-top 30px
314
+ margin 30px auto
313
315
  text-align center
314
316
  font-size 30px
315
317
  font-weight 600
@@ -352,27 +354,13 @@ window.addEventListener('resize', scrollToBottom)
352
354
  .bubble
353
355
  display inline-block
354
356
  max-width 50%
355
- padding 10px 14px
357
+ padding 0 14px
356
358
  border-radius 14px
357
359
  line-height 1.5
358
360
  font-size 15px
359
361
  word-break break-word
360
362
  box-shadow 0 1px 3px rgba(0,0,0,0.08)
361
- pre
362
- margin: 0
363
- padding: 5px
364
- border-radius 10px
365
- & + pre
366
- margin-top 8px
367
- pre, code
368
- white-space: pre-wrap; /* 允许换行 */
369
- word-wrap: break-word; /* 允许长行断开 */
370
- word-break: break-word;
371
- h1, h2, h3, h4, h5, h6, p, ul, ol, dl, figure, blockquote
372
- margin: 0
373
- padding: 0
374
- ul, ol
375
- list-style: none
363
+ @extend .ai-answer-style-reset
376
364
 
377
365
  .meta
378
366
  font-size 12px
@@ -1,10 +1,10 @@
1
1
  // markdown-loader.js
2
2
  let markedInstance = null;
3
3
 
4
- // `1.` 转义为 `1、`,防止 marked 解析失败
4
+ // 防止 ``` 和上一行之前没有空行 marked 解析失败
5
5
  function escapeMD(str) {
6
6
  return str
7
- .replace(/(\s*\b)(\d+)\./g, '$1$2、')
7
+ .replace(/\n(```)/g, '\n\n$1')
8
8
  }
9
9
 
10
10
  function getLangCodeFromExtension(extension) {
@@ -0,0 +1,21 @@
1
+ .ai-answer-style-reset
2
+ pre
3
+ margin 0
4
+ padding 6px 8px
5
+ border-radius 10px
6
+ background #f6f8fa
7
+
8
+ & + pre
9
+ margin-top 8px
10
+
11
+ code
12
+ font-size 14px
13
+ color #24292e
14
+
15
+ pre, code
16
+ white-space pre-wrap
17
+ word-break break-word
18
+ word-break break-word
19
+
20
+ p+p
21
+ margin-top 8px
@@ -65,6 +65,8 @@ function dislike() {
65
65
  </script>
66
66
 
67
67
  <style lang="stylus">
68
+ @import '../ai-answer-style-reset.styl'
69
+
68
70
  .ai-answer-card
69
71
  padding 14px 16px
70
72
  margin-top 12px
@@ -101,27 +103,7 @@ function dislike() {
101
103
  animation fadeIn .25s ease
102
104
 
103
105
  /* --- reset 内容区 --- */
104
- pre
105
- margin 0
106
- padding 6px 8px
107
- border-radius 10px
108
- background #f6f8fa
109
- white-space pre-wrap
110
- word-break break-word
111
-
112
- & + pre
113
- margin-top 8px
114
-
115
- code
116
- white-space pre-wrap
117
- word-break break-word
118
-
119
- h1, h2, h3, h4, h5, h6, p, ul, ol, dl, figure, blockquote
120
- margin 0
121
- padding 0
122
-
123
- ul, ol
124
- list-style none
106
+ @extend .ai-answer-style-reset
125
107
 
126
108
  @keyframes fadeIn
127
109
  from
@@ -42,12 +42,6 @@ $svg-hover-color = #9b9b9b
42
42
  overflow-x: hidden;
43
43
  background-color: $search-container-color
44
44
 
45
- .result-wrap
46
- ul
47
- list-style none
48
- margin 0
49
- padding 0
50
-
51
45
  .algolia-logo
52
46
  display flex
53
47
  justify-content center
@@ -245,7 +245,11 @@ export default {
245
245
  }
246
246
  },
247
247
  showAIMessage() {
248
- return this.searchValue.trim().length >= MAX_AI_ANSWER_LENGTH || this.aiMessage.msg.trim().length > 0
248
+ const searchText = this.searchValue.trim()
249
+ const hasAIMessageHistory = this.aiMessage.msg.trim().length > 0
250
+ const wordLimitExceeded = searchText.length >= MAX_AI_ANSWER_LENGTH
251
+ const hasChineseCharacters = /[\u4e00-\u9fa5]/.test(searchText)
252
+ return this.enableAI && ((wordLimitExceeded && hasChineseCharacters) || hasAIMessageHistory)
249
253
  }
250
254
  },
251
255
 
@@ -356,7 +360,7 @@ export default {
356
360
  }
357
361
  this.aiMessage.msg = ''
358
362
  this.searchAIResult = null
359
- if (this.enableAI && this.searchValue.trim().length) {
363
+ if (this.showAIMessage) {
360
364
  this.searchByAI()
361
365
  }
362
366
  },
@@ -389,7 +393,7 @@ export default {
389
393
  this.totalPage = nbPages;
390
394
  this.curPage = page + 1;
391
395
 
392
- if (this.enableAI && this.curPage === 1 && this.showAIMessage) {
396
+ if (this.curPage === 1 && this.showAIMessage) {
393
397
  this.resultList.splice(1, 0, this.aiMessage);
394
398
  }
395
399
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuepress-theme-uniapp-official",
3
- "version": "1.6.5",
3
+ "version": "1.6.7",
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-noscript-code": "^1.0.2",
49
48
  "vuepress-plugin-expandable-row": "^1.0.10",
50
- "vuepress-plugin-check-md2": "^1.0.5"
49
+ "vuepress-plugin-check-md2": "^1.0.5",
50
+ "vuepress-plugin-noscript-code": "^1.0.2"
51
51
  },
52
52
  "resolutions": {
53
53
  "terser-webpack-plugin": "1.4.6",