mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
支持路由定义请求脚本
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package locationutils
|
||||
|
||||
import (
|
||||
teaconst "github.com/TeaOSLab/EdgeAdmin/internal/const"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
@@ -161,6 +162,18 @@ func (this *LocationHelper) createMenus(serverIdString string, locationIdString
|
||||
"isOn": locationConfig != nil && locationConfig.Web != nil && locationConfig.Web.FastcgiRef != nil && locationConfig.Web.FastcgiRef.IsPrior,
|
||||
})
|
||||
|
||||
if teaconst.IsPlus {
|
||||
if locationConfig.Web != nil && locationConfig.Web.RequestScripts != nil {
|
||||
_ = locationConfig.Web.RequestScripts.Init()
|
||||
}
|
||||
menuItems = append(menuItems, maps.Map{
|
||||
"name": "边缘脚本",
|
||||
"url": "/servers/server/settings/locations/requestScripts?serverId=" + serverIdString + "&locationId=" + locationIdString,
|
||||
"isActive": secondMenuItem == "requestScripts",
|
||||
"isOn": locationConfig.Web != nil && locationConfig.Web.RequestScripts != nil && !locationConfig.Web.RequestScripts.IsEmpty(),
|
||||
})
|
||||
}
|
||||
|
||||
menuItems = append(menuItems, maps.Map{
|
||||
"name": "-",
|
||||
"url": "",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Vue.component("http-request-scripts-config-box", {
|
||||
props: ["vRequestScriptsConfig"],
|
||||
props: ["vRequestScriptsConfig", "v-is-location"],
|
||||
data: function () {
|
||||
let config = this.vRequestScriptsConfig
|
||||
if (config == null) {
|
||||
@@ -25,12 +25,12 @@ Vue.component("http-request-scripts-config-box", {
|
||||
<h4 style="margin-bottom: 0">请求初始化</h4>
|
||||
<p class="comment">在请求刚初始化时调用,此时自定义Header等尚未生效。</p>
|
||||
<div>
|
||||
<script-group-config-box :v-group="config.initGroup" @change="changeInitGroup"></script-group-config-box>
|
||||
<script-group-config-box :v-group="config.initGroup" @change="changeInitGroup" :v-is-location="vIsLocation"></script-group-config-box>
|
||||
</div>
|
||||
<h4 style="margin-bottom: 0">准备发送请求</h4>
|
||||
<p class="comment">在准备执行请求或者转发请求之前调用,此时自定义Header、源站等已准备好。</p>
|
||||
<div>
|
||||
<script-group-config-box :v-group="config.requestGroup" @change="changeRequestGroup"></script-group-config-box>
|
||||
<script-group-config-box :v-group="config.requestGroup" @change="changeRequestGroup" :v-is-location="vIsLocation"></script-group-config-box>
|
||||
</div>
|
||||
<div class="margin"></div>
|
||||
</div>`
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Vue.component("script-group-config-box", {
|
||||
props: ["v-group"],
|
||||
props: ["v-group", "v-is-location"],
|
||||
data: function () {
|
||||
let group = this.vGroup
|
||||
if (group == null) {
|
||||
@@ -33,6 +33,11 @@ Vue.component("script-group-config-box", {
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<script-config-box :v-script-config="script" comment="在接收到客户端请求之后立即调用。预置req、resp变量。" @change="changeScript"></script-config-box>
|
||||
<table class="ui table definition selectable">
|
||||
<prior-checkbox :v-config="group" v-if="vIsLocation"></prior-checkbox>
|
||||
</table>
|
||||
<div :style="{opacity: (!vIsLocation || group.isPrior) ? 1 : 0.5}">
|
||||
<script-config-box :v-script-config="script" comment="在接收到客户端请求之后立即调用。预置req、resp变量。" @change="changeScript" :v-is-location="vIsLocation"></script-config-box>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
Reference in New Issue
Block a user