This commit is contained in:
eric
2026-03-10 11:48:50 -05:00
parent eb33ed9360
commit 296d703307
41 changed files with 9072 additions and 121 deletions

View File

@@ -1,22 +1,24 @@
"use client";
import { useCallback, useEffect, useRef, useState } from "react";
import Image from "next/image";
import { marked } from "marked";
import { useCallback, useEffect, useState } from "react";
import Link from "next/link";
import PocketBase from "pocketbase";
import { indexMd } from "./index-content";
import styles from "./index.module.css";
import { getPayEnv, getDeviceFromEnv } from "@/app/lib/payEnv";
import { getPaymentConfig } from "@/config/services.config";
import { formatRestoreDateShort } from "@/config/promo.config";
import { usePayStatusPoll } from "@/app/lib/usePayStatusPoll";
import { ThemeToggle } from "@/app/components/ThemeToggle";
import styles from "./home.module.css";
const PB_URL =
process.env.NEXT_PUBLIC_POCKETBASE_URL || "https://pocketbase.hackrobot.cn";
/** 微信内支付渠道:zpay | xorpay,改此参数即可切换 */
/** 临时:预览支付成功后的界面,本地调试用,上线前改回 false */
const FORCE_VIP_PREVIEW = false;
/** 微信内支付渠道:zpay | xorpay */
const WECHAT_PAY_PROVIDER: "zpay" | "xorpay" = "xorpay";
/** PC:form POST 到 /api/pay,有中转页 */
function redirectToPayZpay(params: {
user_id: string;
return_url: string;
@@ -51,7 +53,6 @@ function redirectToPayZpay(params: {
form.submit();
}
/** H5 手机:fetch 获取 order_id,新标签页打开支付,当前页保持可轮询 */
async function redirectToPayZpayH5(params: {
user_id: string;
return_url: string;
@@ -98,7 +99,6 @@ async function redirectToPayZpayH5(params: {
return orderId;
}
/** 微信内:fetch 获取 xorpay 参数,直接提交表单到收银台,无中转页 */
async function payWechatXorpay(params: {
user_id: string;
return_url: string;
@@ -154,12 +154,38 @@ function removeStorage(key: string): void {
localStorage.removeItem(key);
}
const FEATURES = [
{
icon: "🚀",
title: "业务方向",
desc: "无人直播、RPA 自动化、Web 开发,找到你的变现路径",
},
{
icon: "⚙️",
title: "技术杠杆",
desc: "云手机、PVE 虚拟化、服务器集群,低成本放大收益",
},
{
icon: "🌐",
title: "海外平台",
desc: "YouTube、TikTok、SaaS 运营实战,出海掘金",
},
];
const UNLOCK_ITEMS = [
{ icon: "📖", title: "电子书", desc: "地理套利·自动化", href: "/ebook" },
{ icon: "🎬", title: "视频教程", desc: "云手机·无人直播", href: "/cloudphone" },
{ icon: "👥", title: "私密社群", desc: "抱团出海", href: null },
{ icon: "🛒", title: "商店", desc: "设备自助", href: null },
{ icon: "💬", title: "即时问答", desc: "技术咨询", href: "https://chatwoot.hackrobot.cn/livechat?user_id=hackrobot" },
{ icon: "🎪", title: "线下沙龙", desc: "面交·对接", href: null },
];
export default function Home() {
const [paidType, setPaidType] = useState<string | null>(null);
const [userName, setUserName] = useState<string | null>(null);
const [loading, setLoading] = useState(true);
const [payPendingOrderId, setPayPendingOrderId] = useState<string | null>(null);
const contentRef = useRef<HTMLDivElement>(null);
const savePaidType = useCallback((type: string | null) => {
if (type) setStorage("paidType", type);
@@ -330,7 +356,6 @@ export default function Home() {
init();
}, [clearAllStorage, getOrCreateUserId, checkPaymentFromPB, savePaidType, saveUserName]);
// 页面重新可见或从 bfcache 恢复时检查支付状态(从 /paid 返回、切换标签页、后退等)
useEffect(() => {
const syncFromStorage = () => {
const localType = getStorage("paidType");
@@ -342,7 +367,7 @@ export default function Home() {
};
const onVisible = () => syncFromStorage();
const onPageShow = (e: PageTransitionEvent) => {
if (e.persisted) syncFromStorage(); // 从 bfcache 恢复
if (e.persisted) syncFromStorage();
};
if (typeof document !== "undefined" && document.addEventListener) {
document.addEventListener("visibilitychange", onVisible);
@@ -354,111 +379,133 @@ export default function Home() {
}
}, [paidType]);
marked.setOptions({ breaks: true, gfm: true });
if (loading) {
return (
<div className={styles.loading}>
<div className={styles.loadingSpinner} />
<p>加载中...</p>
</div>
);
}
return (
<div className={styles.index}>
<div className={`${styles.indexBook} animate__animated animate__pulse`}>
<div className={styles.indexBookLeft}>
<div className={styles.leftTitle}>异度星球</div>
if (FORCE_VIP_PREVIEW || paidType === "vip") {
return (
<div className={styles.root}>
<header className={styles.header}>
<Link href="https://digital.hackrobot.cn/zh" className={styles.logo} target="_blank" rel="noopener">
🌍 异度星球
</Link>
<nav className={styles.nav}>
<ThemeToggle />
</nav>
</header>
<div className={styles.card}>
<div className={styles.cardItem}>
<div className={styles.cardItemLeft}>
<Image
className={styles.cardItemLeftImg}
src="/images/group.svg"
alt="group"
width={40}
height={40}
/>
</div>
<div className={styles.cardItemRight}>
<div className={styles.cardItemRightUp}>数字游民社群</div>
<div className={styles.cardItemRightDown}>还在独自摸索吗?</div>
<main className={styles.main}>
<section className={styles.vipSuccess}>
<div className={`${styles.vipSuccessCard} animate__animated animate__zoomIn`} style={{ animationDelay: "0.1s", animationFillMode: "both" }}>
<div className={styles.vipSuccessIcon}>✅</div>
<h1>欢迎加入异度星球</h1>
<p className={styles.vipSuccessDesc}>您已解锁全部 VIP 权益</p>
<div className={styles.vipCode}>
<div className={styles.vipCodeRow}>
<span>星球地址</span>
<code>qun.hackrobot.cn</code>
</div>
<div className={styles.vipCodeRow}>
<span>账号</span>
<code>{getStorage("userName") || (FORCE_VIP_PREVIEW ? "preview" : "")}</code>
<button type="button" onClick={handleCopyUsername}>复制</button>
</div>
<div className={styles.vipCodeRow}>
<span>密码</span>
<code>123456</code>
</div>
<a
href="https://qun.hackrobot.cn"
target="_blank"
rel="noopener noreferrer"
className={styles.vipCta}
>
进入星球 →
</a>
<p className={styles.vipTip}>打开网页后,请点击「左上角头像」打开侧面栏</p>
</div>
</div>
</div>
</section>
</main>
</div>
);
}
<div
ref={contentRef}
className={`markdown-body ${styles.markVip}`}
dangerouslySetInnerHTML={{ __html: marked(indexMd) as string }}
/>
return (
<div className={styles.root}>
<header className={styles.header}>
<Link href="https://digital.hackrobot.cn/zh" className={styles.logo} target="_blank" rel="noopener">
🌍 异度星球
</Link>
<nav className={styles.nav}>
<ThemeToggle />
</nav>
</header>
<div className={styles.leftBtn}>
{paidType === "vip" ? (
<div className={styles.vipcode}>
<div
onClick={() => {
window.location.href = "https://qun.hackrobot.cn";
}}
style={{ cursor: "pointer" }}
>
👉星球地址: qun.hackrobot.cn
</div>
<div>账号:{getStorage("userName")}</div>
<button onClick={handleCopyUsername}>复制账号</button>
<div>密码:123456</div>
<div>打开网页后,请点击&quot;左上角头像&quot;,打开侧面栏</div>
<main className={styles.main}>
<section className={styles.hero}>
<p className={`${styles.heroBadge} animate__animated animate__fadeInDown`} style={{ animationDelay: "0.1s", animationFillMode: "both" }}>🎒 数字游民进阶社群 · 私密资源</p>
<h1 className={`${styles.heroTitle} animate__animated animate__fadeInDown`} style={{ animationDelay: "0.2s", animationFillMode: "both" }}>
异度星球
</h1>
<p className={`${styles.heroSubtitle} animate__animated animate__fadeInDown`} style={{ animationDelay: "0.3s", animationFillMode: "both" }}>
解锁电子书、视频教程、即时问答 · 抱团出海,技术杠杆
</p>
</section>
<section className={`${styles.section} ${styles.sectionTightTop}`}>
<div className={styles.features}>
{FEATURES.map((f, i) => (
<div key={i} className={`${styles.featureCard} animate__animated animate__fadeInUp`} style={{ animationDelay: `${0.3 + i * 0.1}s`, animationFillMode: "both" }}>
<span className={styles.featureIcon}>{f.icon}</span>
<h3>{f.title}</h3>
<p>{f.desc}</p>
</div>
) : (
<button
onClick={() => {
if (paidType) return;
handlePay();
}}
className={styles.startRead}
type="button"
))}
</div>
</section>
<section className={styles.section}>
<h2 className="animate__animated animate__fadeInDown" style={{ animationDelay: "0.1s", animationFillMode: "both" }}>🔓 解锁 VIP</h2>
<p className={`${styles.sectionDesc} animate__animated animate__fadeInUp`} style={{ animationDelay: "0.2s", animationFillMode: "both" }}>
一次付费·全部解锁
</p>
<div className={styles.unlockGrid}>
{UNLOCK_ITEMS.map((item, i) => (
<div
key={i}
className={`${styles.unlockCard} ${styles.unlockCardDisabled} animate__animated animate__fadeInUp`}
style={{ animationDelay: `${0.25 + i * 0.06}s`, animationFillMode: "both" }}
>
🔒 解锁vip会员
</button>
)}
<span className={styles.unlockIcon}>{item.icon}</span>
<span className={styles.unlockTitle}>{item.title}</span>
<span className={styles.unlockDesc}>{item.desc}</span>
</div>
))}
</div>
</div>
</section>
<div className={styles.indexBookImg}>
<Image
className={styles.bookImg}
src="/images/touxiang.png"
alt="avatar"
width={200}
height={200}
/>
</div>
</div>
<div className={styles.svgItems}>
<div className={styles.svgItem}>
<div className={styles.bookImgItem}>
<Image
src="/images/laptop.svg"
alt="laptop"
width={80}
height={80}
/>
<div className={styles.bookImgText}>无人直播</div>
<section className={`${styles.section} ${styles.sectionCta}`}>
<div className={`${styles.ctaCard} animate__animated animate__zoomIn`} style={{ animationDelay: "0.2s", animationFillMode: "both" }}>
<h2>限时特惠 · {formatRestoreDateShort()}恢复原价</h2>
<p>阶梯定价 · 数字交付 · 不支持退款</p>
<p className={styles.ctaNote}>🚫 不适合躺赚、现金流紧张</p>
<button
type="button"
onClick={() => { handlePay(); }}
className={`${styles.btnPrimary} ${styles.btnLarge}`}
>
🔒 解锁 VIP
</button>
</div>
<div className={styles.bookImgItem}>
<Image
src="/images/travel.svg"
alt="travel"
width={80}
height={80}
/>
<div className={styles.bookImgText}>RPA自动化</div>
</div>
<div className={styles.bookImgItem}>
<Image
src="/images/code.svg"
alt="code"
width={80}
height={80}
/>
<div className={styles.bookImgText}>聊天机器人</div>
</div>
</div>
</div>
</section>
</main>
</div>
);
}