diff --git a/chuan-next/src/app/layout.tsx b/chuan-next/src/app/layout.tsx
index 6aacd9d..6df4d0d 100644
--- a/chuan-next/src/app/layout.tsx
+++ b/chuan-next/src/app/layout.tsx
@@ -25,6 +25,9 @@ export default function RootLayout({
}>) {
return (
+
+
+
diff --git a/chuan-next/src/components/WebRTCSettings.tsx b/chuan-next/src/components/WebRTCSettings.tsx
index 82e07e9..cd6c543 100644
--- a/chuan-next/src/components/WebRTCSettings.tsx
+++ b/chuan-next/src/components/WebRTCSettings.tsx
@@ -251,8 +251,6 @@ interface ServerItemProps {
}
function ServerItem({ server, onRemove, canRemove }: ServerItemProps) {
- const isDefault = server.id.startsWith('google-') || server.id.startsWith('twilio-');
-
return (
@@ -261,8 +259,8 @@ function ServerItem({ server, onRemove, canRemove }: ServerItemProps) {
{server.type?.toUpperCase() || 'STUN'}
- {isDefault && (
-
+ {server.isDefault && (
+
默认
)}
@@ -341,7 +339,8 @@ export default function WebRTCSettings() {
removeIceServer(serverToDelete);
showToast('ICE服务器删除成功', 'success');
} catch (error) {
- showToast('至少需要保留一个ICE服务器', 'error');
+ const errorMessage = error instanceof Error ? error.message : '删除失败';
+ showToast(errorMessage, 'error');
} finally {
setServerToDelete(null);
setShowDeleteDialog(false);
@@ -518,6 +517,13 @@ export default function WebRTCSettings() {
格式:turn:服务器地址:端口
+
+
+
默认服务器:
+
+ 系统预置的可靠ICE服务器,建议保留以确保连接稳定性。可以根据需要删除或添加自定义服务器。
+
+
@@ -537,7 +543,19 @@ export default function WebRTCSettings() {
onClose={cancelDeleteServer}
onConfirm={confirmDeleteServer}
title="删除ICE服务器"
- message={`确定要删除这个ICE服务器吗?删除后将无法恢复。${iceServers.length <= 1 ? '\n\n注意:这是最后一个服务器,删除后将无法建立WebRTC连接。' : ''}`}
+ message={(() => {
+ if (!serverToDelete) return "确定要删除这个ICE服务器吗?";
+
+ const serverToDeleteInfo = iceServers.find(s => s.id === serverToDelete);
+
+ if (iceServers.length <= 1) {
+ return "这是最后一个ICE服务器,删除后将无法建立WebRTC连接。确定要删除吗?";
+ } else if (serverToDeleteInfo?.isDefault) {
+ return "这是一个默认ICE服务器,删除后可能需要手动添加其他服务器。确定要删除吗?";
+ } else {
+ return "确定要删除这个ICE服务器吗?删除后将无法恢复。";
+ }
+ })()}
confirmText="删除"
cancelText="取消"
type="danger"
diff --git a/chuan-next/src/hooks/settings/useIceServersConfig.ts b/chuan-next/src/hooks/settings/useIceServersConfig.ts
index ad14037..671c45a 100644
--- a/chuan-next/src/hooks/settings/useIceServersConfig.ts
+++ b/chuan-next/src/hooks/settings/useIceServersConfig.ts
@@ -7,36 +7,48 @@ export interface IceServerConfig {
credential?: string;
type: 'stun' | 'turn';
enabled: boolean;
+ isDefault?: boolean; // 标记是否为默认服务器
}
const DEFAULT_ICE_SERVERS: IceServerConfig[] = [
+ {
+ id: 'easyvoip-stun',
+ urls: 'stun:stun.easyvoip.com:3478',
+ type: 'stun',
+ enabled: true,
+ isDefault: true,
+ },
+ {
+ id: 'miwifi-stun',
+ urls: 'stun:stun.miwifi.com:3478',
+ type: 'stun',
+ enabled: true,
+ isDefault: true,
+ },
{
id: 'google-stun-1',
urls: 'stun:stun.l.google.com:19302',
type: 'stun',
enabled: true,
+ isDefault: true,
},
{
id: 'google-stun-2',
urls: 'stun:stun1.l.google.com:19302',
type: 'stun',
enabled: true,
- },
- {
- id: 'google-stun-3',
- urls: 'stun:stun2.l.google.com:19302',
- type: 'stun',
- enabled: true,
+ isDefault: true,
},
{
id: 'twilio-stun',
urls: 'stun:global.stun.twilio.com:3478',
type: 'stun',
enabled: true,
- },
+ isDefault: true,
+ }
];
-const STORAGE_KEY = 'webrtc-ice-servers-config';
+const STORAGE_KEY = 'webrtc-ice-servers-config-090901';
export function useIceServersConfig() {
const [iceServers, setIceServers] = useState