import React, { createContext, useState, useEffect } from "react"; import { useApi } from "hooks/servicesProvider"; interface SetupContextType { currentStep: number; setCurrentStep: (step: number) => void; } const SetupContext = createContext({ currentStep: 1, setCurrentStep: () => {}, }); // 步骤组件的通用属性接口 interface StepProps { onNext: () => void; onPrev?: () => void; } // 通用的步骤容器组件 const StepContainer: React.FC<{ title: string; children: React.ReactNode }> = ({ title, children, }) => (

{title}

{children}
); // 通用的导航按钮组件 const NavigationButtons: React.FC = ({ onNext }) => (
); // 输入框组件 const InputField: React.FC<{ label: string; name: string; defaultValue?: string | number; hint?: string; }> = ({ label, name, defaultValue, hint }) => (

{label}

{hint && (

{hint}

)}
); const Introduction: React.FC = ({ onNext }) => (

欢迎使用 Echoes

); const DatabaseConfig: React.FC = ({ onNext }) => { const [dbType, setDbType] = useState("postgresql"); return (

数据库类型

{dbType === "postgresql" && ( <> )} {dbType === "mysql" && ( <> )} {dbType === "sqllite" && ( <> )}
); }; const AdminConfig: React.FC = ({ onNext }) => (
); const SetupComplete: React.FC = () => (

恭喜!安装已完成,系统即将重启...

); // 修改主题切换按钮组件 const ThemeToggle: React.FC = () => { const [isDark, setIsDark] = useState(false); const [isVisible, setIsVisible] = useState(true); useEffect(() => { const isDarkMode = document.documentElement.classList.contains('dark'); setIsDark(isDarkMode); const handleScroll = () => { const currentScrollPos = window.scrollY; setIsVisible(currentScrollPos < 100); // 滚动超过100px就隐藏 }; window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); }, []); const toggleTheme = () => { const newIsDark = !isDark; setIsDark(newIsDark); document.documentElement.classList.toggle('dark'); }; return ( ); }; export default function SetupPage() { let step = Number(import.meta.env.VITE_INIT_STATUS); const [currentStep, setCurrentStep] = useState(step); return (
{currentStep === 1 && ( setCurrentStep(currentStep + 1)} /> )} {currentStep === 2 && ( setCurrentStep(currentStep + 1)} /> )} {currentStep === 3 && ( setCurrentStep(currentStep + 1)} /> )} {currentStep === 4 && }
); }