对接数据

This commit is contained in:
2025-10-24 15:45:38 +08:00
parent 672a2f4c90
commit d3375a347f
138 changed files with 16904 additions and 1026 deletions

View File

@ -0,0 +1,153 @@
<template>
<div class="news-text-content flex flex-col">
<div class="tag-list flex flex-wrap">
<div v-for="(tag, i) in parsedTags" :key="i" class="tag-item">{{ tag }}</div>
</div>
<div class="card flex-1 article-content">
<div v-html="article.content || ''"></div>
</div>
</div>
</template>
<script>
export default {
props: {
article: {
type: Object,
default: () => {
return {}
}
},
},
data() {
return {
}
},
methods: {
safeJsonParse(jsonString) {
try {
return JSON.parse(jsonString);
} catch (error) {
return null;
}
}
},
computed: {
parsedTags() {
if (!this.article || !this.article.tags) {
return [];
}
// 如果tags已经是数组直接返回
if (Array.isArray(this.article.tags)) {
return this.article.tags;
}
// 如果tags是对象但不是数组包装成数组返回
if (typeof this.article.tags === 'object') {
return [this.article.tags];
}
// 如果是字符串尝试解析为JSON
if (typeof this.article.tags === 'string') {
// 处理空字符串情况
if (this.article.tags.trim() === '') {
return [];
}
const parsed = this.safeJsonParse(this.article.tags);
// 如果解析结果是数组,直接返回
if (Array.isArray(parsed)) {
return parsed;
}
// 如果解析结果是对象,包装成数组返回
if (parsed && typeof parsed === 'object') {
return [parsed];
}
// 其他情况返回空数组
return [];
}
return [];
}
},
}
</script>
<style scoped lang="scss">
.card {
padding: 20px;
background-color: #FFFFFF;
border-radius: 12px;
box-shadow: 0 10px 30px 0 rgba(0, 0, 0, 0.08);
}
.news-text-content {
gap: 16px;
height: 100%;
.tag-list {
padding: 0 10px;
margin: 16px 0;
gap: 20px;
.tag-item {
font-family: 'Poppins-Regular', serif;
color: #1E293B;
padding: 4px 12px !important;
@include gradient-border($linear-gradient-start, $linear-gradient-end)
}
}
.article-title {
font-size: 20px;
font-weight: 600;
margin-bottom: 20px;
margin-top: 10px;
font-family: 'Poppins-SemiBold', serif;
color: #1E293B;
display: flex;
align-items: center;
&::before {
content: '';
display: inline-block;
width: 6px;
height: 26px;
background: $header-backgroungd;
margin-right: 8px;
border-radius: 0 6px 6px 0;
}
}
.article-text {
color: #64748B;
font-family: 'Poppins-Regular', serif;
}
.article-graph {
padding-left: 20px;
gap: 10px;
margin-bottom: 20px;
.dot-container {
padding-top: 8px;
}
.dot {
background: $header-backgroungd;
width: 10px;
height: 10px;
border-radius: 50%;
}
.container {
flex: 1;
}
.title {
font-size: 18px;
font-family: 'Poppins-SemiBold', serif;
font-weight: 600;
color: #506179;
}
.content {
font-family: 'Poppins-Regular', serif;
color: #64748B;
margin-top: 18px;
}
}
}
</style>