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

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

View File

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

View File

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

View File

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

View File

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

View File

@ -73,12 +73,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
Template.helper("Moment", Moment);
Template.helper("addons", Config['addons']);
$("#faupload-addon").data("params", function () {
$("#faupload-addon").data("params", function (files, xhr) {
var userinfo = Controller.api.userinfo.get();
return {
uid: userinfo ? userinfo.id : '',
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) {
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;
var addon = data.addon;
var testdata = data.addon.testdata;
@ -213,7 +214,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
});
});
return false;
}, function (data, ret) {
}, function (data, ret, up, file) {
if (ret.msg && ret.msg.match(/(login|登录)/g)) {
return Layer.alert(ret.msg, {
title: __('Warning'),
@ -222,6 +223,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie']
$(".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");
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);
});
});

View File

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

View File

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

View File

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