mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-05 22:30:28 +08:00
实现初版边缘脚本
This commit is contained in:
53
web/public/js/components/server/script-config-box.js
Normal file
53
web/public/js/components/server/script-config-box.js
Normal file
@@ -0,0 +1,53 @@
|
||||
Vue.component("script-config-box", {
|
||||
props: ["id", "v-script-config", "comment"],
|
||||
data: function () {
|
||||
let config = this.vScriptConfig
|
||||
if (config == null) {
|
||||
config = {
|
||||
isPrior: false,
|
||||
isOn: false,
|
||||
code: ""
|
||||
}
|
||||
}
|
||||
|
||||
if (config.code.length == 0) {
|
||||
config.code = "\n\n\n\n"
|
||||
}
|
||||
|
||||
return {
|
||||
config: config
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"config.isOn": function () {
|
||||
this.change()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
change: function () {
|
||||
this.$emit("change", this.config)
|
||||
},
|
||||
changeCode: function (code) {
|
||||
this.config.code = code
|
||||
this.change()
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<table class="ui table definition selectable">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="title">是否启用</td>
|
||||
<td><checkbox v-model="config.isOn"></checkbox></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tbody>
|
||||
<tr :style="{opacity: !config.isOn ? 0.5 : 1}">
|
||||
<td>脚本代码</td>
|
||||
<td><source-code-box :id="id" type="text/javascript" :read-only="false" @change="changeCode">{{config.code}}</source-code-box>
|
||||
<p class="comment">{{comment}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>`
|
||||
})
|
||||
Reference in New Issue
Block a user