重写向编辑优化

pull/119/head
midoks 3 years ago
parent 0f6d87a8a4
commit 9027149dca
  1. 90
      route/static/app/site.js

@ -1495,16 +1495,10 @@ function to301(siteName, type, obj){
}, function(res) { }, function(res) {
res = JSON.parse(res); res = JSON.parse(res);
if (res.status == true) { if (res.status == true) {
layer.msg('删除成功', { layer.msg('删除成功', {time: 1000,icon: 1});
time: 1000, to301(siteName);
icon: 1
});
to301(siteName)
} else { } else {
layer.msg(res.msg, { layer.msg(res.msg, {time: 1000,icon: 2});
time: 1000,
icon: 2
});
} }
}); });
return return
@ -1512,64 +1506,62 @@ function to301(siteName, type, obj){
if (type == 3) { if (type == 3) {
var laoding = layer.load(); var laoding = layer.load();
$.post('/site/get_redirect_conf', { var data = {siteName: siteName,id: obj};
siteName: siteName, $.post('/site/get_redirect_conf', data, function(res) {
id: obj,
}, function(res) {
layer.close(laoding); layer.close(laoding);
res = JSON.parse(res); res = JSON.parse(res);
if (res.status == true) { if (res.status == true) {
var mBody = "<div class='webEdit-box' style='padding: 20px'>\ var mBody = "<div class='webEdit-box' style='padding: 20px'>\
<textarea style='height: 320px; width: 445px; margin-left: 20px; line-height:18px' id='configBody'>"+res.data.result+"</textarea>\ <textarea style='height: 320px; width: 445px; margin-left: 20px; line-height:18px' id='configRedirectBody'>"+res.data.result+"</textarea>\
<div class='info-r'>\ <div class='info-r'>\
<button id='SaveRedirectConfigFileBtn' class='btn btn-success btn-sm' style='margin-top:15px;'>保存</button>\
<ul class='help-info-text c7 ptb10'>\ <ul class='help-info-text c7 ptb10'>\
<li>此处为重定向配置文件,若您不了解配置规则,请勿随意修改.</li>\ <li>此处为重定向配置文件,若您不了解配置规则,请勿随意修改.</li>\
</ul>\ </ul>\
</div>\ </div>\
</div>"; </div>";
var editor;
var index = layer.open({ var index = layer.open({
type: 1, type: 1,
title: '编辑配置文件', title: '编辑配置文件',
closeBtn: 1, closeBtn: 1,
shadeClose: false, shadeClose: true,
area: ['500px', '500px'], area: ['500px', '500px'],
btn: ['提交','关闭'],
content: mBody, content: mBody,
success: function () { success: function () {
$("#SaveRedirectConfigFileBtn").click(function(){ editor = CodeMirror.fromTextArea(document.getElementById("configRedirectBody"), {
$("#configBody").empty(); extraKeys: {"Ctrl-Space": "autocomplete"},
$("#configBody").text(editor.getValue()); lineNumbers: true,
var load = layer.load() matchBrackets:true,
$.post('/site/save_redirect_conf', { });
siteName: siteName, editor.focus();
id: obj, $(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
config: editor.getValue() $("#onlineEditFileBtn").unbind('click');
}, function(res) { },
layer.close(load) yes:function(index,layero){
var res = JSON.parse(res); $("#configRedirectBody").empty().text(editor.getValue());
if (res.status == true) { var load = layer.load();
layer.msg('保存成功', { var data = {
icon: 1 siteName: siteName,
}); id: obj,
layer.close(index); config: editor.getValue(),
} else { };
layer.msg(res.msg, { $.post('/site/save_redirect_conf', data, function(res) {
time: 1000, layer.close(load)
icon: 2 var res = JSON.parse(res);
}); if (res.status == true) {
} layer.msg('保存成功', {icon: 1});
}); layer.close(index);
}) } else {
} layer.msg(res.msg, {time: 3000,icon: 2});
}); }
var editor = CodeMirror.fromTextArea(document.getElementById("configBody"), { });
extraKeys: {"Ctrl-Space": "autocomplete"}, return true;
lineNumbers: true, },
matchBrackets:true,
}); });
$(".CodeMirror-scroll").css({"height":"300px","margin":0,"padding":0});
} else {
} else {
layer.msg('请求错误!!', {time: 3000,icon: 2});
} }
}); });
return return
@ -1597,7 +1589,6 @@ function to301(siteName, type, obj){
$("#webedit-con").html(body); $("#webedit-con").html(body);
var loadT = layer.msg(lan.site.the_msg,{icon:16,time:0,shade: [0.3, '#000']}); var loadT = layer.msg(lan.site.the_msg,{icon:16,time:0,shade: [0.3, '#000']});
$.post('/site/get_redirect','siteName='+siteName, function(response) { $.post('/site/get_redirect','siteName='+siteName, function(response) {
layer.close(loadT); layer.close(loadT);
$("#md-301-loading").remove(); $("#md-301-loading").remove();
@ -1625,7 +1616,6 @@ function to301(siteName, type, obj){
//反向代理 //反向代理
function toProxy(siteName, type, obj) { function toProxy(siteName, type, obj) {
// 设置 页面展示 // 设置 页面展示
if(type == 1) { if(type == 1) {
var proxy_form = layer.open({ var proxy_form = layer.open({

Loading…
Cancel
Save