valaxy-theme-yun 0.14.60 → 0.14.61

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.
Binary file
Binary file
@@ -6,37 +6,39 @@ import { useThemeConfig } from '../composables'
6
6
 
7
7
  const themeConfig = useThemeConfig()
8
8
 
9
- const bgImgOpacity = useCssVar('--va-bg-img-opacity')
10
- if (themeConfig.value.bg_image.opacity)
11
- bgImgOpacity.value = themeConfig.value.bg_image.opacity.toString() || '1'
9
+ if (typeof themeConfig.value.bg_image.url !== 'undefined') {
10
+ const bgImgOpacity = useCssVar('--yun-bg-img-opacity')
11
+ if (themeConfig.value.bg_image.opacity)
12
+ bgImgOpacity.value = themeConfig.value.bg_image.opacity.toString() || '1'
12
13
 
13
- const bgImgUrl = computed(() => {
14
- return isDark.value
15
- ? themeConfig.value.bg_image.dark
16
- : themeConfig.value.bg_image.url
17
- })
14
+ const bgImgUrl = computed(() => {
15
+ return isDark.value
16
+ ? themeConfig.value.bg_image.dark
17
+ : themeConfig.value.bg_image.url
18
+ })
18
19
 
19
- const bgImgCssVar = useCssVar('--va-bg-img')
20
+ const bgImgCssVar = useCssVar('--yun-bg-img')
20
21
 
21
- watch(() => bgImgUrl.value, () => {
22
- bgImgCssVar.value = `url('${bgImgUrl.value}')`
23
- }, { immediate: true })
22
+ watch(() => bgImgUrl.value, () => {
23
+ bgImgCssVar.value = `url('${bgImgUrl.value}')`
24
+ }, { immediate: true })
25
+ }
24
26
  </script>
25
27
 
26
28
  <template>
27
- <div class="va-bg" />
29
+ <div class="yun-bg" />
28
30
  </template>
29
31
 
30
32
  <style lang="scss">
31
33
  @use 'valaxy/client/styles/mixins/index.scss' as *;
32
34
 
33
- .va-bg {
35
+ .yun-bg {
34
36
  position: fixed;
35
37
  width: 100%;
36
38
  height: 100%;
37
39
  z-index: -1;
38
40
 
39
- background-image: var(--va-bg-img);
41
+ background-image: var(--yun-bg-img);
40
42
  background-size: cover;
41
43
  background-position: center;
42
44
  background-repeat: no-repeat;
@@ -44,12 +46,12 @@ watch(() => bgImgUrl.value, () => {
44
46
  background-attachment: fixed;
45
47
  animation-name: bgFadeIn;
46
48
  animation-duration: 2s;
47
- opacity: var(--va-bg-img-opacity, 1);
49
+ opacity: var(--yun-bg-img-opacity, 1);
48
50
  }
49
51
 
50
52
  // for ios
51
53
  @include ios {
52
- .va-bg {
54
+ .yun-bg {
53
55
  background-attachment: scroll;
54
56
  }
55
57
  }
@@ -60,7 +62,7 @@ watch(() => bgImgUrl.value, () => {
60
62
  }
61
63
 
62
64
  to {
63
- opacity: var(--va-bg-img-opacity, 1);
65
+ opacity: var(--yun-bg-img-opacity, 1);
64
66
  }
65
67
  }
66
68
  </style>
@@ -14,9 +14,17 @@ interface LinkType {
14
14
  const props = defineProps<{
15
15
  links: string | LinkType[]
16
16
  random: boolean
17
+ /**
18
+ * @description: 图片加载失败时显示的图片
19
+ */
20
+ errorImg?: string
17
21
  }>()
18
22
 
19
23
  const { data } = useRandomData(props.links, props.random)
24
+
25
+ function onError(e: Event) {
26
+ onImgError(e, props.errorImg)
27
+ }
20
28
  </script>
21
29
 
22
30
  <template>
@@ -25,7 +33,11 @@ const { data } = useRandomData(props.links, props.random)
25
33
  <li v-for="link, i in data" :key="i" class="link-item" :style="`--primary-color: ${link.color}`">
26
34
  <a class="link-url" p="x-4 y-2" :href="link.url" :title="link.name" alt="portrait" rel="friend">
27
35
  <div class="link-left">
28
- <img class="link-avatar" w="16" h="16" loading="lazy" :src="link.avatar" :alt="link.name" :onError="onImgError">
36
+ <img
37
+ class="link-avatar" width="64" height="64" w="16" h="16"
38
+ loading="lazy" :src="link.avatar" :alt="link.name"
39
+ @error="onError"
40
+ >
29
41
  </div>
30
42
  <div class="link-info" m="l-2">
31
43
  <div class="link-blog" font="serif black">{{ link.blog }}</div>
@@ -53,6 +53,7 @@ export default defineConfig<ThemeConfig>({
53
53
 
54
54
  - `links`: 友情链接信息(可以是 YAML 数组形式,也可以是一个 JSON 文件链接)
55
55
  - `random`: 是否随机展示
56
+ - `errorImg`: 图片加载失败时的图片链接
56
57
 
57
58
  譬如:
58
59
 
@@ -81,5 +82,20 @@ links:
81
82
  random: true
82
83
  ---
83
84
 
84
- <YunLinks :links="frontmatter.links" :random="frontmatter.random" />
85
+ <YunLinks :links="frontmatter.links" :random="frontmatter.random" errorImg="https://cdn.yunyoujun.cn/img/avatar/none.jpg" />
86
+ ```
87
+
88
+ ## 样式
89
+
90
+ ### 覆盖背景、侧边栏图片
91
+
92
+ 您可以新建 `styles/css-vars.scss`,覆盖默认 CSS 变量。
93
+
94
+ ```css
95
+ :root {
96
+ /* 背景图片 */
97
+ --yun-bg-img: url("https://cdn.yunyoujun.cn/img/bg/stars-timing-0-blur-30px.jpg");
98
+ /* 侧边栏背景图片 */
99
+ --yun-sidebar-bg-img: url("https://cdn.yunyoujun.cn/img/bg/alpha-stars-timing-1.webp");
100
+ }
85
101
  ```
package/node/config.ts CHANGED
@@ -18,7 +18,7 @@ export const defaultThemeConfig: ThemeConfig = {
18
18
 
19
19
  bg_image: {
20
20
  enable: true,
21
- url: 'https://cdn.yunyoujun.cn/img/bg/stars-timing-0-blur-30px.jpg',
21
+ // url: bgImg,
22
22
  // dark: 'https://cdn.yunyoujun.cn/img/bg/dark-stars-timing-0-blur-30px.png',
23
23
  },
24
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy-theme-yun",
3
- "version": "0.14.60",
3
+ "version": "0.14.61",
4
4
  "author": {
5
5
  "email": "me@yunyoujun.cn",
6
6
  "name": "YunYouJun",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@types/animejs": "^3.1.7",
27
- "valaxy": "0.14.60",
27
+ "valaxy": "0.14.61",
28
28
  "valaxy-addon-waline": "0.1.0"
29
29
  }
30
30
  }
package/styles/vars.scss CHANGED
@@ -5,10 +5,10 @@ $light: () !default;
5
5
  $light: map.merge(
6
6
  (
7
7
  "bg-img":
8
- url("https://cdn.yunyoujun.cn/img/bg/stars-timing-0-blur-30px.jpg"),
8
+ url("../assets/images/light/bg-img.jpg"),
9
9
  "sidebar-bg-color": var(--va-c-bg-light),
10
10
  "sidebar-bg-img":
11
- url("https://cdn.yunyoujun.cn/img/bg/alpha-stars-timing-1.webp"),
11
+ url("../assets/images/light/sidebar-bg-img.webp"),
12
12
  ),
13
13
  $light
14
14
  );
package/types/index.d.ts CHANGED
@@ -72,7 +72,7 @@ export interface ThemeConfig {
72
72
  /**
73
73
  * @en Image url
74
74
  */
75
- url: string
75
+ url?: string
76
76
  /**
77
77
  * @en Image url when dark mode
78
78
  */
package/utils/index.ts CHANGED
@@ -1,10 +1,10 @@
1
- export const anonymousImage = 'https://cdn.yunyoujun.cn/img/avatar/none.jpg'
1
+ import noneImg from '../assets/images/none.jpg'
2
2
 
3
3
  /**
4
4
  * set default img
5
5
  * @param e
6
6
  */
7
- export function onImgError(e: Event, defaultImg = anonymousImage) {
7
+ export function onImgError(e: Event, defaultImg = noneImg) {
8
8
  const targetEl = e.target as HTMLImageElement
9
9
  targetEl.setAttribute('data-src', targetEl.src)
10
10
  targetEl.src = defaultImg