settings.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. $(`*.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 = $(`*.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 = $(`*.conf[name="${key}"]`).val();
  78. layer.prompt({
  79. formType: 2,
  80. value: value,
  81. maxlength:20480,//最大输入长度20kb
  82. title: '请输入 '+key,
  83. area: ['320px', '100px'] //自定义文本域宽高
  84. }, function(value, index, elem){
  85. console.log(value); //得到value
  86. if(checkValue(key,value)){
  87. saveConf(key,value);
  88. }
  89. layer.close(index);
  90. });
  91. });
  92. $('#update_db').click(function (){
  93. if(confirm('确定要升级数据库?升级过程可能较长,需要耐心等待提示完成。判断标准为是否正常打开缓存文件列表-查看界面,如果正常就不需要进行此操作。升级数据库后将正常使用未来功能多选操作,可对规则进行多选显示或者隐藏')){
  94. $.get("/admin/update_db",function(data,status){
  95. console.log(data);
  96. if(data.code === 200){
  97. alert(data.msg);
  98. // location.reload();
  99. }else{
  100. alert(data.msg);
  101. console.log('升级失败了...');
  102. return false
  103. }
  104. });
  105. }
  106. });
  107. });
  108. </script>
  109. <div class="title">欢迎使用DR-PY配置界面<div><span class="ver_title">当前版本: {{ ver }}</span><span
  110. class="ver_title">框架开发:道长</span><span class="ver_title">框架美化:蓝莓</span></div></div>
  111. <div class="nav">
  112. <!-- 列表 -->
  113. <ul>
  114. <!-- 一级菜单 -->
  115. <li class="nav-litem">
  116. <a href="/admin">返回前页</a>
  117. </li>
  118. <li class="nav-litem">
  119. <a href="javascript:void(0);" class="funcbtn" id="update_db">升级数据库</a>
  120. </li>
  121. <li class="nav-litem">
  122. <a href="javascript:copy('cp ./tmp/dr_py/app.py ./app.py');" class="funcbtn" id="update_by_self">升级指令</a>
  123. </li>
  124. <li class="nav-litem">
  125. <a href="javascript:copy('cp ./tmp/dr_py/base/custom.conf base');" class="funcbtn" id="user_custom">用户配置</a>
  126. </li>
  127. </ul>
  128. </div>
  129. <div class="w">
  130. <form action="#" class="m">
  131. {% for conf in conf_lists %}
  132. <span class="label{{conf.name|length}}">
  133. {{ conf.name }}:
  134. </span>
  135. {% if conf.key not in ["SPIDER_JAR","ZB_PLAYER"] %}
  136. <input class="conf" type="text" name="{{ conf.key }}" placeholder="请输入{{ conf.key }}..." value="{{ conf.value }}"/>
  137. {% elif conf.key=="SPIDER_JAR" %}
  138. <select class="conf" name="{{ conf.key }}">
  139. <!-- <option>-请选择-</option>-->
  140. {% for jar in jar_lists %}
  141. {% if jar==jar_now %}
  142. <option selected>{{jar}}</option>
  143. {% else %}
  144. <option>{{jar}}</option>
  145. {% endif %}
  146. {% endfor %}
  147. </select>
  148. {% elif conf.key=="ZB_PLAYER" %}
  149. <select class="conf" name="{{ conf.key }}">
  150. <!-- <option>-请选择-</option>-->
  151. {% for player in ["1","2","3","4"] %}
  152. {% if player==player_now %}
  153. <option selected>{{player}}</option>
  154. {% else %}
  155. <option>{{player}}</option>
  156. {% endif %}
  157. {% endfor %}
  158. </select>
  159. {% endif %}
  160. <a class="edit_conf btn_option" href="javascript:void(0);" value="{{ conf.key }}">编辑</a>
  161. <a class="save_conf btn_option" href="javascript:void(0);" value="{{ conf.key }}">保存</a>
  162. {% if loop.last==False %}</br>{% endif %}{% endfor %}
  163. </form>
  164. </div>
  165. </center>
  166. </body>
  167. </html>