@sugarat/theme 0.2.22 → 0.2.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "author": "sugar",
6
6
  "license": "MIT",
@@ -1,10 +1,14 @@
1
1
  <script lang="ts" setup>
2
2
  import { useData } from 'vitepress'
3
3
  import { computed } from 'vue'
4
- import { useBlogConfig } from '../composables/config/blog'
4
+ import { useBlogConfig, useCurrentArticle } from '../composables/config/blog'
5
5
 
6
6
  const { frontmatter } = useData()
7
7
  const cover = computed(() => frontmatter.value.cover)
8
+
9
+ const currentArticle = useCurrentArticle()
10
+ const realCover = computed<string>(() => import.meta.env.DEV ? cover.value : currentArticle.value?.meta?.cover)
11
+
8
12
  const { article } = useBlogConfig()
9
13
  const hiddenCover = computed(
10
14
  () => frontmatter.value?.hiddenCover ?? article?.hiddenCover ?? false
@@ -12,7 +16,7 @@ const hiddenCover = computed(
12
16
  </script>
13
17
 
14
18
  <template>
15
- <img v-if="cover && !hiddenCover" class="blog-doc-cover" :src="cover">
19
+ <img v-if="cover && !hiddenCover" class="blog-doc-cover" :src="realCover">
16
20
  </template>
17
21
 
18
22
  <style lang="scss" scoped>
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref } from 'vue'
2
+ import { computed, onMounted, ref } from 'vue'
3
3
  import { useRoute, withBase } from 'vitepress'
4
4
  import { ElButton, ElLink } from 'element-plus'
5
5
  import { formatShowDate } from '../utils/client'
@@ -88,6 +88,7 @@ function changePage() {
88
88
  const newIdx
89
89
  = currentPage.value % Math.ceil(recommendList.value.length / pageSize.value)
90
90
  currentPage.value = newIdx + 1
91
+ return newIdx + 1
91
92
  }
92
93
  // 当前页开始的序号
93
94
  const startIdx = computed(() => (currentPage.value - 1) * pageSize.value)
@@ -101,6 +102,22 @@ const currentWikiData = computed(() => {
101
102
  const showChangeBtn = computed(() => {
102
103
  return recommendList.value.length > pageSize.value
103
104
  })
105
+
106
+ onMounted(() => {
107
+ const checkHaveActive = () => {
108
+ const have = currentWikiData.value.some(v => isCurrentDoc(v.route))
109
+ if (have) {
110
+ return
111
+ }
112
+ if (currentPage.value >= changePage()) {
113
+ return
114
+ }
115
+
116
+ // TODO:存在理论闪烁情况,未来优化
117
+ setTimeout(checkHaveActive)
118
+ }
119
+ checkHaveActive()
120
+ })
104
121
  </script>
105
122
 
106
123
  <template>