mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-14 04:10:26 +08:00
实现基础的通知媒介管理
This commit is contained in:
48
web/views/@default/admins/recipients/instances/instance.js
Normal file
48
web/views/@default/admins/recipients/instances/instance.js
Normal file
@@ -0,0 +1,48 @@
|
||||
Tea.context(function () {
|
||||
let scriptEditor = null
|
||||
|
||||
this.from = encodeURIComponent(window.location.toString())
|
||||
|
||||
if (this.instance.media.type == "script" && this.instance.params.scriptType == "code") {
|
||||
this.$delay(function () {
|
||||
this.loadEditor()
|
||||
})
|
||||
}
|
||||
|
||||
this.loadEditor = function () {
|
||||
if (scriptEditor == null) {
|
||||
scriptEditor = CodeMirror(document.getElementById("script-code-editor"), {
|
||||
theme: "idea",
|
||||
lineNumbers: false,
|
||||
value: "",
|
||||
readOnly: true,
|
||||
showCursorWhenSelecting: true,
|
||||
height: "auto",
|
||||
//scrollbarStyle: null,
|
||||
viewportMargin: Infinity,
|
||||
lineWrapping: true,
|
||||
highlightFormatting: false,
|
||||
indentUnit: 4,
|
||||
indentWithTabs: true
|
||||
})
|
||||
}
|
||||
scriptEditor.setValue(this.instance.params.script)
|
||||
|
||||
let lang = "shell"
|
||||
if (this.instance.params.scriptLang != null && this.instance.params.scriptLang.length > 0) {
|
||||
lang = this.instance.params.scriptLang
|
||||
}
|
||||
let mimeType = "text/x-" + lang
|
||||
if (lang == "nodejs") {
|
||||
mimeType = "text/javascript"
|
||||
} else if (lang == "shell") {
|
||||
mimeType = "text/x-sh"
|
||||
}
|
||||
let info = CodeMirror.findModeByMIME(mimeType)
|
||||
if (info != null) {
|
||||
scriptEditor.setOption("mode", info.mode)
|
||||
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js"
|
||||
CodeMirror.autoLoadMode(scriptEditor, info.mode)
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user