feat: add application and file domain input fields; support external link configuration

This commit is contained in:
shiyu
2025-10-09 20:10:15 +08:00
parent 36365d7410
commit 7cf335ab19
3 changed files with 54 additions and 12 deletions

View File

@@ -482,6 +482,7 @@ export const en = {
'Root Directory': 'Root Directory',
'Please input root directory!': 'Please input root directory!',
'e.g., data/ or /var/foxel/data': 'e.g., data/ or /var/foxel/data',
'Optional, used for external links. Leave empty to use the current site.': 'Optional, used for external links. Leave empty to use the current site.',
'Create Admin': 'Create Admin',
'Create admin account': 'Create admin account',
'This is the first account with full permissions': 'This is the first account with full permissions',

View File

@@ -495,6 +495,7 @@ export const zh = {
'Root Directory': '根目录',
'Please input root directory!': '请输入根目录!',
'e.g., data/ or /var/foxel/data': '例如: data/ 或 /var/foxel/data',
'Optional, used for external links. Leave empty to use the current site.': '可选,用于生成外部链接;留空则使用当前站点。',
'Create Admin': '创建管理员',
'Create admin account': '创建管理员账户',
'This is the first account with full permissions': '这是系统的第一个账户,将拥有最高权限。',

View File

@@ -1,7 +1,8 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { Form, Input, Button, Card, message, Steps, Select, Space, Typography } from 'antd';
import { UserOutlined, LockOutlined, HddOutlined } from '@ant-design/icons';
import { adaptersApi } from '../api/adapters';
import { setConfig } from '../api/config';
import { useAuth } from '../contexts/AuthContext';
import { useI18n } from '../i18n';
import LanguageSwitcher from '../components/LanguageSwitcher';
@@ -15,6 +16,14 @@ const SetupPage = () => {
const [form] = Form.useForm();
const { login, register } = useAuth();
const { t } = useI18n();
useEffect(() => {
const origin = window.location.origin;
form.setFieldsValue({
app_domain: origin,
file_domain: origin,
});
}, [form]);
const onFinish = async (values: any) => {
setLoading(true);
try {
@@ -22,17 +31,34 @@ const SetupPage = () => {
await login(values.username, values.password);
message.success(t('Initialization succeeded! Logging you in...'));
setTimeout(async () => {
await adaptersApi.create({
name: values.adapter_name,
type: values.adapter_type,
config: {
root: values.root_dir
},
sub_path: null,
path: values.path,
enabled: true
});
window.location.href = '/';
try {
const tasks: Promise<unknown>[] = [];
const appDomain = values.app_domain?.trim();
const fileDomain = values.file_domain?.trim();
if (appDomain) {
tasks.push(setConfig('APP_DOMAIN', appDomain));
}
if (fileDomain) {
tasks.push(setConfig('FILE_DOMAIN', fileDomain));
}
if (tasks.length) {
await Promise.all(tasks);
}
await adaptersApi.create({
name: values.adapter_name,
type: values.adapter_type,
config: {
root: values.root_dir
},
sub_path: null,
path: values.path,
enabled: true
});
window.location.href = '/';
} catch (configError: any) {
console.error(configError);
message.error(configError.response?.data?.msg || t('Initialization failed, please try later'));
}
}, 2000);
} catch (error: any) {
console.log(error)
@@ -122,6 +148,20 @@ const SetupPage = () => {
>
<Input size="large" placeholder={t('e.g., data/ or /var/foxel/data')} />
</Form.Item>
<Form.Item
label={t('App Domain')}
name="app_domain"
extra={t('Optional, used for external links. Leave empty to use the current site.')}
>
<Input size="large" placeholder="https://your-app-domain.com" />
</Form.Item>
<Form.Item
label={t('File Domain')}
name="file_domain"
extra={t('Optional, used for external links. Leave empty to use the current site.')}
>
<Input size="large" placeholder="https://files.your-domain.com" />
</Form.Item>
</>
)
},