mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 21:50:28 +08:00 
			
		
		
		
	优化请求脚本相关代码
This commit is contained in:
		@@ -1,12 +1,34 @@
 | 
				
			|||||||
Vue.component("script-config-box", {
 | 
					Vue.component("script-config-box", {
 | 
				
			||||||
	props: ["id", "v-script-config", "comment"],
 | 
						props: ["id", "v-script-config", "comment", "v-auditing-status"],
 | 
				
			||||||
 | 
						mounted: function () {
 | 
				
			||||||
 | 
							let that = this
 | 
				
			||||||
 | 
							setTimeout(function () {
 | 
				
			||||||
 | 
								that.$forceUpdate()
 | 
				
			||||||
 | 
							}, 100)
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
	data: function () {
 | 
						data: function () {
 | 
				
			||||||
		let config = this.vScriptConfig
 | 
							let config = this.vScriptConfig
 | 
				
			||||||
		if (config == null) {
 | 
							if (config == null) {
 | 
				
			||||||
			config = {
 | 
								config = {
 | 
				
			||||||
				isPrior: false,
 | 
									isPrior: false,
 | 
				
			||||||
				isOn: false,
 | 
									isOn: false,
 | 
				
			||||||
				code: ""
 | 
									code: "",
 | 
				
			||||||
 | 
									auditingCode: ""
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							let auditingStatus = null
 | 
				
			||||||
 | 
							if (config.auditingCodeMD5 != null && config.auditingCodeMD5.length > 0 && config.auditingCode != null && config.auditingCode.length > 0) {
 | 
				
			||||||
 | 
								config.code = config.auditingCode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (this.vAuditingStatus != null) {
 | 
				
			||||||
 | 
									for (let i = 0; i < this.vAuditingStatus.length; i++) {
 | 
				
			||||||
 | 
										let status = this.vAuditingStatus[i]
 | 
				
			||||||
 | 
										if (status.md5 == config.auditingCodeMD5) {
 | 
				
			||||||
 | 
											auditingStatus = status
 | 
				
			||||||
 | 
											break
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,7 +37,8 @@ Vue.component("script-config-box", {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return {
 | 
							return {
 | 
				
			||||||
			config: config
 | 
								config: config,
 | 
				
			||||||
 | 
								auditingStatus: auditingStatus
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	watch: {
 | 
						watch: {
 | 
				
			||||||
@@ -30,6 +53,12 @@ Vue.component("script-config-box", {
 | 
				
			|||||||
		changeCode: function (code) {
 | 
							changeCode: function (code) {
 | 
				
			||||||
			this.config.code = code
 | 
								this.config.code = code
 | 
				
			||||||
			this.change()
 | 
								this.change()
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							isPlus: function () {
 | 
				
			||||||
 | 
								if (Tea == null || Tea.Vue == null) {
 | 
				
			||||||
 | 
									return false
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return Tea.Vue.teaIsPlus
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	template: `<div>
 | 
						template: `<div>
 | 
				
			||||||
@@ -43,7 +72,14 @@ Vue.component("script-config-box", {
 | 
				
			|||||||
		<tbody>
 | 
							<tbody>
 | 
				
			||||||
			<tr :style="{opacity: !config.isOn ? 0.5 : 1}">
 | 
								<tr :style="{opacity: !config.isOn ? 0.5 : 1}">
 | 
				
			||||||
				<td>脚本代码</td>	
 | 
									<td>脚本代码</td>	
 | 
				
			||||||
				<td><source-code-box :id="id" type="text/javascript" :read-only="false" @change="changeCode">{{config.code}}</source-code-box>
 | 
									<td>
 | 
				
			||||||
 | 
										<p class="comment" v-if="auditingStatus != null">
 | 
				
			||||||
 | 
											<span class="green" v-if="auditingStatus.isPassed">管理员审核结果:审核通过。</span>
 | 
				
			||||||
 | 
											<span class="red" v-else-if="auditingStatus.isRejected">管理员审核结果:驳回     驳回理由:{{auditingStatus.rejectedReason}}</span>
 | 
				
			||||||
 | 
											<span class="red" v-else>当前脚本将在审核后生效,请耐心等待审核结果。 <a href="/servers/user-scripts" target="_blank" v-if="isPlus()">去审核 »</a></span>
 | 
				
			||||||
 | 
										</p>
 | 
				
			||||||
 | 
										<p class="comment" v-if="auditingStatus == null"><span class="green">管理员审核结果:审核通过。</span></p>
 | 
				
			||||||
 | 
										<source-code-box :id="id" type="text/javascript" :read-only="false" @change="changeCode">{{config.code}}</source-code-box>
 | 
				
			||||||
					<p class="comment">{{comment}}</p>
 | 
										<p class="comment">{{comment}}</p>
 | 
				
			||||||
				</td>
 | 
									</td>
 | 
				
			||||||
			</tr>
 | 
								</tr>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
Vue.component("script-group-config-box", {
 | 
					Vue.component("script-group-config-box", {
 | 
				
			||||||
	props: ["v-group", "v-is-location"],
 | 
						props: ["v-group", "v-auditing-status", "v-is-location"],
 | 
				
			||||||
	data: function () {
 | 
						data: function () {
 | 
				
			||||||
		let group = this.vGroup
 | 
							let group = this.vGroup
 | 
				
			||||||
		if (group == null) {
 | 
							if (group == null) {
 | 
				
			||||||
@@ -37,7 +37,7 @@ Vue.component("script-group-config-box", {
 | 
				
			|||||||
			<prior-checkbox :v-config="group" v-if="vIsLocation"></prior-checkbox>
 | 
								<prior-checkbox :v-config="group" v-if="vIsLocation"></prior-checkbox>
 | 
				
			||||||
		</table>
 | 
							</table>
 | 
				
			||||||
		<div :style="{opacity: (!vIsLocation || group.isPrior) ? 1 : 0.5}">
 | 
							<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>
 | 
								<script-config-box :v-script-config="script" :v-auditing-status="vAuditingStatus" comment="在接收到客户端请求之后立即调用。预置req、resp变量。" @change="changeScript" :v-is-location="vIsLocation"></script-config-box>
 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
</div>`
 | 
					</div>`
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
		Reference in New Issue
	
	Block a user