Files
site-10584/components/CmsArticleRelated.vue
2026-01-29 10:43:43 +08:00

49 lines
1.1 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup lang="ts">
import type {CmsArticle} from "~/api/cms/cmsArticle/model";
import {findTags, listCmsArticle, pageCmsArticle} from "~/api/cms/cmsArticle";
const props = withDefaults(
defineProps<{
data?: CmsArticle;
model?: string;
}>(),
{}
);
const i18n = useI18n();
const list = ref<CmsArticle[]>([])
const tags = props.data?.tags ? JSON.parse(props.data?.tags)[0] : '';
const reload = () => {
if(props.data?.tags){
const tags = JSON.parse(props.data?.tags);
findTags({
tags: tags.join(',')
}).then(data => {
if(data){
list.value = data.filter(d => d.model == 'article');
}
})
}
}
watch(
() => props.data?.articleId,
() => {
reload();
},
{immediate: true}
);
</script>
<template>
<div class="relatenew relate"><h4>{{ $t('articleRelated')}}</h4>
<div class="py-1">
<ul id="relate_n" class="news_list clearfix">
<li v-for="(item,index) in list" :key="index"><a :href="detail(item)" :title="item.title">{{ item.title }}</a></li>
</ul>
</div>
</div>
</template>
<style scoped lang="scss">
</style>