mirror of
https://gitee.com/zongzhige/shopxo.git
synced 2024-11-30 02:49:03 +08:00
应用管理优化
This commit is contained in:
parent
6a6d77181d
commit
e4032fc250
@ -94,9 +94,9 @@ class Pluginsadmin extends Common
|
||||
{
|
||||
// 获取数据
|
||||
$ret = PluginsAdminService::PluginsList();
|
||||
if(!empty($ret['data']) && is_array($ret['data']))
|
||||
if(!empty($ret['data']['db_data']) || !empty($ret['data']['dir_data']))
|
||||
{
|
||||
$data = array_column($ret['data'], null, 'plugins');
|
||||
$data = array_column(array_merge($ret['data']['db_data'], $ret['data']['dir_data']), null, 'plugins');
|
||||
if(isset($data[$params['id']]))
|
||||
{
|
||||
$data = $data[$params['id']];
|
||||
|
@ -15,118 +15,121 @@
|
||||
{{/if}}
|
||||
<!-- operation end -->
|
||||
|
||||
{{if !empty($data_list)}}
|
||||
<!-- 操作提示 -->
|
||||
<div class="am-alert">
|
||||
<p>1 列表排序方式[ 自定义排序 -> 最早安装 ]</p>
|
||||
<p>
|
||||
<span>2. 可点击拖动图标按钮调整插件调用和展示顺序</span>
|
||||
<button type="button" class="am-btn am-btn-success am-radius am-btn-xs am-margin-left-xs am-icon-sort-numeric-asc submit-move-sort-open"> 开启排序</button>
|
||||
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-margin-left-xs am-icon-check submit-move-sort-save am-hide"> 保存</button>
|
||||
<button type="button" class="am-btn am-btn-danger am-radius am-btn-xs am-margin-left-xs am-icon-close submit-move-sort-cancel am-hide"> 取消</button>
|
||||
</p>
|
||||
</div>
|
||||
<!-- 已安装 -->
|
||||
<ul data-am-widget="gallery" class="am-gallery am-avg-sm-1 am-avg-md-2 am-avg-lg-3 am-gallery-bordered already-install" data-am-gallery="{}" data-sort-save-url="{{:MyUrl('admin/pluginsadmin/sortsave')}}">
|
||||
{{foreach $data_list as $v}}
|
||||
{{if isset($v['is_install']) and $v['is_install'] eq 1}}
|
||||
<li data-id="{{$v.id}}" data-plugins="{{$v.plugins}}">
|
||||
<div class="am-gallery-item {{if $v['is_enable'] eq 0}}am-active{{/if}}" id="data-list-{{$v.plugins}}">
|
||||
<img src="{{$v.logo}}" class="icon" />
|
||||
<div class="base">
|
||||
<h3 class="name">{{$v.name}}</h3>
|
||||
<p>作者:{{$v.author}}</p>
|
||||
<p>主页:<a href="{{$v.author_url}}" target="_blank">{{$v.author_url}}</a></p>
|
||||
<p>版本:{{$v.version}}</p>
|
||||
{{if !empty($data_list['db_data']) and !empty($data_list['dir_data'])}}
|
||||
{{if !empty($data_list['db_data'])}}
|
||||
<!-- 操作提示 -->
|
||||
<div class="am-alert">
|
||||
<p>1 列表排序方式[ 自定义排序 -> 最早安装 ]</p>
|
||||
<p>
|
||||
<span>2. 可点击拖动图标按钮调整插件调用和展示顺序</span>
|
||||
<button type="button" class="am-btn am-btn-success am-radius am-btn-xs am-margin-left-xs am-icon-sort-numeric-asc submit-move-sort-open"> 开启排序</button>
|
||||
<button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs am-margin-left-xs am-icon-check submit-move-sort-save am-hide"> 保存</button>
|
||||
<button type="button" class="am-btn am-btn-danger am-radius am-btn-xs am-margin-left-xs am-icon-close submit-move-sort-cancel am-hide"> 取消</button>
|
||||
</p>
|
||||
</div>
|
||||
<!-- 已安装 -->
|
||||
<ul data-am-widget="gallery" class="am-gallery am-avg-sm-1 am-avg-md-2 am-avg-lg-3 am-gallery-bordered already-install" data-am-gallery="{}" data-sort-save-url="{{:MyUrl('admin/pluginsadmin/sortsave')}}">
|
||||
{{foreach $data_list['db_data'] as $v}}
|
||||
{{if isset($v['is_install']) and $v['is_install'] eq 1}}
|
||||
<li data-id="{{$v.id}}" data-plugins="{{$v.plugins}}">
|
||||
<div class="am-gallery-item {{if $v['is_enable'] eq 0}}am-active{{/if}}" id="data-list-{{$v.plugins}}">
|
||||
<img src="{{$v.logo}}" class="icon" />
|
||||
<div class="base">
|
||||
<h3 class="name">{{$v.name}}</h3>
|
||||
<p>作者:{{$v.author}}</p>
|
||||
<p>主页:<a href="{{$v.author_url}}" target="_blank">{{$v.author_url}}</a></p>
|
||||
<p>版本:{{$v.version}}</p>
|
||||
</div>
|
||||
<div class="am-gallery-desc">{{$v.desc}}</div>
|
||||
<div class="operation">
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/saveinfo', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit" title="编辑"></a>
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-download" title="打包"></a>
|
||||
{{/if}}
|
||||
|
||||
<a href="javascript:;" data-set-url="{{:PluginsAdminUrl($v['plugins'], 'admin', 'index')}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-gear plugins-set-event" title="设置"></a>
|
||||
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-circle-o submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/uninstall')}}" data-id="{{$v.plugins}}" data-view="reload" data-msg="卸载可能会丢失插件基础配置数据不可恢复、确认操作吗?" title="卸载"></button>
|
||||
|
||||
<a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_enable'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/pluginsadmin/statusupdate')}}" data-id="{{$v.plugins}}" data-state="{{$v['is_enable']}}" data-is-update-status="1" title="状态"></a>
|
||||
|
||||
{{if isset($v['is_home']) and $v['is_home'] eq true}}
|
||||
<a href="{{:PluginsHomeUrl($v['plugins'], 'index', 'index')}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-home" title="首页" target="_blank"></a>
|
||||
{{/if}}
|
||||
|
||||
<button type="button" class="am-btn am-btn-secondary am-btn-xs am-radius am-icon-arrows submit-move am-hide" title="排序"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-gallery-desc">{{$v.desc}}</div>
|
||||
<div class="operation">
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/saveinfo', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit" title="编辑"></a>
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-download" title="打包"></a>
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
<a href="javascript:;" data-set-url="{{:PluginsAdminUrl($v['plugins'], 'admin', 'index')}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-gear plugins-set-event" title="设置"></a>
|
||||
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-circle-o submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/uninstall')}}" data-id="{{$v.plugins}}" data-view="reload" data-msg="卸载可能会丢失插件基础配置数据不可恢复、确认操作吗?" title="卸载"></button>
|
||||
{{if !empty($data_list['dir_data'])}}
|
||||
<!-- 未安装 -->
|
||||
<div class="am-text-center am-margin-top-lg am-margin-bottom-xs middle-divider">
|
||||
<strong>
|
||||
<i class="am-icon-angle-double-down"></i>
|
||||
<span class="am-text-lg am-margin-horizontal-xs">以下插件未安装</span>
|
||||
<i class="am-icon-angle-double-down"></i>
|
||||
</strong>
|
||||
<hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-top-0" />
|
||||
</div>
|
||||
<ul data-am-widget="gallery" class="am-gallery am-avg-sm-1 am-avg-md-2 am-avg-lg-3 am-gallery-bordered" data-am-gallery="{}" data-sort-save-url="{{:MyUrl('admin/pluginsadmin/sortsave')}}">
|
||||
{{foreach $data_list['dir_data'] as $v}}
|
||||
{{if !isset($v['is_install']) or $v['is_install'] eq 0}}
|
||||
<li data-id="{{$v.id}}" data-plugins="{{$v.plugins}}">
|
||||
<div class="am-gallery-item am-active" id="data-list-{{$v.plugins}}">
|
||||
<img src="{{$v.logo}}" class="icon" />
|
||||
<div class="base">
|
||||
<h3 class="name">{{$v.name}}</h3>
|
||||
<p>作者:{{$v.author}}</p>
|
||||
<p>主页:<a href="{{$v.author_url}}" target="_blank">{{$v.author_url}}</a></p>
|
||||
<p>版本:{{$v.version}}</p>
|
||||
</div>
|
||||
<div class="am-gallery-desc">{{$v.desc}}</div>
|
||||
<div class="operation">
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/saveinfo', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit" title="编辑"></a>
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-download" title="打包"></a>
|
||||
{{/if}}
|
||||
|
||||
<a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_enable'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:MyUrl('admin/pluginsadmin/statusupdate')}}" data-id="{{$v.plugins}}" data-state="{{$v['is_enable']}}" data-is-update-status="1" title="状态"></a>
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-remove submit-delete-modal" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="{{$v.plugins}}" title="删除"></button>
|
||||
|
||||
{{if isset($v['is_home']) and $v['is_home'] eq true}}
|
||||
<a href="{{:PluginsHomeUrl($v['plugins'], 'index', 'index')}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-home" title="首页" target="_blank"></a>
|
||||
{{/if}}
|
||||
|
||||
<button type="button" class="am-btn am-btn-secondary am-btn-xs am-radius am-icon-arrows submit-move am-hide" title="排序"></button>
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-cubes submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/install')}}" data-id="{{$v.plugins}}" data-view="reload" data-msg="进行安装操作、确认继续吗?" title="安装"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
|
||||
<!-- 未安装 -->
|
||||
<div class="am-text-center am-margin-top-lg am-margin-bottom-xs middle-divider">
|
||||
<strong>
|
||||
<i class="am-icon-angle-double-down"></i>
|
||||
<span class="am-text-lg am-margin-horizontal-xs">以下插件未安装</span>
|
||||
<i class="am-icon-angle-double-down"></i>
|
||||
</strong>
|
||||
<hr data-am-widget="divider" class="am-divider am-divider-dashed am-margin-top-0" />
|
||||
</div>
|
||||
|
||||
<ul data-am-widget="gallery" class="am-gallery am-avg-sm-1 am-avg-md-2 am-avg-lg-3 am-gallery-bordered" data-am-gallery="{}" data-sort-save-url="{{:MyUrl('admin/pluginsadmin/sortsave')}}">
|
||||
{{foreach $data_list as $v}}
|
||||
{{if !isset($v['is_install']) or $v['is_install'] eq 0}}
|
||||
<li data-id="{{$v.id}}" data-plugins="{{$v.plugins}}">
|
||||
<div class="am-gallery-item am-active" id="data-list-{{$v.plugins}}">
|
||||
<img src="{{$v.logo}}" class="icon" />
|
||||
<div class="base">
|
||||
<h3 class="name">{{$v.name}}</h3>
|
||||
<p>作者:{{$v.author}}</p>
|
||||
<p>主页:<a href="{{$v.author_url}}" target="_blank">{{$v.author_url}}</a></p>
|
||||
<p>版本:{{$v.version}}</p>
|
||||
</div>
|
||||
<div class="am-gallery-desc">{{$v.desc}}</div>
|
||||
<div class="operation">
|
||||
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/saveinfo', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-edit" title="编辑"></a>
|
||||
<a href="{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-download" title="打包"></a>
|
||||
{{/if}}
|
||||
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-remove submit-delete-modal" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="{{$v.plugins}}" title="删除"></button>
|
||||
|
||||
<button class="am-btn am-btn-default am-btn-xs am-radius am-icon-cubes submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/install')}}" data-id="{{$v.plugins}}" data-view="reload" data-msg="进行安装操作、确认继续吗?" title="安装"></button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
<div class="am-padding-vertical-xl am-text-center">
|
||||
<a href="{{$store_url}}" class="am-margin-left-xs">去应用商店挑选更多插件丰富站点 >></a>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 删除弹层 -->
|
||||
<div class="am-modal am-modal-no-btn" tabindex="-1" id="plugins-delete-modal">
|
||||
<div class="am-modal-dialog">
|
||||
<div class="am-modal-hd">
|
||||
<a href="javascript: void(0)" class="am-close" data-am-modal-close>×</a>
|
||||
</div>
|
||||
<div class="am-modal-bd am-margin-top-sm">
|
||||
<div class="am-alert am-text-left" data-am-alert>
|
||||
<p>1. 仅删除应用<span class="am-text-warning">(仅删除应用代码,保留应用数据)</span></p>
|
||||
<p>2. 删除应用并删除数据<span class="am-text-warning">(将删除应用代码和应用数据)</span></p>
|
||||
<!-- 删除弹层 -->
|
||||
<div class="am-modal am-modal-no-btn" tabindex="-1" id="plugins-delete-modal">
|
||||
<div class="am-modal-dialog">
|
||||
<div class="am-modal-hd">
|
||||
<a href="javascript: void(0)" class="am-close" data-am-modal-close>×</a>
|
||||
</div>
|
||||
<p class="am-text-danger am-margin-top">PS:以下操作后均不可恢复,请谨慎操作!</p>
|
||||
<div class="am-margin-top-sm">
|
||||
<button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-circle-o submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="0" data-value="1" data-view="reload" data-msg="删除后不可恢复、确认操作吗?" title="删除"> 删除应用和数据</button>
|
||||
<button class="am-btn am-btn-warning am-btn-xs am-radius am-icon-remove submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="0" data-value="0" data-view="reload" data-msg="删除后不可恢复、确认操作吗?" title="删除"> 仅删除应用</button>
|
||||
<div class="am-modal-bd am-margin-top-sm">
|
||||
<div class="am-alert am-text-left" data-am-alert>
|
||||
<p>1. 仅删除应用<span class="am-text-warning">(仅删除应用代码,保留应用数据)</span></p>
|
||||
<p>2. 删除应用并删除数据<span class="am-text-warning">(将删除应用代码和应用数据)</span></p>
|
||||
</div>
|
||||
<p class="am-text-danger am-margin-top">PS:以下操作后均不可恢复,请谨慎操作!</p>
|
||||
<div class="am-margin-top-sm">
|
||||
<button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-circle-o submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="0" data-value="1" data-view="reload" data-msg="删除后不可恢复、确认操作吗?" title="删除"> 删除应用和数据</button>
|
||||
<button class="am-btn am-btn-warning am-btn-xs am-radius am-icon-remove submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="0" data-value="0" data-view="reload" data-msg="删除后不可恢复、确认操作吗?" title="删除"> 仅删除应用</button>
|
||||
|
||||
<button class="am-btn am-btn-success am-btn-xs am-radius am-icon-reply" data-am-modal-close> 再考虑一下</button>
|
||||
<button class="am-btn am-btn-success am-btn-xs am-radius am-icon-reply" data-am-modal-close> 再考虑一下</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="am-padding-vertical-xl am-text-center">
|
||||
<a href="{{$store_url}}" class="am-margin-left-xs">去应用商店挑选更多插件丰富站点 >></a>
|
||||
</div>
|
||||
{{else /}}
|
||||
<div class="table-no">
|
||||
|
@ -47,13 +47,14 @@ class PluginsAdminService
|
||||
$data = [];
|
||||
$db_data = [];
|
||||
$dir_data = [];
|
||||
$temp_data = [];
|
||||
$plugins_dir = APP_PATH.'plugins'.DS;
|
||||
if(is_dir($plugins_dir))
|
||||
{
|
||||
if($dh = opendir($plugins_dir))
|
||||
{
|
||||
// 获取数据库已安装插件
|
||||
$db_data = Db::name('Plugins')->order(self::$plugins_order_by)->column('*', 'plugins');
|
||||
$temp_data = Db::name('Plugins')->order(self::$plugins_order_by)->column('*', 'plugins');
|
||||
|
||||
// 获取目录所有插件
|
||||
while(($temp_file = readdir($dh)) !== false)
|
||||
@ -66,7 +67,7 @@ class PluginsAdminService
|
||||
{
|
||||
// 获取数据库配置信息
|
||||
$base = $config['base'];
|
||||
$db_config = array_key_exists($base['plugins'], $db_data) ? $db_data[$base['plugins']] : [];
|
||||
$db_config = array_key_exists($base['plugins'], $temp_data) ? $temp_data[$base['plugins']] : [];
|
||||
|
||||
// 数据组装
|
||||
$dir_data[$base['plugins']] = [
|
||||
@ -95,22 +96,22 @@ class PluginsAdminService
|
||||
}
|
||||
|
||||
// 存在插件和数据库插件数据则处理排序合并
|
||||
if(!empty($dir_data) && !empty($db_data))
|
||||
if(!empty($dir_data) && !empty($temp_data))
|
||||
{
|
||||
$temp_data = [];
|
||||
foreach($db_data as $v)
|
||||
foreach($temp_data as $v)
|
||||
{
|
||||
if(array_key_exists($v['plugins'], $dir_data))
|
||||
{
|
||||
$temp_data[] = $dir_data[$v['plugins']];
|
||||
$db_data[] = $dir_data[$v['plugins']];
|
||||
unset($dir_data[$v['plugins']]);
|
||||
}
|
||||
}
|
||||
$data = array_merge($temp_data, array_values($dir_data));
|
||||
} else {
|
||||
$data = array_values($dir_data);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'db_data' => $db_data,
|
||||
'dir_data' => array_values($dir_data),
|
||||
];
|
||||
return DataReturn('处理成功', 0, $data);
|
||||
}
|
||||
|
||||
@ -890,12 +891,12 @@ php;
|
||||
{
|
||||
return DataReturn('应用配置文件没有操作权限'.'['.$config_file.']', -3);
|
||||
}
|
||||
} else {
|
||||
// 创建配置文件
|
||||
if(@file_put_contents($config_file, JsonFormat($data)) === false)
|
||||
{
|
||||
return DataReturn('应用配置文件创建失败', -10);
|
||||
}
|
||||
}
|
||||
|
||||
// 创建配置文件
|
||||
if(@file_put_contents($config_file, JsonFormat($data)) === false)
|
||||
{
|
||||
return DataReturn('应用配置文件创建失败', -10);
|
||||
}
|
||||
|
||||
return DataReturn('操作成功', 0);
|
||||
|
Loading…
Reference in New Issue
Block a user