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 单测
This commit is contained in:
@@ -7,7 +7,12 @@
|
||||
class="w-full rounded-xl border border-gray-200 bg-white px-3.5 py-2.5 text-sm outline-none transition-all focus:border-black focus:ring-2 focus:ring-black/10 disabled:opacity-50"
|
||||
@change="emit('update:modelValue', ($event.target as HTMLSelectElement).value)"
|
||||
>
|
||||
<option v-for="o in options" :key="o.value" :value="o.value">{{ o.label }}</option>
|
||||
<template v-for="o in options" :key="isGroup(o) ? o.group : o.value">
|
||||
<optgroup v-if="isGroup(o)" :label="o.group">
|
||||
<option v-for="opt in o.options" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
|
||||
</optgroup>
|
||||
<option v-else :value="o.value">{{ o.label }}</option>
|
||||
</template>
|
||||
</select>
|
||||
</div>
|
||||
</template>
|
||||
@@ -17,9 +22,14 @@ interface Option {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
withDefaults(defineProps<{ modelValue: string; options: Option[]; label?: string; disabled?: boolean }>(), {
|
||||
label: '',
|
||||
disabled: false,
|
||||
})
|
||||
interface OptionGroup {
|
||||
group: string
|
||||
options: Option[]
|
||||
}
|
||||
withDefaults(
|
||||
defineProps<{ modelValue: string; options: Array<Option | OptionGroup>; label?: string; disabled?: boolean }>(),
|
||||
{ label: '', disabled: false },
|
||||
)
|
||||
const isGroup = (o: Option | OptionGroup): o is OptionGroup => 'group' in o && !!o.group
|
||||
const emit = defineEmits<{ 'update:modelValue': [v: string] }>()
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<!-- 有图显示图片;无图显示品牌渐变兜底 + 标题文字,避免裂图 -->
|
||||
<img
|
||||
v-if="src"
|
||||
:src="src"
|
||||
:alt="alt"
|
||||
v-bind="$attrs"
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
v-bind="$attrs"
|
||||
class="flex items-center justify-center bg-gradient-to-br from-gray-200 via-gray-100 to-gray-200"
|
||||
>
|
||||
<span class="px-4 text-center text-sm md:text-base font-bold tracking-tight text-gray-400">
|
||||
{{ title }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({ inheritAttrs: false })
|
||||
|
||||
defineProps<{
|
||||
src?: string | null
|
||||
alt?: string
|
||||
title?: string
|
||||
}>()
|
||||
</script>
|
||||
@@ -7,7 +7,6 @@
|
||||
@click.self="closeModal"
|
||||
>
|
||||
<div
|
||||
ref="modalRef"
|
||||
class="relative w-full max-w-md bg-white rounded-2xl shadow-2xl overflow-hidden"
|
||||
@click.stop
|
||||
>
|
||||
@@ -20,69 +19,30 @@
|
||||
<Icon name="ph:x" class="w-5 h-5 text-gray-600" />
|
||||
</button>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<!-- 统一身份认证 -->
|
||||
<div class="p-8">
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-2">{{ t('auth.login') }}</h2>
|
||||
<p class="text-gray-600 mb-8">{{ t('auth.loginDescription') }}</p>
|
||||
<p class="text-gray-600 mb-8">{{ t('auth.casdoorDescription') }}</p>
|
||||
|
||||
<form @submit.prevent="handleLogin" class="space-y-5">
|
||||
<div>
|
||||
<label for="account" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.account') }}
|
||||
</label>
|
||||
<input
|
||||
id="account"
|
||||
v-model="account"
|
||||
type="text"
|
||||
required
|
||||
autocomplete="username"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.accountPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<p class="text-sm text-gray-500 mb-4">{{ t('auth.casdoorHint') }}</p>
|
||||
|
||||
<div>
|
||||
<label for="password" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.password') }}
|
||||
</label>
|
||||
<input
|
||||
id="password"
|
||||
v-model="password"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="current-password"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.passwordPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
<!-- 登录按钮:跳转 Casdoor,回跳当前页面 -->
|
||||
<button
|
||||
type="button"
|
||||
:disabled="isRedirecting"
|
||||
class="w-full py-3 rounded-xl font-semibold text-white transition-all duration-300 flex items-center justify-center gap-2 bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl disabled:opacity-60 disabled:cursor-not-allowed"
|
||||
@click="handleLogin"
|
||||
>
|
||||
<Icon name="ph:shield-check" class="w-5 h-5" />
|
||||
<span>{{ isRedirecting ? t('auth.redirecting') : t('auth.loginWithCasdoor') }}</span>
|
||||
</button>
|
||||
|
||||
<!-- 错误消息 -->
|
||||
<div v-if="errorMessage" class="p-3 rounded-lg bg-red-50 border border-red-200 text-red-800 text-sm">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="isSubmitting || !account || !password"
|
||||
class="w-full py-3 rounded-xl font-semibold text-white transition-all duration-300 flex items-center justify-center gap-2"
|
||||
:class="isSubmitting || !account || !password
|
||||
? 'bg-gray-400 cursor-not-allowed'
|
||||
: 'bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl'"
|
||||
>
|
||||
<Icon v-if="isSubmitting" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
|
||||
<span>{{ isSubmitting ? t('auth.loggingIn') : t('auth.loginButton') }}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- 注册账号链接 -->
|
||||
<!-- 注册:前往 Casdoor 注册页 -->
|
||||
<p class="mt-6 text-center text-sm text-gray-600">
|
||||
{{ t('auth.noAccount') }}
|
||||
<button @click="authModal.switchToRegister()" class="text-black font-semibold hover:underline">
|
||||
<a :href="signupUrl" target="_blank" rel="noopener" class="text-black font-semibold hover:underline">
|
||||
{{ t('auth.createAccount') }}
|
||||
</button>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -93,54 +53,39 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { useRoute } from '#app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
import { useApiError } from '~/composables/useApiError'
|
||||
import { getCasdoorSignupUrl } from '~/utils/casdoorClient'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const route = useRoute()
|
||||
const authModal = useAuthModalStore()
|
||||
const apiError = useApiError()
|
||||
|
||||
const account = ref('')
|
||||
const password = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const isRedirecting = ref(false)
|
||||
const signupUrl = getCasdoorSignupUrl()
|
||||
|
||||
const closeModal = () => {
|
||||
if (!isSubmitting.value) {
|
||||
if (!isRedirecting.value) {
|
||||
authModal.closeAll()
|
||||
}
|
||||
}
|
||||
|
||||
// 打开时重置表单
|
||||
// 打开时重置状态
|
||||
watch(
|
||||
() => authModal.isLoginOpen,
|
||||
(open) => {
|
||||
if (open) {
|
||||
account.value = ''
|
||||
password.value = ''
|
||||
errorMessage.value = ''
|
||||
}
|
||||
if (open) isRedirecting.value = false
|
||||
},
|
||||
)
|
||||
|
||||
const handleLogin = async () => {
|
||||
if (isSubmitting.value) return
|
||||
isSubmitting.value = true
|
||||
errorMessage.value = ''
|
||||
|
||||
const result = await userStore.login(account.value, password.value)
|
||||
|
||||
if (result.success) {
|
||||
account.value = ''
|
||||
password.value = ''
|
||||
authModal.closeAll()
|
||||
} else {
|
||||
errorMessage.value = apiError({ data: { code: result.code } })
|
||||
}
|
||||
isSubmitting.value = false
|
||||
const handleLogin = () => {
|
||||
if (isRedirecting.value) return
|
||||
isRedirecting.value = true
|
||||
const next = route.fullPath
|
||||
const target = next.startsWith('/') && !next.startsWith('//') ? next : '/'
|
||||
const url = `/api/auth/casdoor-login?next=${encodeURIComponent(target)}`
|
||||
window.location.assign(url)
|
||||
}
|
||||
|
||||
// ESC 关闭
|
||||
@@ -179,4 +124,4 @@ if (typeof window !== 'undefined') {
|
||||
transform: scale(0.95) translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -1,263 +0,0 @@
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<Transition name="modal">
|
||||
<div
|
||||
v-if="authModal.isRegisterOpen"
|
||||
class="fixed inset-0 z-[100] flex items-center justify-center bg-black/50 backdrop-blur-sm px-4"
|
||||
@click.self="closeModal"
|
||||
>
|
||||
<div
|
||||
ref="modalRef"
|
||||
class="relative w-full max-w-md bg-white rounded-2xl shadow-2xl overflow-hidden"
|
||||
@click.stop
|
||||
>
|
||||
<!-- 关闭按钮 -->
|
||||
<button
|
||||
@click="closeModal"
|
||||
class="absolute top-4 right-4 w-8 h-8 flex items-center justify-center rounded-full hover:bg-gray-100 transition-colors z-10"
|
||||
aria-label="Close"
|
||||
>
|
||||
<Icon name="ph:x" class="w-5 h-5 text-gray-600" />
|
||||
</button>
|
||||
|
||||
<!-- 注册表单 -->
|
||||
<div class="p-8">
|
||||
<h2 class="text-2xl md:text-3xl font-bold text-black mb-2">{{ t('auth.register') }}</h2>
|
||||
<p class="text-gray-600 mb-8">{{ t('auth.registerDescription') }}</p>
|
||||
|
||||
<form @submit.prevent="handleRegister" class="space-y-5">
|
||||
<div>
|
||||
<label for="reg-username" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.username') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-username"
|
||||
v-model="username"
|
||||
type="text"
|
||||
required
|
||||
autocomplete="username"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.usernamePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="reg-email" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.email') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-email"
|
||||
v-model="email"
|
||||
type="email"
|
||||
required
|
||||
autocomplete="email"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.emailPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="reg-phone" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.phone') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-phone"
|
||||
v-model="phone"
|
||||
type="tel"
|
||||
autocomplete="tel"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.phonePlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="reg-password" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.password') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-password"
|
||||
v-model="password"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="new-password"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.passwordPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="reg-confirm-password" class="block text-sm font-semibold text-gray-800 mb-2">
|
||||
{{ t('auth.confirmPassword') }}
|
||||
</label>
|
||||
<input
|
||||
id="reg-confirm-password"
|
||||
v-model="confirmPassword"
|
||||
type="password"
|
||||
required
|
||||
autocomplete="new-password"
|
||||
:disabled="isSubmitting"
|
||||
class="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-black focus:ring-2 focus:ring-black/5 outline-none transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
:placeholder="t('auth.confirmPasswordPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 错误消息 -->
|
||||
<div v-if="errorMessage" class="p-3 rounded-lg bg-red-50 border border-red-200 text-red-800 text-sm">
|
||||
{{ errorMessage }}
|
||||
</div>
|
||||
|
||||
<!-- 成功消息 -->
|
||||
<div v-if="successMessage" class="p-3 rounded-lg bg-green-50 border border-green-200 text-green-800 text-sm">
|
||||
{{ successMessage }}
|
||||
</div>
|
||||
|
||||
<!-- 注册按钮 -->
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="isSubmitting || !username || !email || !password || !confirmPassword"
|
||||
class="w-full py-3 rounded-xl font-semibold text-white transition-all duration-300 flex items-center justify-center gap-2"
|
||||
:class="isSubmitting || !username || !email || !password || !confirmPassword
|
||||
? 'bg-gray-400 cursor-not-allowed'
|
||||
: 'bg-black hover:bg-gray-800 shadow-lg hover:shadow-xl'"
|
||||
>
|
||||
<Icon v-if="isSubmitting" name="ph:circle-notch" class="w-5 h-5 animate-spin" />
|
||||
<span>{{ isSubmitting ? t('auth.registering') : t('auth.registerButton') }}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- 返回登录链接 -->
|
||||
<p class="mt-6 text-center text-sm text-gray-600">
|
||||
{{ t('auth.alreadyHaveAccount') }}
|
||||
<button @click="authModal.switchToLogin()" class="text-black font-semibold hover:underline">
|
||||
{{ t('auth.backToLogin') }}
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
import { useApiError } from '~/composables/useApiError'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const authModal = useAuthModalStore()
|
||||
const apiError = useApiError()
|
||||
|
||||
const username = ref('')
|
||||
const email = ref('')
|
||||
const phone = ref('')
|
||||
const password = ref('')
|
||||
const confirmPassword = ref('')
|
||||
const isSubmitting = ref(false)
|
||||
const errorMessage = ref('')
|
||||
const successMessage = ref('')
|
||||
|
||||
const closeModal = () => {
|
||||
if (!isSubmitting.value) {
|
||||
authModal.closeAll()
|
||||
}
|
||||
}
|
||||
|
||||
// 打开时重置表单
|
||||
watch(
|
||||
() => authModal.isRegisterOpen,
|
||||
(open) => {
|
||||
if (open) {
|
||||
username.value = ''
|
||||
email.value = ''
|
||||
phone.value = ''
|
||||
password.value = ''
|
||||
confirmPassword.value = ''
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const handleRegister = async () => {
|
||||
if (isSubmitting.value) return
|
||||
errorMessage.value = ''
|
||||
successMessage.value = ''
|
||||
|
||||
if (password.value !== confirmPassword.value) {
|
||||
errorMessage.value = t('auth.passwordMismatch')
|
||||
return
|
||||
}
|
||||
if (phone.value && !/^1[3-9]\d{9}$/.test(phone.value)) {
|
||||
errorMessage.value = t('auth.invalidPhone')
|
||||
return
|
||||
}
|
||||
|
||||
isSubmitting.value = true
|
||||
const result = await userStore.register({
|
||||
username: username.value,
|
||||
email: email.value,
|
||||
phone: phone.value,
|
||||
password: password.value,
|
||||
})
|
||||
|
||||
if (result.success) {
|
||||
successMessage.value = t('auth.registerSuccess')
|
||||
username.value = ''
|
||||
email.value = ''
|
||||
phone.value = ''
|
||||
password.value = ''
|
||||
confirmPassword.value = ''
|
||||
setTimeout(() => {
|
||||
authModal.closeAll()
|
||||
}, 1500)
|
||||
} else {
|
||||
errorMessage.value = apiError({ data: { code: result.code } })
|
||||
}
|
||||
isSubmitting.value = false
|
||||
}
|
||||
|
||||
// ESC 关闭
|
||||
const handleKeydown = (e: KeyboardEvent) => {
|
||||
if (e.key === 'Escape' && authModal.isRegisterOpen) {
|
||||
closeModal()
|
||||
}
|
||||
}
|
||||
if (typeof window !== 'undefined') {
|
||||
window.addEventListener('keydown', handleKeydown)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-enter-from,
|
||||
.modal-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.modal-enter-active .relative,
|
||||
.modal-leave-active .relative {
|
||||
transition: transform 0.3s ease, opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-enter-from .relative {
|
||||
transform: scale(0.95) translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.modal-leave-to .relative {
|
||||
transform: scale(0.95) translateY(20px);
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<section ref="rootRef" class="relative bg-black text-white min-h-screen flex items-center justify-center overflow-hidden">
|
||||
<section v-if="achievements.length" ref="rootRef" class="relative bg-black text-white min-h-screen flex items-center justify-center overflow-hidden">
|
||||
<!-- 背景粒子 -->
|
||||
<canvas ref="canvasRef" class="absolute inset-0 w-full h-full opacity-30"></canvas>
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
<!-- 描述 -->
|
||||
<div class="flex-1">
|
||||
<h3 class="text-2xl md:text-3xl font-bold mb-3">
|
||||
{{ t(`home.achievements.items.${achievement.id}.title`) }}
|
||||
{{ achievement.title }}
|
||||
</h3>
|
||||
<p class="text-gray-400 text-base md:text-lg leading-relaxed">
|
||||
{{ t(`home.achievements.items.${achievement.id}.description`) }}
|
||||
{{ achievement.description }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,14 +45,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
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 } = useI18n()
|
||||
const { locale } = useI18n()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const canvasRef = ref<HTMLCanvasElement | null>(null)
|
||||
@@ -69,37 +71,28 @@ const setNumberRef = (el: any, index: number) => {
|
||||
if (el) numberElements.value[index] = el
|
||||
}
|
||||
|
||||
const achievements = [
|
||||
{
|
||||
id: 'projects',
|
||||
number: 150,
|
||||
suffix: '+',
|
||||
color: 'text-blue-400',
|
||||
bgColor: 'bg-blue-500'
|
||||
},
|
||||
{
|
||||
id: 'clients',
|
||||
number: 85,
|
||||
suffix: '+',
|
||||
color: 'text-purple-400',
|
||||
bgColor: 'bg-purple-500'
|
||||
},
|
||||
{
|
||||
id: 'experience',
|
||||
number: 12,
|
||||
suffix: '+',
|
||||
color: 'text-green-400',
|
||||
bgColor: 'bg-green-500'
|
||||
},
|
||||
{
|
||||
id: 'satisfaction',
|
||||
number: 98,
|
||||
suffix: '%',
|
||||
color: 'text-orange-400',
|
||||
bgColor: 'bg-orange-500'
|
||||
}
|
||||
// 颜色预设按序号循环,后台无需逐条选色
|
||||
const ACHIEVEMENT_STYLES = [
|
||||
{ color: 'text-blue-400', bgColor: 'bg-blue-500' },
|
||||
{ color: 'text-purple-400', bgColor: 'bg-purple-500' },
|
||||
{ color: 'text-green-400', bgColor: 'bg-green-500' },
|
||||
{ color: 'text-orange-400', bgColor: 'bg-orange-500' },
|
||||
]
|
||||
|
||||
const locStr = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
|
||||
|
||||
// 成就数据来自后台配置(/admin/settings 首页成就数据),空则不渲染该板块
|
||||
const achievements = computed(() =>
|
||||
(settings.value?.achievements ?? []).map((a, i) => ({
|
||||
id: a.id,
|
||||
number: Number(a.number) || 0,
|
||||
suffix: a.suffix,
|
||||
title: locStr(a.titleZh, a.titleEn),
|
||||
description: locStr(a.descriptionZh, a.descriptionEn),
|
||||
...ACHIEVEMENT_STYLES[i % ACHIEVEMENT_STYLES.length],
|
||||
})),
|
||||
)
|
||||
|
||||
// 粒子动画
|
||||
const initParticles = () => {
|
||||
const canvas = canvasRef.value
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onBeforeUnmount, ref } from 'vue'
|
||||
import { onMounted, onBeforeUnmount, ref, computed } from 'vue'
|
||||
import { useNuxtApp } from '#app'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import gsap from 'gsap'
|
||||
import AnimatedButton from '~/components/common/AnimatedButton.vue'
|
||||
import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
// 定义背景画廊与主视图绑定的总滚动距离(像素),数值越大,用户向下滚动时 Hero 面板缩放的过程就越长
|
||||
const heroPinDistance = 1200
|
||||
const heroGalleryColumns = [
|
||||
{ side: 'left', images: ['1018', '1015', '1024', '1039'].map(id => `https://picsum.photos/id/${id}/900/1200`) },
|
||||
{ side: 'right', images: ['1043', '1050', '1067', '1074'].map(id => `https://picsum.photos/id/${id}/900/1200`) },
|
||||
] as const
|
||||
// 背景画廊:由后台「首页 Hero 画廊」配置,图片均分到左右两列;为空时显示品牌纯色兜底
|
||||
const heroGalleryColumns = computed(() => {
|
||||
const gallery = settings.value?.hero?.gallery ?? []
|
||||
const left = gallery.filter((_, i) => i % 2 === 0)
|
||||
const right = gallery.filter((_, i) => i % 2 === 1)
|
||||
const columns: { side: 'left' | 'right'; images: string[] }[] = []
|
||||
if (left.length) columns.push({ side: 'left', images: left })
|
||||
if (right.length) columns.push({ side: 'right', images: right })
|
||||
return columns
|
||||
})
|
||||
|
||||
const heroStageRef = ref<HTMLElement | null>(null)
|
||||
const heroRef = ref<HTMLElement | null>(null)
|
||||
@@ -202,14 +210,16 @@ defineExpose({ play })
|
||||
class="relative bg-black"
|
||||
:style="{ height: `calc(100svh + ${heroPinDistance}px)` }"
|
||||
>
|
||||
<section ref="heroRef" class="sticky top-0 h-[100svh] overflow-hidden bg-[#111]" v-once>
|
||||
<section ref="heroRef" class="sticky top-0 h-[100svh] overflow-hidden bg-[#111]">
|
||||
<div class="absolute inset-0 overflow-hidden bg-black" aria-hidden="true">
|
||||
<div
|
||||
v-for="column in heroGalleryColumns"
|
||||
:key="column.side"
|
||||
class="absolute -bottom-10 -top-10 w-[49vw] overflow-hidden"
|
||||
:class="column.side === 'left' ? 'left-0' : 'right-0'"
|
||||
>
|
||||
<!-- 有后台画廊配置时渲染图片列;否则显示品牌纯色兜底 -->
|
||||
<template v-if="heroGalleryColumns.length">
|
||||
<div
|
||||
v-for="column in heroGalleryColumns"
|
||||
:key="column.side"
|
||||
class="absolute -bottom-10 -top-10 w-[49vw] overflow-hidden"
|
||||
:class="column.side === 'left' ? 'left-0' : 'right-0'"
|
||||
>
|
||||
<!-- 复制两份图片组,配合 translateY(-50%) 做无缝循环。 -->
|
||||
<div
|
||||
class="hero-gallery-track will-change-transform"
|
||||
@@ -228,6 +238,11 @@ defineExpose({ play })
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<!-- 兜底:无后台画廊配置时的品牌背景 -->
|
||||
<div class="absolute inset-0 bg-gradient-to-br from-neutral-800 via-neutral-900 to-black"></div>
|
||||
</template>
|
||||
</div>
|
||||
<div ref="heroPanelRef" class="absolute inset-0 flex flex-col justify-between items-center bg-white text-black will-change-transform pt-24 pb-8 md:pt-36 md:pb-12 overflow-hidden">
|
||||
<div class="flex flex-col justify-between w-page-container max-w-[calc(100%-2rem)] mx-auto px-4 h-full">
|
||||
|
||||
@@ -3,10 +3,12 @@ import { onMounted, onUnmounted, ref, computed, watch } 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()
|
||||
|
||||
interface WorkItem {
|
||||
slug: string
|
||||
@@ -26,40 +28,8 @@ const rootRef = ref<HTMLElement | null>(null)
|
||||
const workSectionRef = ref<HTMLElement | null>(null)
|
||||
const workPinRef = ref<HTMLElement | null>(null)
|
||||
|
||||
const partners = [
|
||||
{
|
||||
id: 'p1',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 44V20h12c7 0 12 4 12 10s-5 10-12 10h-6v4H20Z" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/><path d="M34 40l10 12" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p2',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 32c0-9.94 8.06-18 18-18s18 8.06 18 18-8.06 18-18 18-18-8.06-18-18Z" stroke="currentColor" stroke-width="3"/><path d="M24 32c0-4.42 3.58-8 8-8s8 3.58 8 8-3.58 8-8 8-8-3.58-8-8Z" stroke="currentColor" stroke-width="3"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p3',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M32 14v10M32 40v10M14 32h10M40 32h10" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M32 22c5.52 0 10 4.48 10 10s-4.48 10-10 10-10-4.48-10-10 4.48-10 10-10Z" stroke="currentColor" stroke-width="3"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p4',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 44c10-2 12-14 18-18s10-1 18-6" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M16 34c8-2 10 8 18 6s10-18 18-18" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p5',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 38c0-9 6-18 14-18s14 9 14 18" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M22 42h20" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p6',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 20v24M30 20v24M42 20v24" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M14 20h36M14 44h36" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p7',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 44V20h10c9 0 18 7 18 12s-9 12-18 12H18Z" stroke="currentColor" stroke-width="3" stroke-linejoin="round"/></svg>',
|
||||
},
|
||||
{
|
||||
id: 'p8',
|
||||
svg: '<svg viewBox="0 0 64 64" width="34" height="34" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16 34c8-14 18-14 32-4" stroke="currentColor" stroke-width="3" stroke-linecap="round"/><path d="M18 44c10-10 20-10 30-2" stroke="currentColor" stroke-width="3" stroke-linecap="round"/></svg>',
|
||||
},
|
||||
]
|
||||
// 合作伙伴来自后台配置(/admin/settings 合作伙伴),空则隐藏该排展示
|
||||
const partners = computed(() => settings.value?.partners ?? [])
|
||||
|
||||
let st: ScrollTrigger | null = null
|
||||
let madeTweens: gsap.core.Animation[] = []
|
||||
@@ -191,23 +161,39 @@ onUnmounted(() => {
|
||||
<template>
|
||||
<section ref="rootRef" class="bg-[#F5F5F5]">
|
||||
<div class="w-page-container max-w-[calc(100%-2rem)] mx-auto px-6 md:px-10 lg:px-14 pt-24 pb-20">
|
||||
<div class="grid grid-cols-[1fr_auto_1fr] items-center">
|
||||
<p class="justify-self-start text-xs font-semibold tracking-tight text-black">( {{ t('home.partners.label') }} )</p>
|
||||
<div class="flex items-center justify-self-center gap-8 text-xs font-semibold tracking-tight text-black">
|
||||
<span class="h-1 w-1 rounded-full bg-black" />
|
||||
<span>{{ t('home.partners.years') }}</span>
|
||||
<!-- 合作伙伴(后台配置;空则不展示该排) -->
|
||||
<template v-if="partners.length">
|
||||
<div class="grid grid-cols-[1fr_auto_1fr] items-center">
|
||||
<p class="justify-self-start text-xs font-semibold tracking-tight text-black">( {{ t('home.partners.label') }} )</p>
|
||||
<div class="flex items-center justify-self-center gap-8 text-xs font-semibold tracking-tight text-black">
|
||||
<span class="h-1 w-1 rounded-full bg-black" />
|
||||
<span>{{ t('home.partners.years') }}</span>
|
||||
</div>
|
||||
<span class="justify-self-end h-1 w-1 rounded-full bg-black" />
|
||||
</div>
|
||||
<span class="justify-self-end h-1 w-1 rounded-full bg-black" />
|
||||
</div>
|
||||
|
||||
<div class="mt-12 grid grid-cols-2 sm:grid-cols-4 gap-5">
|
||||
<div
|
||||
v-for="item in partners"
|
||||
:key="item.id"
|
||||
class="h-[152px] rounded-[20px] bg-white flex items-center justify-center text-black border-0 shadow-none outline-none ring-0"
|
||||
v-html="item.svg"
|
||||
/>
|
||||
</div>
|
||||
<div class="mt-12 grid grid-cols-2 sm:grid-cols-4 gap-5">
|
||||
<template v-for="item in partners" :key="item.id">
|
||||
<a
|
||||
v-if="item.url"
|
||||
:href="item.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="h-[152px] rounded-[20px] bg-white flex items-center justify-center border-0 shadow-none outline-none ring-0 group"
|
||||
>
|
||||
<img v-if="item.logo" :src="item.logo" :alt="item.name" class="max-h-[72px] max-w-[80%] object-contain" />
|
||||
<span v-else class="text-lg font-bold text-gray-400 group-hover:text-black transition-colors">{{ item.name }}</span>
|
||||
</a>
|
||||
<div
|
||||
v-else
|
||||
class="h-[152px] rounded-[20px] bg-white flex items-center justify-center border-0 shadow-none outline-none ring-0"
|
||||
>
|
||||
<img v-if="item.logo" :src="item.logo" :alt="item.name" class="max-h-[72px] max-w-[80%] object-contain" />
|
||||
<span v-else class="text-lg font-bold text-gray-400">{{ item.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<section id="work" ref="workSectionRef" class="bg-white">
|
||||
@@ -244,12 +230,11 @@ onUnmounted(() => {
|
||||
:to="`/work/${item.slug}`"
|
||||
class="will-change-transform relative block"
|
||||
>
|
||||
<img
|
||||
class="h-full w-full object-cover"
|
||||
:src="item.image || ''"
|
||||
<CoverImage
|
||||
:src="item.image"
|
||||
:alt="locText(item.titleZh, item.titleEn)"
|
||||
loading="eager"
|
||||
decoding="async"
|
||||
:title="locText(item.titleZh, item.titleEn)"
|
||||
class="h-full w-full object-cover"
|
||||
@load="refresh"
|
||||
/>
|
||||
<div class="absolute left-6 top-6 flex items-baseline gap-3">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<section 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">
|
||||
<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">
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
<!-- 评价内容 -->
|
||||
<p class="text-gray-700 text-base md:text-lg leading-relaxed mb-8 italic">
|
||||
"{{ t(`home.testimonials.items.${item.id}.content`) }}"
|
||||
"{{ item.content }}"
|
||||
</p>
|
||||
|
||||
<!-- 客户信息 -->
|
||||
@@ -45,10 +45,10 @@
|
||||
</div>
|
||||
<div>
|
||||
<h4 class="text-lg md:text-xl font-bold text-black">
|
||||
{{ t(`home.testimonials.items.${item.id}.name`) }}
|
||||
{{ item.name }}
|
||||
</h4>
|
||||
<p class="text-sm md:text-base text-gray-500">
|
||||
{{ t(`home.testimonials.items.${item.id}.role`) }}
|
||||
{{ item.role }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -69,10 +69,12 @@ 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 } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const { settings } = useSiteSettings()
|
||||
|
||||
const rootRef = ref<HTMLElement | null>(null)
|
||||
const headerRef = ref<HTMLElement | null>(null)
|
||||
@@ -80,16 +82,31 @@ const trackRef = ref<HTMLElement | null>(null)
|
||||
let ctx: gsap.Context | null = null
|
||||
let animFrameId: number | null = null
|
||||
|
||||
const testimonials = [
|
||||
{ id: 'client1', initial: 'A', avatarGradient: 'from-blue-500 to-cyan-500' },
|
||||
{ id: 'client2', initial: 'B', avatarGradient: 'from-purple-500 to-pink-500' },
|
||||
{ id: 'client3', initial: 'C', avatarGradient: 'from-orange-500 to-red-500' },
|
||||
{ id: 'client4', initial: 'D', avatarGradient: 'from-green-500 to-emerald-500' },
|
||||
{ id: 'client5', initial: 'E', avatarGradient: 'from-indigo-500 to-purple-500' },
|
||||
// 头像渐变预设按序号循环,后台无需逐条选色
|
||||
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, ...testimonials])
|
||||
const allTestimonials = computed(() => [...testimonials.value, ...testimonials.value])
|
||||
|
||||
// 自动滚动状态
|
||||
const offset = ref(0)
|
||||
@@ -98,7 +115,7 @@ let isPaused = false
|
||||
const cardWidth = 400 + 32 // 卡片宽度 + gap
|
||||
|
||||
const startAutoplay = () => {
|
||||
const totalWidth = testimonials.length * cardWidth
|
||||
const totalWidth = testimonials.value.length * cardWidth
|
||||
|
||||
const animate = () => {
|
||||
if (!isPaused) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { onMounted, ref, onUnmounted } from 'vue'
|
||||
import { onMounted, ref, onUnmounted, computed } from 'vue'
|
||||
import { gsap } from 'gsap'
|
||||
import { ScrollTrigger } from 'gsap/ScrollTrigger'
|
||||
import FooterLogo from '~/components/common/FooterLogo.vue'
|
||||
@@ -10,6 +10,9 @@ import { useSiteSettings } from '~/composables/useSiteSettings'
|
||||
const { t } = useI18n()
|
||||
const { settings, loc } = useSiteSettings()
|
||||
|
||||
// 仅展示已填写 URL 的社交入口
|
||||
const socials = computed(() => (settings.value?.socials ?? []).filter((s) => s.url))
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
const footerRef = ref<HTMLElement | null>(null)
|
||||
@@ -266,9 +269,9 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 animated-item">
|
||||
<div v-if="socials.length" class="flex gap-3 animated-item">
|
||||
<a
|
||||
v-for="social in settings?.socials ?? []"
|
||||
v-for="social in socials"
|
||||
:key="social.name"
|
||||
:href="social.url"
|
||||
target="_blank"
|
||||
|
||||
@@ -9,7 +9,6 @@ import { useUserStore } from '~/stores/user'
|
||||
import { useAuthModalStore } from '~/stores/authModal'
|
||||
import AppLogo from '~/components/common/AppLogo.vue'
|
||||
import LoginModal from '~/components/common/LoginModal.vue'
|
||||
import RegisterModal from '~/components/common/RegisterModal.vue'
|
||||
|
||||
gsap.registerPlugin(ScrollTrigger)
|
||||
|
||||
@@ -491,9 +490,6 @@ if (typeof window !== 'undefined') {
|
||||
<!-- 登录弹窗(由 authModal store 控制开关) -->
|
||||
<LoginModal />
|
||||
|
||||
<!-- 注册弹窗(由 authModal store 控制开关) -->
|
||||
<RegisterModal />
|
||||
|
||||
<header ref="bottomHeaderRef" class="site-header-bottom z-50 bg-white/80 backdrop-blur-md">
|
||||
<!-- 左侧菜单 (前两个菜单项) -->
|
||||
<nav class="flex items-center justify-evenly md:justify-end gap-3 md:gap-4 w-full">
|
||||
|
||||
Reference in New Issue
Block a user