hulai-website/components/home/DestinationCompare.vue
刘涛 a25f3a77ce sync: 同步最新呼籁官网代码到仓库
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-22 21:57:35 +08:00

285 行
6.0 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<section class="section">
<div class="container">
<CommonSectionTitle :title="data.title" :subtitle="data.subtitle" />
<p class="compare-intro">{{ data.intro }}</p>
<!-- 对比表格 -->
<div class="compare-table">
<!-- 表头三个目的地 -->
<div class="compare-header">
<div class="compare-label-col"></div>
<div
v-for="dest in data.destinations"
:key="dest.id"
class="compare-dest-col"
:class="{ 'compare-dest-col--highlight': dest.highlight }"
>
<h3 class="dest-name">{{ dest.name }}</h3>
<span class="dest-tag">{{ dest.tag }}</span>
</div>
</div>
<!-- 对比行 -->
<div v-for="dim in data.dimensions" :key="dim.label" class="compare-row">
<div class="compare-label-col">
<span class="dim-icon">{{ dim.icon }}</span>
<span class="dim-label">{{ dim.label }}</span>
</div>
<div
v-for="(val, i) in dim.values"
:key="i"
class="compare-value-col"
:class="{ 'compare-value-col--highlight': data.destinations[i]?.highlight }"
>
<span class="dim-label-mobile">{{ dim.icon }} {{ dim.label }}</span>
{{ val }}
</div>
</div>
</div>
<!-- 坦诚说明 -->
<div class="honest-block">
<h3 class="honest-title">{{ data.honestNote.title }}</h3>
<p class="honest-subtitle">{{ data.honestNote.subtitle }}</p>
<ul class="honest-list">
<li v-for="(item, i) in data.honestNote.items" :key="i">{{ item }}</li>
</ul>
</div>
<!-- 结语 -->
<div class="closing-block">
<h3 class="closing-title">{{ data.closing.title }}</h3>
<p class="closing-text">{{ data.closing.text }}</p>
</div>
<!-- 数据来源 -->
<p class="data-source">{{ data.dataSources }}</p>
</div>
</section>
</template>
<script setup>
import data from '~/data/destinations.json'
</script>
<style lang="less" scoped>
.compare-intro {
max-width: 800px;
margin: 0 auto @space-xl;
font-size: @font-size-base;
color: @color-text-secondary;
line-height: @line-height-loose;
text-align: center;
}
// 对比表格
.compare-table {
margin-bottom: @space-2xl;
border: 1px solid @color-border;
border-radius: @border-radius-lg;
overflow: hidden;
}
.compare-header {
display: none;
.respond-md({
display: grid;
grid-template-columns: 120px repeat(3, 1fr);
background: @color-bg-gray;
border-bottom: 1px solid @color-border;
});
}
.compare-label-col {
padding: @space-md @space-lg;
display: flex;
align-items: center;
gap: @space-sm;
font-weight: @font-weight-medium;
color: @color-text-muted;
font-size: @font-size-sm;
}
.compare-dest-col {
padding: @space-lg;
text-align: center;
&--highlight {
background: @color-primary-bg;
position: relative;
&::after {
content: '推荐';
position: absolute;
top: @space-xs;
right: @space-sm;
padding: 2px @space-sm;
font-size: 11px;
font-weight: @font-weight-bold;
color: #fff;
background: @color-primary;
border-radius: @border-radius-sm;
}
}
}
.dest-name {
font-size: @font-size-lg;
font-weight: @font-weight-bold;
color: @color-text-primary;
margin-bottom: @space-xs;
}
.dest-tag {
font-size: @font-size-xs;
color: @color-text-muted;
}
// 对比行
.compare-row {
display: flex;
flex-direction: column;
border-bottom: 1px solid @color-border;
&:last-child {
border-bottom: none;
}
.respond-md({
display: grid;
grid-template-columns: 120px repeat(3, 1fr);
flex-direction: row;
});
}
.compare-value-col {
padding: @space-md @space-lg;
font-size: @font-size-sm;
color: @color-text-secondary;
line-height: @line-height-base;
border-bottom: 1px solid fadeout(@color-border, 50%);
.respond-md({
border-bottom: none;
border-left: 1px solid fadeout(@color-border, 50%);
});
&:last-child {
border-bottom: none;
}
&--highlight {
background: fadeout(@color-primary-bg, 30%);
color: @color-text-primary;
font-weight: @font-weight-medium;
}
}
// 移动端:每个值前显示维度标签
.dim-label-mobile {
display: block;
font-size: @font-size-xs;
font-weight: @font-weight-bold;
color: @color-text-muted;
margin-bottom: @space-xs;
.respond-md({
display: none;
});
}
.dim-icon {
font-size: @font-size-base;
}
.dim-label {
font-size: @font-size-sm;
}
// 移动端隐藏左侧标签列
.compare-label-col {
display: none;
.respond-md({
display: flex;
});
}
// 坦诚说明
.honest-block {
max-width: 800px;
margin: 0 auto @space-xl;
padding: @space-xl;
background: #FFF7ED;
border-radius: @border-radius-lg;
border-left: 4px solid #F59E0B;
}
.honest-title {
font-size: @font-size-lg;
font-weight: @font-weight-bold;
color: #B45309;
margin-bottom: @space-xs;
}
.honest-subtitle {
font-size: @font-size-sm;
color: @color-text-muted;
margin-bottom: @space-md;
}
.honest-list {
display: flex;
flex-direction: column;
gap: @space-sm;
li {
font-size: @font-size-sm;
color: @color-text-secondary;
line-height: @line-height-base;
padding-left: @space-md;
position: relative;
&::before {
content: '•';
position: absolute;
left: 0;
color: #F59E0B;
font-weight: bold;
}
}
}
// 结语
.closing-block {
max-width: 800px;
margin: 0 auto @space-xl;
padding: @space-xl;
background: @color-primary-bg;
border-radius: @border-radius-lg;
border-left: 4px solid @color-primary;
}
.closing-title {
font-size: @font-size-lg;
font-weight: @font-weight-bold;
color: @color-primary;
margin-bottom: @space-md;
}
.closing-text {
font-size: @font-size-base;
color: @color-text-secondary;
line-height: @line-height-loose;
}
// 数据来源
.data-source {
text-align: center;
font-size: @font-size-xs;
color: @color-text-muted;
}
</style>