Skip to content

Commit 50896bb

Browse files
author
xuqingkai
committed
docs: ✏️ 友情链接支持来自线上配置
1 parent adac43f commit 50896bb

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

docs/.vitepress/theme/components/HomeFriendly.vue

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
<!--
2-
* @Author: weisheng
3-
* @Date: 2024-02-02 15:40:08
4-
* @LastEditTime: 2024-02-03 23:56:17
5-
* @LastEditors: weisheng
6-
* @Description:
7-
* @FilePath: \wot-design-uni\docs\.vitepress\theme\components\HomeFriendly.vue
8-
* 记得注释
9-
-->
10-
<style scoped></style>
11-
121
<script setup lang="ts">
132
import { computed } from 'vue'
143
import { useFriendly } from '../composables/friendly'
@@ -17,8 +6,8 @@ import VPFeature from 'vitepress/dist/client/theme-default/components/VPFeature.
176
const { data } = useFriendly()
187
198
20-
const features = computed(() => {
21-
return data && data.value ? data.value : [{
9+
const links = computed(() => {
10+
return data.value.length ? data.value : [{
2211
icon: "https://www.flowerui.com/logo.png",
2312
title: 'Flower Library',
2413
details: 'uni-app 多平台多版本兼容的轻量、简洁、高效、全面的移动端组件库',
@@ -32,7 +21,7 @@ const features = computed(() => {
3221
})
3322
3423
const grid = computed(() => {
35-
const length = features.value.length || 0
24+
const length = links.value.length || 0
3625
if (!length) {
3726
return
3827
} else {
@@ -42,12 +31,12 @@ const grid = computed(() => {
4231
</script>
4332

4433
<template>
45-
<div v-if="features && features.length" class="VPFeatures">
34+
<div v-if="links && links.length" class="VPFeatures">
4635
<div class="container">
4736
<h1 class="friendly-title">友情链接</h1>
4837

4938
<div class="items">
50-
<div v-for="feature in features" :key="feature.title" class="item" :class="[grid]">
39+
<div v-for="feature in links" :key="feature.title" class="item" :class="[grid]">
5140
<VPFeature :icon="{ src: feature.icon, height: '48px', width: 'auto' }" :title="feature.title"
5241
:details="feature.details" :link="feature.link" />
5342
</div>

docs/.vitepress/theme/composables/friendly.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
/*
22
* @Author: weisheng
33
* @Date: 2023-08-01 11:12:05
4-
* @LastEditTime: 2024-02-02 15:39:09
4+
* @LastEditTime: 2024-02-04 09:57:32
55
* @LastEditors: weisheng
66
* @Description:
77
* @FilePath: \wot-design-uni\docs\.vitepress\theme\composables\friendly.ts
88
* 记得注释
99
*/
1010
import { ref, onMounted } from 'vue'
1111

12+
export type FriendlyLink = {
13+
icon: string
14+
title: string
15+
details: string
16+
link: string
17+
}
1218

13-
const data = ref()
19+
const data = ref<FriendlyLink[]>([])
1420

1521
export function useFriendly() {
1622
onMounted(async () => {
@@ -19,7 +25,7 @@ export function useFriendly() {
1925
}
2026
const result = await fetch('https://historysoa.oss-cn-hongkong.aliyuncs.com/sponsors/friendly.json')
2127
const json = await result.json()
22-
data.value = json
28+
data.value = json && json.links ? json.links : []
2329
})
2430

2531
return {

0 commit comments

Comments
 (0)