add
This commit is contained in:
parent
f8f3e7985e
commit
3432b1af79
|
@ -7,11 +7,18 @@ import {
|
|||
VisitType,
|
||||
} from '@nice/common';
|
||||
export async function updateTotalCourseViewCount(type: VisitType) {
|
||||
const courses = await db.post.findMany({
|
||||
where: { type: PostType.COURSE },
|
||||
select: { id: true },
|
||||
const posts = await db.post.findMany({
|
||||
where: {
|
||||
type: { in: [PostType.COURSE, PostType.LECTURE] },
|
||||
deletedAt: null,
|
||||
},
|
||||
select: { id: true, type: true },
|
||||
});
|
||||
const courseIds = courses.map((course) => course.id);
|
||||
|
||||
const courseIds = posts
|
||||
.filter((post) => post.type === PostType.COURSE)
|
||||
.map((course) => course.id);
|
||||
const lectures = posts.filter((post) => post.type === PostType.LECTURE);
|
||||
const totalViews = await db.visit.aggregate({
|
||||
_sum: {
|
||||
views: true,
|
||||
|
@ -30,6 +37,10 @@ export async function updateTotalCourseViewCount(type: VisitType) {
|
|||
meta: true,
|
||||
},
|
||||
});
|
||||
const staffs = await db.staff.count({
|
||||
where: { deletedAt: null },
|
||||
});
|
||||
|
||||
const baseSeting = appConfig.meta as BaseSetting;
|
||||
await db.appConfig.update({
|
||||
where: {
|
||||
|
@ -38,7 +49,15 @@ export async function updateTotalCourseViewCount(type: VisitType) {
|
|||
data: {
|
||||
meta: {
|
||||
...baseSeting,
|
||||
reads: totalViews._sum.views,
|
||||
appConfig: {
|
||||
...(baseSeting?.appConfig || {}),
|
||||
statistics: {
|
||||
reads: totalViews._sum.views || 0,
|
||||
courses: courseIds?.length || 0,
|
||||
staffs: staffs || 0,
|
||||
lectures: lectures?.length || 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -45,16 +45,16 @@ const carouselItems: CarouselItem[] = [
|
|||
},
|
||||
];
|
||||
|
||||
const platformStats: PlatformStat[] = [
|
||||
{ icon: <TeamOutlined />, value: "50,000+", label: "注册学员" },
|
||||
{ icon: <BookOutlined />, value: "1,000+", label: "精品课程" },
|
||||
// { icon: <StarOutlined />, value: '98%', label: '好评度' },
|
||||
{ icon: <EyeOutlined />, value: "100万+", label: "观看次数" },
|
||||
];
|
||||
|
||||
const HeroSection = () => {
|
||||
const carouselRef = useRef<CarouselRef>(null);
|
||||
const { statistics, baseSetting } = useAppConfig();
|
||||
|
||||
const platformStats: PlatformStat[] = [
|
||||
{ icon: <TeamOutlined />, value: "50,000+", label: "注册学员" },
|
||||
{ icon: <BookOutlined />, value: "1,000+", label: "精品课程" },
|
||||
// { icon: <StarOutlined />, value: '98%', label: '好评度' },
|
||||
{ icon: <EyeOutlined />, value: "4552", label: "观看次数" },
|
||||
];
|
||||
const handlePrev = useCallback(() => {
|
||||
carouselRef.current?.prev();
|
||||
}, []);
|
||||
|
@ -74,8 +74,8 @@ const HeroSection = () => {
|
|||
dots={{
|
||||
className: "carousel-dots !bottom-32 !z-20",
|
||||
}}>
|
||||
{Array.isArray(carouselItems)?
|
||||
(carouselItems.map((item, index) => (
|
||||
{Array.isArray(carouselItems) ? (
|
||||
carouselItems.map((item, index) => (
|
||||
<div key={index} className="relative h-[600px]">
|
||||
<div
|
||||
className="absolute inset-0 bg-cover bg-center transform transition-[transform,filter] duration-[2000ms] group-hover:scale-105 group-hover:brightness-110 will-change-[transform,filter]"
|
||||
|
@ -93,11 +93,10 @@ const HeroSection = () => {
|
|||
{/* Content Container */}
|
||||
<div className="relative h-full max-w-7xl mx-auto px-6 lg:px-8"></div>
|
||||
</div>
|
||||
)))
|
||||
:(
|
||||
<div></div>
|
||||
)
|
||||
}
|
||||
))
|
||||
) : (
|
||||
<div></div>
|
||||
)}
|
||||
</Carousel>
|
||||
|
||||
{/* Navigation Buttons */}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React from "react";
|
||||
import React, { ReactNode } from "react";
|
||||
export interface MenuItemType {
|
||||
icon: React.;
|
||||
icon: ReactNode;
|
||||
label: string;
|
||||
action: () => void;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ import {
|
|||
SkeletonItem,
|
||||
SkeletonSection,
|
||||
} from "@web/src/components/presentation/Skeleton";
|
||||
import { api } from "packages/client/dist";
|
||||
|
||||
export const CourseDetailSkeleton = () => {
|
||||
return (
|
||||
|
|
|
@ -10,6 +10,7 @@ export function useAppConfig() {
|
|||
api.app_config.findFirst.useQuery({
|
||||
where: { slug: AppConfigSlug.BASE_SETTING },
|
||||
});
|
||||
|
||||
const handleMutationSuccess = useCallback(() => {
|
||||
utils.app_config.invalidate();
|
||||
}, [utils]);
|
||||
|
@ -26,7 +27,8 @@ export function useAppConfig() {
|
|||
});
|
||||
useEffect(() => {
|
||||
if (data?.meta) {
|
||||
setBaseSetting(JSON.parse(data?.meta));
|
||||
// console.log(JSON.parse(data?.meta));
|
||||
setBaseSetting(data?.meta);
|
||||
}
|
||||
}, [data, isLoading]);
|
||||
const splashScreen = useMemo(() => {
|
||||
|
@ -38,6 +40,16 @@ export function useAppConfig() {
|
|||
const slides = useMemo(() => {
|
||||
return baseSetting?.appConfig?.slides || [];
|
||||
}, [baseSetting]);
|
||||
const statistics = useMemo(() => {
|
||||
return (
|
||||
baseSetting?.appConfig?.statistics || {
|
||||
reads: 0,
|
||||
staffs: 0,
|
||||
courses: 0,
|
||||
lectures: 0,
|
||||
}
|
||||
);
|
||||
}, [baseSetting]);
|
||||
return {
|
||||
create,
|
||||
deleteMany,
|
||||
|
@ -47,5 +59,6 @@ export function useAppConfig() {
|
|||
devDept,
|
||||
isLoading,
|
||||
slides,
|
||||
statistics,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -44,7 +44,12 @@ export interface BaseSetting {
|
|||
splashScreen?: string;
|
||||
devDept?: string;
|
||||
slides?: [];
|
||||
reads?: number;
|
||||
statistics?: {
|
||||
reads?: number;
|
||||
courses?: number;
|
||||
lectures?: number;
|
||||
staffs?: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
export type RowModelResult = {
|
||||
|
|
Loading…
Reference in New Issue