@sugarat/theme 0.4.12 → 0.5.0
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/node.d.ts +16 -74
- package/node.js +148 -51
- package/node.mjs +753 -0
- package/package.json +10 -6
- package/src/components/BlogAlert.vue +10 -9
- package/src/components/BlogApp.vue +0 -2
- package/src/components/BlogArticleAnalyze.vue +8 -9
- package/src/components/BlogAuthor.vue +6 -5
- package/src/components/BlogBackToTop.vue +8 -10
- package/src/components/BlogButtonAfterArticle.vue +5 -14
- package/src/components/BlogCommentWrapper.vue +11 -28
- package/src/components/BlogDocCover.vue +3 -3
- package/src/components/BlogFooter.vue +3 -1
- package/src/components/BlogFriendLink.vue +4 -3
- package/src/components/BlogHomeBanner.vue +7 -6
- package/src/components/BlogHomeHeaderAvatar.vue +3 -3
- package/src/components/BlogHomeOverview.vue +3 -3
- package/src/components/BlogHomeTags.vue +5 -5
- package/src/components/BlogHotArticle.vue +4 -7
- package/src/components/BlogItem.vue +1 -1
- package/src/components/BlogList.vue +7 -6
- package/src/components/BlogRecommendArticle.vue +11 -14
- package/src/components/BlogSidebar.vue +9 -15
- package/src/components/CommentArtalk.vue +7 -5
- package/src/components/CommentGiscus.vue +7 -8
- package/src/components/Icon.vue +33 -0
- package/src/composables/config/blog.ts +203 -87
- package/src/composables/config/index.ts +12 -79
- package/src/hooks/useOml2d.ts +15 -8
- package/src/index.ts +3 -0
- package/src/node.ts +5 -1
- package/src/styles/index.scss +6 -6
- package/src/utils/node/hot-reload-plugin.ts +31 -1
- package/src/utils/node/index.ts +0 -2
- package/src/utils/node/mdPlugins.ts +4 -0
- package/src/utils/node/theme.ts +15 -18
- package/src/utils/node/vitePlugins.ts +122 -33
- package/src/components/BlogPopover.vue +0 -290
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { ElButton, ElIcon } from 'element-plus'
|
|
3
|
-
import { CircleCloseFilled } from '@element-plus/icons-vue'
|
|
4
|
-
import { computed, h, onMounted, ref, watch } from 'vue'
|
|
5
|
-
import type { BlogPopover } from '@sugarat/theme'
|
|
6
|
-
import { parseStringStyle } from '@vue/shared'
|
|
7
|
-
import { useDebounceFn, useWindowSize } from '@vueuse/core'
|
|
8
|
-
import { useRoute, useRouter } from 'vitepress'
|
|
9
|
-
import { useBlogConfig } from '../composables/config/blog'
|
|
10
|
-
import { vOuterHtml } from '../directives'
|
|
11
|
-
|
|
12
|
-
const { popover: popoverProps } = useBlogConfig()
|
|
13
|
-
|
|
14
|
-
const show = ref(false)
|
|
15
|
-
|
|
16
|
-
const bodyContent = computed(() => {
|
|
17
|
-
return popoverProps?.body || []
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
const footerContent = computed(() => {
|
|
21
|
-
return popoverProps?.footer || []
|
|
22
|
-
})
|
|
23
|
-
const storageKey = 'theme-blog-popover'
|
|
24
|
-
const closeFlag = `${storageKey}-close`
|
|
25
|
-
|
|
26
|
-
// 移动端最小化
|
|
27
|
-
const { width } = useWindowSize()
|
|
28
|
-
const router = useRouter()
|
|
29
|
-
const route = useRoute()
|
|
30
|
-
onMounted(() => {
|
|
31
|
-
if (!popoverProps?.title) {
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 取旧值
|
|
36
|
-
const oldValue = localStorage.getItem(storageKey)
|
|
37
|
-
const newValue = JSON.stringify(popoverProps)
|
|
38
|
-
localStorage.setItem(storageKey, newValue)
|
|
39
|
-
|
|
40
|
-
// 移动端最小化
|
|
41
|
-
if (width.value < 768 && popoverProps?.mobileMinify) {
|
|
42
|
-
show.value = false
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// >= 0 每次都展示,区别是否自动消失
|
|
47
|
-
if (Number(popoverProps?.duration ?? '') >= 0) {
|
|
48
|
-
show.value = true
|
|
49
|
-
if (popoverProps?.duration) {
|
|
50
|
-
setTimeout(() => {
|
|
51
|
-
show.value = false
|
|
52
|
-
}, popoverProps?.duration)
|
|
53
|
-
}
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (oldValue !== newValue && popoverProps?.duration === -1) {
|
|
58
|
-
// 当做新值处理
|
|
59
|
-
show.value = true
|
|
60
|
-
localStorage.removeItem(closeFlag)
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// 新旧相等,判断是否点击过close,没点击关闭依然展示
|
|
65
|
-
if (oldValue === newValue && popoverProps?.duration === -1 && !localStorage.getItem(closeFlag)) {
|
|
66
|
-
show.value = true
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
const onAfterRouteChanged = useDebounceFn(() => {
|
|
71
|
-
popoverProps?.onRouteChanged?.(route, show)
|
|
72
|
-
}, 10)
|
|
73
|
-
|
|
74
|
-
watch(route, onAfterRouteChanged, { immediate: true })
|
|
75
|
-
|
|
76
|
-
function handleClose() {
|
|
77
|
-
show.value = false
|
|
78
|
-
if (popoverProps?.duration === -1) {
|
|
79
|
-
localStorage.setItem(closeFlag, `${+new Date()}`)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function PopoverValue(props: { key: number; item: BlogPopover.Value },
|
|
84
|
-
{ slots }: any) {
|
|
85
|
-
const { key, item } = props
|
|
86
|
-
if (item.type === 'title') {
|
|
87
|
-
return h(
|
|
88
|
-
'h4',
|
|
89
|
-
{
|
|
90
|
-
style: parseStringStyle(item.style || '')
|
|
91
|
-
},
|
|
92
|
-
item.content
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
if (item.type === 'text') {
|
|
96
|
-
return h(
|
|
97
|
-
'p',
|
|
98
|
-
{
|
|
99
|
-
style: parseStringStyle(item.style || '')
|
|
100
|
-
},
|
|
101
|
-
item.content
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
if (item.type === 'image') {
|
|
105
|
-
return h('img', {
|
|
106
|
-
src: item.src,
|
|
107
|
-
style: parseStringStyle(item.style || '')
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
if (item.type === 'button') {
|
|
111
|
-
return h(
|
|
112
|
-
ElButton,
|
|
113
|
-
{
|
|
114
|
-
type: 'primary',
|
|
115
|
-
onClick: () => {
|
|
116
|
-
if (/^\s*http(s)?:\/\//.test(item.link)) {
|
|
117
|
-
window.open(item.link)
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
router.go(item.link)
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
style: parseStringStyle(item.style || ''),
|
|
124
|
-
...item.props
|
|
125
|
-
},
|
|
126
|
-
slots
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
return h(
|
|
130
|
-
'div',
|
|
131
|
-
{
|
|
132
|
-
key
|
|
133
|
-
},
|
|
134
|
-
''
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
</script>
|
|
138
|
-
|
|
139
|
-
<template>
|
|
140
|
-
<div v-show="show" class="theme-blog-popover" data-pagefind-ignore="all">
|
|
141
|
-
<div class="header">
|
|
142
|
-
<div class="title-wrapper">
|
|
143
|
-
<ElIcon size="20px">
|
|
144
|
-
<i v-if="popoverProps?.icon" v-outer-html="popoverProps.icon" />
|
|
145
|
-
<svg v-else t="1716085184855" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4274" width="200" height="200"><path d="M660.48 872.448q6.144 0-3.584 15.36t-29.696 33.792-47.104 33.792-57.856 15.36q-27.648 0-53.248-15.36t-45.056-33.792-29.696-33.792-6.144-15.36l272.384 0zM914.432 785.408q7.168 9.216 6.656 17.92t-4.608 14.848-10.24 9.728-12.288 3.584l-747.52 0q-14.336 0-20.992-11.776t4.608-29.184q17.408-30.72 40.96-68.608t44.544-81.408 36.352-92.16 15.36-101.888q0-51.2 14.336-92.16t37.376-71.68 53.248-52.224 62.976-32.768q-16.384-26.624-16.384-55.296 0-41.984 28.672-70.656t70.656-28.672 70.656 28.672 28.672 70.656q0 14.336-4.096 28.16t-11.264 25.088q34.816 11.264 66.048 32.768t54.272 53.248 36.864 72.704 13.824 91.136q0 51.2 15.36 100.864t36.864 94.208 45.568 81.408 43.52 63.488zM478.208 142.336q0 16.384 11.264 28.16t27.648 11.776l2.048 0q16.384-1.024 27.648-12.288t11.264-27.648q0-17.408-11.264-28.672t-28.672-11.264-28.672 11.264-11.264 28.672z" p-id="4275" /></svg>
|
|
146
|
-
</ElIcon>
|
|
147
|
-
<span class="title">{{ popoverProps?.title }}</span>
|
|
148
|
-
</div>
|
|
149
|
-
<ElIcon class="close-icon" size="20px" @click="handleClose">
|
|
150
|
-
<i v-if="popoverProps?.closeIcon" v-outer-html="popoverProps.closeIcon" />
|
|
151
|
-
<CircleCloseFilled v-else />
|
|
152
|
-
</ElIcon>
|
|
153
|
-
</div>
|
|
154
|
-
<div v-if="bodyContent.length" class="body content">
|
|
155
|
-
<PopoverValue v-for="(v, idx) in bodyContent" :key="idx" :item="v">
|
|
156
|
-
{{ v.type !== 'image' ? v.content : '' }}
|
|
157
|
-
</PopoverValue>
|
|
158
|
-
<hr v-if="footerContent.length">
|
|
159
|
-
</div>
|
|
160
|
-
<div class="footer content">
|
|
161
|
-
<PopoverValue v-for="(v, idx) in footerContent" :key="idx" :item="v">
|
|
162
|
-
{{ v.type !== 'image' ? v.content : '' }}
|
|
163
|
-
</PopoverValue>
|
|
164
|
-
</div>
|
|
165
|
-
</div>
|
|
166
|
-
<div
|
|
167
|
-
v-show="!show && (popoverProps?.reopen ?? true) && popoverProps?.title" class="theme-blog-popover-close"
|
|
168
|
-
:class="{ twinkle: !show && (popoverProps?.twinkle ?? true) }"
|
|
169
|
-
@click="show = true"
|
|
170
|
-
>
|
|
171
|
-
<ElIcon>
|
|
172
|
-
<i v-if="popoverProps?.icon" v-outer-html="popoverProps.icon" />
|
|
173
|
-
<svg v-else t="1716085184855" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4274" width="200" height="200"><path d="M660.48 872.448q6.144 0-3.584 15.36t-29.696 33.792-47.104 33.792-57.856 15.36q-27.648 0-53.248-15.36t-45.056-33.792-29.696-33.792-6.144-15.36l272.384 0zM914.432 785.408q7.168 9.216 6.656 17.92t-4.608 14.848-10.24 9.728-12.288 3.584l-747.52 0q-14.336 0-20.992-11.776t4.608-29.184q17.408-30.72 40.96-68.608t44.544-81.408 36.352-92.16 15.36-101.888q0-51.2 14.336-92.16t37.376-71.68 53.248-52.224 62.976-32.768q-16.384-26.624-16.384-55.296 0-41.984 28.672-70.656t70.656-28.672 70.656 28.672 28.672 70.656q0 14.336-4.096 28.16t-11.264 25.088q34.816 11.264 66.048 32.768t54.272 53.248 36.864 72.704 13.824 91.136q0 51.2 15.36 100.864t36.864 94.208 45.568 81.408 43.52 63.488zM478.208 142.336q0 16.384 11.264 28.16t27.648 11.776l2.048 0q16.384-1.024 27.648-12.288t11.264-27.648q0-17.408-11.264-28.672t-28.672-11.264-28.672 11.264-11.264 28.672z" p-id="4275" /></svg>
|
|
174
|
-
</ElIcon>
|
|
175
|
-
</div>
|
|
176
|
-
</template>
|
|
177
|
-
|
|
178
|
-
<style lang="scss" scoped>
|
|
179
|
-
.theme-blog-popover {
|
|
180
|
-
width: 258px;
|
|
181
|
-
position: fixed;
|
|
182
|
-
top: 80px;
|
|
183
|
-
right: 20px;
|
|
184
|
-
z-index: 22;
|
|
185
|
-
box-sizing: border-box;
|
|
186
|
-
border: 1px solid var(--vp-c-brand-3);
|
|
187
|
-
border-radius: 6px;
|
|
188
|
-
background-color: rgba(var(--bg-gradient-home));
|
|
189
|
-
box-shadow: var(--box-shadow);
|
|
190
|
-
|
|
191
|
-
:deep(.el-button.el-button--primary) {
|
|
192
|
-
background-color: var(--vp-c-brand-2);
|
|
193
|
-
border-color: var(--vp-c-brand-2);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.header {
|
|
198
|
-
background-color: var(--vp-c-brand-3);
|
|
199
|
-
color: #fff;
|
|
200
|
-
padding: 6px 4px;
|
|
201
|
-
display: flex;
|
|
202
|
-
justify-content: space-between;
|
|
203
|
-
align-items: center;
|
|
204
|
-
|
|
205
|
-
.close-icon {
|
|
206
|
-
cursor: pointer;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
.title-wrapper {
|
|
211
|
-
display: flex;
|
|
212
|
-
align-items: center;
|
|
213
|
-
|
|
214
|
-
.title {
|
|
215
|
-
font-size: 14px;
|
|
216
|
-
padding-left: 6px;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.body {
|
|
221
|
-
box-sizing: border-box;
|
|
222
|
-
padding: 10px 10px 0;
|
|
223
|
-
|
|
224
|
-
hr {
|
|
225
|
-
border: none;
|
|
226
|
-
border-bottom: 1px solid #eaecef;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.footer {
|
|
231
|
-
box-sizing: border-box;
|
|
232
|
-
padding: 10px;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
.body.content,
|
|
236
|
-
.footer.content {
|
|
237
|
-
text-align: center;
|
|
238
|
-
|
|
239
|
-
h4 {
|
|
240
|
-
text-align: center;
|
|
241
|
-
font-size: 12px;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
p {
|
|
245
|
-
text-align: center;
|
|
246
|
-
padding: 10px 0;
|
|
247
|
-
font-size: 14px;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
img {
|
|
251
|
-
width: 100%;
|
|
252
|
-
// TODO: 未来优化,自动预获取图片高度填充
|
|
253
|
-
height: 100px;
|
|
254
|
-
object-fit: contain;
|
|
255
|
-
margin: 0 auto;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
.theme-blog-popover-close {
|
|
260
|
-
cursor: pointer;
|
|
261
|
-
opacity: 0.5;
|
|
262
|
-
position: fixed;
|
|
263
|
-
z-index: 22;
|
|
264
|
-
top: 80px;
|
|
265
|
-
right: 10px;
|
|
266
|
-
position: fixed;
|
|
267
|
-
background-color: var(--vp-c-brand-3);
|
|
268
|
-
padding: 8px;
|
|
269
|
-
color: #fff;
|
|
270
|
-
font-size: 12px;
|
|
271
|
-
border-radius: 50%;
|
|
272
|
-
display: flex;
|
|
273
|
-
flex-direction: column;
|
|
274
|
-
}
|
|
275
|
-
.theme-blog-popover-close.twinkle {
|
|
276
|
-
animation: twinkle 1s ease-in-out infinite;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
@keyframes twinkle {
|
|
280
|
-
0% {
|
|
281
|
-
opacity: 0.5;
|
|
282
|
-
}
|
|
283
|
-
50% {
|
|
284
|
-
opacity: 0;
|
|
285
|
-
}
|
|
286
|
-
100% {
|
|
287
|
-
opacity: 0.5;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
</style>
|