From 6a4153da36aacce930003680e4e40896ca59afc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=9A=E9=A3=8E=E6=8B=82=E6=9F=B3=E9=A2=9C?= <434857005@qq.com> Date: Mon, 3 Jul 2023 10:41:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86-=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E7=AE=A1=E7=90=86=E5=A2=9E=E5=8A=A0=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E6=BA=90=E6=B8=85=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/admin.py | 21 ++++++++++++++++++++- js/version.txt | 2 +- templates/admin.html | 17 +++++++++++++++++ utils/files.py | 17 +++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/controllers/admin.py b/controllers/admin.py index e8192dd..5a66b01 100644 --- a/controllers/admin.py +++ b/controllers/admin.py @@ -21,7 +21,7 @@ from utils.parser import runJScode from werkzeug.utils import secure_filename from utils.web import md5 from utils.common_api import js_render -from utils.files import get_jar_list +from utils.files import get_jar_list, get_jsd_list, get_drop_js admin = Blueprint("admin", __name__) @@ -364,6 +364,25 @@ def admin_change_use_py(): msg = f'已修改的配置记录id为:{id},结果为{state}' return R.success(msg) +@admin.route('/clear_drop') +def admin_clear_drop(): + if not verfy_token(): + return R.failed('请登录后再试') + + jsd_list = get_jsd_list() + logger.info(f'jsd文件列表:{jsd_list}') + js_list = get_drop_js(jsd_list) + rm_list = [] + for i in range(len(js_list)): + js_file = js_list[i] + # shutil.rmtree(js_file, ignore_errors=False, onerror=None) + if os.path.exists(js_file): + os.remove(js_file) + rm_list.append(jsd_list[i][:-1]) + logger.info(f'待删除js文件列表:{rm_list}') + rm_str = ','.join(rm_list) + msg = f'清理完毕,本次共计清理{len(rm_list)}个\n {rm_str}' + return R.success(msg) # @admin.route('/get_use_py') # def admin_get_use_py(): diff --git a/js/version.txt b/js/version.txt index 17675f8..84c94cf 100644 --- a/js/version.txt +++ b/js/version.txt @@ -1 +1 @@ -3.9.45beta3 \ No newline at end of file +3.9.45beta4 \ No newline at end of file diff --git a/templates/admin.html b/templates/admin.html index 74e58fb..8da2af7 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -233,6 +233,22 @@ location.href = '/admin/logtail'; }); + $('#clear_drop').click(function () { + if(confirm('若js目录存在同名的jsd文件则视为该源为废弃源。执行此功能将清理与jsd文件同名的js文件。执行此功能前请确保项目的jsd文件跟仓库一致,防止误删。推荐进容器 rm -rf js/*.jsd 后强制升级一次再使用此功能。立即执行则确认否则取消执行')){ + $.get("/admin/clear_drop", function (data, status) { + console.log(data); + if (data.code === 200) { + alert(data.msg); + location.reload(); + } else { + alert(data.msg); + console.log('清理失败了...'); + return false + } + }); + } + }); + $('#lives').click(function () { location.href = '/admin/lives' }); @@ -275,6 +291,7 @@