Refactor site configuration and color scheme management

- Replaced static config with dynamic site info context.
- Updated color scheme handling in various components to use site info.
- Removed deprecated config file and integrated site info fetching.
- Enhanced user preference page to allow color scheme selection.
- Adjusted blog and console components to reflect new site info structure.
- Improved error handling and fallback mechanisms for site info retrieval.
This commit is contained in:
2025-09-26 00:25:34 +08:00
parent 0812e334df
commit f501948f91
42 changed files with 770 additions and 199 deletions

View File

@ -7,7 +7,8 @@ import { calculateReadingTime } from "@/utils/common/post";
import { CommentSection } from "@/components/comment";
import { TargetType } from '@/models/types';
import * as motion from "motion/react-client"
import config from "@/config";
import { fallbackSiteInfo, useSiteInfo } from "@/contexts/site-info-context";
import { getSiteInfo } from "@/api/misc";
function PostMeta({ post }: { post: Post }) {
return (
@ -141,6 +142,7 @@ async function PostContent({ post }: { post: Post }) {
async function BlogPost({ post }: { post: Post}) {
const siteInfo = await getSiteInfo().then(res => res.data).catch(() => fallbackSiteInfo);
return (
<div className="h-full"
>
@ -148,14 +150,14 @@ async function BlogPost({ post }: { post: Post}) {
<motion.div
initial={{ opacity: 0, y: -30 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: config.animationDurationSecond, ease: "easeOut" }}>
transition={{ duration: siteInfo.animationDurationSecond, ease: "easeOut" }}>
<PostHeader post={post} />
</motion.div>
<motion.div
initial={{ opacity: 0, y: 30 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: config.animationDurationSecond, ease: "easeOut" }}>
transition={{ duration: siteInfo.animationDurationSecond, ease: "easeOut" }}>
<PostContent post={post} />
</motion.div>