feat: Update index.html and add media files for photo wall project
- Modified index.html to include favicon, title, and linked assets for Vite app. - Added three new media files: LaguBangsaJohor.mp4, LaguNegaraku.mp4, and LaguTeoChew.mp4. - Created nameList.json containing the names of the first founders with their status. - Introduced demo/photoWall/v0/index.html for a dynamic carousel with background video and marquee text. - Added demo/photoWall/v1/index.html for a photo wall layout with responsive design. - Created demo/photoWall/v3/images.json and nameList.json for image and name data. - Implemented demo/photoWall/v3/index.html with Vue.js for an interactive photo wall experience.
This commit is contained in:
377
demo/photoWall/v0/index.html
Normal file
377
demo/photoWall/v0/index.html
Normal file
@@ -0,0 +1,377 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
||||
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
||||
<title>动态翻页轮播图</title>
|
||||
<style>
|
||||
.carousel-container {
|
||||
perspective: 1000px;
|
||||
}
|
||||
.carousel-item {
|
||||
transition: transform 0.6s ease-in-out, opacity 0.6s ease-in-out;
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
/* 响应式调整 */
|
||||
@media (max-width: 768px) {
|
||||
.carousel-container {
|
||||
width: 100% !important;
|
||||
height: 60vh !important;
|
||||
}
|
||||
.carousel-image {
|
||||
width: 90% !important;
|
||||
height: auto !important;
|
||||
}
|
||||
}
|
||||
|
||||
.marquee-text {
|
||||
overflow: clip;
|
||||
}
|
||||
|
||||
.marquee-text-track {
|
||||
display: flex;
|
||||
padding-left: 4.8rem;
|
||||
gap: 4.8rem;
|
||||
width: max-content;
|
||||
animation: marquee-move-text 120s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes marquee-move-text {
|
||||
to {
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-red-500 min-h-screen flex items-center justify-center">
|
||||
<div id="app">
|
||||
<!-- 背景视频(在最底层)打开页面自动播放 -->
|
||||
<video
|
||||
src="assets/麦卉 - 前人种树后人凉《潮州劲歌金曲》.mp4"
|
||||
class="absolute w-full h-full object-cover blur-2xl"
|
||||
autoplay
|
||||
loop
|
||||
controls
|
||||
></video>
|
||||
<div
|
||||
class="carousel-container w-screen h-screen flex items-center justify-center overflow-hidden"
|
||||
>
|
||||
<div class="relative w-full h-full flex items-center justify-center">
|
||||
<!-- 轮播图片容器 -->
|
||||
<div class="relative w-full h-full flex items-center justify-center">
|
||||
<!-- 第一张图片 (prev) -->
|
||||
<div
|
||||
class="absolute carousel-item carousel-image h-172 w-7xl object-cover rounded-2xl shadow-2xl z-10"
|
||||
:class="getImageClass(0)"
|
||||
>
|
||||
<img
|
||||
:src="getImage(displayImages[0])"
|
||||
:alt="`图片 ${displayImages[0] + 1}`"
|
||||
class="w-full h-full object-cover rounded-2xl"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 第二张图片 (current) -->
|
||||
<div
|
||||
class="absolute carousel-item carousel-image h-172 w-7xl object-cover rounded-2xl shadow-2xl z-20"
|
||||
:class="getImageClass(1)"
|
||||
>
|
||||
<img
|
||||
:src="getImage(displayImages[1])"
|
||||
:alt="`图片 ${displayImages[1] + 1}`"
|
||||
class="w-full h-full object-cover rounded-2xl"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 第三张图片 (next) -->
|
||||
<div
|
||||
class="absolute carousel-item carousel-image h-172 w-7xl object-cover rounded-2xl shadow-2xl z-10"
|
||||
:class="getImageClass(2)"
|
||||
>
|
||||
<img
|
||||
:src="getImage(displayImages[2])"
|
||||
:alt="`图片 ${displayImages[2] + 1}`"
|
||||
class="w-full h-full object-cover rounded-2xl"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 第四张图片 (helper) -->
|
||||
<div
|
||||
class="absolute carousel-item carousel-image h-172 w-7xl object-cover rounded-2xl shadow-2xl z-0"
|
||||
:class="getImageClass(3)"
|
||||
>
|
||||
<img
|
||||
:src="getImage(displayImages[3])"
|
||||
:alt="`图片 ${displayImages[3] + 1}`"
|
||||
class="w-full h-full object-cover rounded-2xl"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 控制按钮 -->
|
||||
<button
|
||||
@click="prevSlide"
|
||||
class="absolute left-4 z-30 bg-white/20 hover:bg-white/30 text-white p-3 rounded-full transition-all"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-6 w-6"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M15 19l-7-7 7-7"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<button
|
||||
@click="nextSlide"
|
||||
class="absolute right-4 z-30 bg-white/20 hover:bg-white/30 text-white p-3 rounded-full transition-all"
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="h-6 w-6"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M9 5l7 7-7 7"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<!-- 指示器 -->
|
||||
<!-- <div class="absolute bottom-4 z-30 flex space-x-2">
|
||||
<button
|
||||
v-for="i in images.length"
|
||||
:key="i"
|
||||
@click="goToSlide(i-1)"
|
||||
class="w-3 h-3 rounded-full transition-all"
|
||||
:class="currentIndex === i-1 ? 'bg-white' : 'bg-white/50'"
|
||||
></button>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Breaking News 滚动条 -->
|
||||
<div
|
||||
class="fixed top-0 left-0 w-full bg-red-700 text-yellow-400 text-2xl py-3 overflow-hidden z-50 breaking-news-container"
|
||||
>
|
||||
<div
|
||||
class="absolute left-0 top-0 bg-red-900 text-yellow-100 px-4 py-3 font-bold z-10 breaking-news-label"
|
||||
>
|
||||
2005年第一届创办人名表:
|
||||
</div>
|
||||
<div class="marquee-text">
|
||||
<div class="marquee-text-track">
|
||||
<span>|</span>
|
||||
<span>楊吉陽(已故)</span>
|
||||
<span>唐華(已故)</span>
|
||||
<span>許仁菘(已故)</span>
|
||||
<span>許汶信(已故)</span>
|
||||
<span>劉炎松(已故)</span>
|
||||
<span>楊淑清(已故)</span>
|
||||
<span>黃芝芳(已故)</span>
|
||||
<span>|</span>
|
||||
<span>劉吉棟</span>
|
||||
<span>許任隆</span>
|
||||
<span>楊順發</span>
|
||||
<span>吳祥森</span>
|
||||
<span>林庭芝</span>
|
||||
<span>林炳華</span>
|
||||
<span>林庭珠</span>
|
||||
<span>李玉媚</span>
|
||||
<span>林應財</span>
|
||||
<span>許斯杰</span>
|
||||
<span>許敏捷</span>
|
||||
<span>許智興</span>
|
||||
<span>劉德祥</span>
|
||||
<span>李豫梅</span>
|
||||
<span>黄潮明</span>
|
||||
<span>楊信陞</span>
|
||||
<span>蔡立義</span>
|
||||
<span>林炳龍</span>
|
||||
<span>劉振昌</span>
|
||||
<span>劉迪發</span>
|
||||
<span>楊美雄</span>
|
||||
<span>彭三媚</span>
|
||||
<span>楊光豐</span>
|
||||
<span>楊秀娥</span>
|
||||
<span>莊秀清</span>
|
||||
<span>李玉嬌</span>
|
||||
<span>趙惜嬌</span>
|
||||
<span>陳秀珠</span>
|
||||
<span>張彩雁</span>
|
||||
<span>劉暐康</span>
|
||||
<span>王貴興</span>
|
||||
<span>劉林順</span>
|
||||
<span>劉益華</span>
|
||||
<span>紀有平</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const { createApp, ref, computed, onMounted, onUnmounted } = Vue;
|
||||
|
||||
createApp({
|
||||
setup() {
|
||||
// 图片数组
|
||||
const images = Array.from(
|
||||
{ length: 25 },
|
||||
(_, i) => `assets/image (${i + 1}).png`
|
||||
);
|
||||
|
||||
// 当前索引
|
||||
const currentIndex = ref(0);
|
||||
|
||||
// 显示图片的索引数组
|
||||
const displayImages = ref([]);
|
||||
|
||||
// 初始化显示图片
|
||||
const initializeDisplayImages = () => {
|
||||
const len = images.length;
|
||||
displayImages.value = [
|
||||
(currentIndex.value - 1 + len) % len,
|
||||
currentIndex.value,
|
||||
(currentIndex.value + 1) % len,
|
||||
(currentIndex.value + 2) % len,
|
||||
];
|
||||
};
|
||||
|
||||
// 获取图片URL
|
||||
const getImage = (index) => images[index];
|
||||
|
||||
// 获取图片类名
|
||||
const getImageClass = (position) => {
|
||||
switch (position) {
|
||||
case 0: // 上一张
|
||||
return "scale-90 -translate-x-3/4 opacity-80";
|
||||
case 1: // 当前
|
||||
return "scale-100 translate-x-0 opacity-100";
|
||||
case 2: // 下一张
|
||||
return "scale-90 translate-x-3/4 opacity-80";
|
||||
case 3: // 隐藏的搬运工
|
||||
return "scale-90 translate-x-full opacity-0";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
// 轮播控制
|
||||
const nextSlide = () => {
|
||||
// 将第一个元素移到末尾
|
||||
displayImages.value.push(displayImages.value.shift());
|
||||
|
||||
// 更新当前索引
|
||||
currentIndex.value = (currentIndex.value + 1) % images.length;
|
||||
|
||||
// 更新最后一个元素(搬运工角色)
|
||||
displayImages.value[3] = (currentIndex.value + 2) % images.length;
|
||||
};
|
||||
|
||||
const prevSlide = () => {
|
||||
// 将最后一个元素移到开头
|
||||
displayImages.value.unshift(displayImages.value.pop());
|
||||
|
||||
// 更新当前索引
|
||||
currentIndex.value =
|
||||
(currentIndex.value - 1 + images.length) % images.length;
|
||||
|
||||
// 更新第一个元素(搬运工角色)
|
||||
displayImages.value[0] =
|
||||
(currentIndex.value - 1 + images.length) % images.length;
|
||||
};
|
||||
|
||||
const goToSlide = (index) => {
|
||||
const diff = index - currentIndex.value;
|
||||
if (diff > 0) {
|
||||
for (let i = 0; i < diff; i++) {
|
||||
nextSlide();
|
||||
}
|
||||
} else if (diff < 0) {
|
||||
for (let i = 0; i < Math.abs(diff); i++) {
|
||||
prevSlide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 自动轮播
|
||||
let autoPlayInterval = null;
|
||||
|
||||
const startAutoPlay = () => {
|
||||
autoPlayInterval = setInterval(nextSlide, 3000);
|
||||
};
|
||||
|
||||
const stopAutoPlay = () => {
|
||||
if (autoPlayInterval) {
|
||||
clearInterval(autoPlayInterval);
|
||||
autoPlayInterval = null;
|
||||
}
|
||||
};
|
||||
|
||||
// 生命周期
|
||||
onMounted(() => {
|
||||
initializeDisplayImages();
|
||||
startAutoPlay();
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
stopAutoPlay();
|
||||
});
|
||||
|
||||
return {
|
||||
images,
|
||||
currentIndex,
|
||||
displayImages,
|
||||
getImage,
|
||||
getImageClass,
|
||||
nextSlide,
|
||||
prevSlide,
|
||||
goToSlide,
|
||||
startAutoPlay,
|
||||
stopAutoPlay,
|
||||
};
|
||||
},
|
||||
}).mount("#app");
|
||||
|
||||
// 监听用户的第一次交互(点击或触摸)
|
||||
document.addEventListener("click", initVideo, { once: true });
|
||||
document.addEventListener("touchstart", initVideo, { once: true });
|
||||
|
||||
function initVideo() {
|
||||
const video = document.querySelector("video");
|
||||
if (video) {
|
||||
video.muted = false; // 允许声音播放
|
||||
video.play().catch((err) => {
|
||||
console.warn("视频无法自动播放:", err);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Duplicate the marquee text track children node
|
||||
// and make it aria-hidden to create a seamless loop
|
||||
const marqueeTextTrack = document.querySelector(".marquee-text-track");
|
||||
const childCount = marqueeTextTrack.children.length; // ✅ 固定长度
|
||||
|
||||
for (let i = 0; i < childCount; i++) {
|
||||
const child = marqueeTextTrack.children[i];
|
||||
const clone = child.cloneNode(true);
|
||||
clone.setAttribute("aria-hidden", "true");
|
||||
marqueeTextTrack.appendChild(clone);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
250
demo/photoWall/v1/index.html
Normal file
250
demo/photoWall/v1/index.html
Normal file
@@ -0,0 +1,250 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>宴会回忆录照片墙</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Helvetica Neue", Arial, sans-serif;
|
||||
background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
z-index: 10;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
padding: 15px 30px;
|
||||
border-radius: 10px;
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3.5rem;
|
||||
margin-bottom: 10px;
|
||||
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 1.5rem;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.photo-wall {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(5, 1fr);
|
||||
grid-template-rows: repeat(5, 1fr);
|
||||
gap: 15px;
|
||||
width: 95%;
|
||||
height: 70%;
|
||||
max-width: 1400px;
|
||||
perspective: 1000px;
|
||||
}
|
||||
|
||||
.photo-container {
|
||||
position: relative;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
|
||||
transition: transform 0.5s ease, z-index 0.5s;
|
||||
transform-style: preserve-3d;
|
||||
}
|
||||
|
||||
.photo {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 0.8s ease, opacity 0.8s ease;
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.photo-container.active {
|
||||
transform: scale(1.15) rotateY(5deg);
|
||||
z-index: 10;
|
||||
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.photo-container.active .photo {
|
||||
opacity: 1;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.overlay {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
|
||||
padding: 20px 10px 10px;
|
||||
color: white;
|
||||
transform: translateY(100%);
|
||||
transition: transform 0.5s ease;
|
||||
}
|
||||
|
||||
.photo-container.active .overlay {
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.photo-caption {
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 30px;
|
||||
text-align: center;
|
||||
font-size: 1.2rem;
|
||||
opacity: 0.8;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* 背景装饰元素 */
|
||||
.bg-decoration {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: -1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.decoration {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
animation: float 15s infinite linear;
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
0% {
|
||||
transform: translateY(0) rotate(0deg);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-20px) rotate(180deg);
|
||||
}
|
||||
100% {
|
||||
transform: translateY(0) rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式调整 */
|
||||
@media (max-width: 1200px) {
|
||||
.photo-wall {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
grid-template-rows: repeat(7, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.photo-wall {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
grid-template-rows: repeat(9, 1fr);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="bg-decoration" id="bgDecoration"></div>
|
||||
|
||||
<div class="header">
|
||||
<h1>美好时光回忆录</h1>
|
||||
<div class="subtitle">珍藏每一刻的欢笑与感动</div>
|
||||
</div>
|
||||
|
||||
<div class="photo-wall" id="photoWall">
|
||||
<!-- 照片将通过JavaScript动态添加 -->
|
||||
</div>
|
||||
|
||||
<div class="footer">感谢与我们共度这段美好时光</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const photoWall = document.getElementById("photoWall");
|
||||
const bgDecoration = document.getElementById("bgDecoration");
|
||||
|
||||
// 生成25张示例照片
|
||||
for (let i = 1; i <= 25; i++) {
|
||||
const photoContainer = document.createElement("div");
|
||||
photoContainer.className = "photo-container";
|
||||
|
||||
const photo = document.createElement("img");
|
||||
photo.className = "photo";
|
||||
// 使用随机图片API生成示例图片,实际使用中替换为真实图片URL
|
||||
photo.src = `https://picsum.photos/400/300?random=${i}`;
|
||||
photo.alt = `宴会照片 ${i}`;
|
||||
|
||||
const overlay = document.createElement("div");
|
||||
overlay.className = "overlay";
|
||||
|
||||
const caption = document.createElement("div");
|
||||
caption.className = "photo-caption";
|
||||
caption.textContent = `美好时刻 ${i}`;
|
||||
|
||||
overlay.appendChild(caption);
|
||||
photoContainer.appendChild(photo);
|
||||
photoContainer.appendChild(overlay);
|
||||
photoWall.appendChild(photoContainer);
|
||||
}
|
||||
|
||||
// 创建背景装饰元素
|
||||
for (let i = 0; i < 15; i++) {
|
||||
const decoration = document.createElement("div");
|
||||
decoration.className = "decoration";
|
||||
const size = Math.random() * 100 + 50;
|
||||
decoration.style.width = `${size}px`;
|
||||
decoration.style.height = `${size}px`;
|
||||
decoration.style.left = `${Math.random() * 100}%`;
|
||||
decoration.style.top = `${Math.random() * 100}%`;
|
||||
decoration.style.animationDelay = `${Math.random() * 15}s`;
|
||||
decoration.style.animationDuration = `${15 + Math.random() * 10}s`;
|
||||
bgDecoration.appendChild(decoration);
|
||||
}
|
||||
|
||||
// 自动轮播逻辑
|
||||
const photoContainers = document.querySelectorAll(".photo-container");
|
||||
let currentIndex = 0;
|
||||
|
||||
function activatePhoto(index) {
|
||||
// 移除所有活动状态
|
||||
photoContainers.forEach((container) => {
|
||||
container.classList.remove("active");
|
||||
});
|
||||
|
||||
// 激活当前照片
|
||||
photoContainers[index].classList.add("active");
|
||||
|
||||
// 更新索引
|
||||
currentIndex = (index + 1) % photoContainers.length;
|
||||
}
|
||||
|
||||
// 初始激活第一张照片
|
||||
activatePhoto(currentIndex);
|
||||
|
||||
// 设置定时器,每3秒切换一张照片
|
||||
setInterval(() => {
|
||||
activatePhoto(currentIndex);
|
||||
}, 3000);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
29
demo/photoWall/v3/images.json
Normal file
29
demo/photoWall/v3/images.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"images": [
|
||||
{ "src": "./assets/image (1).png" },
|
||||
{ "src": "./assets/image (2).png" },
|
||||
{ "src": "./assets/image (3).png" },
|
||||
{ "src": "./assets/image (4).png" },
|
||||
{ "src": "./assets/image (5).png" },
|
||||
{ "src": "./assets/image (6).png" },
|
||||
{ "src": "./assets/image (7).png" },
|
||||
{ "src": "./assets/image (8).png" },
|
||||
{ "src": "./assets/image (9).png" },
|
||||
{ "src": "./assets/image (10).png" },
|
||||
{ "src": "./assets/image (11).png" },
|
||||
{ "src": "./assets/image (12).png" },
|
||||
{ "src": "./assets/image (13).png" },
|
||||
{ "src": "./assets/image (14).png" },
|
||||
{ "src": "./assets/image (15).png" },
|
||||
{ "src": "./assets/image (16).png" },
|
||||
{ "src": "./assets/image (17).png" },
|
||||
{ "src": "./assets/image (18).png" },
|
||||
{ "src": "./assets/image (19).png" },
|
||||
{ "src": "./assets/image (20).png" },
|
||||
{ "src": "./assets/image (21).png" },
|
||||
{ "src": "./assets/image (22).png" },
|
||||
{ "src": "./assets/image (23).png" },
|
||||
{ "src": "./assets/image (24).png" },
|
||||
{ "src": "./assets/image (25).png" }
|
||||
]
|
||||
}
|
||||
356
demo/photoWall/v3/index.html
Normal file
356
demo/photoWall/v3/index.html
Normal file
@@ -0,0 +1,356 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<title>照片墙</title>
|
||||
|
||||
<!-- Vue 3 -->
|
||||
<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
|
||||
<!-- Tailwind 浏览器版(用于快速原型) -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
||||
|
||||
<style>
|
||||
/* 顶部走马灯 */
|
||||
.special-marquee-track {
|
||||
animation: special-marquee-move-text 120s linear infinite;
|
||||
}
|
||||
@keyframes special-marquee-move-text {
|
||||
to {
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
}
|
||||
|
||||
/* 布局小调整 */
|
||||
.carousel-item {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
transition: transform 520ms cubic-bezier(0.2, 0.9, 0.2, 1), width 520ms,
|
||||
opacity 520ms;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="bg-gray-900 text-white">
|
||||
<div id="app" class="relative flex flex-col h-screen w-screen">
|
||||
<!-- 背景视频(在最底层)打开页面自动播放 -->
|
||||
<video
|
||||
src="assets/麦卉 - 前人种树后人凉《潮州劲歌金曲》.mp4"
|
||||
class="absolute w-full h-full object-cover blur-2xl"
|
||||
autoplay
|
||||
loop
|
||||
controls
|
||||
ref="bgVideo"
|
||||
></video>
|
||||
|
||||
<!-- 顶部走马灯 -->
|
||||
<div
|
||||
class="bg-red-500 backdrop-blur-md rounded-t-xl border-t border-white/40 shadow-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<div
|
||||
class="p-4 text-6xl font-bold text-nowrap bg-black/50 text-white"
|
||||
>
|
||||
{{bannerTitle}}
|
||||
</div>
|
||||
<div class="overflow-hidden flex-1 mask-x-from-95% mask-x-to-100%">
|
||||
<div
|
||||
class="flex w-max pl-8 gap-8 special-marquee-track items-center"
|
||||
>
|
||||
<template v-for="(n, idx) in nameListDoubled" :key="n._uid">
|
||||
<div class="text-2xl select-none">
|
||||
<div
|
||||
v-if="n.isPassedAway"
|
||||
class="px-3 py-1 border-2 border-white inline-block"
|
||||
>
|
||||
{{ n.name }}
|
||||
</div>
|
||||
<div v-else class="inline-block">{{ n.name }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主体:图片走马灯 / 照片墙 -->
|
||||
<div
|
||||
class="relative flex-1 bg-linear-to-br from-red-600 via-purple-800 to-slate-900 overflow-hidden"
|
||||
>
|
||||
<!-- 左箭头 -->
|
||||
<button
|
||||
@click="prevImage"
|
||||
class="absolute left-6 top-1/2 -translate-y-1/2 z-40 bg-black/40 p-3 rounded-full hover:bg-black/60"
|
||||
>
|
||||
‹
|
||||
</button>
|
||||
|
||||
<!-- 右箭头 -->
|
||||
<button
|
||||
@click="nextImage"
|
||||
class="absolute right-6 top-1/2 -translate-y-1/2 z-40 bg-black/40 p-3 rounded-full hover:bg-black/60"
|
||||
>
|
||||
›
|
||||
</button>
|
||||
|
||||
<!-- 图片:通过 computed 分配 transform -->
|
||||
<template v-for="(img, i) in images" :key="img.id">
|
||||
<img
|
||||
:src="img.src"
|
||||
:alt="img.alt || `Image ${i}`"
|
||||
class="carousel-item rounded-2xl shadow-2xl pointer-events-none"
|
||||
:class="imageWidthClass(i)"
|
||||
:style="imageStyle(i)"
|
||||
@click="onClickImage(i)"
|
||||
@mouseenter="pauseAutoplay"
|
||||
@mouseleave="resumeAutoplay"
|
||||
:aria-hidden="i === currentIndex ? 'false' : 'true'"
|
||||
:tabindex="i === currentIndex ? 0 : -1"
|
||||
:title="img.alt || ''"
|
||||
loading="lazy"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 底部小点 -->
|
||||
<div
|
||||
class="absolute bottom-6 left-1/2 -translate-x-1/2 z-50 flex gap-2"
|
||||
>
|
||||
<button
|
||||
v-for="(img, i) in images"
|
||||
:key="img.id+'dot'"
|
||||
@click="goTo(i)"
|
||||
:class="['w-3 h-3 rounded-full', i===currentIndex ? 'bg-white' : 'bg-white/30']"
|
||||
aria-label="'跳转到图片 '+(i+1)"
|
||||
></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const { createApp, ref, computed, onMounted, onBeforeUnmount } = Vue;
|
||||
|
||||
createApp({
|
||||
setup() {
|
||||
const bannerTitle = ref("照片墙");
|
||||
const nameList = ref([]); // 从 JSON 加载
|
||||
const images = ref([]); // 从 JSON 加载
|
||||
const currentIndex = ref(0);
|
||||
|
||||
// 背景视频
|
||||
const bgVideo = ref(null);
|
||||
|
||||
// 自动轮播控制
|
||||
let timer = null;
|
||||
const autoplayInterval = 4500;
|
||||
const isPaused = ref(false);
|
||||
|
||||
// fetch 数据(示例 JSON 路径,按需修改)
|
||||
const loadData = async () => {
|
||||
try {
|
||||
// 并行加载名字和图片(如果没有这些 JSON,请用示例文件)
|
||||
const [r1, r2] = await Promise.all([
|
||||
fetch("./nameList.json"),
|
||||
fetch("./images.json"),
|
||||
]);
|
||||
if (!r1.ok)
|
||||
throw new Error("加载 nameList.json 失败: " + r1.status);
|
||||
if (!r2.ok)
|
||||
throw new Error("加载 images.json 失败: " + r2.status);
|
||||
|
||||
const jd1 = await r1.json();
|
||||
const jd2 = await r2.json();
|
||||
|
||||
bannerTitle.value = jd1.title || bannerTitle.value;
|
||||
// 保证每个名字有稳定唯一 id(避免重复 key)
|
||||
nameList.value = (jd1.nameList || []).map((n, idx) => ({
|
||||
...n,
|
||||
_uid: `n-${idx}`,
|
||||
}));
|
||||
images.value = (jd2.images || []).map((img, idx) => ({
|
||||
id: img.id ?? `img-${idx}`,
|
||||
src: img.src,
|
||||
alt: img.alt ?? "",
|
||||
}));
|
||||
|
||||
// 防止空数组导致问题:提供占位
|
||||
if (!images.value.length) {
|
||||
images.value = [
|
||||
{
|
||||
id: "placeholder",
|
||||
src: "https://via.placeholder.com/1600x900?text=No+Image",
|
||||
alt: "占位图",
|
||||
},
|
||||
];
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
// 失败时回退到最小数据
|
||||
bannerTitle.value = "照片墙";
|
||||
nameList.value = [
|
||||
{ name: "示例名字", isPassedAway: false, _uid: "n-demo" },
|
||||
];
|
||||
images.value = [
|
||||
{
|
||||
id: "fallback",
|
||||
src: "https://placehold.co/1600x900?text=Fallback",
|
||||
alt: "回退图",
|
||||
},
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
await loadData();
|
||||
startAutoplay();
|
||||
|
||||
// 键盘支持
|
||||
window.addEventListener("keydown", onKeydown);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopAutoplay();
|
||||
window.removeEventListener("keydown", onKeydown);
|
||||
});
|
||||
|
||||
// 走马灯:返回重复一遍的数组,用不同 uid
|
||||
const nameListDoubled = computed(() => {
|
||||
const first = nameList.value.map((n) => ({
|
||||
...n,
|
||||
_uid: n._uid + "-a",
|
||||
}));
|
||||
const second = nameList.value.map((n) => ({
|
||||
...n,
|
||||
_uid: n._uid + "-b",
|
||||
}));
|
||||
return [...first, ...second];
|
||||
});
|
||||
|
||||
// 图片位置/样式逻辑(通用、支持任意图片数量)
|
||||
const imageStyle = (i) => {
|
||||
const n = images.value.length;
|
||||
if (n === 0) return {};
|
||||
// 相对偏移(以百分比表示,每张图片间隔125%)
|
||||
const rel = (i - currentIndex.value + n) % n; // 0..n-1
|
||||
// 将 rel 转换成 -k .. +k 的范围(把较大的移到负端)
|
||||
const middle = Math.floor(n / 2);
|
||||
let signed = rel;
|
||||
if (rel > middle) signed = rel - n;
|
||||
const offsetPercent = signed * 125; // 每张间隔 125%
|
||||
const isCenter = i === currentIndex.value;
|
||||
const scale = isCenter ? 1.06 : 0.92;
|
||||
const opacity =
|
||||
Math.abs(signed) > 3
|
||||
? 0
|
||||
: Math.max(0.25, 1 - Math.abs(signed) * 0.18);
|
||||
return {
|
||||
transform: `translate(-50%, -50%) translateX(${offsetPercent}%) scale(${scale})`,
|
||||
opacity: opacity,
|
||||
};
|
||||
};
|
||||
|
||||
// 宽度类(让中心图更大)
|
||||
const imageWidthClass = (i) => {
|
||||
return i === currentIndex.value ? "w-7xl" : "w-5xl";
|
||||
};
|
||||
|
||||
// 操作
|
||||
const prevImage = () => {
|
||||
const n = images.value.length;
|
||||
currentIndex.value = (currentIndex.value - 1 + n) % n;
|
||||
};
|
||||
const nextImage = () => {
|
||||
const n = images.value.length;
|
||||
currentIndex.value = (currentIndex.value + 1) % n;
|
||||
};
|
||||
const goTo = (i) => {
|
||||
currentIndex.value = i;
|
||||
};
|
||||
|
||||
// 点击图片:如果不是中心则跳到它
|
||||
const onClickImage = (i) => {
|
||||
if (i !== currentIndex.value) {
|
||||
goTo(i);
|
||||
} else {
|
||||
// 中心图点击可以触发展示大图/详情(可扩展)
|
||||
console.log("点击中心图", images.value[i]);
|
||||
}
|
||||
};
|
||||
|
||||
// 键盘支持
|
||||
const onKeydown = (e) => {
|
||||
const k = String(e.key);
|
||||
if (k === "ArrowLeft") {
|
||||
prevImage();
|
||||
} else if (k === "ArrowRight") {
|
||||
nextImage();
|
||||
} else if (k === " ") {
|
||||
// 空格暂停/恢复轮播(阻止页面滚动)
|
||||
e.preventDefault();
|
||||
if (isPaused.value) resumeAutoplay();
|
||||
else pauseAutoplay();
|
||||
} else if (k.toLowerCase() === "p") {
|
||||
// 新增:按 'p' 切换背景视频播放/暂停
|
||||
toggleBgVideo();
|
||||
}
|
||||
};
|
||||
|
||||
// 自动轮播
|
||||
const startAutoplay = () => {
|
||||
stopAutoplay();
|
||||
timer = setInterval(() => {
|
||||
if (!isPaused.value) nextImage();
|
||||
}, autoplayInterval);
|
||||
};
|
||||
const stopAutoplay = () => {
|
||||
if (timer) {
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
}
|
||||
};
|
||||
const pauseAutoplay = () => {
|
||||
isPaused.value = true;
|
||||
};
|
||||
const resumeAutoplay = () => {
|
||||
isPaused.value = false;
|
||||
};
|
||||
|
||||
// 切换背景视频播放/暂停
|
||||
const toggleBgVideo = () => {
|
||||
const vid = bgVideo.value;
|
||||
if (!vid) return;
|
||||
try {
|
||||
if (vid.paused) {
|
||||
// play() 返回 Promise,catch 防止未授权自动播放报错
|
||||
vid.play().catch(() => {});
|
||||
} else {
|
||||
vid.pause();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("切换背景视频失败:", err);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
bannerTitle,
|
||||
nameList,
|
||||
nameListDoubled,
|
||||
images,
|
||||
currentIndex,
|
||||
imageStyle,
|
||||
imageWidthClass,
|
||||
prevImage,
|
||||
nextImage,
|
||||
goTo,
|
||||
onClickImage,
|
||||
pauseAutoplay,
|
||||
resumeAutoplay,
|
||||
toggleBgVideo,
|
||||
};
|
||||
},
|
||||
}).mount("#app");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
46
demo/photoWall/v3/nameList.json
Normal file
46
demo/photoWall/v3/nameList.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"title": "2005年第一届创馆人",
|
||||
"nameList": [
|
||||
{ "name": "楊吉陽", "isPassedAway": true },
|
||||
{ "name": "唐華", "isPassedAway": true },
|
||||
{ "name": "許仁菘", "isPassedAway": true },
|
||||
{ "name": "許汶信", "isPassedAway": true },
|
||||
{ "name": "劉炎松", "isPassedAway": true },
|
||||
{ "name": "楊淑清", "isPassedAway": true },
|
||||
{ "name": "黃芝芳", "isPassedAway": true },
|
||||
{ "name": "劉吉棟", "isPassedAway": false },
|
||||
{ "name": "許任隆", "isPassedAway": false },
|
||||
{ "name": "楊順發", "isPassedAway": false },
|
||||
{ "name": "吳祥森", "isPassedAway": false },
|
||||
{ "name": "林庭芝", "isPassedAway": false },
|
||||
{ "name": "林炳華", "isPassedAway": false },
|
||||
{ "name": "林庭珠", "isPassedAway": false },
|
||||
{ "name": "李玉媚", "isPassedAway": false },
|
||||
{ "name": "林應財", "isPassedAway": false },
|
||||
{ "name": "許斯杰", "isPassedAway": false },
|
||||
{ "name": "許敏捷", "isPassedAway": false },
|
||||
{ "name": "許智興", "isPassedAway": false },
|
||||
{ "name": "劉德祥", "isPassedAway": false },
|
||||
{ "name": "李豫梅", "isPassedAway": false },
|
||||
{ "name": "黄潮明", "isPassedAway": false },
|
||||
{ "name": "楊信陞", "isPassedAway": false },
|
||||
{ "name": "蔡立義", "isPassedAway": false },
|
||||
{ "name": "林炳龍", "isPassedAway": false },
|
||||
{ "name": "劉振昌", "isPassedAway": false },
|
||||
{ "name": "劉迪發", "isPassedAway": false },
|
||||
{ "name": "楊美雄", "isPassedAway": false },
|
||||
{ "name": "彭三媚", "isPassedAway": false },
|
||||
{ "name": "楊光豐", "isPassedAway": false },
|
||||
{ "name": "楊秀娥", "isPassedAway": false },
|
||||
{ "name": "莊秀清", "isPassedAway": false },
|
||||
{ "name": "李玉嬌", "isPassedAway": false },
|
||||
{ "name": "趙惜嬌", "isPassedAway": false },
|
||||
{ "name": "陳秀珠", "isPassedAway": false },
|
||||
{ "name": "張彩雁", "isPassedAway": false },
|
||||
{ "name": "劉暐康", "isPassedAway": false },
|
||||
{ "name": "王貴興", "isPassedAway": false },
|
||||
{ "name": "劉林順", "isPassedAway": false },
|
||||
{ "name": "劉益華", "isPassedAway": false },
|
||||
{ "name": "紀有平", "isPassedAway": false }
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user