diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json
index 9b0e73e0..c8e3f484 100644
--- a/web/src/i18n/locales/en.json
+++ b/web/src/i18n/locales/en.json
@@ -1439,12 +1439,6 @@
"对外运营模式": "Default mode",
"密码长度至少为8个字符": "Password must be at least 8 characters long",
"表单引用错误,请刷新页面重试": "Form reference error, please refresh the page and try again",
- "默认模式,适用于为多个用户提供服务的场景。": "Default mode, suitable for scenarios where multiple users are provided.",
- "此模式下,系统将计算每次调用的用量,您需要对每个模型都设置价格,如果没有设置价格,用户将无法使用该模型。": "In this mode, the system will calculate the usage of each call, you need to set the price for each model, if the price is not set, the user will not be able to use the model.",
- "适用于个人使用的场景。": "Suitable for personal use.",
- "不需要设置模型价格,系统将弱化用量计算,您可专注于使用模型。": "No need to set the model price, the system will weaken the usage calculation, you can focus on using the model.",
- "适用于展示系统功能的场景。": "Suitable for scenarios where the system functions are displayed.",
- "可在初始化后修改": "Can be modified after initialization",
"初始化系统": "Initialize system",
"支持众多的大模型供应商": "Supporting various LLM providers",
"统一的大模型接口网关": "The Unified LLMs API Gateway",
@@ -1602,21 +1596,20 @@
"暂无公告": "No Notice",
"操练场": "Playground",
"欢迎使用,请完成以下设置以开始使用系统": "Welcome to use, please complete the following settings to start using the system",
+ "数据库检查": "Database Check",
+ "验证数据库连接状态": "Verify database connection status",
+ "设置管理员登录信息": "Set administrator login information",
+ "选择系统运行模式": "Select system running mode",
+ "完成初始化": "Complete initialization",
+ "确认设置并完成初始化": "Confirm settings and complete initialization",
"数据库信息": "Database Information",
+ "请填写完整的管理员账号信息": "Please fill in the complete administrator account information",
+ "准备完成初始化": "Ready to complete initialization",
+ "请确认以下设置信息,点击\"初始化系统\"开始配置": "Please confirm the following settings information, click \"Initialize system\" to start configuration",
+ "数据库类型": "Database Type",
"您正在使用 MySQL 数据库。MySQL 是一个可靠的关系型数据库管理系统,适合生产环境使用。": "You are using the MySQL database. MySQL is a reliable relational database management system, suitable for production environments.",
"您正在使用 PostgreSQL 数据库。PostgreSQL 是一个功能强大的开源关系型数据库系统,提供了出色的可靠性和数据完整性,适合生产环境使用。": "You are using the PostgreSQL database. PostgreSQL is a powerful open-source relational database system that provides excellent reliability and data integrity, suitable for production environments.",
- "设置系统管理员的登录信息": "Set the login information for the system administrator",
"选择适合您使用场景的模式": "Select the mode suitable for your usage scenario",
- "使用模式说明": "Usage mode description",
- "计费模式": "Billing mode",
- "多用户支持": "Multi-user support",
- "个人使用": "Personal use",
- "功能演示": "Function demonstration",
- "体验试用": "Experience trial",
- "默认模式": "Default Mode",
- "无需计费": "No Charge",
- "演示体验": "Demo Experience",
- "提供基础功能演示,方便用户了解系统特性。": "Provide basic feature demonstrations to help users understand the system features.",
"适用于为多个用户提供服务的场景": "Suitable for scenarios where multiple users are provided.",
"适用于个人使用的场景,不需要设置模型价格": "Suitable for personal use, no need to set model price.",
"适用于展示系统功能的场景,提供基础功能演示": "Suitable for scenarios where the system functions are displayed, providing basic feature demonstrations.",
diff --git a/web/src/index.css b/web/src/index.css
index 53c79511..964beb02 100644
--- a/web/src/index.css
+++ b/web/src/index.css
@@ -52,7 +52,7 @@ code {
}
/* ==================== 导航和侧边栏样式 ==================== */
-/* 导航项样式 */
+.semi-radio,
.semi-tagInput,
.semi-input-textarea-wrapper,
.semi-navigation-sub-title,
diff --git a/web/src/pages/Setup/index.js b/web/src/pages/Setup/index.js
index 8d72a473..8e2f5cb6 100644
--- a/web/src/pages/Setup/index.js
+++ b/web/src/pages/Setup/index.js
@@ -17,581 +17,15 @@ along with this program. If not, see
.
For commercial licensing, please contact support@quantumnous.com
*/
-import React, { useEffect, useState, useRef } from 'react';
-import {
- Card,
- Form,
- Button,
- Typography,
- Modal,
- Banner,
- Layout,
- Tag,
-} from '@douyinfe/semi-ui';
-import { API, showError, showNotice } from '../../helpers';
-import { useTranslation } from 'react-i18next';
-import {
- IconHelpCircle,
- IconInfoCircle,
- IconUser,
- IconLock,
- IconSetting,
- IconCheckCircleStroked,
-} from '@douyinfe/semi-icons';
-import { Shield, Rocket, FlaskConical, Database, Layers } from 'lucide-react';
+import React from 'react';
+import { SetupWizard } from '../../components/setup';
+/**
+ * Setup页面组件
+ * 使用新的组件化结构进行系统初始化
+ */
const Setup = () => {
- const { t } = useTranslation();
- const [loading, setLoading] = useState(false);
- const [selfUseModeInfoVisible, setUsageModeInfoVisible] = useState(false);
- const [setupStatus, setSetupStatus] = useState({
- status: false,
- root_init: false,
- database_type: '',
- });
- const { Text, Title } = Typography;
- const formRef = useRef(null);
-
- const [formData, setFormData] = useState({
- username: '',
- password: '',
- confirmPassword: '',
- usageMode: 'external',
- });
-
- useEffect(() => {
- fetchSetupStatus();
- }, []);
-
- const fetchSetupStatus = async () => {
- try {
- const res = await API.get('/api/setup');
- const { success, data } = res.data;
- if (success) {
- setSetupStatus(data);
-
- // If setup is already completed, redirect to home
- if (data.status) {
- window.location.href = '/';
- }
- } else {
- showError(t('获取初始化状态失败'));
- }
- } catch (error) {
- console.error('Failed to fetch setup status:', error);
- showError(t('获取初始化状态失败'));
- }
- };
-
- const handleUsageModeChange = (val) => {
- setFormData({ ...formData, usageMode: val });
- };
-
- const onSubmit = () => {
- if (!formRef.current) {
- console.error('Form reference is null');
- showError(t('表单引用错误,请刷新页面重试'));
- return;
- }
-
- const values = formRef.current.getValues();
- console.log('Form values:', values);
-
- // For root_init=false, validate admin username and password
- if (!setupStatus.root_init) {
- if (!values.username || !values.username.trim()) {
- showError(t('请输入管理员用户名'));
- return;
- }
-
- if (!values.password || values.password.length < 8) {
- showError(t('密码长度至少为8个字符'));
- return;
- }
-
- if (values.password !== values.confirmPassword) {
- showError(t('两次输入的密码不一致'));
- return;
- }
- }
-
- // Prepare submission data
- const formValues = { ...values };
- formValues.SelfUseModeEnabled = values.usageMode === 'self';
- formValues.DemoSiteEnabled = values.usageMode === 'demo';
-
- // Remove usageMode as it's not needed by the backend
- delete formValues.usageMode;
-
- console.log('Submitting data to backend:', formValues);
- setLoading(true);
-
- // Submit to backend
- API.post('/api/setup', formValues)
- .then((res) => {
- const { success, message } = res.data;
- console.log('API response:', res.data);
-
- if (success) {
- showNotice(t('系统初始化成功,正在跳转...'));
- setTimeout(() => {
- window.location.reload();
- }, 1500);
- } else {
- showError(message || t('初始化失败,请重试'));
- }
- })
- .catch((error) => {
- console.error('API error:', error);
- showError(t('系统初始化失败,请重试'));
- setLoading(false);
- })
- .finally(() => {
- // setLoading(false);
- });
- };
-
- return (
-
-
-
-
-
- {/* 主卡片容器 */}
-
- {/* 顶部装饰性区域 */}
-
- {/* 装饰性背景元素 */}
-
-
-
-
-
-
-
-
- {t('系统初始化')}
-
-
- {t('欢迎使用,请完成以下设置以开始使用系统')}
-
-
-
- {/* 数据库警告 */}
- {setupStatus.database_type === 'sqlite' && (
-
-
-
-
- }
- closeIcon={null}
- title={
-
- {t('数据库警告')}
-
- SQLite
-
-
- }
- description={
-
-
- {t(
- '您正在使用 SQLite 数据库。如果您在容器环境中运行,请确保已正确设置数据库文件的持久化映射,否则容器重启后所有数据将丢失!',
- )}
-
-
- {t(
- '建议在生产环境中使用 MySQL 或 PostgreSQL 数据库,或确保 SQLite 数据库文件已映射到宿主机的持久化存储。',
- )}
-
-
- }
- className="!rounded-xl mb-6"
- fullMode={false}
- bordered
- />
-
- )}
- {/* MySQL数据库提示 */}
- {setupStatus.database_type === 'mysql' && (
-
-
-
-
- }
- closeIcon={null}
- title={
-
- {t('数据库信息')}
-
- MySQL
-
-
- }
- description={
-
-
- {t(
- '您正在使用 MySQL 数据库。MySQL 是一个可靠的关系型数据库管理系统,适合生产环境使用。',
- )}
-
-
- }
- className="!rounded-xl mb-6"
- fullMode={false}
- bordered
- />
-
- )}
- {/* PostgreSQL数据库提示 */}
- {setupStatus.database_type === 'postgres' && (
-
-
-
-
- }
- closeIcon={null}
- title={
-
- {t('数据库信息')}
-
- PostgreSQL
-
-
- }
- description={
-
-
- {t(
- '您正在使用 PostgreSQL 数据库。PostgreSQL 是一个功能强大的开源关系型数据库系统,提供了出色的可靠性和数据完整性,适合生产环境使用。',
- )}
-
-
- }
- className="!rounded-xl mb-6"
- fullMode={false}
- bordered
- />
-
- )}
-
-
- {/* 主内容区域 */}
-
- }
- closeIcon={null}
- description={
-
- }
- className="!rounded-lg"
- />
- >
- ) : (
- <>
-
}
- showClear
- size='large'
- className="mb-4 !rounded-lg"
- noLabel={false}
- validateStatus="default"
- onChange={(value) =>
- setFormData({ ...formData, username: value })
- }
- />
-
}
- showClear
- size='large'
- className="mb-4 !rounded-lg"
- noLabel={false}
- mode="password"
- validateStatus="default"
- onChange={(value) =>
- setFormData({ ...formData, password: value })
- }
- />
-
}
- showClear
- size='large'
- className="!rounded-lg"
- noLabel={false}
- mode="password"
- validateStatus="default"
- onChange={(value) =>
- setFormData({ ...formData, confirmPassword: value })
- }
- />
- >
- )}
-
-
- {/* 使用模式 */}
-