diff --git a/backend/src/api/setup.rs b/backend/src/api/setup.rs index f0a0973..5d4028c 100644 --- a/backend/src/api/setup.rs +++ b/backend/src/api/setup.rs @@ -25,13 +25,13 @@ pub struct InstallReplyData { password: String, } -#[post("/install", format = "application/json", data = "")] -pub async fn install( +#[post("/sql", format = "application/json", data = "")] +pub async fn steup_sql( data: Json, state: &State>, ) -> AppResult>> { let mut config = config::Config::read().unwrap_or_default(); - if config.info.install { + if config.init.sql { return Err(status::Custom( Status::BadRequest, "Database already initialized".to_string(), @@ -39,7 +39,7 @@ pub async fn install( } let data = data.into_inner(); let sql = { - config.info.install = true; + config.init.sql = true; config.sql_config = data.sql_config.clone(); sql::Database::initial_setup(data.sql_config.clone()) .await diff --git a/backend/src/common/config.rs b/backend/src/common/config.rs index f75f8eb..b56fe78 100644 --- a/backend/src/common/config.rs +++ b/backend/src/common/config.rs @@ -7,7 +7,7 @@ use std::{env, fs}; pub struct Config { pub address: String, pub port: u32, - pub info: Info, + pub init: Init, pub sql_config: SqlConfig, } @@ -16,23 +16,25 @@ impl Default for Config { Self { address: "0.0.0.0".to_string(), port: 22000, - info: Info::default(), + init: Init::default(), sql_config: SqlConfig::default(), } } } #[derive(Deserialize, Serialize, Debug, Clone)] -pub struct Info { - pub install: bool, - pub non_relational: bool, +pub struct Init { + pub sql: bool, + pub no_sql: bool, + pub administrator: bool, } -impl Default for Info { +impl Default for Init { fn default() -> Self { Self { - install: false, - non_relational: false, + sql: false, + no_sql: false, + administrator: false, } } } diff --git a/frontend/app/env.d.ts b/frontend/app/env.d.ts index 4ecb1e6..ebb1615 100644 --- a/frontend/app/env.d.ts +++ b/frontend/app/env.d.ts @@ -8,9 +8,10 @@ interface ImportMetaEnv { readonly VITE_SERVER_API: string; // 用于访问API的基础URL - readonly VITE_SYSTEM_PORT: number; // 系统端口 - VITE_SYSTEM_USERNAME: string; // 前端账号名称 - VITE_SYSTEM_PASSWORD: string; // 前端账号密码 + readonly VITE_ADDRESS: string; // 前端地址 + readonly VITE_PORT: number; // 前端系统端口 + VITE_USERNAME: string; // 前端账号名称 + VITE_PASSWORD: string; // 前端账号密码 VITE_INIT_STATUS: boolean; // 系统是否进行安装 } diff --git a/frontend/app/index.css b/frontend/app/index.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/frontend/app/index.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/frontend/app/init.tsx b/frontend/app/init.tsx index d3a8ed4..1911606 100644 --- a/frontend/app/init.tsx +++ b/frontend/app/init.tsx @@ -1,3 +1,198 @@ -export default function page(){ - return <>安装中 +import React, { useContext, createContext, useState } from "react"; + +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, onPrev }) => ( +
+ {onPrev && ( + + )} + +
+); + +// 输入框组件 +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, onPrev }) => { + const [dbType, setDbType] = useState("postgresql"); + + return ( + +
+
+

+ 数据库类型 +

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

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

+
+
+); + +export default function SetupPage() { + const [currentStep, setCurrentStep] = useState(1); + + return ( +
+
+
+

+ Echoes +

+
+ + {currentStep === 1 && ( + setCurrentStep(currentStep + 1)} /> + )} + {currentStep === 2 && ( + setCurrentStep(currentStep + 1)} + onPrev={() => setCurrentStep(currentStep - 1)} + /> + )} + {currentStep === 3 && ( + setCurrentStep(currentStep + 1)} + onPrev={() => setCurrentStep(currentStep - 1)} + /> + )} + {currentStep === 4 && } + +
+
+ ); } \ No newline at end of file diff --git a/frontend/app/root.tsx b/frontend/app/root.tsx index 6006375..1e2ff67 100644 --- a/frontend/app/root.tsx +++ b/frontend/app/root.tsx @@ -2,13 +2,13 @@ import { Links, Meta, Outlet, + Scripts, ScrollRestoration, } from "@remix-run/react"; import { BaseProvider } from "hooks/servicesProvider"; -import { LinksFunction } from "@remix-run/react/dist/routeModules"; -import "~/tailwind.css"; +import "~/index.css"; export function Layout({ children }: { children: React.ReactNode }) { return ( @@ -20,19 +20,49 @@ export function Layout({ children }: { children: React.ReactNode }) { - - {children} + + + + +