diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index eac2e65..ab229c6 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -4,7 +4,7 @@ ### 1. Vercel部署 -```bash +\`\`\`bash # 安装Vercel CLI npm install -g vercel @@ -13,7 +13,7 @@ vercel login # 部署项目 vercel --prod -``` +\`\`\` ### 2. 环境变量配置 @@ -71,7 +71,7 @@ vercel --prod ## 本地开发 -```bash +\`\`\`bash # 安装依赖 npm install @@ -79,7 +79,7 @@ npm install npm run dev # 访问 http://localhost:3000 -``` +\`\`\` ## 注意事项 diff --git a/app/my/page.tsx b/app/my/page.tsx index e6bc295..1ade62e 100644 --- a/app/my/page.tsx +++ b/app/my/page.tsx @@ -2,149 +2,177 @@ import { useState, useEffect } from "react" import Link from "next/link" -import { User, ShoppingBag, Share2, LogOut, ChevronRight, BookOpen } from "lucide-react" +import { User, ShoppingBag, Share2, LogOut, ChevronRight, BookOpen, Copy, Check } from "lucide-react" import { useStore } from "@/lib/store" import { AuthModal } from "@/components/modules/auth/auth-modal" -import { getFullBookPrice } from "@/lib/book-data" +import { getFullBookPrice, getAllSections } from "@/lib/book-data" export default function MyPage() { const { user, isLoggedIn, logout } = useStore() const [showAuthModal, setShowAuthModal] = useState(false) const [mounted, setMounted] = useState(false) + const [copied, setCopied] = useState(false) useEffect(() => { setMounted(true) }, []) + const copyCode = () => { + if (user?.referralCode) { + navigator.clipboard.writeText(user.referralCode) + setCopied(true) + setTimeout(() => setCopied(false), 2000) + } + } + if (!mounted) { return ( -
-
+
+
) } if (!isLoggedIn) { return ( -
-
-
-
- -
-

登录后查看更多

-

查看购买记录、分销收益

- -
+
+
+
+

登录后查看更多

+

查看购买记录、分销收益

+ setShowAuthModal(false)} />
) } + const totalSections = getAllSections().length + const purchasedCount = user?.hasFullBook ? totalSections : user?.purchasedSections.length || 0 + const purchaseProgress = Math.round((purchasedCount / totalSections) * 100) const fullBookPrice = getFullBookPrice() return ( -
- {/* User Profile Header */} -
-
-
-
- -
-
-

{user?.nickname || "用户"}

-

{user?.phone}

-
+
+ {/* 用户信息头部 */} +
+
+
+
- - {/* Stats */} -
-
-

- {user?.hasFullBook ? "全部" : user?.purchasedSections.length || 0} -

-

已购章节

-
-
-

¥{(user?.earnings || 0).toFixed(1)}

-

累计收益

-
+
+

{user?.nickname || "用户"}

+

{user?.phone}

+ + {/* 数据统计卡片 */} +
+ {/* 购买进度 */} +
+
+ 购买进度 + {purchaseProgress}% +
+
+
+
+

+ {user?.hasFullBook ? "全书" : `${purchasedCount}/${totalSections}`} +

+

已购章节

+
+ + {/* 分销收益 */} +
+
+ 累计收益 + +
+

¥{(user?.earnings || 0).toFixed(2)}

+

推荐{user?.referralCount || 0}人

+
+
+ + {/* 购买整本书提示 */} + {!user?.hasFullBook && ( + +
+
+
+ +
+

购买整本书

+

解锁全部{totalSections}章内容

+
+
+ ¥{fullBookPrice} +
+
+ + )}
- {/* Menu Items */} -
-
- {/* Purchase prompt */} - {!user?.hasFullBook && ( - -
-
-
- - 购买整本书 -
- ¥{fullBookPrice} -
-
- - )} - - {/* Menu List - simplified, removed settings and docs */} -
- -
- - 我的购买 -
- - - - -
- - 分销收益 -
-
- ¥{(user?.earnings || 0).toFixed(1)} - -
- -
- - {/* Referral Code */} -
-
-
-

我的邀请码

- {user?.referralCode} -
- + {/* 菜单列表 */} +
+
+ +
+ + 我的购买
-
+
+ {purchasedCount}章 + +
+ - {/* Logout */} - + +
+ + 分销收益 +
+
+ ¥{(user?.earnings || 0).toFixed(1)} + +
+
+ + {/* 邀请码 */} +
+
+
+

我的邀请码

+ {user?.referralCode} +
+ +
+

分享给好友,好友购买你获得90%佣金

+
+ + {/* 退出登录 */} +
) diff --git a/app/page.tsx b/app/page.tsx index 1432dc3..028beb2 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,31 +1,133 @@ -import { BookCover } from "@/components/book-cover" -import { BookIntro } from "@/components/book-intro" -import { TableOfContents } from "@/components/table-of-contents" -import { PurchaseSection } from "@/components/purchase-section" -import { Footer } from "@/components/footer" -import { getBookStructure } from "@/lib/book-file-system" +"use client" -// 强制动态渲染,确保内容实时更新 -export const dynamic = 'force-dynamic'; +import { useState, useEffect } from "react" +import Link from "next/link" +import { ChevronRight, Sparkles, User } from "lucide-react" +import { bookData, getAllSections, getFullBookPrice } from "@/lib/book-data" +import { useStore } from "@/lib/store" +import { AuthModal } from "@/components/modules/auth/auth-modal" -export default async function HomePage() { - const parts = getBookStructure() +export default function HomePage() { + const [sectionsCount, setSectionsCount] = useState(64) + const [isAuthOpen, setIsAuthOpen] = useState(false) + const { isLoggedIn, user } = useStore() + + useEffect(() => { + const sections = getAllSections() + setSectionsCount(sections.length) + }, []) + + // 计算每篇的章节数 + const partsWithCount = bookData.map((part) => ({ + ...part, + chaptersCount: part.chapters.length, + sectionsCount: part.chapters.reduce((acc, c) => acc + c.sections.length, 0), + })) return ( -
- {/* 背景渐变效果 */} -
- - {/* 装饰性光晕 */} -
- - - - - - {/* 隐藏派对功能 */} - {/* */} -