admin.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>管理员操作中心-{{rules.count}}条规则</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"
  9. content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  10. <link rel="stylesheet" media="screen" href="/static/css/admin.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. </head>
  16. <body>
  17. <script>
  18. $(document).ready(function () {
  19. $(".view").click(function () {
  20. let rule = this.innerText.trim();
  21. location.href = '/admin/view/' + rule + '.js';
  22. });
  23. $(".view_home").click(function () {
  24. let rule = this.getAttribute('value').trim();
  25. location.href = '/vod?{% if js0_password %}pwd={{js0_password}}&{% endif %}rule=' + rule;
  26. });
  27. $(".view_search").click(function () {
  28. let rule = this.getAttribute('value').trim();
  29. location.href = '/vod?{% if js0_password %}pwd={{js0_password}}&{% endif %}rule=' + rule + '&wd=斗罗大陆';
  30. });
  31. $("#checkUpdate").click(function () {
  32. console.log('开始检查升级...');
  33. $.get("/admin/get_ver", function (data, status) {
  34. console.log("数据: " + data + "\n状态: " + status);
  35. if (data.msg) {
  36. alert(data.msg);
  37. return false
  38. } else {
  39. if (data.local_ver && data.online_ver && !data.msg) {
  40. if (data.local_ver !== data.online_ver) {
  41. msg = `本地版本:${data.local_ver}\n线上版本:${data.online_ver}\n是否立即执行升级?`;
  42. if (confirm(msg)) {
  43. $.get("/admin/update_ver", function (data, status) {
  44. console.log(data);
  45. if (data.code === 200) {
  46. // alert(data.msg+'\n除主程序app.py需要自行检测替换升级外,其他关键文件全部更新完毕');
  47. alert(data.msg);
  48. location.reload();
  49. } else {
  50. alert(data.msg || '未知数据,具体到数据控制台查看');
  51. console.log('升级失败了...');
  52. return false
  53. }
  54. });
  55. }
  56. } else {
  57. alert('已经是最新版,无需升级!')
  58. }
  59. } else if (data.msg) {
  60. alert('检测升级疑似发生了问题:\n' + data.msg);
  61. } else {
  62. alert('已经是最新版,无需升级!')
  63. }
  64. }
  65. });
  66. });
  67. $(".clear").click(function () {
  68. let rule = this.getAttribute('value').trim();
  69. if (confirm('确认删除内置规则:' + rule + '?')) {
  70. let code = $.ajax({ url: '/admin/clear/' + rule + '.js', async: false }).responseText;
  71. code = typeof (code) === "object" ? code : JSON.parse(code);
  72. if (code.code === 200) {
  73. alert('操作成功!\n' + code.msg);
  74. location.reload()
  75. } else {
  76. alert('操作失败!\n' + code.msg);
  77. }
  78. }
  79. });
  80. $('#upload').click(function () {
  81. var file_data = $("input[name='file']").prop("files")[0];
  82. // console.log(file_data);
  83. if (!file_data) {
  84. alert('文件必选');
  85. return false
  86. }
  87. var name = file_data.name;
  88. if (!name.endsWith('.js')) {
  89. alert('仅支持上传js文件');
  90. return false
  91. }
  92. var form_data = new FormData();
  93. // 把所有表单信息
  94. form_data.append("id", "001");
  95. form_data.append("name", name);
  96. form_data.append("file", file_data);
  97. $.ajax({
  98. type: "POST",
  99. url: "/admin/upload",
  100. dataType: "json",
  101. processData: false, // 注意:让jQuery不要处理数据
  102. contentType: false, // 注意:让jQuery不要设置contentType
  103. data: form_data
  104. }).success(function (ret) {
  105. console.log(ret);
  106. alert(ret.msg);
  107. location.reload();
  108. }).fail(function (ret) {
  109. console.log(ret);
  110. alert(ret.msg);
  111. });
  112. });
  113. $('#update_lives').click(function () {
  114. let live_url = $('#live_url').val();
  115. // console.log(live_url);
  116. let new_live_url = prompt('输入临时同步远程直播源地址(自动获取当前配置)', live_url);
  117. if (new_live_url.startsWith('http')) {
  118. $.get("/admin/update_lives?url=" + new_live_url, function (data, status) {
  119. console.log("数据: " + data + "\n状态: " + status);
  120. if (data.code === 200) {
  121. alert('操作成功!\n' + data.msg);
  122. // location.reload();
  123. } else {
  124. alert('操作失败!\n' + data.msg);
  125. }
  126. });
  127. }
  128. });
  129. $('#write_lives').click(function () {
  130. let live_url = $('#live_url').val();
  131. let new_live_url = prompt('请修改默认的远程直播源地址', live_url);
  132. if (new_live_url) {
  133. console.log('修改直播源地址为:' + new_live_url);
  134. $.get("/admin/write_live_url?url=" + new_live_url, function (data, status) {
  135. console.log("数据: " + data + "\n状态: " + status);
  136. if (data.code === 200) {
  137. alert('操作成功!\n' + data.msg);
  138. location.reload();
  139. } else {
  140. alert('操作失败!\n' + data.msg);
  141. }
  142. });
  143. }
  144. });
  145. $('#force_update').click(function () {
  146. let msg = `
  147. 升级过程中由于新版本升级脚本发生改变可能会导致升级完毕但是升级不完整。
  148. 此时需要重启服务后执行强制升级操作通过更新后的升级脚本把本地升级包文件再次覆盖完成完整升级。
  149. 是否继续(请确认你升级完后重启过,不然点确定毫无必要)?
  150. `;
  151. if (confirm(msg)) {
  152. $.get("/admin/force_update", function (data, status) {
  153. console.log(data);
  154. if (data.code === 200) {
  155. // alert(data.msg+'\n除主程序app.py需要自行检测替换升级外,其他关键文件全部更新完毕');
  156. alert(data.msg);
  157. location.reload();
  158. } else {
  159. alert(data.msg || '未知数据,具体到数据控制台查看');
  160. console.log('升级失败了...');
  161. return false
  162. }
  163. });
  164. }
  165. });
  166. $('#use_py').click(function () {
  167. $.get("/admin/change_use_py", function (data, status) {
  168. console.log(data);
  169. if (data.code === 200) {
  170. alert(data.msg);
  171. location.reload();
  172. } else {
  173. alert(data.msg);
  174. console.log('升级失败了...');
  175. return false
  176. }
  177. });
  178. });
  179. $("#logtail").click(function () {
  180. location.href = '/admin/logtail';
  181. });
  182. $('#lives').click(function () {
  183. location.href = '/admin/lives'
  184. });
  185. });
  186. function getFileSize(fileObj) {
  187. $('#file_size').text('文件大小为:' + fileObj.files[0].size / 1024 + 'kb');
  188. }
  189. </script>
  190. <div class="title">欢迎使用DR-PY管理界面<div><span class="ver_title">当前版本: {{ ver }}</span><span
  191. class="ver_title">框架开发:道长</span><span class="ver_title">框架美化:蓝莓</span></div>
  192. </div>
  193. <div class="nav">
  194. <!-- 列表 -->
  195. <ul>
  196. <!-- 一级菜单 -->
  197. <li class="nav-litem">
  198. <a href="/index">返回首页</a>
  199. </li>
  200. <li class="nav-litem">
  201. <a href="javascript:;">功能管理</a>
  202. <!-- 二级菜单 -->
  203. <ul>
  204. <li><a href="/admin/settings">设置中心</a></li>
  205. <li><a href="/layui/index">未来功能</a></li>
  206. <li><a href="javascript:void(0);" class="funcbtn" id="logtail">在线日志</a></li>
  207. <li><a href="/vods" class="funcbtn" target="_blank">搜索看板</a></li>
  208. </ul>
  209. </li>
  210. <li class="nav-litem">
  211. <a href="javascript:;">项目升级</a>
  212. <!-- 二级菜单 -->
  213. <ul>
  214. <li><a href="javascript:void(0);" class="funcbtn" id="checkUpdate">检测升级</a></li>
  215. <li><a href="javascript:void(0);" class="funcbtn" id="force_update">强制升级</a></li>
  216. </ul>
  217. </li>
  218. <li class="nav-litem">
  219. <a href="javascript:;">直播设置</a>
  220. <!-- 二级菜单 -->
  221. <ul>
  222. <li><a href="javascript:void(0);" class="funcbtn" id="write_lives">修改直播源</a></li>
  223. <li><a href="javascript:void(0);" class="funcbtn" id="update_lives">同步直播源</a></li>
  224. <li><a href="javascript:void(0);" class="funcbtn" id="use_py">已{% if pystate=='1' %}启用{% else %}关闭{% endif %}py源</a></li>
  225. <li><a href="javascript:void(0);" class="funcbtn" id="lives">直播源列表</a></li>
  226. </ul>
  227. </li>
  228. </ul>
  229. </div>
  230. <input id="live_url" value="{{live_url}}" style="display: none">
  231. <p class="box">你可以在此界面在线管理JS目录里规则文件的上传/删除</p>
  232. <form action="/admin/upload" method="POST" enctype="multipart/form-data">
  233. <!-- <input type = "file" name = "file" class="btn" accept=".js" onchange="getFileSize(this)"/>-->
  234. <input type="file" name="file" class="btn" onchange="getFileSize(this)" />
  235. <!-- <input type = "submit" value="上传" class="btn"/>-->
  236. <input type="button" id="upload" value="上传" class="btn" />
  237. </form>
  238. <p id="file_size"></p>
  239. <details open>
  240. <summary class="xl">数据列表已展开 点击隐藏详情</summary>
  241. <h4>规则列表数据-共{{rules.count+cache_count}}条(内置:{{rules.count}} 缓存:{{cache_count}})</h4>
  242. {% if rules.count < 1 %} <h3>暂无内置的规则</h3>
  243. {% endif %}
  244. <div class="zt">
  245. {% for rule in rules.list %}
  246. <div class="red">
  247. <div class="mz"><a class="view" href="javascript:void(0);">{{ rule.name }}</a></div>
  248. <div class="sj"><a class="view_home" href="javascript:void(0);" value="{{ rule.name }}">主页</a></div>
  249. <div class="ss"><a class="view_search" href="javascript:void(0);" value="{{ rule.name }}">搜索</a></div>
  250. <div class="sc"><a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a></div>
  251. </div>
  252. {% endfor %}
  253. </div>
  254. </details>
  255. </body>
  256. </html>