新增插件管理本地安装升级和版本检测

优化前台
优化fieldlist组件
优化上传组件传递参数
优化composer依赖
pull/462/MERGE
Karson 2024-03-26 17:51:30 +08:00
parent e45b435b48
commit d1c240bd91
9 changed files with 43 additions and 13 deletions

View File

@ -230,6 +230,7 @@ class Addon extends Backend
$uid = $this->request->post("uid"); $uid = $this->request->post("uid");
$token = $this->request->post("token"); $token = $this->request->post("token");
$faversion = $this->request->post("faversion"); $faversion = $this->request->post("faversion");
$force = $this->request->post("force");
if (!$uid || !$token) { if (!$uid || !$token) {
throw new Exception(__('Please login and try to install')); throw new Exception(__('Please login and try to install'));
} }
@ -238,7 +239,7 @@ class Addon extends Backend
'token' => $token, 'token' => $token,
'faversion' => $faversion 'faversion' => $faversion
]; ];
$info = Service::local($file, $extend); $info = Service::local($file, $extend, $force);
} catch (AddonException $e) { } catch (AddonException $e) {
$this->result($e->getData(), $e->getCode(), __($e->getMessage())); $this->result($e->getData(), $e->getCode(), __($e->getMessage()));
} catch (Exception $e) { } catch (Exception $e) {

View File

@ -33,6 +33,7 @@ return [
'Store not available tips' => '插件市场暂不可用,是否切换到本地插件?', 'Store not available tips' => '插件市场暂不可用,是否切换到本地插件?',
'Switch to the local' => '切换到本地插件', 'Switch to the local' => '切换到本地插件',
'try to reload' => '重新尝试加载', 'try to reload' => '重新尝试加载',
'Please disable addon first' => '请先禁用插件再进行操作',
'Please disable the add before trying to upgrade' => '请先禁用插件再进行升级', 'Please disable the add before trying to upgrade' => '请先禁用插件再进行升级',
'Please disable the add before trying to uninstall' => '请先禁用插件再进行卸载', 'Please disable the add before trying to uninstall' => '请先禁用插件再进行卸载',
'Login now' => '立即登录', 'Login now' => '立即登录',

View File

@ -167,6 +167,11 @@
</div> </div>
</div> </div>
</script> </script>
<script id="upgradetpl" type="text/html">
<div class="">
<div class=""><%=#__("Upgrade tips", addon['title'])%></div>
</div>
</script>
<script id="conflicttpl" type="text/html"> <script id="conflicttpl" type="text/html">
<div class="alert alert-dismissable alert-danger"> <div class="alert alert-dismissable alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button> <button type="button" class="close" data-dismiss="alert">×</button>

View File

@ -21,7 +21,7 @@
"topthink/think-installer": "^1.0.14", "topthink/think-installer": "^1.0.14",
"topthink/think-queue": "1.1.6", "topthink/think-queue": "1.1.6",
"topthink/think-helper": "^1.0.7", "topthink/think-helper": "^1.0.7",
"karsonzhang/fastadmin-addons": "~1.3.2", "karsonzhang/fastadmin-addons": "~1.4.0",
"overtrue/pinyin": "^3.0", "overtrue/pinyin": "^3.0",
"phpoffice/phpspreadsheet": "1.19", "phpoffice/phpspreadsheet": "1.19",
"overtrue/wechat": "^4.6", "overtrue/wechat": "^4.6",
@ -32,7 +32,11 @@
"txthinking/mailer": "^2.0" "txthinking/mailer": "^2.0"
}, },
"config": { "config": {
"preferred-install": "dist" "preferred-install": "dist",
"allow-plugins": {
"topthink/think-installer": true,
"easywechat-composer/easywechat-composer": true
}
}, },
"repositories": [ "repositories": [
{ {

View File

@ -317,6 +317,10 @@ a:focus {
height: 60px; height: 60px;
line-height: 27px; line-height: 27px;
} }
.navbar-white .navbar-brand {
height: 60px;
line-height: 27px;
}
.navbar-white .navbar-nav > li > a { .navbar-white .navbar-nav > li > a {
height: 60px; height: 60px;
line-height: 27px; line-height: 27px;

View File

@ -73,12 +73,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
Template.helper("Moment", Moment); Template.helper("Moment", Moment);
Template.helper("addons", Config['addons']); Template.helper("addons", Config['addons']);
$("#faupload-addon").data("params", function () { $("#faupload-addon").data("params", function (files, xhr) {
var userinfo = Controller.api.userinfo.get(); var userinfo = Controller.api.userinfo.get();
return { return {
uid: userinfo ? userinfo.id : '', uid: userinfo ? userinfo.id : '',
token: userinfo ? userinfo.token : '', token: userinfo ? userinfo.token : '',
version: Config.faversion version: Config.faversion,
force: (files[0].force || false) ? 1 : 0
}; };
}); });
@ -185,7 +186,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
// 离线安装 // 离线安装
require(['upload'], function (Upload) { require(['upload'], function (Upload) {
Upload.api.upload("#faupload-addon", function (data, ret) { Upload.api.upload("#faupload-addon", function (data, ret, up, file) {
Config['addons'][data.addon.name] = data.addon; Config['addons'][data.addon.name] = data.addon;
var addon = data.addon; var addon = data.addon;
var testdata = data.addon.testdata; var testdata = data.addon.testdata;
@ -213,7 +214,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
}); });
}); });
return false; return false;
}, function (data, ret) { }, function (data, ret, up, file) {
if (ret.msg && ret.msg.match(/(login|登录)/g)) { if (ret.msg && ret.msg.match(/(login|登录)/g)) {
return Layer.alert(ret.msg, { return Layer.alert(ret.msg, {
title: __('Warning'), title: __('Warning'),
@ -222,6 +223,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
$(".btn-userinfo").trigger("click"); $(".btn-userinfo").trigger("click");
} }
}); });
} else if (ret.code === -1) {
Layer.confirm(__('Upgrade tips', data.title), {title: __('Warmtips')}, function (index, layero) {
up.removeFile(file);
file.force = true;
up.uploadFile(file);
Layer.close(index);
});
return false;
} }
}); });
@ -651,7 +660,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
} }
var version = $(this).data("version"); var version = $(this).data("version");
Layer.confirm(__('Upgrade tips', Config['addons'][name].title), function (index, layero) { Layer.confirm(__('Upgrade tips', Config['addons'][name].title), {title: __('Warmtips')}, function (index, layero) {
upgrade(name, version); upgrade(name, version);
}); });
}); });

View File

@ -389,7 +389,7 @@ define(['jquery', 'bootstrap', 'upload', 'validator', 'validator-lang'], functio
fieldlist.on("click", ".btn-append,.append", function (e, row) { fieldlist.on("click", ".btn-append,.append", function (e, row) {
var container = $(this).closest(".fieldlist"); var container = $(this).closest(".fieldlist");
append(container, row); append(container, row);
// refresh(container); refresh(container);
}); });
//移除控制(点击按钮) //移除控制(点击按钮)
fieldlist.on("click", ".btn-remove", function () { fieldlist.on("click", ".btn-remove", function () {

View File

@ -38,7 +38,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
onDomUploadSuccess = Upload.api.custom[onDomUploadSuccess]; onDomUploadSuccess = Upload.api.custom[onDomUploadSuccess];
} }
if (typeof onDomUploadSuccess === 'function') { if (typeof onDomUploadSuccess === 'function') {
var result = onDomUploadSuccess.call(button, data, ret); var result = onDomUploadSuccess.call(button, data, ret, up, file);
if (result === false) if (result === false)
return; return;
} }
@ -46,7 +46,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
} }
if (typeof onUploadSuccess === 'function') { if (typeof onUploadSuccess === 'function') {
var result = onUploadSuccess.call(button, data, ret); var result = onUploadSuccess.call(button, data, ret, up, file);
if (result === false) if (result === false)
return; return;
} }
@ -63,7 +63,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
onDomUploadError = Upload.api.custom[onDomUploadError]; onDomUploadError = Upload.api.custom[onDomUploadError];
} }
if (typeof onDomUploadError === 'function') { if (typeof onDomUploadError === 'function') {
var result = onDomUploadError.call(button, data, ret); var result = onDomUploadError.call(button, data, ret, up, file);
if (result === false) if (result === false)
return; return;
} }
@ -71,7 +71,7 @@ define(['jquery', 'bootstrap', 'dropzone', 'template'], function ($, undefined,
} }
if (typeof onUploadError === 'function') { if (typeof onUploadError === 'function') {
var result = onUploadError.call(button, data, ret); var result = onUploadError.call(button, data, ret, up, file);
if (result === false) { if (result === false) {
return; return;
} }

View File

@ -87,6 +87,12 @@ a {
} }
} }
.navbar-white {
.navbar-brand {
height: 60px;
line-height: 27px;
}
}
.navbar-white .navbar-nav { .navbar-white .navbar-nav {
> li > a { > li > a {
height: 60px; height: 60px;