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,34 @@
"use client";
import React from "react";
import { Card, CardBody } from "@nextui-org/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 flex flex-col justify-between">
<div className="bg-gradient-to-b from-gray-800 to-gray-900 text-white">
<Navigation items={navItems} />
</div>
<main className="flex-1 bg-gray-100 mt-20">
<div className="max-w-7xl mx-auto px-6 py-12">
<Card className="border border-gray-200 shadow-md rounded-md">
<CardBody className="p-8">
<AboutContent />
</CardBody>
</Card>
</div>
</main>
<Footer />
</div>
);
};
@@ -0,0 +1,92 @@
import React from "react";
const ClassicDemo: React.FC = () => {
return (
<div className="w-full h-full bg-gray-50 relative overflow-hidden">
{/* Header */}
<div className="bg-slate-800 text-white px-4 py-2">
<div className="flex items-center justify-between">
<div className="flex items-center space-x-2">
<div className="w-6 h-6 bg-red-600 rounded-sm"></div>
<span className="text-sm font-bold">PLATFORM</span>
</div>
<div className="flex space-x-2">
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
<div className="w-1.5 h-1.5 bg-white rounded-sm"></div>
</div>
</div>
</div>
{/* Navigation */}
<div className="bg-gray-100 border-b border-gray-300 px-4 py-1">
<div className="flex space-x-4">
<div className="text-xs text-gray-700 font-medium">Home</div>
<div className="text-xs text-gray-500">Services</div>
<div className="text-xs text-gray-500">About</div>
</div>
</div>
{/* Hero Section */}
<div className="px-4 py-6 bg-white border-b border-gray-200">
<div className="text-center">
<h1 className="text-lg font-bold text-slate-800 mb-1">
Professional Platform
</h1>
<p className="text-xs text-gray-600 mb-3">
Traditional & Reliable Business Solution
</p>
{/* CTA Button */}
<div className="inline-block bg-red-600 text-white text-xs px-4 py-2 rounded-sm shadow-md font-medium">
Learn More
</div>
</div>
</div>
{/* Content Section */}
<div className="px-4 py-4 bg-gray-50">
<div className="grid grid-cols-1 gap-3">
{/* Service Item */}
<div className="bg-white border border-gray-200 rounded-sm p-3 shadow-sm">
<div className="flex items-start space-x-3">
<div className="w-4 h-4 bg-slate-600 rounded-sm mt-0.5"></div>
<div className="flex-1">
<div className="text-xs font-semibold text-slate-800 mb-1">
Business Service
</div>
<div className="text-xs text-gray-600">
Professional solutions for enterprise
</div>
</div>
</div>
</div>
{/* Service Item */}
<div className="bg-white border border-gray-200 rounded-sm p-3 shadow-sm">
<div className="flex items-start space-x-3">
<div className="w-4 h-4 bg-red-600 rounded-sm mt-0.5"></div>
<div className="flex-1">
<div className="text-xs font-semibold text-slate-800 mb-1">
Consulting
</div>
<div className="text-xs text-gray-600">
Expert guidance and support
</div>
</div>
</div>
</div>
</div>
</div>
{/* Footer */}
<div className="absolute bottom-0 left-0 right-0 bg-slate-700 px-4 py-2">
<div className="text-center">
<div className="text-xs text-gray-300">© 2025 Platform</div>
</div>
</div>
</div>
);
};
export default ClassicDemo;
@@ -0,0 +1,259 @@
"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 { ProductOverview } from "@/shared/components/marketplace/ProductOverview";
import { ProductNotFound } from "@/shared/components/marketplace/ProductNotFound";
import { FileText, Wrench, Cog } from "lucide-react";
import { Navigation } from "./Navigation";
import { Footer } from "./Footer";
import Link from "next/link";
import { Price } from "@/shared/components/marketplace/Price";
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 top-0 left-0 right-0 bottom-0 flex flex-col justify-between">
<Navigation items={navItems} />
<div>
{/* Classic Product Header */}
<div className="bg-white border-b border-gray-200 shadow-sm pt-28 pb-6">
<div className="mx-auto p-6 max-w-7xl">
<div className="bg-gray-50 rounded-sm p-6 border border-gray-200">
<Card shadow="none" className="bg-gray-50">
<CardBody>
{/* Breadcrumb */}
<nav className="text-sm text-default-500 flex items-center gap-1 mb-10">
<Link href="/" className="hover:underline">
{t("Home")}
</Link>
<span>/</span>
<b className="text-default-700">{t(product.name)}</b>
</nav>
{/* Header with title and price */}
<div className="flex items-start justify-between mb-4">
<div className="flex-1">
<h1 className="text-3xl font-bold mb-2">
{product.name}
</h1>
{/* Tags */}
{product.tags && product.tags.length > 0 && (
<div className="flex flex-wrap gap-2 my-3">
{product.tags.map((tag, index) => (
<Chip
key={index}
size="sm"
variant="flat"
color="primary"
radius="sm"
className="text-xs h-5"
>
{tag}
</Chip>
))}
</div>
)}
<p className="text-lg mb-4">
{product.short_description ||
t("No description available")}
</p>
</div>
</div>
{/* Price section */}
{product.charge_type && (
<div className="flex gap-2 items-center">
<b className="text-xs">{t("Price")}:</b>
<Price
price={product.price}
charge_type={product.charge_type}
/>
</div>
)}
</CardBody>
</Card>
</div>
</div>
</div>
{/* Main Content */}
<div className="mx-auto p-6 max-w-7xl">
<div className="flex gap-6 mt-6">
{/* Left side - Main content */}
<div className="flex-1">
<Card className="bg-white border border-gray-200 shadow-sm rounded-sm">
<CardBody className="p-0">
<Tabs
selectedKey={activeTab}
onSelectionChange={(key) => setActiveTab(key as string)}
variant="underlined"
color="primary"
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-red-600",
tab: "max-w-fit px-0 h-12",
tabContent:
"group-data-[selected=true]:text-red-600 font-semibold 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 pt-4">
<ProductOverview product={product} />
</div>
</Tab>
<Tab
key="tools"
title={
<div className="flex gap-2 items-center">
<Wrench className="w-4 h-4" />
<span>{t("Tools")}</span>
<Chip
size="sm"
className="h-4 text-xs bg-red-600 text-white rounded-sm"
>
{product.tools.length}
</Chip>
</div>
}
>
<div className="p-6 pt-4">
<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-red-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>
</Tabs>
</CardBody>
</Card>
</div>
{/* Right side - Server Config */}
<div className="min-w-[400px] w-[40%] max-w-100 flex-shrink-0">
<Card className="bg-white border border-gray-200 shadow-sm rounded-sm">
<CardBody>
<div className="flex items-center gap-3 mb-4">
<div className="w-8 h-8 bg-red-600 rounded-sm flex items-center justify-center">
<Cog className="w-5 h-5 text-white" />
</div>
<h3 className="font-semibold text-lg text-gray-900">
{t("Configuration")}
</h3>
</div>
{/* Code Snippet */}
<Card className="w-full max-w-2xl 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>
</CardBody>
</Card>
</div>
</div>
{/* SEO-friendly: Simple text content for search engines */}
<div className="hidden" aria-hidden="true">
<h2>Tools ({product.tools.length})</h2>
{product.tools.length > 0 &&
product.tools.map((tool, index) => (
<div key={`seo-${product.service_id}-tool-${index}`}>
<h4>{tool.name}</h4>
<p>{tool.description || ""}</p>
</div>
))}
</div>
</div>
</div>
<div>
<Footer />
</div>
</div>
);
};
@@ -0,0 +1,32 @@
"use client";
import React from "react";
import { usePlatformConfig } from "@/shared/contexts/PlatformConfigContext";
import Link from "next/link";
interface FooterProps {}
export const Footer: React.FC<FooterProps> = ({}) => {
const { platformConfig } = usePlatformConfig();
return (
<>
{/* Classic Footer */}
<footer className="bg-slate-700 text-white py-1">
<div className="mx-auto px-6 max-w-7xl">
<div className="text-center">
<span className="text-gray-300 text-xs mr-2">
© 2025 {platformConfig?.name}
</span>
<Link
className="text-xs text-primary-500 hover:text-primary-600 transition-colors"
href="https://xpack.ai"
>
Powered By XPack.AI
</Link>
</div>
</div>
</footer>
</>
);
};
@@ -0,0 +1,254 @@
"use client";
import React from "react";
import { Spinner } from "@nextui-org/react";
import { Search, Star, Grid, ArrowRight } from "lucide-react";
import {
Input,
Button,
Pagination,
Card,
CardBody,
CardFooter,
} 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,
searchSuggestions = [],
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 bg-gray-50 top-0 left-0 right-0 bottom-0 flex flex-col justify-between">
<Navigation items={navItems} />
<div>
{/* Classic Hero Section */}
<div className="bg-white border-b border-gray-200 pt-20">
<div className="mx-auto px-6 py-16 max-w-6xl">
<div className="text-center mb-12">
{/* Classic Icon */}
<div className="flex justify-center mb-6">
<div className="w-12 h-12 bg-red-600 rounded-sm flex items-center justify-center">
<Grid className="w-6 h-6 text-white" />
</div>
</div>
{/* Classic Title */}
<h1 className="text-4xl lg:text-5xl font-bold mb-6 text-slate-800">
{t(
platformConfig.headline ||
_DefaultPlatformConfig.headline ||
""
)}
</h1>
{/* Classic Subtitle */}
<p className="text-xl text-gray-600 max-w-3xl mx-auto leading-relaxed">
{t(
platformConfig.subheadline ||
_DefaultPlatformConfig.subheadline ||
""
)}
</p>
</div>
{/* Classic Search Bar */}
<div className="max-w-2xl mx-auto">
<div className="bg-white border border-gray-300 rounded-sm shadow-md overflow-hidden">
<div className="flex">
<div className="flex-1">
<Input
size="lg"
placeholder={
searchSuggestions.length > 0
? t(searchSuggestions[0])
: 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="w-full"
classNames={{
input:
"text-lg text-gray-900 placeholder:text-gray-500",
inputWrapper: "h-14 shadow-none px-4 bg-white border-0",
}}
variant="flat"
radius="none"
/>
</div>
<Button
onPress={onSearch}
className="bg-red-600 text-white hover:bg-red-700 transition-colors duration-200 h-14 px-8 rounded-sm font-medium"
size="lg"
>
{t("Search")}
</Button>
</div>
</div>
</div>
</div>
</div>
{/* Service List Section */}
{loading ? (
<div className="mx-auto h-[200px] flex items-center justify-center">
<div className="bg-white p-8 rounded-lg shadow-md">
<Spinner size="lg" color="primary" />
</div>
</div>
) : (
<div className="bg-gray-50 py-16">
<div className="mx-auto px-6 max-w-7xl">
{/* Services Grid */}
<div className="grid grid-cols-1 md: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 h-[200px] hover:shadow-lg transition-shadow duration-200 cursor-pointer border border-gray-200 bg-white rounded-sm shadow-sm">
<CardBody className="p-4">
{/* Header */}
<div className="flex items-start justify-between mb-3">
<div className="flex items-center gap-2">
<div className="w-8 h-8 bg-slate-600 rounded-sm flex items-center justify-center">
<Star className="w-4 h-4 text-white" />
</div>
<div className="flex-1 min-w-0">
<h3 className="font-semibold text-gray-900 text-base mb-1 truncate group-hover:text-slate-700 transition-colors">
{service.name}
</h3>
</div>
</div>
<ArrowRight className="w-4 h-4 text-gray-400 group-hover:text-slate-600 transition-colors" />
</div>
{/* Description */}
<p className="text-gray-600 text-sm line-clamp-3 leading-relaxed mb-4">
{service.short_description ||
t("No description available")}
</p>
</CardBody>
{/* Footer */}
<CardFooter className="pt-0 px-4 pb-4">
<div className="flex items-center justify-between w-full">
{/* Tools count */}
<div className="flex items-center gap-2">
<div className="w-2 h-2 bg-slate-600 rounded-full"></div>
<span className="text-sm font-medium text-gray-700">
{t("{{count}} Tools", {
count: service.tools.length,
})}
</span>
</div>
{/* Price */}
<div className="flex flex-col items-end">
<Price
price={service.price}
charge_type={service.charge_type}
/>
</div>
</div>
</CardFooter>
</Card>
</Link>
))}
</div>
{/* Classic Pagination */}
{totalPages > 1 && (
<div className="flex justify-center mt-8">
<Pagination
total={totalPages}
page={currentPage}
onChange={onPageChange}
showControls
classNames={{
wrapper:
"gap-0 overflow-visible h-8 border border-gray-300 bg-white shadow-sm rounded-none overflow-hidden",
item: "w-8 h-8 text-small rounded-none bg-transparent text-gray-700 hover:bg-gray-50 rounded-none",
cursor:
"bg-red-600 border-red-600 text-white font-medium rounded-none",
next: "rounded-none",
prev: "rounded-none",
}}
size="sm"
variant="light"
/>
</div>
)}
</div>
</div>
)}
</div>
<div>
<Footer />
</div>
</div>
);
};
@@ -0,0 +1,55 @@
"use client";
import React from "react";
import { Button } from "@nextui-org/react";
import { useTranslation } from "react-i18next";
import { DynamicLogo } from "@/shared/components/DynamicLogo";
import { useAuth } from "@/shared/lib/useAuth";
import Link from "next/link";
import { NavigationItem } from "@/shared/components/Navigation";
interface NavigationProps {
items?: NavigationItem[];
}
export const Navigation: React.FC<NavigationProps> = ({ items }) => {
const { t } = useTranslation();
const { handleLogin } = useAuth();
return (
<div className="fixed top-0 left-0 right-0 z-50">
{/* Classic Header */}
<div className="bg-slate-800 text-white px-4 py-2 ">
<div className="flex items-center justify-between max-w-7xl mx-auto">
<div className="flex items-center space-x-2">
<DynamicLogo alt="Platform Logo" className="h-[20px] text-white" />
</div>
<div className="flex space-x-2">
<Button
color="primary"
className="bg-red-600 hover:bg-red-700 text-white text-sm px-4 py-1 rounded-sm font-medium"
size="sm"
onPress={handleLogin}
>
{t("Get Started")}
</Button>
</div>
</div>
</div>
{/* Classic Navigation */}
<div className="bg-gray-100 border-b border-gray-300 px-4 py-2">
<div className="flex items-center justify-between max-w-7xl mx-auto">
<div className="flex space-x-6">
{items?.map((item) => (
<Link href={item.href} className="text-sm text-gray-500">
{t(item.label)}
</Link>
))}
</div>
</div>
</div>
</div>
);
};