vuepress-theme-uniapp-official 1.4.14 → 1.4.16

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.
@@ -0,0 +1,12 @@
1
+ interface Header {
2
+ title: string
3
+ width?: number
4
+ align?: 'left' | 'center' | 'right'
5
+ }
6
+
7
+ type Row = string[]
8
+
9
+ export interface MdTableOptions {
10
+ rows: Row[]
11
+ headers: Header[]
12
+ }
@@ -0,0 +1,47 @@
1
+ <script setup>
2
+ import { ref, defineProps } from 'vue'
3
+ import Popover from './Popover.vue'
4
+
5
+ const props = defineProps({
6
+ table: String
7
+ })
8
+
9
+ /** @type {MdTableOptions} */
10
+ const TABLE_OPTIONS = JSON.parse(props.table.replace(/\\/g, ''))
11
+
12
+ const resolveTableCelContent = (content) => {
13
+ if (/~~.+~~/.test(content)) {
14
+ return `<s>${content}</s>`
15
+ }
16
+ return content
17
+ }
18
+ </script>
19
+
20
+ <template>
21
+ <Popover>
22
+ <table>
23
+ <thead>
24
+ <tr>
25
+ <th v-for="header in TABLE_OPTIONS.headers" :style="header.align ? { textAlign: header.align } : ''"
26
+ :key="header.title">
27
+ {{ header.title }}
28
+ </th>
29
+ </tr>
30
+ </thead>
31
+ <tbody>
32
+ <tr v-for="(row, rowIndex) in TABLE_OPTIONS.rows">
33
+ <td v-for="(cel, celIndex) in row" :key="celIndex"
34
+ :style="TABLE_OPTIONS.headers[rowIndex].align ? { textAlign: TABLE_OPTIONS.headers[rowIndex].align } : ''">
35
+ <span v-html="resolveTableCelContent(cel)" />
36
+ </td>
37
+ </tr>
38
+ </tbody>
39
+ </table>
40
+ </Popover>
41
+ </template>
42
+
43
+ <style lang="stylus" scoped>
44
+ table {
45
+ margin: 0;
46
+ }
47
+ </style>
@@ -0,0 +1,143 @@
1
+ <script setup>
2
+ import { ref } from 'vue'
3
+ import { getNavbarHeight } from '../helper'
4
+
5
+ const props = defineProps({
6
+ table: String
7
+ })
8
+
9
+ const infoHover = ref(false)
10
+ let iconMouseOptions = {}
11
+
12
+ const iconMouseEnter = (e) => {
13
+ const { top, left, bottom, right, height, width } = e.target.getBoundingClientRect()
14
+ iconMouseOptions = {
15
+ top,
16
+ left,
17
+ bottom,
18
+ right,
19
+ height,
20
+ width
21
+ }
22
+ infoHover.value = true
23
+ }
24
+
25
+ const iconMouseLeave = (e) => {
26
+ infoHover.value = false
27
+ }
28
+
29
+ const vPopover = {
30
+ inserted(el, binding, vnode, prevVnode) {
31
+ const ThemeDefaultContent = document.querySelector('.theme-default-content')
32
+ if (ThemeDefaultContent) {
33
+ ThemeDefaultContent.appendChild(el)
34
+ }
35
+ },
36
+ componentUpdated(el, binding, vnode, prevVnode) {
37
+ const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
38
+ const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
39
+ const screenWidth = document.documentElement.clientWidth
40
+
41
+ const { width, height } = el.getBoundingClientRect()
42
+ const { left: targetLeft, top: targetTop, bottom: targetBottom, right: targetRight, height: targetHeight, width: targetWidth } = iconMouseOptions
43
+ const OFFSET = 10
44
+ const NAVBAR_HEIGHT = getNavbarHeight()
45
+
46
+ // 默认 icon 正中间位置
47
+ const HALF_WIDTH = width / 2
48
+ const HALF_TARGET_WIDTH = targetWidth / 2
49
+ const TOP = height // + OFFSET
50
+ const LEFT = HALF_TARGET_WIDTH - HALF_WIDTH
51
+
52
+ const DEFAULT_TOP = targetTop + scrollTop
53
+ const DEFAULT_LEFT = targetLeft + scrollLeft
54
+
55
+ let currentTop = DEFAULT_TOP - TOP
56
+ let currentLeft = DEFAULT_LEFT + LEFT
57
+
58
+ if (targetTop - NAVBAR_HEIGHT - TOP - OFFSET > 0) {
59
+ // 上方空间够
60
+ currentTop = currentTop - OFFSET
61
+ } else {
62
+ // 上方空间不够
63
+ currentTop = currentTop + (height + targetHeight) + OFFSET
64
+ }
65
+
66
+ const RIGHT_OFFSET = (screenWidth - (targetLeft + HALF_TARGET_WIDTH)) - HALF_WIDTH
67
+ // const LEFT_OFFSET = (screenWidth - targetLeft - HALF_TARGET_WIDTH) - HALF_WIDTH
68
+
69
+ if (RIGHT_OFFSET < 0) {
70
+ // 右侧空间不够
71
+ currentLeft = screenWidth - width
72
+ }
73
+ el.style.top = `${currentTop < 0 ? 0 : currentTop}px`
74
+ el.style.left = `${currentLeft < 0 ? 0 : currentLeft}px`
75
+ }
76
+ }
77
+ </script>
78
+
79
+ <template>
80
+ <div class="popover-container">
81
+ <i class="info" :class="{ 'info-hover': infoHover }" @mouseenter="iconMouseEnter" @mouseleave="iconMouseLeave">
82
+ <svg t="1715917545486" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
83
+ p-id="10306">
84
+ <path
85
+ d="M512 958.016C266.08 958.016 65.984 757.952 65.984 512 65.984 266.08 266.08 65.984 512 65.984c245.952 0 446.016 200.064 446.016 446.016 0 245.952-200.064 446.016-446.016 446.016z m0-828.032c-210.656 0-382.016 171.36-382.016 382.016 0 210.624 171.36 382.016 382.016 382.016 210.624 0 382.016-171.36 382.016-382.016S722.624 129.984 512 129.984z"
86
+ p-id="10307" fill="#2c3e50"></path>
87
+ <path
88
+ d="M464 304a1.5 1.5 0 1 0 96 0 1.5 1.5 0 1 0-96 0zM512 768c-17.664 0-32-14.304-32-32V448c0-17.664 14.336-32 32-32s32 14.336 32 32v288c0 17.696-14.336 32-32 32z"
89
+ p-id="10308" fill="#2c3e50"></path>
90
+ </svg>
91
+ </i>
92
+ <transition name="fade-in">
93
+ <div class="popover-content-container" v-show="infoHover" v-popover>
94
+ <slot></slot>
95
+ </div>
96
+ </transition>
97
+ </div>
98
+
99
+ </template>
100
+
101
+ <style lang="stylus" scoped>
102
+ .popover-container {
103
+ position: relative;
104
+
105
+ .info {
106
+ user-select: none;
107
+ display: inline-block;
108
+ cursor: pointer;
109
+ width: 20px;
110
+ height: 20px;
111
+ padding: 5px;
112
+ border-radius: 5px;
113
+ }
114
+
115
+ .info-hover {
116
+ background-color: #f0f0f0;
117
+ }
118
+ }
119
+
120
+ .popover-content-container {
121
+ position: absolute;
122
+ background-color: #fff;
123
+ z-index: 1;
124
+ border-radius: 5px;
125
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
126
+ transition: opacity .1s cubic-bezier(0.57, 0.85, 0.85, 0.57);
127
+ box-sizing: border-box;
128
+ padding: 10px;
129
+
130
+ &.show {
131
+ opacity: 1;
132
+ }
133
+ }
134
+
135
+ .fade-in-enter-active,.fade-in-leave-active {
136
+ transition: all .1s cubic-bezier(.55,0,.1,1)
137
+ }
138
+
139
+ .fade-in-enter,.fade-in-leave-active {
140
+ opacity: 0
141
+ }
142
+
143
+ </style>
package/index.js CHANGED
@@ -41,6 +41,7 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
41
41
  })
42
42
 
43
43
  pluginAPI.options.extendMarkdown.add('vuepress-theme-uni-app-md-plugins', (md) =>{
44
+ md.core.ruler.disable('emoji', true)
44
45
  md.use(require('markdown-it-attrs'), {
45
46
  leftDelimiter: '#{',
46
47
  rightDelimiter: '}',
@@ -49,6 +50,21 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
49
50
  md.use(require('markdown-it-raw-table'));
50
51
  })
51
52
 
53
+ const originalShouldPrefetch = ctx.siteConfig.shouldPrefetch || function () { return false }
54
+ /**
55
+ *
56
+ * @param {string} path path: js 资源文件路径
57
+ * @param {string} type type: 资源文件类型,取值有 script 等
58
+ * @returns {boolean}
59
+ */
60
+ ctx.siteConfig.shouldPrefetch = function (path, type) {
61
+ let themeShouldPrefetch = true
62
+ if (type === 'script') themeShouldPrefetch = path.includes('vendors~') || path.includes('layout-') || path.includes('index.')
63
+ else { themeShouldPrefetch = false }
64
+ return originalShouldPrefetch.call(this, path, type) || themeShouldPrefetch
65
+ }
66
+ ctx.siteConfig.patterns = ctx.siteConfig.patterns || ['**/!(_sidebar).md', '**/*.vue']
67
+
52
68
  const klass = 'info'
53
69
  const config = {
54
70
  extend: '@vuepress/theme-default',
@@ -140,7 +156,8 @@ module.exports = (themeConfig, ctx, pluginAPI) => {
140
156
  if (configPluginIndex !== -1 && Array.isArray(item)) {
141
157
  const configPlugin = config.plugins[configPluginIndex]
142
158
  if (Array.isArray(configPlugin) && typeof item[1] !== 'undefined') {
143
- configPlugin[1] = Object.assign(configPlugin[1], item[1])
159
+ if (item[1] === false) configPlugin[1] = false
160
+ else { configPlugin[1] = Object.assign({}, configPlugin[1], item[1]) }
144
161
  } else {
145
162
  config.plugins[configPluginIndex] = item
146
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuepress-theme-uniapp-official",
3
- "version": "1.4.14",
3
+ "version": "1.4.16",
4
4
  "description": "uni-app official website theme for vuepress",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "algoliasearch": "^4.13.1",
40
40
  "clipboard": "^2.0.11",
41
41
  "vuepress-plugin-check-md2": "^1.0.5",
42
- "vuepress-plugin-expandable-row": "^1.0.6",
42
+ "vuepress-plugin-expandable-row": "^1.0.7",
43
43
  "vuepress-plugin-juejin-style-copy": "^1.0.4",
44
44
  "vuepress-plugin-mermaidjs": "1.9.1",
45
45
  "vuepress-plugin-named-chunks": "^1.1.4",
@@ -195,9 +195,10 @@
195
195
  color: var(--vt-c-text-1);
196
196
  }
197
197
 
198
- .custom-block.warning a{
198
+ /* .custom-block.warning a{
199
199
  color $textColor
200
200
  }
201
+ */
201
202
 
202
203
  .custom-block.danger {
203
204
  background-color: var(--vt-c-bg-soft);
@@ -209,9 +210,9 @@
209
210
  color: var(--vt-c-text-1);
210
211
  }
211
212
 
212
- .custom-block.danger a{
213
+ /* .custom-block.danger a{
213
214
  color $textColor
214
- }
215
+ } */
215
216
 
216
217
  .custom-block.details {
217
218
  display block
@@ -229,13 +230,13 @@
229
230
  }
230
231
 
231
232
  .custom-block.details figure:last-child{
232
- margin-bottom 0
233
- padding-bottom 0
233
+ margin-bottom 0
234
+ padding-bottom 0
234
235
  }
235
236
 
236
237
  .custom-block.details p:last-child{
237
- margin-bottom 0
238
- padding-bottom 0
238
+ margin-bottom 0
239
+ padding-bottom 0
239
240
  }
240
241
 
241
242
  .custom-block.details summary {
@@ -332,5 +333,5 @@
332
333
 
333
334
  .custom-block.danger a,
334
335
  .custom-block.warning a {
335
- color: var(--vt-c-text-code);
336
+ color: $accentColor;
336
337
  }