@wot-ui/vitepress-theme 2.0.0-alpha.19 → 2.0.0-alpha.21
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/README.md +6 -0
- package/dist/theme/components/AsideSponsors.vue +20 -5
- package/dist/theme/components/VPDoc.vue +18 -4
- package/dist/types.d.ts +24 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -96,6 +96,11 @@ export default createWotVitePressTheme({
|
|
|
96
96
|
},
|
|
97
97
|
cases: {
|
|
98
98
|
urls: ['https://api.example.com/cases.json']
|
|
99
|
+
},
|
|
100
|
+
specialSponsor: {
|
|
101
|
+
urls: ['https://api.example.com/sponsor.json'],
|
|
102
|
+
enabled: true,
|
|
103
|
+
sponsorLink: '/reward/sponsor'
|
|
99
104
|
}
|
|
100
105
|
})
|
|
101
106
|
```
|
|
@@ -135,6 +140,7 @@ const { data: sponsors } = useSponsor()
|
|
|
135
140
|
- `analytics.trackBaiduRoute`: 开启后,在路由变化时调用 `_hmt.push(['_trackPageview'])`。
|
|
136
141
|
- `demoIframe`: 配置右侧手机模拟器相关选项。
|
|
137
142
|
- `banner` / `sponsors` / `ads` / `team` / `friendly` / `cases`: 提供给对应功能模块的请求地址数组(支持多线路重试)。
|
|
143
|
+
- `specialSponsor`: 特别赞助位配置,支持赞助数据源 `urls`、右侧赞助位显示开关 `enabled`,以及开通赞助位跳转地址 `sponsorLink`。
|
|
138
144
|
|
|
139
145
|
## 构建要求
|
|
140
146
|
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed } from 'vue'
|
|
2
|
+
import { computed, inject } from 'vue'
|
|
3
3
|
import { useSpecialSponsor } from '../composables/specialSponsor'
|
|
4
|
+
import { wotThemeOptionsKey } from '../options'
|
|
4
5
|
|
|
5
6
|
const { data } = useSpecialSponsor()
|
|
7
|
+
const options = inject(wotThemeOptionsKey)
|
|
8
|
+
const defaultSponsorLink = '/reward/sponsor'
|
|
9
|
+
|
|
10
|
+
const specialSponsorOptions = computed(() => {
|
|
11
|
+
return options?.specialSponsor === false ? null : options?.specialSponsor
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
const showAsideSponsors = computed(() => {
|
|
15
|
+
return specialSponsorOptions.value?.enabled !== false
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const sponsorLink = computed(() => {
|
|
19
|
+
return specialSponsorOptions.value?.sponsorLink || defaultSponsorLink
|
|
20
|
+
})
|
|
6
21
|
|
|
7
22
|
// 分离超级赞助和金牌赞助
|
|
8
23
|
const superSponsors = computed(() => {
|
|
@@ -20,8 +35,8 @@ const isGoldSponsorsOdd = computed(() => {
|
|
|
20
35
|
</script>
|
|
21
36
|
|
|
22
37
|
<template>
|
|
23
|
-
<div class="VPDocAsideSponsors">
|
|
24
|
-
<a class="sponsors-aside-text" href="
|
|
38
|
+
<div v-if="showAsideSponsors" class="VPDocAsideSponsors">
|
|
39
|
+
<a class="sponsors-aside-text" :href="sponsorLink">赞助位</a>
|
|
25
40
|
<div class="VPSponsors vp-sponsor aside">
|
|
26
41
|
<!-- 超级赞助:一行一个 -->
|
|
27
42
|
<section class="vp-sponsor-section" v-if="superSponsors?.items.length">
|
|
@@ -52,7 +67,7 @@ const isGoldSponsorsOdd = computed(() => {
|
|
|
52
67
|
</div>
|
|
53
68
|
<!-- 当金牌赞助为奇数时,默认赞助位填补到金牌赞助位置 -->
|
|
54
69
|
<div class="vp-sponsor-grid-item" v-if="isGoldSponsorsOdd">
|
|
55
|
-
<a class="vp-sponsor-grid-link" href="
|
|
70
|
+
<a class="vp-sponsor-grid-link" :href="sponsorLink" rel="sponsored noopener">
|
|
56
71
|
<article class="vp-sponsor-grid-box">
|
|
57
72
|
<span class="vp-sponsor-grid-text">成为赞助商</span>
|
|
58
73
|
</article>
|
|
@@ -65,7 +80,7 @@ const isGoldSponsorsOdd = computed(() => {
|
|
|
65
80
|
<section class="vp-sponsor-section" v-if="!isGoldSponsorsOdd || !goldSponsors?.items.length">
|
|
66
81
|
<div class="VPSponsorsGrid vp-sponsor-grid xmini" data-vp-grid="1">
|
|
67
82
|
<div class="vp-sponsor-grid-item">
|
|
68
|
-
<a class="vp-sponsor-grid-link" href="
|
|
83
|
+
<a class="vp-sponsor-grid-link" :href="sponsorLink" rel="sponsored noopener">
|
|
69
84
|
<article class="vp-sponsor-grid-box">
|
|
70
85
|
<span class="vp-sponsor-grid-text">成为赞助商</span>
|
|
71
86
|
</article>
|
|
@@ -16,10 +16,24 @@ const themeOptions = inject(wotThemeOptionsKey)
|
|
|
16
16
|
const demoIframeOptions = themeOptions?.demoIframe
|
|
17
17
|
|
|
18
18
|
const pageName = computed(() => route.path.replace(/[./]+/g, '_').replace(/_html$/, ''))
|
|
19
|
-
const isComponent = computed(
|
|
20
|
-
()
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const isComponent = computed(() => {
|
|
20
|
+
if (demoIframeOptions === false) return false
|
|
21
|
+
|
|
22
|
+
const { routePatterns, excludePatterns } = demoIframeOptions || {}
|
|
23
|
+
|
|
24
|
+
// 检查是否在排除列表中
|
|
25
|
+
if (excludePatterns && excludePatterns.some((pattern) => route.path.includes(pattern))) {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// 如果有自定义路由模式,使用自定义模式
|
|
30
|
+
if (routePatterns && routePatterns.length) {
|
|
31
|
+
return routePatterns.some((pattern) => route.path.includes(pattern))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 默认逻辑(保持向后兼容)
|
|
35
|
+
return (route.path.startsWith('/component') || route.path.startsWith('/en-US/component')) && !route.path.includes('/use-')
|
|
36
|
+
})
|
|
23
37
|
const expanded = ref(true)
|
|
24
38
|
</script>
|
|
25
39
|
|
package/dist/types.d.ts
CHANGED
|
@@ -27,6 +27,19 @@ export interface WotThemeSponsorOptions {
|
|
|
27
27
|
*/
|
|
28
28
|
urls: string[];
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* 特别赞助位配置。
|
|
32
|
+
*/
|
|
33
|
+
export interface WotThemeSpecialSponsorOptions extends WotThemeSponsorOptions {
|
|
34
|
+
/**
|
|
35
|
+
* 是否显示文档右侧赞助位,默认为 true。
|
|
36
|
+
*/
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* 开通赞助位跳转地址。
|
|
40
|
+
*/
|
|
41
|
+
sponsorLink?: string;
|
|
42
|
+
}
|
|
30
43
|
/**
|
|
31
44
|
* 广告位配置。
|
|
32
45
|
*/
|
|
@@ -79,6 +92,14 @@ export interface WotThemeDemoIframeOptions {
|
|
|
79
92
|
* 是否启用二维码。
|
|
80
93
|
*/
|
|
81
94
|
enabled?: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* 自定义需要显示 iframe 的路由模式。
|
|
97
|
+
*/
|
|
98
|
+
routePatterns?: string[];
|
|
99
|
+
/**
|
|
100
|
+
* 自定义需要排除的路由模式。
|
|
101
|
+
*/
|
|
102
|
+
excludePatterns?: string[];
|
|
82
103
|
}
|
|
83
104
|
/**
|
|
84
105
|
* 主题运行时可选能力配置。
|
|
@@ -99,7 +120,7 @@ export interface WotVitePressThemeOptions {
|
|
|
99
120
|
/**
|
|
100
121
|
* 特别赞助位配置,传入 false 表示关闭。
|
|
101
122
|
*/
|
|
102
|
-
specialSponsor?: false |
|
|
123
|
+
specialSponsor?: false | WotThemeSpecialSponsorOptions;
|
|
103
124
|
/**
|
|
104
125
|
* 广告位配置,传入 false 表示关闭。
|
|
105
126
|
*/
|
|
@@ -218,7 +239,7 @@ export interface WotVitePressConfigOptions {
|
|
|
218
239
|
/**
|
|
219
240
|
* 站点默认语言。
|
|
220
241
|
*/
|
|
221
|
-
lang
|
|
242
|
+
lang?: string;
|
|
222
243
|
/**
|
|
223
244
|
* 站点描述。
|
|
224
245
|
*/
|
|
@@ -292,7 +313,7 @@ export interface WotResolvedThemeOptions {
|
|
|
292
313
|
/**
|
|
293
314
|
* 归一化后的特别赞助位配置。
|
|
294
315
|
*/
|
|
295
|
-
specialSponsor: false |
|
|
316
|
+
specialSponsor: false | WotThemeSpecialSponsorOptions;
|
|
296
317
|
}
|
|
297
318
|
/**
|
|
298
319
|
* 过滤空值后的有效 Vite 插件类型。
|