diff --git a/index.html b/index.html
index b444482..5f7834f 100644
--- a/index.html
+++ b/index.html
@@ -223,7 +223,7 @@
}
.MuiTypography-h6 {
- font-size: 1.1rem !important;
+ font-size: 1.1rem !重要;
}
/* 表单样式 */
@@ -405,6 +405,27 @@
);
});
+ // 在 App 组件外部添加地址格式化函数
+ const formatApiUrl = (url) => {
+ if (!url) return '';
+
+ // 移除末尾的斜杠
+ url = url.replace(/\/+$/, '');
+
+ // 如果不包含协议,添加 http://
+ if (!/^https?:\/\//i.test(url)) {
+ url = 'http://' + url;
+ }
+
+ try {
+ // 使用 URL API 解析和规范化地址
+ const urlObj = new URL(url);
+ return urlObj.toString().replace(/\/+$/, '');
+ } catch (e) {
+ return url;
+ }
+ };
+
function App() {
const [tabValue, setTabValue] = React.useState(0);
const [qrInput, setQrInput] = React.useState('');
@@ -431,7 +452,7 @@
...JSON.parse(localStorage.getItem('customBackends') || '[]')
]);
const [isDialogOpen, setIsDialogOpen] = React.useState(false);
- const [newBackend, setNewBackend] = React.useState({ label: '', value: '' });
+ const [newBackend, setNewBackend] = React.useState({ label: '', value: '', formattedUrl: '' });
const [snackbarOpen, setSnackbarOpen] = React.useState(false);
const [snackbarMessage, setSnackbarMessage] = React.useState('');
const [menuAnchorEl, setMenuAnchorEl] = React.useState(null);
@@ -554,7 +575,7 @@
const handleDialogClose = () => {
setIsDialogOpen(false);
- setNewBackend({ label: '', value: '' });
+ setNewBackend({ label: '', value: '', formattedUrl: '' });
};
const handleSaveBackend = () => {
@@ -610,6 +631,12 @@
handleMenuClose();
};
+ const handleNewBackendChange = (e) => {
+ const value = e.target.value;
+ const formattedUrl = formatApiUrl(value);
+ setNewBackend(prev => ({...prev, value: value, formattedUrl: formattedUrl}));
+ };
+
// 加载表单配置
const [formConfigs, setFormConfigs] = React.useState(null);
@@ -759,6 +786,7 @@
))}
+
+
+
+ {/* 新增认证提示区域 */}
+