mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-12 01:30:09 +08:00
【调整】SSH地址支持域名形式
【新增】支持自定义监控端口 【新增】通知类型-企业微信 【新增】申请证书(Buypass)、自定义ACME服务器地址 【新增】授权API管理(namesilo、Bunny、Gcore、name.com、京东云)
This commit is contained in:
@@ -14,7 +14,7 @@ import {
|
||||
useLoadingMask,
|
||||
} from '@baota/naive-ui/hooks'
|
||||
import { useError } from '@baota/hooks/error'
|
||||
import { isDomain } from '@baota/utils/business'
|
||||
import { isDomain, isPort, isIp } from '@baota/utils/business'
|
||||
import { $t } from '@locales/index'
|
||||
|
||||
// Store和组件
|
||||
@@ -64,6 +64,31 @@ const {
|
||||
// 错误处理
|
||||
const { handleError } = useError()
|
||||
|
||||
/**
|
||||
* 验证域名(或IP)+端口格式
|
||||
* @param value - 要验证的值
|
||||
* @returns {boolean} 如果是有效的域名、IP地址或它们加端口的格式,则返回 true
|
||||
*/
|
||||
const isDomainWithPort = (value: string): boolean => {
|
||||
if (!value) return false
|
||||
|
||||
// 检查是否包含端口号
|
||||
const parts = value.split(':')
|
||||
|
||||
if (parts.length === 1) {
|
||||
// 只有域名或IP,验证域名或IP地址
|
||||
return isDomain(value) || isIp(value)
|
||||
} else if (parts.length === 2) {
|
||||
// 域名/IP+端口格式
|
||||
const [host, port] = parts
|
||||
if (!host || !port) return false
|
||||
return (isDomain(host) || isIp(host)) && isPort(port)
|
||||
}
|
||||
|
||||
// 超过一个冒号,格式不正确(IPv6除外,但这里暂不处理IPv6+端口的复杂情况)
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控管理业务逻辑控制器
|
||||
* @description 处理监控列表页面的业务逻辑,包括表格展示、添加、编辑、删除等操作
|
||||
@@ -318,7 +343,7 @@ export const useMonitorFormController = (data: UpdateSiteMonitorParams | null =
|
||||
*/
|
||||
const config = computed(() => [
|
||||
useFormInput('名称', 'name'),
|
||||
useFormInput('域名', 'domain'),
|
||||
useFormInput('域名/IP地址', 'domain'),
|
||||
useFormInputNumber('周期(分钟)', 'cycle', { class: 'w-full' }),
|
||||
useFormCustom(() => {
|
||||
return (
|
||||
@@ -342,11 +367,11 @@ export const useMonitorFormController = (data: UpdateSiteMonitorParams | null =
|
||||
name: { required: true, message: '请输入名称', trigger: 'input' },
|
||||
domain: {
|
||||
required: true,
|
||||
message: '请输入正确的域名',
|
||||
message: '请输入正确的域名或IP地址',
|
||||
trigger: 'input',
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
if (!isDomain(value)) {
|
||||
callback(new Error('请输入正确的域名'))
|
||||
if (!isDomainWithPort(value)) {
|
||||
callback(new Error('请输入正确的域名或IP地址(支持域名:端口或IP:端口格式)'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user