Tea.context(function () {
this.mediaType = ""
this.advancedOptionsVisible = true
let that = this
this.changeMediaType = function (media) {
that.mediaType = media.type
}
/**
* 邮箱
*/
this.emailUsername = "";
this.emailUsernameHelp = "";
this.changeEmailUsername = function () {
this.emailUsernameHelp = "";
if (this.emailUsername.indexOf("qq.com") > 0) {
this.emailUsernameHelp = ",QQ邮箱相关设置帮助";
} else if (this.emailUsername.indexOf("163.com") > 0) {
this.emailUsernameHelp = ",网易邮箱相关设置帮助";
}
};
/**
* webHook
*/
this.methods = ["GET", "POST"]
this.webHookMethod = "GET";
this.webHookHeadersAdding = false;
this.webHookHeaders = [];
this.webHookHeadersAddingName = "";
this.webHookHeadersAddingValue = "";
this.addWebHookHeader = function () {
this.webHookHeadersAdding = true;
this.$delay(function () {
this.$find("form input[name='webHookHeaderName']").focus();
});
};
this.cancelWebHookHeadersAdding = function () {
this.webHookHeadersAdding = false;
};
this.confirmWebHookHeadersAdding = function () {
this.webHookHeaders.push({
"name": this.webHookHeadersAddingName,
"value": this.webHookHeadersAddingValue
});
this.webHookHeadersAddingName = "";
this.webHookHeadersAddingValue = "";
this.webHookHeadersAdding = false;
};
this.removeWebHookHeader = function (index) {
if (!window.confirm("确定要删除此Header吗?")) {
return;
}
this.webHookHeaders.$remove(index);
};
this.webHookContentType = "params";
this.selectWebHookContentType = function (contentType) {
this.webHookContentType = contentType;
this.$delay(function () {
if (contentType == "params") {
} else if (contentType == "body") {
this.$find("form textarea[name='webHookBody']").focus();
}
});
};
this.webHookParamsAdding = false;
this.webHookParams = [];
this.webHookParamsAddingName = "";
this.webHookParamsAddingValue = "";
this.addWebHookParam = function () {
this.webHookParamsAdding = true;
this.$delay(function () {
this.$find("form input[name='webHookParamName']").focus();
});
};
this.cancelWebHookParamsAdding = function () {
this.webHookParamsAdding = false;
};
this.confirmWebHookParamsAdding = function () {
this.webHookParams.push({
"name": this.webHookParamsAddingName,
"value": this.webHookParamsAddingValue
});
this.webHookParamsAddingName = "";
this.webHookParamsAddingValue = "";
this.webHookParamsAdding = false;
};
this.removeWebHookParam = function (index) {
if (!window.confirm("确定要删除此参数吗?")) {
return;
}
this.webHookParams.$remove(index);
};
this.webHookBody = "";
/**
* 企业微信
*/
this.qyWeixinTextFormat = "text";
/**
* 企业微信群机器人
*/
this.qyWeixinRobotTextFormat = "text";
/**
* 脚本
*/
let scriptEditor = null
this.scriptTab = "path";
this.scriptLang = "shell";
this.scriptLangs = [
{
"name": "Shell",
"code": "shell"
},
{
"name": "批处理(bat)",
"code": "bat"
},
{
"name": "PHP",
"code": "php"
},
{
"name": "Python",
"code": "python"
},
{
"name": "Ruby",
"code": "ruby"
},
{
"name": "NodeJS",
"code": "nodejs"
}
];
this.selectScriptTab = function (tab) {
this.scriptTab = tab;
if (tab == "path") {
this.$delay(function () {
this.$find("form input[name='scriptPath']").focus();
});
} else if (tab == "code") {
this.$delay(function () {
this.loadEditor();
});
}
};
this.selectScriptLang = function (lang) {
this.scriptLang = lang;
switch (lang) {
case "shell":
scriptEditor.setValue("#!/usr/bin/env bash\n\n# your commands here\n");
var info = CodeMirror.findModeByMIME("text/x-sh");
if (info != null) {
scriptEditor.setOption("mode", info.mode);
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
CodeMirror.autoLoadMode(scriptEditor, info.mode);
}
break;
case "bat":
scriptEditor.setValue("");
break;
case "php":
scriptEditor.setValue("#!/usr/bin/env php\n\n