mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	优化请求脚本配置交互
This commit is contained in:
		@@ -10,12 +10,12 @@ Vue.component("http-request-scripts-config-box", {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	methods: {
 | 
						methods: {
 | 
				
			||||||
		changeInitScript: function (scriptConfig) {
 | 
							changeInitGroup: function (group) {
 | 
				
			||||||
			this.config.onInitScript = scriptConfig
 | 
								this.config.initGroup = group
 | 
				
			||||||
			this.$forceUpdate()
 | 
								this.$forceUpdate()
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		changeRequestScript: function (scriptConfig) {
 | 
							changeRequestGroup: function (group) {
 | 
				
			||||||
			this.config.onRequestScript = scriptConfig
 | 
								this.config.requestGroup = group
 | 
				
			||||||
			this.$forceUpdate()
 | 
								this.$forceUpdate()
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
@@ -25,12 +25,12 @@ Vue.component("http-request-scripts-config-box", {
 | 
				
			|||||||
	<h4 style="margin-bottom: 0">请求初始化</h4>
 | 
						<h4 style="margin-bottom: 0">请求初始化</h4>
 | 
				
			||||||
	<p class="comment">在请求刚初始化时调用,此时自定义Header等尚未生效。</p>
 | 
						<p class="comment">在请求刚初始化时调用,此时自定义Header等尚未生效。</p>
 | 
				
			||||||
	<div>
 | 
						<div>
 | 
				
			||||||
		<script-config-box id="init-script" :v-script-config="config.onInitScript" comment="在接收到客户端请求之后立即调用。预置req、resp变量。" @change="changeInitScript"></script-config-box>
 | 
							<script-group-config-box :v-group="config.initGroup" @change="changeInitGroup"></script-group-config-box>
 | 
				
			||||||
	</div>
 | 
						</div>
 | 
				
			||||||
	<h4 style="margin-bottom: 0">准备发送请求</h4>
 | 
						<h4 style="margin-bottom: 0">准备发送请求</h4>
 | 
				
			||||||
	<p class="comment">在准备执行请求或者转发请求之前调用,此时自定义Header、源站等已准备好。</p>
 | 
						<p class="comment">在准备执行请求或者转发请求之前调用,此时自定义Header、源站等已准备好。</p>
 | 
				
			||||||
	<div>
 | 
						<div>
 | 
				
			||||||
		<script-config-box id="request-script" :v-script-config="config.onRequestScript" comment="在准备好转发客户端请求之前调用。预置req、resp变量。" @change="changeRequestScript"></script-config-box>
 | 
							<script-group-config-box :v-group="config.requestGroup" @change="changeRequestGroup"></script-group-config-box>
 | 
				
			||||||
	</div>
 | 
						</div>
 | 
				
			||||||
	<div class="margin"></div>
 | 
						<div class="margin"></div>
 | 
				
			||||||
</div>`
 | 
					</div>`
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										38
									
								
								web/public/js/components/server/script-group-config-box.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								web/public/js/components/server/script-group-config-box.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					Vue.component("script-group-config-box", {
 | 
				
			||||||
 | 
						props: ["v-group"],
 | 
				
			||||||
 | 
						data: function () {
 | 
				
			||||||
 | 
							let group = this.vGroup
 | 
				
			||||||
 | 
							if (group == null) {
 | 
				
			||||||
 | 
								group = {
 | 
				
			||||||
 | 
									isPrior: false,
 | 
				
			||||||
 | 
									isOn: true,
 | 
				
			||||||
 | 
									scripts: []
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (group.scripts == null) {
 | 
				
			||||||
 | 
								group.scripts = []
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							let script = null
 | 
				
			||||||
 | 
							if (group.scripts.length > 0) {
 | 
				
			||||||
 | 
								script = group.scripts[group.scripts.length - 1]
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return {
 | 
				
			||||||
 | 
								group: group,
 | 
				
			||||||
 | 
								script: script
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						methods: {
 | 
				
			||||||
 | 
							changeScript: function (script) {
 | 
				
			||||||
 | 
								this.group.scripts = [script] // 目前只支持单个脚本
 | 
				
			||||||
 | 
								this.change()
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							change: function () {
 | 
				
			||||||
 | 
								this.$emit("change", this.group)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
						template: `<div>
 | 
				
			||||||
 | 
							<script-config-box :v-script-config="script" comment="在接收到客户端请求之后立即调用。预置req、resp变量。" @change="changeScript"></script-config-box>
 | 
				
			||||||
 | 
					</div>`
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
		Reference in New Issue
	
	Block a user