fix: 优化友链展示逻辑,确保友链在组件挂载时正确显示

This commit is contained in:
2026-06-25 22:27:08 +08:00
parent b70bfc12e0
commit 4408f48cbd

View File

@@ -181,8 +181,9 @@
</template> </template>
<script setup> <script setup>
import { reactive, ref, watch, computed } from "vue"; import { reactive, ref, watch, computed, onMounted } from "vue";
import siteConfig from "../config/siteConfig"; import siteConfig from "../config/siteConfig";
defineOptions({ inheritAttrs: false });
const props = defineProps({ friends: { type: Array, default: () => [] } }); const props = defineProps({ friends: { type: Array, default: () => [] } });
const showFormModal = ref(false); const showFormModal = ref(false);
const loading = ref(false); const loading = ref(false);
@@ -212,11 +213,15 @@ const shuffle = (list) => {
watch( watch(
() => props.friends, () => props.friends,
(val) => { (val) => {
displayedFriends.value = shuffle(val || []); displayedFriends.value = val ? [...val] : [];
}, },
{ immediate: true } { immediate: true }
); );
onMounted(() => {
displayedFriends.value = shuffle(props.friends || []);
});
const exampleJson = computed(() => { const exampleJson = computed(() => {
const name = siteConfig.profile?.name || siteConfig.siteMeta?.title || ""; const name = siteConfig.profile?.name || siteConfig.siteMeta?.title || "";
const url = siteConfig.siteMeta?.url || ""; const url = siteConfig.siteMeta?.url || "";