feat/0.2:add theme setting and about page setting and support use email and password login

This commit is contained in:
lethe committed 2025-07-24 10:28:42 +08:00
1 parent 58292b0e6e
commit ca2b732952
85 files changed
+5797 -816

No files matched your search

@@ -0,0 +1,27 @@
"use client";
import React from "react";
import { AboutContent } from "@/components/about/AboutContent";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { NavigationItem } from "@/shared/components/Navigation";
interface AboutProps {
navItems?: NavigationItem[];
}
export const About: React.FC<AboutProps> = ({ navItems = [] }) => {
return (
<div className="min-h-screen bg-gray-50 absolute top-0 left-0 right-0 bottom-0 flex flex-col justify-between bg-white">
<Navigation items={navItems} />
<main className="flex-1 pt-32">
<div className="max-w-7xl mx-auto px-6 pb-12">
<AboutContent />
</div>
</main>
<Footer />
</div>
);
};
+103
View File
@@ -0,0 +1,103 @@
"use client";
import React from "react";
import { ShoppingBag, Search, Tag, Star } from "lucide-react";
const TemuDemo: React.FC = () => {
return (
<div className="w-full h-full bg-gradient-to-r from-orange-400 via-orange-500 to-red-500 relative overflow-hidden">
{/* Header */}
<div className="absolute top-0 left-0 right-0 bg-white/10 backdrop-blur-sm px-3 py-2">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<ShoppingBag className="w-4 h-4 text-white" />
<span className="text-white font-bold text-sm">MCP Store</span>
</div>
<div className="flex items-center gap-1">
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
<div className="w-2 h-2 bg-white/60 rounded-full"></div>
</div>
</div>
</div>
{/* Hero Section */}
<div className="absolute top-8 left-0 right-0 px-3 py-4">
<div className="text-center">
{/* Title */}
<h1 className="text-lg font-bold text-white mb-1">
Discover Amazing Services
</h1>
{/* Subtitle */}
<p className="text-xs text-white/90 mb-3">
Find the perfect MCP service for your needs
</p>
{/* Search Bar */}
<div className="flex gap-1 mb-3">
<div className="flex-1 bg-white rounded-md px-2 py-1 flex items-center gap-1">
<Search className="w-3 h-3 text-gray-400" />
<span className="text-xs text-gray-500">Search...</span>
</div>
<div className="bg-white px-3 py-1 rounded-md">
<span className="text-xs text-orange-500 font-medium">Go</span>
</div>
</div>
</div>
</div>
{/* Products Section */}
<div className="absolute top-[150px] left-0 right-0 bg-white rounded-t-lg px-3 py-3">
{/* Section Header */}
<div className="flex items-center gap-1 mb-2">
<Tag className="w-3 h-3 text-orange-500" />
<span className="text-sm font-bold text-gray-900">Featured</span>
</div>
{/* Products Grid */}
<div className="grid grid-cols-2 gap-2">
{/* Product 1 */}
<div className="bg-gray-50 rounded-lg p-2 border border-gray-100">
<div className="mb-1">
<h3 className="text-xs font-semibold text-gray-900 line-clamp-1">
AI Assistant
</h3>
<p className="text-xs text-gray-600 line-clamp-1">
Smart AI helper
</p>
</div>
<div className="flex items-center justify-between">
<span className="text-xs font-bold text-orange-600">$9.99</span>
<div className="flex items-center gap-1">
<Star className="w-2 h-2 text-yellow-400 fill-current" />
<span className="text-xs text-gray-500">4.8</span>
</div>
</div>
</div>
{/* Product 2 */}
<div className="bg-gray-50 rounded-lg p-2 border border-gray-100">
<div className="mb-1">
<h3 className="text-xs font-semibold text-gray-900 line-clamp-1">
Data Analyzer
</h3>
<p className="text-xs text-gray-600 line-clamp-1">
Powerful analytics
</p>
</div>
<div className="flex items-center justify-between">
<span className="text-xs font-bold text-orange-600">$14.99</span>
<div className="flex items-center gap-1">
<Star className="w-2 h-2 text-yellow-400 fill-current" />
<span className="text-xs text-gray-500">4.9</span>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default TemuDemo;
@@ -0,0 +1,195 @@
"use client";
import React, { useState } from "react";
import { useTranslation } from "@/shared/lib/useTranslation";
import { Tabs, Tab, Chip, Card, CardBody } from "@nextui-org/react";
import { ServiceData } from "@/shared/types/marketplace";
import { ProductHeader } from "@/shared/components/marketplace/ProductHeader";
import { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
import { ProductTools } from "@/shared/components/marketplace/ProductTools";
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
import { FileText, Wrench, Cog } from "lucide-react";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { NavigationItem } from "@/shared/components/Navigation";
interface DetailProps {
product: ServiceData;
breadcrumbs?: {
link: string;
name: string;
}[];
url?: string;
// navigation items
navItems?: NavigationItem[];
}
export const Detail: React.FC<DetailProps> = ({
product,
breadcrumbs,
url,
navItems = [],
}) => {
const { t } = useTranslation();
const [activeTab, setActiveTab] = useState("overview");
const { platformConfig } = usePlatformConfig();
if (!product) {
return <ProductNotFound />;
}
return (
<div className="min-h-screen bg-gray-50 flex flex-col justify-between">
<Navigation items={navItems} />
<div>
{/* Temu Style Product Header */}
<div className="bg-white border-b border-gray-200 shadow-sm pt-20">
<div className="mx-auto p-6 max-w-7xl">
{/* Breadcrumbs */}
{breadcrumbs && breadcrumbs.length > 0 && (
<nav className="mb-4">
<ol className="flex items-center space-x-2 text-sm text-gray-600">
{breadcrumbs.map((crumb, index) => (
<li key={index} className="flex items-center">
{index > 0 && (
<span className="mx-2 text-gray-400">/</span>
)}
<a
href={crumb.link}
className="hover:text-orange-500 transition-colors"
>
{crumb.name}
</a>
</li>
))}
</ol>
</nav>
)}
<ProductHeader product={product} breadcrumbs={breadcrumbs} />
</div>
</div>
{/* Main Content */}
<div className="mx-auto p-6 max-w-7xl mt-6">
<Card className="bg-white border border-gray-200 shadow-sm">
<CardBody className="p-0">
<Tabs
selectedKey={activeTab}
onSelectionChange={(key) => setActiveTab(key as string)}
variant="underlined"
color="warning"
className="px-6 pt-6"
classNames={{
tabList:
"gap-6 w-full relative rounded-none p-0 border-b border-gray-200",
cursor: "w-full bg-orange-500",
tab: "max-w-fit px-0 h-12",
tabContent:
"group-data-[selected=true]:text-orange-600 font-medium text-gray-700",
}}
>
<Tab
key="overview"
title={
<div className="flex items-center gap-2">
<FileText className="w-4 h-4" />
<span>{t("Overview")}</span>
</div>
}
>
<div className="p-6">
<ProductOverview product={product} />
</div>
</Tab>
<Tab
key="tools"
title={
<div className="flex items-center gap-2">
<Wrench className="w-4 h-4" />
<span>{t("Tools")}</span>
</div>
}
>
<div className="p-2">
<div className="space-y-4 px-3">
{product.tools.length > 0 ? (
product.tools.map((tool, index) => (
<Card
radius="sm"
key={`${product.service_id}-tool-${index}`}
shadow="none"
className="border-1"
>
<CardBody>
<h4 className="font-semibold text-sm mb-2 text-orange-600">
{tool.name}
</h4>
<p className="text-sm mb-3">
{tool.description ||
t("No description available")}
</p>
</CardBody>
</Card>
))
) : (
<Card>
<CardBody>
<p className="text-center">
{t("No tools available in this service.")}
</p>
</CardBody>
</Card>
)}
</div>
</div>
</Tab>
<Tab
key="config"
title={
<div className="flex items-center gap-2">
<Cog className="w-4 h-4" />
<span>{t("Configuration")}</span>
</div>
}
>
<div className="p-6">
{/* Code Snippet */}
<Card className="w-full bg-black text-white p-2 sm:p-4 rounded-lg relative z-10">
<div className="text-left font-mono">
<Chip
className="mb-2 text-white"
size="sm"
variant="flat"
>
{platformConfig?.name} MCP
</Chip>
<pre className="p-2 sm:p-4 rounded-md text-xs overflow-x-auto">
<code className="text-gray-300 whitespace-pre-wrap">
{`{
"mcpServers": {
"xpack-mcp-market": {
"type": "sse",
"autoApprove"":"all",
"url": "${url}?apikey=`}
<span className="text-success">{`{Your-${platformConfig?.name}-API-Key}`}</span>
{`"
}
}
}`}
</code>
</pre>
</div>
</Card>
</div>
</Tab>
</Tabs>
</CardBody>
</Card>
</div>
</div>
<Footer />
</div>
);
};
@@ -0,0 +1,68 @@
"use client";
import React from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import { ShoppingBag, Star, Heart } from "lucide-react";
import { useTranslation } from "react-i18next";
interface FooterProps {}
export const Footer: React.FC<FooterProps> = ({}) => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
return (
<>
{/* Temu Style Footer */}
<footer className="bg-gray-50 border-t border-gray-200">
<div className="mx-auto px-6 pt-12 pb-6 max-w-7xl">
<div className="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
{/* Company Info */}
<div>
<h3 className="text-lg font-bold text-gray-900 mb-4">
{platformConfig?.name}
</h3>
<p className="text-gray-600 text-sm mb-4">
{t(
"A marketplace for AI tools and services. Discover and integrate powerful AI solutions for your projects."
)}
</p>
<div className="flex items-center gap-2 text-orange-500">
<ShoppingBag className="w-5 h-5" />
<span className="text-sm font-medium">
{t("AI Tools Marketplace")}
</span>
</div>
</div>
</div>
{/* Bottom Section */}
<div className="border-t border-gray-200 pt-8">
<div className="flex flex-col md:flex-row justify-between items-center gap-4">
{/* Copyright */}
<div className="flex items-center gap-2 text-gray-600 text-sm">
<span>
© 2025 {platformConfig?.name}. All rights reserved.
</span>
</div>
{/* Powered By */}
<div className="flex items-center gap-4">
<a
href="https://xpack.ai"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center gap-2 text-gray-600 hover:text-orange-500 transition-colors text-sm font-medium"
>
<div className="flex items-center gap-2 bg-white px-3 py-1 rounded-full border border-gray-200 hover:border-orange-200 transition-all duration-200">
<Star className="w-4 h-4 text-orange-500" />
<span>Powered By XPack.AI</span>
</div>
</a>
</div>
</div>
</div>
</div>
</footer>
</>
);
};
+220
View File
@@ -0,0 +1,220 @@
"use client";
import React from "react";
import { CardFooter, Spinner } from "@nextui-org/react";
import { Search, ShoppingBag, Tag, TrendingUp } from "lucide-react";
import {
Input,
Button,
Pagination,
Card,
CardBody,
Chip,
} from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { ServiceData } from "@/shared/types/marketplace";
import { Price } from "@/shared/components/marketplace/Price";
import {
_DefaultPlatformConfig,
usePlatformConfig,
} from "@/shared/contexts/PlatformConfigContext";
import { Footer } from "./Footer";
import { Navigation } from "./Navigation";
import { NavigationItem } from "@/shared/components/Navigation";
interface HomeProps {
// 状态
searchQuery: string;
services: ServiceData[];
currentPage: number;
total: number;
pageSize: number;
loading: boolean;
error: string | null;
// 事件处理函数
onSearchChange: (value: string) => void;
onSearch: () => void;
onPageChange: (page: number) => void;
// 可选配置
searchSuggestions?: string[];
// navigation items
navItems?: NavigationItem[];
}
export const Home: React.FC<HomeProps> = ({
searchQuery,
services,
currentPage,
total,
pageSize,
loading,
error,
onSearchChange,
onSearch,
onPageChange,
navItems = [],
}) => {
const { platformConfig } = usePlatformConfig();
const { t } = useTranslation();
const totalPages = Math.ceil(total / pageSize);
// 如果有错误,显示错误信息
if (error) {
return (
<div className="min-h-screen bg-gray-50">
<div className="mx-auto h-[100px] flex items-center justify-center">
<div className="text-red-600 bg-white px-6 py-4 rounded-lg shadow-md border border-red-200">
Error: {error}
</div>
</div>
</div>
);
}
return (
<div className="min-h-screen absolute top-0 left-0 right-0 bottom-0">
<Navigation items={navItems} />
{/* Temu Style Hero Section */}
<div className="bg-gradient-to-r from-orange-400 via-orange-500 to-red-500 pt-20">
<div className="mx-auto px-6 py-16 max-w-7xl">
<div className="text-center mb-12">
{/* Icon */}
<div className="flex justify-center mb-6">
<div className="bg-white/20 p-4 rounded-2xl backdrop-blur-sm">
<ShoppingBag className="w-10 h-10 text-white" />
</div>
</div>
{/* Title */}
<h1 className="text-4xl lg:text-6xl font-bold mb-6 text-white">
{t(
platformConfig.headline || _DefaultPlatformConfig.headline || ""
)}
</h1>
{/* Subtitle */}
<p className="text-xl text-white/90 mb-8 max-w-2xl mx-auto">
{t(
platformConfig.subheadline ||
_DefaultPlatformConfig.subheadline ||
""
)}
</p>
{/* Search Bar */}
<div className="max-w-2xl mx-auto mb-8">
<div className="flex gap-3">
<Input
placeholder={t("Search services...")}
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
onKeyDown={(e) => e.key === "Enter" && onSearch()}
startContent={<Search className="w-5 h-5 text-gray-400" />}
className="flex-1"
classNames={{
input: "text-lg",
inputWrapper: "h-14 bg-white shadow-lg border-0",
}}
radius="lg"
/>
<Button
onPress={onSearch}
className="bg-white text-orange-500 hover:bg-gray-50 font-semibold px-8 h-14 shadow-lg"
radius="lg"
>
{t("Search")}
</Button>
</div>
</div>
</div>
</div>
</div>
{/* Products Section */}
<div className="mx-auto px-6 py-12 max-w-7xl">
{/* Section Header */}
<div className="flex items-center justify-between mb-8">
<div className="flex items-center gap-3">
<Tag className="w-6 h-6 text-orange-500" />
<h2 className="text-2xl font-bold text-gray-900">
{searchQuery ? t("Search Results") : t("Featured Products")}
</h2>
{searchQuery && (
<Chip color="warning" variant="flat">
{total} {t("results")}
</Chip>
)}
</div>
</div>
{/* Loading State */}
{loading && (
<div className="flex justify-center items-center py-20">
<Spinner size="lg" color="warning" />
</div>
)}
{/* Products Grid */}
{!loading && (
<>
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6 mb-12">
{services.map((service) => (
<Link
key={service.service_id}
href={`/marketplace/${service.service_id}`}
>
<Card className="group hover:shadow-xl transition-all duration-300 hover:-translate-y-1 border border-gray-200 hover:border-orange-200 h-[200px]">
<CardBody className="p-0">
{/* Product Info */}
<div className="p-4">
<h3 className="font-semibold text-gray-900 mb-2 line-clamp-2 group-hover:text-orange-600 transition-colors">
{service.name}
</h3>
<p className="text-gray-600 text-sm mb-3 line-clamp-2">
{service.short_description ||
service.long_description ||
"No description available"}
</p>
</div>
</CardBody>
<CardFooter>
{/* Price */}
<div className="flex items-center gap-2">
<Price
price={service.price}
charge_type={service.charge_type}
/>
</div>
</CardFooter>
</Card>
</Link>
))}
</div>
{/* Pagination */}
{totalPages > 1 && (
<div className="flex justify-center">
<Pagination
total={totalPages}
page={currentPage}
onChange={onPageChange}
color="warning"
size="lg"
showControls
className="gap-2"
/>
</div>
)}
</>
)}
</div>
<Footer />
</div>
);
};
@@ -0,0 +1,113 @@
"use client";
import React from "react";
import { Button } from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import Link from "next/link";
import { useState } from "react";
import {
Navbar,
NavbarContent,
NavbarMenuToggle,
NavbarMenu,
NavbarMenuItem,
} from "@nextui-org/react";
import { ArrowRightIcon, ShoppingCart } from "lucide-react";
import { DynamicLogo } from "@/shared/components/DynamicLogo";
import { useAuth } from "@/shared/lib/useAuth";
import { NavigationItem } from "@/shared/components/Navigation";
interface NavigationProps {
items?: NavigationItem[];
}
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
const { t } = useTranslation();
const { handleLogin } = useAuth();
const [isMenuOpen, setIsMenuOpen] = useState(false);
return (
<>
{/* Temu Style Navigation */}
<Navbar
onMenuOpenChange={setIsMenuOpen}
maxWidth="full"
className="mt-0 bg-white border-b border-gray-200 shadow-sm fixed top-0 z-50"
height="70px"
isBordered={false}
classNames={{
wrapper: "max-w-7xl mx-auto",
}}
>
<NavbarContent>
<NavbarMenuToggle
aria-label={isMenuOpen ? "Close menu" : "Open menu"}
className="sm:hidden text-gray-700"
/>
<div className="flex justify-start bg-transparent w-max">
<Link href="/">
<DynamicLogo alt="Platform Logo" className="h-[24px]" />
</Link>
</div>
<div className="hidden lg:flex gap-8 justify-center ml-8">
{items?.map((item) => (
<Link
href={item.href}
className="text-gray-700 hover:text-orange-500 font-medium transition-colors"
>
{t(item.label)}
</Link>
))}
</div>
</NavbarContent>
<NavbarContent justify="end" className="items-center gap-2 sm:gap-4">
<div className="hidden sm:flex items-center gap-3">
<Button
className="bg-orange-500 hover:bg-orange-600 text-white font-semibold px-6 h-[40px] transition-all duration-200"
radius="md"
onPress={handleLogin}
>
{t("Sign In")}
</Button>
</div>
<div className="sm:hidden">
<Button
className="bg-orange-500 hover:bg-orange-600 text-white font-semibold"
onPress={handleLogin}
size="sm"
>
{t("Sign In")}
</Button>
</div>
</NavbarContent>
<NavbarMenu className="pt-6 pb-6 bg-white border-r border-gray-200">
<NavbarMenuItem className="mb-4">
<Link
href="/"
className="text-gray-700 hover:text-orange-500 font-medium text-lg"
>
Home
</Link>
</NavbarMenuItem>
<NavbarMenuItem className="mb-4">
<Link
href="/marketplace"
className="text-gray-700 hover:text-orange-500 font-medium text-lg"
>
Marketplace
</Link>
</NavbarMenuItem>
<NavbarMenuItem className="mt-6">
<Button
className="w-full bg-orange-500 hover:bg-orange-600 text-white font-semibold h-[45px]"
radius="md"
onPress={handleLogin}
>
{t("Sign In")}
</Button>
</NavbarMenuItem>
</NavbarMenu>
</Navbar>
</>
);
};