mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-09-05 07:36:53 +08:00
feat: normalize adapter types and improve validation in adapters
This commit is contained in:
@@ -21,7 +21,6 @@ export interface AdapterTypeField {
|
||||
|
||||
export interface AdapterTypeMeta {
|
||||
type: string;
|
||||
name: string;
|
||||
config_schema: AdapterTypeField[];
|
||||
}
|
||||
|
||||
|
||||
@@ -525,6 +525,15 @@ export const en = {
|
||||
'Select adapter type': 'Select adapter type',
|
||||
'/ or /drive': '/ or /drive',
|
||||
'Adapter Config': 'Adapter Config',
|
||||
'adapter.type.local': 'Local Filesystem',
|
||||
'adapter.type.webdav': 'WebDAV',
|
||||
'adapter.type.googledrive': 'Google Drive',
|
||||
'adapter.type.onedrive': 'OneDrive',
|
||||
'adapter.type.s3': 'Amazon S3',
|
||||
'adapter.type.ftp': 'FTP',
|
||||
'adapter.type.sftp': 'SFTP',
|
||||
'adapter.type.telegram': 'Telegram',
|
||||
'adapter.type.quark': 'Quark Drive',
|
||||
|
||||
// Tasks
|
||||
'Automation Tasks': 'Automation Tasks',
|
||||
|
||||
@@ -528,6 +528,15 @@ export const zh = {
|
||||
'Select adapter type': '选择适配器类型',
|
||||
'/ or /drive': '/或/drive',
|
||||
'Adapter Config': '适配器配置',
|
||||
'adapter.type.local': '本地文件系统',
|
||||
'adapter.type.webdav': 'WebDAV',
|
||||
'adapter.type.googledrive': 'Google Drive',
|
||||
'adapter.type.onedrive': 'OneDrive',
|
||||
'adapter.type.s3': 'Amazon S3',
|
||||
'adapter.type.ftp': 'FTP',
|
||||
'adapter.type.sftp': 'SFTP',
|
||||
'adapter.type.telegram': 'Telegram',
|
||||
'adapter.type.quark': '夸克网盘',
|
||||
|
||||
// Tasks
|
||||
'Automation Tasks': '自动化任务',
|
||||
|
||||
@@ -130,9 +130,16 @@ const AdaptersPage = memo(function AdaptersPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const renderTypeLabel = useCallback((type?: string) => {
|
||||
if (!type) return '-';
|
||||
const key = `adapter.type.${type}`;
|
||||
const label = t(key);
|
||||
return label === key ? type : label;
|
||||
}, [t]);
|
||||
|
||||
const columns = [
|
||||
{ title: t('Name'), dataIndex: 'name' },
|
||||
{ title: t('Type'), dataIndex: 'type', width: 100 },
|
||||
{ title: t('Type'), dataIndex: 'type', width: 140, render: (value: string) => renderTypeLabel(value) },
|
||||
{ title: t('Mount Path'), dataIndex: 'path', width: 140, render: (v: string) => v || '-' },
|
||||
{ title: t('Sub Path'), dataIndex: 'sub_path', width: 140, render: (v: string) => v || '-' },
|
||||
{
|
||||
@@ -233,9 +240,9 @@ const AdaptersPage = memo(function AdaptersPage() {
|
||||
<Form.Item name="type" label={t('Type')} rules={[{ required: true }]}>
|
||||
<Select
|
||||
placeholder={t('Select adapter type')}
|
||||
options={availableTypes.map(t => ({ value: t.type, label: `${t.name} (${t.type})` }))}
|
||||
onChange={() => {
|
||||
const t = availableTypes.find(v => v.type === form.getFieldValue('type'));
|
||||
options={availableTypes.map(t => ({ value: t.type, label: renderTypeLabel(t.type) }))}
|
||||
onChange={(value) => {
|
||||
const t = availableTypes.find(v => v.type === value);
|
||||
const cfgDefaults: Record<string, any> = {};
|
||||
t?.config_schema.forEach(f => {
|
||||
if (f.default !== undefined) cfgDefaults[f.key] = f.default;
|
||||
|
||||
Reference in New Issue
Block a user