From 7a1dbfbf85f903024741ad76d8b4e4d39188d524 Mon Sep 17 00:00:00 2001 From: midoks Date: Tue, 5 Jul 2022 23:32:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E5=AE=89=E8=A3=85=E9=A2=84?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/plugins_api.py | 4 ++++ route/static/app/public.js | 6 ++--- route/static/app/soft.js | 49 +++++++++++++++++++++++++++++++++----- 3 files changed, 49 insertions(+), 10 deletions(-) diff --git a/class/core/plugins_api.py b/class/core/plugins_api.py index 3b1e26cc0..7b7773783 100755 --- a/class/core/plugins_api.py +++ b/class/core/plugins_api.py @@ -485,6 +485,7 @@ class plugins_api: "setup": False, "setup_version": "", "status": False, + "install_pre_inspection": False, } if checks.find('VERSION') > -1: @@ -507,6 +508,9 @@ class plugins_api: else: pInfo['setup_version'] = self.getVersion(pInfo['install_checks']) # pluginInfo['status'] = self.checkStatus(pluginInfo) + + if 'install_pre_inspection' in info: + pInfo['install_pre_inspection'] = info['install_pre_inspection'] pInfo['status'] = False return pInfo diff --git a/route/static/app/public.js b/route/static/app/public.js index e0b87726b..824562716 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -821,9 +821,7 @@ function fly(a) { }, onEnd: function() { layer.closeAll(); - layer.msg(lan.bt.task_add, { - icon: 1 - }); + layer.msg(lan.bt.task_add, {icon: 1}); getTaskCount(); } }); @@ -1350,7 +1348,7 @@ function webShell() { term.open(); term.setOption('cursorBlink', true); term.setOption('fontSize', 14); - gterm = term + gterm = term; socket.on('server_response', function (data) { term.write(data.data); diff --git a/route/static/app/soft.js b/route/static/app/soft.js index 8f59f2a80..7c2149375 100755 --- a/route/static/app/soft.js +++ b/route/static/app/soft.js @@ -98,12 +98,11 @@ function getSList(isdisplay) { } - var handle = '安装'; - + var handle = '安装'; if (plugin.setup == true) { - var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '更新 | '; + var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '更新 | '; // if (plugin.versions[n] == '') mupdate = ''; handle = mupdate + '设置 | 卸载'; titleClick = 'onclick="softMain(\'' + plugin.name + '\',\'' + plugin.setup_version + '\')" style="cursor:pointer"'; @@ -160,7 +159,24 @@ function getSList(isdisplay) { },'json'); } -function addVersion(name, ver, type, obj, title) { +function installPreInspection(name, ver, callback){ + var loading = layer.msg('正在检查安装环境...', { icon: 16, time: 0, shade: [0.3, '#000'] }); + $.post("/plugins/run", {'name':name,'version':ver,'func':'install_pre_inspection'}, function(rdata) { + layer.close(loading); + if (rdata.status){ + if (rdata.data == 'ok'){ + callback(); + } else { + layer.msg(rdata.data, { icon: 2 }); + } + } else { + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + } + },'json'); + +} + +function addVersion(name, ver, type, obj, title, install_pre_inspection) { var option = ''; var titlename = name; if (ver.indexOf('|') >= 0){ @@ -194,6 +210,9 @@ function addVersion(name, ver, type, obj, title) { }); $("#bi-btn").click(function() { + + + var info = $("#SelectVersion").val().toLowerCase(); if (info == ''){ info = $("#SelectVersion").text().toLowerCase(); @@ -203,15 +222,33 @@ function addVersion(name, ver, type, obj, title) { var type = $('.fangshi input').prop("checked") ? '1' : '0'; var data = "name=" + name + "&version=" + version + "&type=" + type; + if (install_pre_inspection){ + //安装检查 + installPreInspection(name,version, function(){ + var loadT = layer.msg('正在添加到安装器...', { icon: 16, time: 0, shade: [0.3, '#000'] }); + $.post("/plugins/install", data, function(rdata) { + layer.closeAll(); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); + getSList(); + },'json'); + + installTips(); + fly("bi-btn"); + }); + return; + } + var loadT = layer.msg('正在添加到安装器...', { icon: 16, time: 0, shade: [0.3, '#000'] }); $.post("/plugins/install", data, function(rdata) { layer.closeAll(); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 2 }); getSList(); },'json'); + + installTips(); + fly("bi-btn"); }); - installTips(); - fly("bi-btn"); + } //卸载软件