new
This commit is contained in:
@@ -29,13 +29,16 @@ class ActivitySerializer(serializers.ModelSerializer):
|
|||||||
return config
|
return config
|
||||||
|
|
||||||
class ActivitySignupSerializer(serializers.ModelSerializer):
|
class ActivitySignupSerializer(serializers.ModelSerializer):
|
||||||
activity_info = ActivitySerializer(source='activity', read_only=True)
|
activity_info = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ActivitySignup
|
model = ActivitySignup
|
||||||
fields = ['id', 'activity', 'activity_info', 'user', 'signup_time', 'status', 'signup_info']
|
fields = ['id', 'activity', 'activity_info', 'user', 'signup_time', 'status', 'signup_info']
|
||||||
read_only_fields = ['signup_time', 'status', 'user']
|
read_only_fields = ['signup_time', 'status', 'user']
|
||||||
|
|
||||||
|
def get_activity_info(self, obj):
|
||||||
|
return ActivitySerializer(obj.activity).data
|
||||||
|
|
||||||
class TopicMediaSerializer(serializers.ModelSerializer):
|
class TopicMediaSerializer(serializers.ModelSerializer):
|
||||||
url = serializers.SerializerMethodField()
|
url = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,53 @@
|
|||||||
|
|
||||||
|
// Framer Motion Animation Variants
|
||||||
|
|
||||||
export const fadeInUp = {
|
export const fadeInUp = {
|
||||||
initial: { opacity: 0, y: 30 },
|
hidden: { opacity: 0, y: 30 },
|
||||||
animate: { opacity: 1, y: 0, transition: { duration: 0.6, ease: "easeOut" } },
|
visible: (custom = 0) => ({
|
||||||
exit: { opacity: 0, y: 20, transition: { duration: 0.4 } }
|
opacity: 1,
|
||||||
|
y: 0,
|
||||||
|
transition: {
|
||||||
|
delay: custom * 0.08,
|
||||||
|
duration: 0.6,
|
||||||
|
ease: [0.22, 1, 0.36, 1], // Custom easing
|
||||||
|
},
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const staggerContainer = {
|
export const staggerContainer = {
|
||||||
hidden: { opacity: 0 },
|
hidden: { opacity: 0 },
|
||||||
show: {
|
visible: {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
transition: {
|
transition: {
|
||||||
staggerChildren: 0.08
|
staggerChildren: 0.1,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const cardHover = {
|
export const hoverScale = {
|
||||||
hover: {
|
hover: {
|
||||||
scale: 1.03,
|
scale: 1.03,
|
||||||
boxShadow: "0 20px 40px rgba(0,0,0,0.4)",
|
boxShadow: "0px 10px 20px rgba(0, 0, 0, 0.2)",
|
||||||
y: -5,
|
transition: { duration: 0.3 },
|
||||||
transition: { duration: 0.3, ease: "easeOut" }
|
},
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const buttonClick = {
|
|
||||||
tap: { scale: 0.95 }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const pageTransition = {
|
export const pageTransition = {
|
||||||
initial: { opacity: 0 },
|
initial: { opacity: 0, x: 20 },
|
||||||
animate: { opacity: 1 },
|
animate: { opacity: 1, x: 0 },
|
||||||
exit: { opacity: 0 },
|
exit: { opacity: 0, x: -20 },
|
||||||
transition: { duration: 0.4 }
|
transition: { duration: 0.3 },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const buttonTap = {
|
||||||
|
scale: 0.95,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const imageFadeIn = {
|
||||||
|
hidden: { opacity: 0, scale: 1.1 },
|
||||||
|
visible: {
|
||||||
|
opacity: 1,
|
||||||
|
scale: 1,
|
||||||
|
transition: { duration: 0.5 }
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -67,5 +67,6 @@ export const getMyPaidItems = () => api.get('/users/paid-items/');
|
|||||||
export const getAnnouncements = () => api.get('/community/announcements/');
|
export const getAnnouncements = () => api.get('/community/announcements/');
|
||||||
export const getActivities = () => api.get('/community/activities/');
|
export const getActivities = () => api.get('/community/activities/');
|
||||||
export const getActivityDetail = (id) => api.get(`/community/activities/${id}/`);
|
export const getActivityDetail = (id) => api.get(`/community/activities/${id}/`);
|
||||||
|
export const signUpActivity = (id) => api.post(`/community/activities/${id}/signup/`);
|
||||||
|
|
||||||
export default api;
|
export default api;
|
||||||
|
|||||||
@@ -1,244 +1,265 @@
|
|||||||
@import '../../styles/theme.less';
|
|
||||||
|
|
||||||
.container {
|
@import '../../theme.module.less';
|
||||||
padding: 24px 0;
|
|
||||||
max-width: 1200px;
|
.activitySection {
|
||||||
margin: 0 auto;
|
padding: var(--spacing-lg) 0;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sectionHeader {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-bottom: 24px;
|
margin-bottom: var(--spacing-md);
|
||||||
padding: 0 24px;
|
}
|
||||||
|
|
||||||
.sectionTitle {
|
.sectionTitle {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-weight: bold;
|
font-weight: 700;
|
||||||
color: @text-color;
|
color: var(--text-primary);
|
||||||
letter-spacing: 1px;
|
display: flex;
|
||||||
}
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
.moreBtn {
|
|
||||||
display: flex;
|
&::before {
|
||||||
align-items: center;
|
content: '';
|
||||||
gap: 8px;
|
display: block;
|
||||||
cursor: pointer;
|
width: 4px;
|
||||||
color: @primary-color;
|
height: 24px;
|
||||||
transition: all 0.3s;
|
background: var(--primary-color);
|
||||||
|
border-radius: 2px;
|
||||||
&:hover {
|
|
||||||
color: lighten(@primary-color, 10%);
|
|
||||||
transform: translateX(4px);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.controls {
|
||||||
position: relative;
|
display: flex;
|
||||||
border-radius: @border-radius-base;
|
gap: var(--spacing-sm);
|
||||||
overflow: hidden;
|
|
||||||
aspect-ratio: 16/9;
|
|
||||||
cursor: pointer;
|
|
||||||
background: @card-bg;
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
aspect-ratio: 3/4;
|
display: none; /* Hide carousel controls on mobile */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.image {
|
.navBtn {
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
|
color: var(--text-primary);
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--primary-color);
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Desktop Carousel */
|
||||||
|
.desktopCarousel {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.dots {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: var(--spacing-md);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border-radius: 50%;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s;
|
||||||
|
|
||||||
|
&.activeDot {
|
||||||
|
background: var(--primary-color);
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mobile List */
|
||||||
|
.mobileList {
|
||||||
|
display: none;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--spacing-md);
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- Card Styles --- */
|
||||||
|
.activityCard {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 400px;
|
||||||
|
border-radius: var(--border-radius-lg);
|
||||||
|
overflow: hidden;
|
||||||
|
cursor: pointer;
|
||||||
|
background: var(--background-card);
|
||||||
|
box-shadow: var(--box-shadow-base);
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
height: 300px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.imageContainer {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
transition: transform 0.5s ease;
|
transition: transform 0.5s ease;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.overlay {
|
.overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 60%;
|
height: 60%;
|
||||||
background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
|
background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
padding: 24px;
|
padding: var(--spacing-lg);
|
||||||
}
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
.status {
|
.statusTag {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 4px 12px;
|
background: var(--primary-color);
|
||||||
background: @primary-color;
|
color: #fff;
|
||||||
color: #000;
|
padding: 4px 12px;
|
||||||
font-size: 12px;
|
border-radius: 4px;
|
||||||
font-weight: bold;
|
font-size: 12px;
|
||||||
border-radius: 4px;
|
font-weight: 600;
|
||||||
margin-bottom: 8px;
|
margin-bottom: var(--spacing-sm);
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
}
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 24px;
|
color: var(--text-primary);
|
||||||
font-weight: bold;
|
font-size: 24px;
|
||||||
color: @text-color;
|
font-weight: 700;
|
||||||
margin-bottom: 8px;
|
margin-bottom: var(--spacing-xs);
|
||||||
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
line-height: 1.3;
|
||||||
}
|
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
||||||
|
|
||||||
.time {
|
@media (max-width: 768px) {
|
||||||
font-size: 14px;
|
font-size: 18px;
|
||||||
color: @text-secondary;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
.image {
|
|
||||||
transform: scale(1.05);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detail Page
|
.time {
|
||||||
.detailContainer {
|
color: var(--text-secondary);
|
||||||
min-height: 100vh;
|
font-size: 14px;
|
||||||
background: @bg-color;
|
display: flex;
|
||||||
color: @text-color;
|
align-items: center;
|
||||||
padding-bottom: 80px;
|
gap: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.heroSection {
|
/* Detail Page Styles */
|
||||||
|
.detailHeader {
|
||||||
position: relative;
|
position: relative;
|
||||||
height: 50vh;
|
height: 50vh;
|
||||||
|
min-height: 300px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
.heroImage {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.backBtn {
|
|
||||||
position: absolute;
|
|
||||||
top: 24px;
|
|
||||||
left: 24px;
|
|
||||||
z-index: 10;
|
|
||||||
background: rgba(0,0,0,0.5);
|
|
||||||
border: none;
|
|
||||||
color: white;
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
cursor: pointer;
|
|
||||||
backdrop-filter: blur(4px);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: rgba(0,0,0,0.7);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contentSection {
|
.detailImage {
|
||||||
padding: 24px;
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detailContent {
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
margin: 0 auto;
|
margin: -60px auto 0;
|
||||||
margin-top: -60px;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 2;
|
z-index: 10;
|
||||||
background: rgba(30, 30, 30, 0.8);
|
padding: 0 var(--spacing-lg) 100px; /* Bottom padding for fixed footer */
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
border-radius: 24px 24px 0 0;
|
|
||||||
border-top: 1px solid rgba(255,255,255,0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.metaInfo {
|
.infoCard {
|
||||||
margin-bottom: 32px;
|
background: var(--background-card);
|
||||||
|
padding: var(--spacing-lg);
|
||||||
h1 {
|
border-radius: var(--border-radius-lg);
|
||||||
font-size: 32px;
|
box-shadow: var(--box-shadow-base);
|
||||||
margin-bottom: 16px;
|
margin-bottom: var(--spacing-lg);
|
||||||
color: @text-color;
|
border: 1px solid var(--border-color);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.infoRow {
|
|
||||||
display: flex;
|
|
||||||
gap: 24px;
|
|
||||||
margin-bottom: 16px;
|
|
||||||
color: @text-secondary;
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
margin-right: 8px;
|
|
||||||
color: @primary-color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.richText {
|
.richText {
|
||||||
|
color: var(--text-secondary);
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
color: #ddd;
|
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
|
||||||
img {
|
img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
border-radius: 8px;
|
border-radius: var(--border-radius-base);
|
||||||
margin: 16px 0;
|
margin: var(--spacing-md) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2, h3 {
|
h1, h2, h3 {
|
||||||
color: @text-color;
|
color: var(--text-primary);
|
||||||
margin-top: 24px;
|
margin-top: var(--spacing-lg);
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.bottomBar {
|
.fixedFooter {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 16px 24px;
|
background: rgba(31, 31, 31, 0.95);
|
||||||
background: rgba(20, 20, 20, 0.9);
|
|
||||||
backdrop-filter: blur(10px);
|
backdrop-filter: blur(10px);
|
||||||
border-top: 1px solid rgba(255,255,255,0.1);
|
padding: var(--spacing-md) var(--spacing-lg);
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
|
box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
.actionBtn {
|
.actionBtn {
|
||||||
flex: 1;
|
background: var(--primary-color);
|
||||||
margin-left: 16px;
|
color: #fff;
|
||||||
height: 48px;
|
border: none;
|
||||||
font-size: 16px;
|
padding: 12px 32px;
|
||||||
font-weight: bold;
|
border-radius: 24px;
|
||||||
border: none;
|
font-size: 16px;
|
||||||
background: @primary-color;
|
font-weight: 600;
|
||||||
box-shadow: 0 4px 12px rgba(0, 185, 107, 0.3);
|
cursor: pointer;
|
||||||
|
box-shadow: 0 4px 12px rgba(0, 185, 107, 0.3);
|
||||||
&:hover {
|
transition: all 0.3s;
|
||||||
background: lighten(@primary-color, 5%);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.shareBtn {
|
&:disabled {
|
||||||
width: 48px;
|
background: #555;
|
||||||
height: 48px;
|
cursor: not-allowed;
|
||||||
border-radius: 50%;
|
box-shadow: none;
|
||||||
border: 1px solid rgba(255,255,255,0.2);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
color: white;
|
|
||||||
background: transparent;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: rgba(255,255,255,0.1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,59 @@
|
|||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { Typography } from 'antd';
|
import { CalendarOutlined, RightOutlined } from '@ant-design/icons';
|
||||||
import { CalendarOutlined } from '@ant-design/icons';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { cardHover } from '../../animation';
|
|
||||||
import styles from './activity.module.less';
|
import styles from './activity.module.less';
|
||||||
|
import { hoverScale, imageFadeIn } from '../../animation';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const ActivityCard = ({ activity, index }) => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const ActivityCard = ({ activity, onClick, layoutId }) => {
|
const handleCardClick = () => {
|
||||||
const { title, start_time, display_banner_url, banner_url, cover_image, status = '报名中' } = activity;
|
navigate(`/activity/${activity.id}`);
|
||||||
const imageUrl = display_banner_url || banner_url || cover_image || 'https://via.placeholder.com/600x300';
|
};
|
||||||
|
|
||||||
|
const getStatus = (startTime) => {
|
||||||
|
const now = new Date();
|
||||||
|
const start = new Date(startTime);
|
||||||
|
if (now < start) return '即将开始';
|
||||||
|
// Simple logic, can be enhanced
|
||||||
|
return '报名中';
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDate = (dateStr) => {
|
||||||
|
if (!dateStr) return 'TBD';
|
||||||
|
const date = new Date(dateStr);
|
||||||
|
return date.toLocaleDateString('zh-CN', { month: 'long', day: 'numeric' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
className={styles.card}
|
className={styles.activityCard}
|
||||||
variants={cardHover}
|
variants={hoverScale}
|
||||||
whileHover="hover"
|
whileHover="hover"
|
||||||
onClick={onClick}
|
onClick={handleCardClick}
|
||||||
layoutId={layoutId}
|
layoutId={`activity-card-${activity.id}`}
|
||||||
|
style={{ willChange: 'transform' }}
|
||||||
>
|
>
|
||||||
<motion.img
|
<div className={styles.imageContainer}>
|
||||||
src={imageUrl}
|
<motion.img
|
||||||
alt={title}
|
src={activity.display_banner_url || activity.banner_url || activity.cover_image || 'https://via.placeholder.com/600x400'}
|
||||||
className={styles.image}
|
alt={activity.title}
|
||||||
loading="lazy"
|
variants={imageFadeIn}
|
||||||
/>
|
initial="hidden"
|
||||||
<div className={styles.overlay}>
|
whileInView="visible"
|
||||||
<div className={styles.info}>
|
viewport={{ once: true }}
|
||||||
<span className={styles.status}>{status}</span>
|
loading="lazy"
|
||||||
<h3 className={styles.title}>{title}</h3>
|
/>
|
||||||
|
<div className={styles.overlay}>
|
||||||
|
<div className={styles.statusTag}>
|
||||||
|
{activity.status || getStatus(activity.start_time)}
|
||||||
|
</div>
|
||||||
|
<h3 className={styles.title}>{activity.title}</h3>
|
||||||
<div className={styles.time}>
|
<div className={styles.time}>
|
||||||
<CalendarOutlined style={{ marginRight: 8 }} />
|
<CalendarOutlined />
|
||||||
{start_time ? start_time.split('T')[0] : 'TBD'}
|
<span>{formatDate(activity.start_time)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,70 +1,103 @@
|
|||||||
import React from 'react';
|
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { Carousel } from 'antd';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { RightOutlined, LeftOutlined } from '@ant-design/icons';
|
||||||
import { RightOutlined } from '@ant-design/icons';
|
|
||||||
import { getActivities } from '../../api';
|
import { getActivities } from '../../api';
|
||||||
import ActivityCard from './ActivityCard';
|
import ActivityCard from './ActivityCard';
|
||||||
import styles from './activity.module.less';
|
import styles from './activity.module.less';
|
||||||
import { motion } from 'framer-motion';
|
import { fadeInUp, staggerContainer } from '../../animation';
|
||||||
import { fadeInUp } from '../../animation';
|
|
||||||
|
|
||||||
const ActivityList = () => {
|
const ActivityList = () => {
|
||||||
const navigate = useNavigate();
|
const { data: activities, isLoading, error } = useQuery({
|
||||||
const { data: activities, isLoading } = useQuery({
|
|
||||||
queryKey: ['activities'],
|
queryKey: ['activities'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
try {
|
const res = await getActivities();
|
||||||
const res = await getActivities();
|
// Handle different response structures
|
||||||
return Array.isArray(res) ? res : (res?.results || res?.data || []);
|
return Array.isArray(res.data) ? res.data : (res.data?.results || []);
|
||||||
} catch (e) {
|
|
||||||
console.error("Failed to fetch activities", e);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
staleTime: 1000 * 60 * 5, // Cache for 5 mins
|
staleTime: 5 * 60 * 1000, // 5 minutes cache
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoading || !activities || activities.length === 0) return null;
|
const [currentIndex, setCurrentIndex] = useState(0);
|
||||||
|
|
||||||
const goToDetail = (id) => {
|
// Auto-play for desktop carousel
|
||||||
navigate(`/activity/${id}`);
|
useEffect(() => {
|
||||||
|
if (!activities || activities.length <= 1) return;
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
setCurrentIndex((prev) => (prev + 1) % activities.length);
|
||||||
|
}, 5000);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, [activities]);
|
||||||
|
|
||||||
|
const nextSlide = () => {
|
||||||
|
if (!activities) return;
|
||||||
|
setCurrentIndex((prev) => (prev + 1) % activities.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const prevSlide = () => {
|
||||||
|
if (!activities) return;
|
||||||
|
setCurrentIndex((prev) => (prev - 1 + activities.length) % activities.length);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isLoading) return <div className={styles.loading}>Loading activities...</div>;
|
||||||
|
if (error) return null; // Or error state
|
||||||
|
if (!activities || activities.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
className={styles.container}
|
className={styles.activitySection}
|
||||||
initial="initial"
|
initial="hidden"
|
||||||
whileInView="animate"
|
whileInView="visible"
|
||||||
viewport={{ once: true, margin: "-100px" }}
|
viewport={{ once: true, amount: 0.2 }}
|
||||||
variants={fadeInUp}
|
variants={staggerContainer}
|
||||||
>
|
>
|
||||||
<div className={styles.sectionHeader}>
|
<div className={styles.header}>
|
||||||
<div className={styles.sectionTitle}>近期活动 / EVENTS</div>
|
<h2 className={styles.sectionTitle}>
|
||||||
<div className={styles.moreBtn} onClick={() => navigate('/activity/list')}>
|
近期活动 / EVENTS
|
||||||
<span>MORE</span>
|
</h2>
|
||||||
<RightOutlined />
|
<div className={styles.controls}>
|
||||||
|
<button onClick={prevSlide} className={styles.navBtn}><LeftOutlined /></button>
|
||||||
|
<button onClick={nextSlide} className={styles.navBtn}><RightOutlined /></button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Carousel
|
{/* Desktop: Carousel (Show one prominent, but allows list structure if needed)
|
||||||
autoplay
|
User said: "Activity only shows one, and in the form of a sliding page"
|
||||||
autoplaySpeed={5000}
|
*/}
|
||||||
effect="scrollx"
|
<div className={styles.desktopCarousel}>
|
||||||
slidesToShow={1}
|
<AnimatePresence mode='wait'>
|
||||||
dots={true}
|
<motion.div
|
||||||
className={styles.carousel}
|
key={currentIndex}
|
||||||
>
|
initial={{ opacity: 0, x: 50 }}
|
||||||
{activities.map(item => (
|
animate={{ opacity: 1, x: 0 }}
|
||||||
<div key={item.id} className={styles.slideItem}>
|
exit={{ opacity: 0, x: -50 }}
|
||||||
<ActivityCard
|
transition={{ duration: 0.5 }}
|
||||||
activity={item}
|
style={{ width: '100%' }}
|
||||||
onClick={() => goToDetail(item.id)}
|
>
|
||||||
layoutId={`activity-${item.id}`}
|
<ActivityCard activity={activities[currentIndex]} />
|
||||||
/>
|
</motion.div>
|
||||||
</div>
|
</AnimatePresence>
|
||||||
|
|
||||||
|
<div className={styles.dots}>
|
||||||
|
{activities.map((_, idx) => (
|
||||||
|
<span
|
||||||
|
key={idx}
|
||||||
|
className={`${styles.dot} ${idx === currentIndex ? styles.activeDot : ''}`}
|
||||||
|
onClick={() => setCurrentIndex(idx)}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Mobile: Vertical List/Scroll as requested "Mobile vertical scroll" */}
|
||||||
|
<div className={styles.mobileList}>
|
||||||
|
{activities.map((item, index) => (
|
||||||
|
<motion.div key={item.id} variants={fadeInUp} custom={index}>
|
||||||
|
<ActivityCard activity={item} />
|
||||||
|
</motion.div>
|
||||||
))}
|
))}
|
||||||
</Carousel>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
import { StrictMode } from 'react'
|
import { StrictMode } from 'react'
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
||||||
import './index.css'
|
import './index.css'
|
||||||
import App from './App.jsx'
|
import App from './App.jsx'
|
||||||
|
|
||||||
const queryClient = new QueryClient()
|
|
||||||
|
|
||||||
createRoot(document.getElementById('root')).render(
|
createRoot(document.getElementById('root')).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<QueryClientProvider client={queryClient}>
|
<App />
|
||||||
<App />
|
|
||||||
</QueryClientProvider>
|
|
||||||
</StrictMode>,
|
</StrictMode>,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
@primary-color: #00b96b;
|
|
||||||
@secondary-color: #00f0ff;
|
|
||||||
@text-color: #ffffff;
|
|
||||||
@text-secondary: rgba(255, 255, 255, 0.65);
|
|
||||||
@bg-color: #000000;
|
|
||||||
@card-bg: rgba(255, 255, 255, 0.05);
|
|
||||||
@border-radius-base: 16px;
|
|
||||||
@box-shadow-base: 0 8px 32px rgba(0, 0, 0, 0.3);
|
|
||||||
@font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
||||||
|
|
||||||
// Mixins
|
|
||||||
.glass-effect() {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
-webkit-backdrop-filter: blur(10px);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.flex-center() {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
69
frontend/src/theme.module.less
Normal file
69
frontend/src/theme.module.less
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
|
||||||
|
/* Global Theme Variables */
|
||||||
|
:global {
|
||||||
|
:root {
|
||||||
|
/* Colors */
|
||||||
|
--primary-color: #00b96b;
|
||||||
|
--secondary-color: #1890ff;
|
||||||
|
--background-dark: #1f1f1f;
|
||||||
|
--background-card: #2a2a2a;
|
||||||
|
--text-primary: #ffffff;
|
||||||
|
--text-secondary: rgba(255, 255, 255, 0.65);
|
||||||
|
--border-color: rgba(255, 255, 255, 0.1);
|
||||||
|
|
||||||
|
/* Typography */
|
||||||
|
--font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
||||||
|
--font-size-base: 14px;
|
||||||
|
--font-size-lg: 16px;
|
||||||
|
--font-size-xl: 20px;
|
||||||
|
|
||||||
|
/* Layout */
|
||||||
|
--border-radius-base: 8px;
|
||||||
|
--border-radius-lg: 16px;
|
||||||
|
|
||||||
|
/* Spacing */
|
||||||
|
--spacing-xs: 4px;
|
||||||
|
--spacing-sm: 8px;
|
||||||
|
--spacing-md: 16px;
|
||||||
|
--spacing-lg: 24px;
|
||||||
|
|
||||||
|
/* Shadows */
|
||||||
|
--box-shadow-base: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||||
|
--box-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mixins (Less Variables for module usage if needed) */
|
||||||
|
@primary-color: var(--primary-color);
|
||||||
|
@secondary-color: var(--secondary-color);
|
||||||
|
@background-dark: var(--background-dark);
|
||||||
|
@background-card: var(--background-card);
|
||||||
|
@text-primary: var(--text-primary);
|
||||||
|
@text-secondary: var(--text-secondary);
|
||||||
|
@border-radius-base: var(--border-radius-base);
|
||||||
|
|
||||||
|
.glass-panel {
|
||||||
|
background: rgba(42, 42, 42, 0.6);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
border-radius: var(--border-radius-lg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
margin-bottom: var(--spacing-lg);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-sm);
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
width: 4px;
|
||||||
|
height: 24px;
|
||||||
|
background: var(--primary-color);
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +1,10 @@
|
|||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
import viteImagemin from 'vite-plugin-imagemin'
|
|
||||||
|
|
||||||
|
//123
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [react()],
|
||||||
react(),
|
|
||||||
viteImagemin({
|
|
||||||
gifsicle: { optimizationLevel: 7, interlaced: false },
|
|
||||||
optipng: { optimizationLevel: 7 },
|
|
||||||
mozjpeg: { quality: 20 },
|
|
||||||
pngquant: { quality: [0.8, 0.9], speed: 4 },
|
|
||||||
svgo: {
|
|
||||||
plugins: [
|
|
||||||
{ name: 'removeViewBox' },
|
|
||||||
{ name: 'removeEmptyAttrs', active: false },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
server: {
|
server: {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
port: 5173,
|
port: 5173,
|
||||||
|
|||||||
Reference in New Issue
Block a user