settings.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>管理员操作中心-配置修改</title>
  6. <meta name="description" content="particles.js is a lightweight JavaScript library for creating particles.">
  7. <meta name="author" content="道长"/>
  8. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  9. <link rel="stylesheet" media="screen" href="/static/css/admin.css">
  10. <link rel="stylesheet" media="screen" href="/static/css/settings.css">
  11. <link rel="icon" href="/static/img/logo.png" type="image/x-icon">
  12. <script src="/static/js/jquery.min.js"></script>
  13. <script src="/static/js/common.js"></script>
  14. <script src="/static/js/grey.js"></script>
  15. <link rel="stylesheet" href="/static/plugin/layui/css/layui.css">
  16. <script src="/static/plugin/layui/layui.js"></script>
  17. </head>
  18. <body style="margin:0 auto">
  19. <center>
  20. <script>
  21. function saveConf(key,value){
  22. // let thisObj=$(obj);//js对象转jquery对象
  23. // let key = thisObj.attr("value");
  24. // let value = $('.conf[name="'+key+'"]').val();
  25. console.log('key:'+key+',value:'+value);
  26. if(!key||typeof(value)==='undefined'){
  27. layer.msg('saveConf传参异常',{time:1000});
  28. return
  29. }
  30. let params = {
  31. key:key,
  32. value:value
  33. };
  34. $.post("/admin/save_conf",params,function(data,status){
  35. // console.log(data);
  36. if(data.code === 200){
  37. // alert(data.msg);
  38. layer.msg(data.msg,{time:1000});
  39. console.log('保存'+key+'成功了...');
  40. $(`input.conf[name="${key}"]`).val(value);
  41. if(/UNAME|PWD/.test(params.key)){
  42. location.reload();
  43. }
  44. }else{
  45. if(/登录/.test(data.msg)){
  46. location.href = '/admin'
  47. }else{
  48. // alert(data.msg);
  49. layer.msg(data.msg,{time:1000});
  50. console.log('保存'+key+'失败了...');
  51. return false
  52. }
  53. }
  54. });
  55. }
  56. function checkValue(key,value){
  57. if(key==='ENV'){
  58. try {
  59. JSON.parse(value);
  60. }catch (e) {
  61. layer.msg(`保存失败,变量 ${key}必须为json格式!`);
  62. return false;
  63. }
  64. }
  65. return true;
  66. }
  67. $(document).ready(function() {
  68. $(".save_conf").click(function () {
  69. let key = $(this).attr('value');
  70. let value = $(`input.conf[name="${key}"]`).val();
  71. if(checkValue(key,value)){
  72. saveConf(key,value);
  73. }
  74. });
  75. $('.edit_conf').click(function (){
  76. let key = $(this).attr('value');
  77. let value = $(`input.conf[name="${key}"]`).val();
  78. layer.prompt({
  79. formType: 2,
  80. value: value,
  81. title: '请输入 '+key,
  82. area: ['320px', '100px'] //自定义文本域宽高
  83. }, function(value, index, elem){
  84. console.log(value); //得到value
  85. if(checkValue(key,value)){
  86. saveConf(key,value);
  87. }
  88. layer.close(index);
  89. });
  90. });
  91. $('#update_db').click(function (){
  92. if(confirm('确定要升级数据库?升级过程可能较长,需要耐心等待提示完成。判断标准为是否正常打开缓存文件列表-查看界面,如果正常就不需要进行此操作。升级数据库后将正常使用未来功能多选操作,可对规则进行多选显示或者隐藏')){
  93. $.get("/admin/update_db",function(data,status){
  94. console.log(data);
  95. if(data.code === 200){
  96. alert(data.msg);
  97. // location.reload();
  98. }else{
  99. alert(data.msg);
  100. console.log('升级失败了...');
  101. return false
  102. }
  103. });
  104. }
  105. });
  106. });
  107. </script>
  108. <div class="title">欢迎使用DR-PY配置界面<div><span class="ver_title">当前版本: {{ ver }}</span><span
  109. class="ver_title">框架开发:道长</span><span class="ver_title">框架美化:蓝莓</span></div></div>
  110. <div class="nav">
  111. <!-- 列表 -->
  112. <ul>
  113. <!-- 一级菜单 -->
  114. <li class="nav-litem">
  115. <a href="/admin">返回前页</a>
  116. </li>
  117. <li class="nav-litem">
  118. <a href="javascript:void(0);" class="funcbtn" id="update_db">升级数据库</a>
  119. </li>
  120. <li class="nav-litem">
  121. <a href="javascript:copy('cp ./tmp/dr_py/app.py ./app.py');" class="funcbtn" id="update_by_self">升级指令</a>
  122. </li>
  123. <li class="nav-litem">
  124. <a href="javascript:copy('cp ./tmp/dr_py/base/custom.conf base');" class="funcbtn" id="user_custom">用户配置</a>
  125. </li>
  126. </ul>
  127. </div>
  128. <div class="w">
  129. <form action="#" class="m">
  130. {% for conf in conf_lists %}
  131. <span class="label{{conf.name|length}}">
  132. {{ conf.name }}:
  133. </span>
  134. <input class="conf" type="text" name="{{ conf.key }}" placeholder="请输入{{ conf.key }}..." value="{{ conf.value }}"/>
  135. <a class="edit_conf btn_option" href="javascript:void(0);" value="{{ conf.key }}">编辑</a>
  136. <a class="save_conf btn_option" href="javascript:void(0);" value="{{ conf.key }}">保存</a>
  137. {% if loop.last==False %}</br>{% endif %}{% endfor %}
  138. </form>
  139. </div>
  140. </center>
  141. </body>
  142. </html>