Files
arcticnewone/app/components/home/HomeTestimonials.vue
T
virtheart 337eb4f05a feat: 登录改为 Casdoor 统一身份认证(SSO),重建用户体系
- 移除内置密码注册/登录/改密/删号/头像,统一走 Casdoor OIDC 授权码
- 服务端 casdoor-nodejs-sdk:code 换 token + 证书公钥验签 + get-account 补齐资料
- 用户表重建为 provider+provider_id(Casdoor sub 为准),邮箱不再唯一
- 管理员由 Casdoor token 的 isAdmin/IsAdmin 字段或 admin 角色判定,删除角色切换接口
- 前端登录弹窗改为申统认证跳转,注册去 Casdoor;后台用户列表只读角色
- 会话沿用 an_session httpOnly Cookie,requireUser/requireAdmin 守卫保留
- 配置注入 deploy.sh/.env.example;新增 casdoor 单测,删除 password 单测
2026-08-09 00:18:47 +08:00

181 lines
5.6 KiB
Vue

<template>
<section v-if="testimonials.length" ref="rootRef" class="relative bg-gradient-to-b from-gray-50 to-white min-h-screen flex flex-col items-center justify-center overflow-hidden py-20">
<div class="w-full max-w-[1400px] mx-auto px-6 md:px-10">
<!-- 标题 -->
<div ref="headerRef" class="text-center mb-16 md:mb-20">
<h2 class="text-5xl md:text-7xl font-bold tracking-tight text-black mb-6">
{{ t('home.testimonials.title') }}
</h2>
<p class="text-lg md:text-xl text-gray-600 max-w-2xl mx-auto">
{{ t('home.testimonials.subtitle') }}
</p>
</div>
<!-- 自动滚动轮播 -->
<div class="relative -mx-6 md:-mx-10 px-6 md:px-10 overflow-hidden" style="mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%); -webkit-mask-image: linear-gradient(to right, transparent 0%, black 5%, black 95%, transparent 100%);">
<div
ref="trackRef"
class="flex gap-6 md:gap-8 py-4"
:style="{ transform: `translateX(${offset}px)` }"
@mouseenter="pauseAutoplay"
@mouseleave="resumeAutoplay"
>
<!-- 复制两份实现无缝循环 -->
<div
v-for="(item, index) in allTestimonials"
:key="`card-${index}`"
class="testimonial-card flex-shrink-0 w-[320px] md:w-[400px] bg-white rounded-3xl p-8 md:p-10 shadow-lg hover:shadow-xl transition-shadow duration-300"
>
<!-- 评分 -->
<div class="flex gap-1 mb-6">
<Icon v-for="i in 5" :key="i" name="ph:star-fill" class="w-5 h-5 text-yellow-400" />
</div>
<!-- 评价内容 -->
<p class="text-gray-700 text-base md:text-lg leading-relaxed mb-8 italic">
"{{ item.content }}"
</p>
<!-- 客户信息 -->
<div class="flex items-center gap-4">
<div class="w-14 h-14 md:w-16 md:h-16 rounded-full overflow-hidden bg-gradient-to-br" :class="item.avatarGradient">
<div class="w-full h-full flex items-center justify-center text-white text-xl md:text-2xl font-bold">
{{ item.initial }}
</div>
</div>
<div>
<h4 class="text-lg md:text-xl font-bold text-black">
{{ item.name }}
</h4>
<p class="text-sm md:text-base text-gray-500">
{{ item.role }}
</p>
</div>
</div>
<!-- 装饰引号 -->
<div class="absolute top-8 right-8 w-10 h-10 opacity-10">
<Icon name="ph:quotes-duotone" class="w-full h-full text-black" />
</div>
</div>
</div>
</div>
</div>
</section>
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted, nextTick, computed } from 'vue'
import { useI18n } from 'vue-i18n'
import gsap from 'gsap'
import { ScrollTrigger } from 'gsap/ScrollTrigger'
import { useSiteSettings } from '~/composables/useSiteSettings'
gsap.registerPlugin(ScrollTrigger)
const { t, locale } = useI18n()
const { settings } = useSiteSettings()
const rootRef = ref<HTMLElement | null>(null)
const headerRef = ref<HTMLElement | null>(null)
const trackRef = ref<HTMLElement | null>(null)
let ctx: gsap.Context | null = null
let animFrameId: number | null = null
// 头像渐变预设按序号循环,后台无需逐条选色
const AVATAR_STYLES = [
'from-blue-500 to-cyan-500',
'from-purple-500 to-pink-500',
'from-orange-500 to-red-500',
'from-green-500 to-emerald-500',
'from-indigo-500 to-purple-500',
]
const locStr = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
// 客户评价来自后台配置(/admin/settings 客户评价),空则不渲染该板块
const testimonials = computed(() =>
(settings.value?.testimonials ?? []).map((t, i) => ({
id: t.id,
name: t.name,
role: locStr(t.roleZh, t.roleEn),
content: locStr(t.contentZh, t.contentEn),
initial: (t.name || '?').trim().charAt(0).toUpperCase(),
avatarGradient: AVATAR_STYLES[i % AVATAR_STYLES.length],
})),
)
// 复制一份用于无缝循环
const allTestimonials = computed(() => [...testimonials.value, ...testimonials.value])
// 自动滚动状态
const offset = ref(0)
const speed = 1.5 // 每帧移动像素
let isPaused = false
const cardWidth = 400 + 32 // 卡片宽度 + gap
const startAutoplay = () => {
const totalWidth = testimonials.value.length * cardWidth
const animate = () => {
if (!isPaused) {
offset.value -= speed
// 当第一组卡片完全滚出时,重置位置实现无缝
if (Math.abs(offset.value) >= totalWidth) {
offset.value += totalWidth
}
}
animFrameId = requestAnimationFrame(animate)
}
animFrameId = requestAnimationFrame(animate)
}
const pauseAutoplay = () => {
isPaused = true
}
const resumeAutoplay = () => {
isPaused = false
}
onMounted(async () => {
await nextTick()
if (!rootRef.value || !headerRef.value) return
ctx = gsap.context(() => {
// 标题入场动画
gsap.fromTo(headerRef.value,
{ autoAlpha: 0, y: 50 },
{
scrollTrigger: {
trigger: rootRef.value,
start: 'top 75%',
toggleActions: 'play none none none',
},
autoAlpha: 1,
y: 0,
duration: 0.8,
ease: 'power3.out',
}
)
}, rootRef.value)
// 启动自动滚动
startAutoplay()
})
onUnmounted(() => {
ctx?.revert()
if (animFrameId) cancelAnimationFrame(animFrameId)
})
</script>
<style scoped>
.testimonial-card {
position: relative;
will-change: transform;
}
</style>