mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
✨ 优化忽略规则配置和 Agent 获取 IP
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 9.6 KiB |
@@ -41,61 +41,53 @@ function showFormModal(modelSelector, formID, URL, getData) {
|
||||
const data = getData
|
||||
? getData()
|
||||
: $(formID)
|
||||
.serializeArray()
|
||||
.reduce(function (obj, item) {
|
||||
// ID 类的数据
|
||||
if (
|
||||
item.name.endsWith("_id") ||
|
||||
item.name === "id" ||
|
||||
item.name === "ID" ||
|
||||
item.name === "RequestType" ||
|
||||
item.name === "RequestMethod" ||
|
||||
item.name === "DisplayIndex" ||
|
||||
item.name === "Type"
|
||||
) {
|
||||
obj[item.name] = parseInt(item.value);
|
||||
} else {
|
||||
obj[item.name] = item.value;
|
||||
}
|
||||
.serializeArray()
|
||||
.reduce(function (obj, item) {
|
||||
// ID 类的数据
|
||||
if (
|
||||
item.name.endsWith("_id") ||
|
||||
item.name === "id" ||
|
||||
item.name === "ID" ||
|
||||
item.name === "RequestType" ||
|
||||
item.name === "RequestMethod" ||
|
||||
item.name === "DisplayIndex" ||
|
||||
item.name === "Type" ||
|
||||
item.name === "Cover"
|
||||
) {
|
||||
obj[item.name] = parseInt(item.value);
|
||||
} else {
|
||||
obj[item.name] = item.value;
|
||||
}
|
||||
|
||||
if (item.name.endsWith("ServersRaw")) {
|
||||
if (item.value.length > 2) {
|
||||
obj[item.name] = JSON.stringify(
|
||||
[...item.value.matchAll(/\d+/gm)].map((k) =>
|
||||
parseInt(k[0])
|
||||
)
|
||||
);
|
||||
}
|
||||
if (item.name.endsWith("ServersRaw")) {
|
||||
if (item.value.length > 2) {
|
||||
obj[item.name] = JSON.stringify(
|
||||
[...item.value.matchAll(/\d+/gm)].map((k) =>
|
||||
parseInt(k[0])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}, {});
|
||||
return obj;
|
||||
}, {});
|
||||
$.post(URL, JSON.stringify(data))
|
||||
.done(function (resp) {
|
||||
if (resp.code == 200) {
|
||||
if (resp.message) {
|
||||
$.suiAlert({
|
||||
title: "操作成功",
|
||||
type: "success",
|
||||
description: resp.message,
|
||||
time: "3",
|
||||
position: "top-center",
|
||||
});
|
||||
}
|
||||
window.location.reload();
|
||||
window.location.reload()
|
||||
} else {
|
||||
form.append(
|
||||
`<div class="ui negative message"><div class="header">操作失败</div><p>` +
|
||||
resp.message +
|
||||
`</p></div>`
|
||||
resp.message +
|
||||
`</p></div>`
|
||||
);
|
||||
}
|
||||
})
|
||||
.fail(function (err) {
|
||||
form.append(
|
||||
`<div class="ui negative message"><div class="header">网络错误</div><p>` +
|
||||
err.responseText +
|
||||
`</p></div>`
|
||||
err.responseText +
|
||||
`</p></div>`
|
||||
);
|
||||
})
|
||||
.always(function () {
|
||||
@@ -197,6 +189,7 @@ function addOrEditMonitor(monitor) {
|
||||
modal.find("input[name=Name]").val(monitor ? monitor.Name : null);
|
||||
modal.find("input[name=Target]").val(monitor ? monitor.Target : null);
|
||||
modal.find("select[name=Type]").val(monitor ? monitor.Type : 1);
|
||||
modal.find("select[name=Cover]").val(monitor ? monitor.Cover : 0);
|
||||
if (monitor && monitor.Notify) {
|
||||
modal.find(".ui.nb-notify.checkbox").checkbox("set checked");
|
||||
} else {
|
||||
@@ -210,10 +203,10 @@ function addOrEditMonitor(monitor) {
|
||||
for (let i = 0; i < serverList.length; i++) {
|
||||
node.after(
|
||||
'<a class="ui label transition visible" data-value="' +
|
||||
serverList[i] +
|
||||
'" style="display: inline-block !important;">ID:' +
|
||||
serverList[i] +
|
||||
'<i class="delete icon"></i></a>'
|
||||
serverList[i] +
|
||||
'" style="display: inline-block !important;">ID:' +
|
||||
serverList[i] +
|
||||
'<i class="delete icon"></i></a>'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -245,10 +238,10 @@ function addOrEditCron(cron) {
|
||||
for (let i = 0; i < serverList.length; i++) {
|
||||
node.after(
|
||||
'<a class="ui label transition visible" data-value="' +
|
||||
serverList[i] +
|
||||
'" style="display: inline-block !important;">ID:' +
|
||||
serverList[i] +
|
||||
'<i class="delete icon"></i></a>'
|
||||
serverList[i] +
|
||||
'" style="display: inline-block !important;">ID:' +
|
||||
serverList[i] +
|
||||
'<i class="delete icon"></i></a>'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -367,5 +360,5 @@ $(document).ready(() => {
|
||||
cache: false,
|
||||
},
|
||||
});
|
||||
} catch (error) {}
|
||||
} catch (error) { }
|
||||
});
|
||||
|
||||
12
resource/template/component/cron.html
vendored
12
resource/template/component/cron.html
vendored
@@ -17,7 +17,14 @@
|
||||
<textarea name="Command"></textarea>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>执行服务器列表</label>
|
||||
<label>覆盖范围</label>
|
||||
<select name="Cover" class="ui fluid dropdown">
|
||||
<option value="0">忽略所有,仅通过指定服务器执行</option>
|
||||
<option value="1">覆盖所有,仅指定服务器不执行</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>指定服务器</label>
|
||||
<div class="ui fluid multiple servers search selection dropdown">
|
||||
<input type="hidden" name="ServersRaw">
|
||||
<i class="dropdown icon"></i>
|
||||
@@ -37,7 +44,8 @@
|
||||
计划的格式为:<code>* * * * *</code> 分 时 天 月 星期,详情见 <a
|
||||
href="https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format"
|
||||
target="_blank">计划表达式格式</a><br>
|
||||
命令:就像写 shell/bat 脚本一样,但是不推荐换行,多个命令使用 <code>&&</code>/<code>&</code> 连接,如果遇到 xxx 命令找不到,可能是 <code>PATH</code> 环境变量的问题,<code>Linux</code> 主机在命令开头加入
|
||||
命令:就像写 shell/bat 脚本一样,但是不推荐换行,多个命令使用 <code>&&</code>/<code>&</code> 连接,如果遇到 xxx 命令找不到,可能是
|
||||
<code>PATH</code> 环境变量的问题,<code>Linux</code> 主机在命令开头加入
|
||||
<code>source ~/.bashrc</code>或者使用绝对路径执行。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
9
resource/template/component/monitor.html
vendored
9
resource/template/component/monitor.html
vendored
@@ -25,7 +25,14 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>不通过下列服务器请求</label>
|
||||
<label>覆盖范围</label>
|
||||
<select name="Cover" class="ui fluid dropdown">
|
||||
<option value="0">覆盖所有,仅忽略指定服务器</option>
|
||||
<option value="1">忽略所有,仅通过指定服务器请求</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>指定服务器</label>
|
||||
<div class="ui fluid multiple servers search selection dropdown">
|
||||
<input type="hidden" name="SkipServersRaw" />
|
||||
<i class="dropdown icon"></i>
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
<th>计划</th>
|
||||
<th>命令</th>
|
||||
<th>成功推送</th>
|
||||
<th>执行者</th>
|
||||
<th>覆盖范围</th>
|
||||
<th>排除服务器</th>
|
||||
<th>最后执行</th>
|
||||
<th>最后结果</th>
|
||||
<th>管理</th>
|
||||
@@ -32,6 +33,7 @@
|
||||
<td>{{$cron.Scheduler}}</td>
|
||||
<td>{{$cron.Command}}</td>
|
||||
<td>{{$cron.PushSuccessful}}</td>
|
||||
<td>{{if eq $cron.Cover 0}}忽略所有{{else}}覆盖所有{{end}}</td>
|
||||
<td>{{$cron.ServersRaw}}</td>
|
||||
<td>{{$cron.LastExecutedAt|tf}}</td>
|
||||
<td>{{$cron.LastResult}}</td>
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
<div class="ui container">
|
||||
<div class="ui grid">
|
||||
<div class="right floated right aligned twelve wide column">
|
||||
<button
|
||||
class="ui right labeled positive icon button"
|
||||
onclick="addOrEditMonitor()"
|
||||
>
|
||||
<button class="ui right labeled positive icon button" onclick="addOrEditMonitor()">
|
||||
<i class="add icon"></i> 添加监控
|
||||
</button>
|
||||
</div>
|
||||
@@ -18,7 +15,8 @@
|
||||
<th>ID</th>
|
||||
<th>名称</th>
|
||||
<th>目标</th>
|
||||
<th>跳过的服务器</th>
|
||||
<th>覆盖范围</th>
|
||||
<th>排除服务器</th>
|
||||
<th>类型</th>
|
||||
<th>通知</th>
|
||||
<th>管理</th>
|
||||
@@ -30,6 +28,7 @@
|
||||
<td>{{$monitor.ID}}</td>
|
||||
<td>{{$monitor.Name}}</td>
|
||||
<td>{{$monitor.Target}}</td>
|
||||
<td>{{if eq $monitor.Cover 0}}覆盖所有{{else}}忽略所有{{end}}</td>
|
||||
<td>{{$monitor.SkipServersRaw}}</td>
|
||||
<td>
|
||||
{{if eq $monitor.Type 1}}HTTP(S)/SSL证书 {{else if eq $monitor.Type
|
||||
@@ -38,16 +37,11 @@
|
||||
<td>{{$monitor.Notify}}</td>
|
||||
<td>
|
||||
<div class="ui mini icon buttons">
|
||||
<button
|
||||
class="ui button"
|
||||
onclick="addOrEditMonitor({{$monitor}})"
|
||||
>
|
||||
<button class="ui button" onclick="addOrEditMonitor({{$monitor}})">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button
|
||||
class="ui button"
|
||||
onclick="showConfirm('删除监控','确认删除此监控?',deleteRequest,'/api/monitor/'+{{$monitor.ID}})"
|
||||
>
|
||||
<button class="ui button"
|
||||
onclick="showConfirm('删除监控','确认删除此监控?',deleteRequest,'/api/monitor/'+{{$monitor.ID}})">
|
||||
<i class="trash alternate outline icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -62,4 +56,4 @@
|
||||
<script>
|
||||
$(".checkbox").checkbox();
|
||||
</script>
|
||||
{{end}}
|
||||
{{end}}
|
||||
@@ -17,6 +17,7 @@
|
||||
<th>名称</th>
|
||||
<th>分组</th>
|
||||
<th>IP</th>
|
||||
<th>版本号</th>
|
||||
<th>密钥</th>
|
||||
<th>备注</th>
|
||||
<th>管理</th>
|
||||
@@ -29,6 +30,7 @@
|
||||
<td>{{$server.Name}}</td>
|
||||
<td>{{$server.Tag}}</td>
|
||||
<td>{{$server.Host.IP}}</td>
|
||||
<td>{{$server.Host.Version}}</td>
|
||||
<td>{{$server.Secret}}</td>
|
||||
<td style="word-break: break-word;">{{$server.Note}}</td>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user