Skip to content

Commit 5622636

Browse files
committed
优化请求脚本相关代码
1 parent 372c276 commit 5622636

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

web/public/js/components/server/script-config-box.js

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
11
Vue.component("script-config-box", {
2-
props: ["id", "v-script-config", "comment"],
2+
props: ["id", "v-script-config", "comment", "v-auditing-status"],
3+
mounted: function () {
4+
let that = this
5+
setTimeout(function () {
6+
that.$forceUpdate()
7+
}, 100)
8+
},
39
data: function () {
410
let config = this.vScriptConfig
511
if (config == null) {
612
config = {
713
isPrior: false,
814
isOn: false,
9-
code: ""
15+
code: "",
16+
auditingCode: ""
17+
}
18+
}
19+
20+
let auditingStatus = null
21+
if (config.auditingCodeMD5 != null && config.auditingCodeMD5.length > 0 && config.auditingCode != null && config.auditingCode.length > 0) {
22+
config.code = config.auditingCode
23+
24+
if (this.vAuditingStatus != null) {
25+
for (let i = 0; i < this.vAuditingStatus.length; i++) {
26+
let status = this.vAuditingStatus[i]
27+
if (status.md5 == config.auditingCodeMD5) {
28+
auditingStatus = status
29+
break
30+
}
31+
}
1032
}
1133
}
1234

@@ -15,7 +37,8 @@ Vue.component("script-config-box", {
1537
}
1638

1739
return {
18-
config: config
40+
config: config,
41+
auditingStatus: auditingStatus
1942
}
2043
},
2144
watch: {
@@ -30,6 +53,12 @@ Vue.component("script-config-box", {
3053
changeCode: function (code) {
3154
this.config.code = code
3255
this.change()
56+
},
57+
isPlus: function () {
58+
if (Tea == null || Tea.Vue == null) {
59+
return false
60+
}
61+
return Tea.Vue.teaIsPlus
3362
}
3463
},
3564
template: `<div>
@@ -43,7 +72,14 @@ Vue.component("script-config-box", {
4372
<tbody>
4473
<tr :style="{opacity: !config.isOn ? 0.5 : 1}">
4574
<td>脚本代码</td>
46-
<td><source-code-box :id="id" type="text/javascript" :read-only="false" @change="changeCode">{{config.code}}</source-code-box>
75+
<td>
76+
<p class="comment" v-if="auditingStatus != null">
77+
<span class="green" v-if="auditingStatus.isPassed">管理员审核结果:审核通过。</span>
78+
<span class="red" v-else-if="auditingStatus.isRejected">管理员审核结果:驳回 &nbsp; &nbsp; 驳回理由:{{auditingStatus.rejectedReason}}</span>
79+
<span class="red" v-else>当前脚本将在审核后生效,请耐心等待审核结果。 <a href="/servers/user-scripts" target="_blank" v-if="isPlus()">去审核 &raquo;</a></span>
80+
</p>
81+
<p class="comment" v-if="auditingStatus == null"><span class="green">管理员审核结果:审核通过。</span></p>
82+
<source-code-box :id="id" type="text/javascript" :read-only="false" @change="changeCode">{{config.code}}</source-code-box>
4783
<p class="comment">{{comment}}</p>
4884
</td>
4985
</tr>

web/public/js/components/server/script-group-config-box.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Vue.component("script-group-config-box", {
2-
props: ["v-group", "v-is-location"],
2+
props: ["v-group", "v-auditing-status", "v-is-location"],
33
data: function () {
44
let group = this.vGroup
55
if (group == null) {
@@ -37,7 +37,7 @@ Vue.component("script-group-config-box", {
3737
<prior-checkbox :v-config="group" v-if="vIsLocation"></prior-checkbox>
3838
</table>
3939
<div :style="{opacity: (!vIsLocation || group.isPrior) ? 1 : 0.5}">
40-
<script-config-box :v-script-config="script" comment="在接收到客户端请求之后立即调用。预置req、resp变量。" @change="changeScript" :v-is-location="vIsLocation"></script-config-box>
40+
<script-config-box :v-script-config="script" :v-auditing-status="vAuditingStatus" comment="在接收到客户端请求之后立即调用。预置req、resp变量。" @change="changeScript" :v-is-location="vIsLocation"></script-config-box>
4141
</div>
4242
</div>`
4343
})

0 commit comments

Comments
 (0)