Files
arcticnewone/app/pages/work/[slug].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

282 lines
11 KiB
Vue
Raw 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.
<template>
<main class="min-h-screen">
<!-- 返回按钮 -->
<div class="fixed top-28 left-4 md:left-8 z-30">
<NuxtLink
to="/work"
class="inline-flex items-center gap-2 px-4 py-2.5 rounded-full bg-white/90 backdrop-blur-sm shadow-lg hover:shadow-xl transition-all duration-300 text-sm font-semibold text-black hover:-translate-x-1"
>
<Icon name="ph:arrow-left" class="w-5 h-5" />
{{ t('work.backToList') }}
</NuxtLink>
</div>
<!-- Hero 大图 -->
<section class="relative h-[60vh] md:h-[70vh] overflow-hidden">
<CoverImage
:src="project.image"
:alt="title"
:title="title"
class="w-full h-full object-cover"
/>
<div class="absolute inset-0 bg-gradient-to-t from-black/80 via-black/40 to-transparent"></div>
<div class="absolute bottom-0 left-0 right-0 p-8 md:p-16">
<div class="max-w-[1200px] mx-auto">
<div class="flex flex-wrap gap-2 mb-4">
<span
v-for="tag in project.tags"
:key="tag"
class="px-3 py-1 text-xs md:text-sm bg-white/20 backdrop-blur-sm text-white rounded-full"
>
{{ tag }}
</span>
</div>
<h1 class="text-4xl md:text-6xl lg:text-7xl font-bold text-white mb-4 tracking-tight">
{{ title }}
</h1>
<p class="text-lg md:text-xl text-white/80 max-w-2xl">
{{ description }}
</p>
</div>
</div>
</section>
<!-- 项目信息 -->
<section class="max-w-[1200px] mx-auto px-6 md:px-10 py-16 md:py-24">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-12 lg:gap-16">
<!-- 左侧:项目详情 -->
<div class="lg:col-span-2 space-y-12">
<div>
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.overview') }}</h2>
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
{{ locText(project.overviewZh, project.overviewEn) }}
</p>
</div>
<div>
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.challenge') }}</h2>
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
{{ locText(project.challengeZh, project.challengeEn) }}
</p>
</div>
<div>
<h2 class="text-2xl md:text-3xl font-bold text-black mb-6">{{ t('work.detail.solution') }}</h2>
<p class="text-gray-700 text-base md:text-lg leading-relaxed">
{{ locText(project.solutionZh, project.solutionEn) }}
</p>
</div>
<!-- 项目截图 -->
<div v-if="project.gallery.length" class="space-y-6">
<h2 class="text-2xl md:text-3xl font-bold text-black">{{ t('work.detail.gallery') }}</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div
v-for="(img, index) in project.gallery"
:key="index"
class="rounded-2xl overflow-hidden shadow-lg hover:shadow-2xl transition-shadow duration-300"
>
<img :src="img" :alt="`${title} screenshot ${index + 1}`" class="w-full h-auto" />
</div>
</div>
</div>
</div>
<!-- 右侧:项目信息卡片 -->
<div class="space-y-8">
<div class="bg-gray-50 rounded-2xl p-6 md:p-8 sticky top-32">
<h3 class="text-lg font-bold text-black mb-6">{{ t('work.detail.projectInfo') }}</h3>
<div class="space-y-5">
<div>
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.client') }}</p>
<p class="text-base font-semibold text-black">{{ locText(project.clientZh, project.clientEn) }}</p>
</div>
<div>
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.year') }}</p>
<p class="text-base font-semibold text-black">{{ project.year }}</p>
</div>
<div>
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.duration') }}</p>
<p class="text-base font-semibold text-black">{{ locText(project.durationZh, project.durationEn) }}</p>
</div>
<div>
<p class="text-sm text-gray-500 mb-1">{{ t('work.detail.services') }}</p>
<div class="flex flex-wrap gap-2 mt-2">
<span
v-for="tag in project.tags"
:key="tag"
class="px-3 py-1 text-xs bg-black text-white rounded-full"
>
{{ tag }}
</span>
</div>
</div>
</div>
<div class="mt-8 space-y-3">
<!-- 访问项目(仅存在真实地址时渲染) -->
<a
v-if="project.url"
:href="project.url"
target="_blank"
rel="noopener noreferrer"
class="w-full inline-flex items-center justify-center gap-2 px-6 py-3.5 rounded-full bg-black text-white font-semibold hover:bg-gray-800 transition-colors duration-300"
>
{{ t('work.detail.visitProject') }}
<Icon name="ph:arrow-up-right" class="w-5 h-5" />
</a>
<!-- 收藏 -->
<FavoriteButton :work-slug="slug" />
</div>
<!-- 分享 -->
<div class="mt-8 pt-6 border-t border-gray-200">
<p class="text-sm text-gray-500 mb-3">{{ t('share.article') }}</p>
<div class="flex gap-3">
<button
@click="shareToX"
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black flex items-center justify-center transition-all duration-300"
:title="'X'"
aria-label="Share on X"
>
<Icon name="ph:x-logo" class="w-5 h-5" />
</button>
<button
@click="shareToLinkedIn"
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black flex items-center justify-center transition-all duration-300"
:title="'LinkedIn'"
aria-label="Share on LinkedIn"
>
<Icon name="ph:linkedin-logo" class="w-5 h-5" />
</button>
<button
@click="copyLink"
class="w-10 h-10 rounded-full bg-white border border-gray-200 hover:bg-black hover:text-white hover:border-black flex items-center justify-center transition-all duration-300"
:title="t('share.copy')"
aria-label="Copy link"
>
<Icon name="ph:link" class="w-5 h-5" />
</button>
</div>
<p v-if="copyFeedback" class="text-sm mt-3 text-green-600">{{ copyFeedback }}</p>
</div>
</div>
</div>
</div>
</section>
<!-- 相关项目 -->
<section class="bg-gray-50 py-16 md:py-24">
<div class="max-w-[1200px] mx-auto px-6 md:px-10">
<h2 class="text-2xl md:text-3xl font-bold text-black mb-10 text-center">{{ t('work.detail.relatedProjects') }}</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<NuxtLink
v-for="related in relatedProjects"
:key="related.slug"
:to="`/work/${related.slug}`"
class="group block rounded-2xl overflow-hidden bg-white shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1"
>
<div class="relative aspect-[4/3] overflow-hidden">
<CoverImage :src="related.image" :alt="locText(related.titleZh, related.titleEn)" :title="locText(related.titleZh, related.titleEn)" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-105" />
</div>
<div class="p-5">
<h3 class="text-lg font-bold text-black group-hover:text-gray-600 transition-colors">{{ locText(related.titleZh, related.titleEn) }}</h3>
<p class="text-sm text-gray-500 mt-1">{{ related.tags?.[0] }}</p>
</div>
</NuxtLink>
</div>
</div>
</section>
</main>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useRoute } from 'vue-router'
import { useI18n } from 'vue-i18n'
import { useSeoMeta, createError } from '#imports'
const { t, locale } = useI18n()
const route = useRoute()
const slug = route.params.slug as string
interface WorkItem {
slug: string
category: 'webDesign' | 'branding' | 'development'
titleZh: string
titleEn: string
descriptionZh: string
descriptionEn: string
overviewZh: string
overviewEn: string
challengeZh: string
challengeEn: string
solutionZh: string
solutionEn: string
clientZh: string
clientEn: string
durationZh: string
durationEn: string
year: string
tags: string[]
image: string | null
gallery: string[]
url: string | null
}
const [{ data, error }, { data: listData }] = await Promise.all([
useFetch<{ work: WorkItem }>(`/api/work/${slug}`),
useFetch<{ works: WorkItem[] }>('/api/work'),
])
// 未发布 / 不存在 → 404
if (error.value || !data.value?.work) {
throw createError({ statusCode: 404, statusMessage: 'Project not found' })
}
const project = computed<WorkItem>(() => data.value!.work)
const locText = (zh: string, en: string) => (locale.value === 'zh' ? zh : en)
const title = computed(() => locText(project.value.titleZh, project.value.titleEn))
const description = computed(() => locText(project.value.descriptionZh, project.value.descriptionEn))
const relatedProjects = computed(() =>
(listData.value?.works ?? []).filter((p) => p.slug !== slug).slice(0, 3),
)
useSeoMeta({
title: () => `${title.value} - ${t('work.title')}`,
description: () => description.value,
})
// ---- 分享(真实动作) ----
const copyFeedback = ref('')
const shareUrl = () => (typeof window !== 'undefined' ? window.location.href : '')
const shareText = () => title.value
const shareToX = () => {
const url = `https://twitter.com/intent/tweet?url=${encodeURIComponent(shareUrl())}&text=${encodeURIComponent(shareText())}`
window.open(url, '_blank', 'noopener,noreferrer,width=600,height=480')
}
const shareToLinkedIn = () => {
const url = `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(shareUrl())}`
window.open(url, '_blank', 'noopener,noreferrer,width=600,height=480')
}
const copyLink = async () => {
try {
await navigator.clipboard.writeText(shareUrl())
copyFeedback.value = t('share.copied')
} catch {
// 剪贴板不可用时回退到 prompt 复制
window.prompt(t('share.copyFailed'), shareUrl())
}
setTimeout(() => (copyFeedback.value = ''), 3000)
}
</script>