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,7 +15,8 @@
|
||||
{{/if}}
|
||||
<!-- operation end -->
|
||||
|
||||
{{if !empty($data_list)}}
|
||||
{{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>
|
||||
@ -28,7 +29,7 @@
|
||||
</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}}
|
||||
{{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}}">
|
||||
@ -63,7 +64,9 @@
|
||||
{{/if}}
|
||||
{{/foreach}}
|
||||
</ul>
|
||||
{{/if}}
|
||||
|
||||
{{if !empty($data_list['dir_data'])}}
|
||||
<!-- 未安装 -->
|
||||
<div class="am-text-center am-margin-top-lg am-margin-bottom-xs middle-divider">
|
||||
<strong>
|
||||
@ -73,9 +76,8 @@
|
||||
</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}}
|
||||
{{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}}">
|
||||
@ -102,10 +104,6 @@
|
||||
{{/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">
|
||||
@ -128,6 +126,11 @@
|
||||
</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">
|
||||
<i class="am-icon-warning"></i> 还没有相关应用
|
||||
|
@ -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,13 +891,13 @@ php;
|
||||
{
|
||||
return DataReturn('应用配置文件没有操作权限'.'['.$config_file.']', -3);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
// 创建配置文件
|
||||
if(@file_put_contents($config_file, JsonFormat($data)) === false)
|
||||
{
|
||||
return DataReturn('应用配置文件创建失败', -10);
|
||||
}
|
||||
}
|
||||
|
||||
return DataReturn('操作成功', 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user