fix: 在官网跳转按钮的禁用及触发判断中增加对 base_url 是否以 http:// 或 https:// 开头的严格校验
This commit is contained in:
@@ -94,7 +94,7 @@
|
|||||||
<el-table-column label="操作" width="320">
|
<el-table-column label="操作" width="320">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div class="action-row">
|
<div class="action-row">
|
||||||
<el-button size="small" text :disabled="!row.base_url" @click="openOfficialSite(row)" title="在新标签页中打开上游官网">官网</el-button>
|
<el-button size="small" text :disabled="!isValidHttpUrl(row.base_url)" @click="openOfficialSite(row)" title="在新标签页中打开上游官网">官网</el-button>
|
||||||
<el-button size="small" text @click="openEdit(row)" title="编辑上游配置(认证、接口、余额等)">编辑</el-button>
|
<el-button size="small" text @click="openEdit(row)" title="编辑上游配置(认证、接口、余额等)">编辑</el-button>
|
||||||
<el-button size="small" text @click="testUpstream(row)" :loading="row._testing" title="仅验证连通性:登录 + 拉取分组列表,不写快照、不触发通知">测试连接</el-button>
|
<el-button size="small" text @click="testUpstream(row)" :loading="row._testing" title="仅验证连通性:登录 + 拉取分组列表,不写快照、不触发通知">测试连接</el-button>
|
||||||
<el-button size="small" text @click="checkNow(row)" :loading="row._checking" title="完整同步:拉取倍率 → 生成快照 → 对比变化 → 触发 Webhook → 同步 Key">立即同步</el-button>
|
<el-button size="small" text @click="checkNow(row)" :loading="row._checking" title="完整同步:拉取倍率 → 生成快照 → 对比变化 → 触发 Webhook → 同步 Key">立即同步</el-button>
|
||||||
@@ -978,8 +978,13 @@ function openCreate() {
|
|||||||
drawerVisible.value = true
|
drawerVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidHttpUrl(url: string | null | undefined): boolean {
|
||||||
|
if (!url) return false
|
||||||
|
return url.startsWith('http://') || url.startsWith('https://')
|
||||||
|
}
|
||||||
|
|
||||||
function openOfficialSite(row: UpstreamData) {
|
function openOfficialSite(row: UpstreamData) {
|
||||||
if (!row.base_url) return
|
if (!isValidHttpUrl(row.base_url)) return
|
||||||
window.open(row.base_url, '_blank', 'noopener,noreferrer')
|
window.open(row.base_url, '_blank', 'noopener,noreferrer')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user