mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-04-30 01:46:37 +08:00
fix: 修复设置页 IPv6 URL 拼接问题 #241
统一处理 Settings 页面中的主机地址格式,避免 IPv6 场景下 RTSP 地址展示和重启后跳转 URL 因缺少方括号而失效。 Made-with: Cursor
This commit is contained in:
@@ -236,8 +236,16 @@ const rtspLocalConfig = ref<RtspConfigUpdate & { password?: string }>({
|
|||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function formatHostForUrl(hostname: string): string {
|
||||||
|
if (!hostname) return '127.0.0.1'
|
||||||
|
return hostname.includes(':') && !hostname.startsWith('[')
|
||||||
|
? `[${hostname}]`
|
||||||
|
: hostname
|
||||||
|
}
|
||||||
|
|
||||||
const rtspStreamUrl = computed(() => {
|
const rtspStreamUrl = computed(() => {
|
||||||
const host = window.location.hostname || '127.0.0.1'
|
const host = formatHostForUrl(window.location.hostname || '127.0.0.1')
|
||||||
const path = (rtspLocalConfig.value.path || 'live').trim().replace(/^\/+|\/+$/g, '') || 'live'
|
const path = (rtspLocalConfig.value.path || 'live').trim().replace(/^\/+|\/+$/g, '') || 'live'
|
||||||
const port = Number(rtspLocalConfig.value.port) || 8554
|
const port = Number(rtspLocalConfig.value.port) || 8554
|
||||||
return `rtsp://${host}:${port}/${path}`
|
return `rtsp://${host}:${port}/${path}`
|
||||||
@@ -1515,7 +1523,8 @@ async function restartServer() {
|
|||||||
const port = webServerConfig.value.https_enabled
|
const port = webServerConfig.value.https_enabled
|
||||||
? webServerConfig.value.https_port
|
? webServerConfig.value.https_port
|
||||||
: webServerConfig.value.http_port
|
: webServerConfig.value.http_port
|
||||||
const newUrl = `${protocol}://${window.location.hostname}:${port}`
|
const host = formatHostForUrl(window.location.hostname || '127.0.0.1')
|
||||||
|
const newUrl = `${protocol}://${host}:${port}`
|
||||||
window.location.href = newUrl
|
window.location.href = newUrl
|
||||||
}, 3000)
|
}, 3000)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user