mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2025-12-12 19:02:49 +00:00
update
This commit is contained in:
parent
5536266962
commit
07767b9d4a
@ -85,6 +85,16 @@ class Addon extends BaseAdminController
|
||||
return success('ADDON_UNINSTALL_SUCCESS');
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件安装环境检测
|
||||
* @param $addon
|
||||
* @return Response
|
||||
*/
|
||||
public function uninstallCheck($addon)
|
||||
{
|
||||
return (new AddonService())->uninstallCheck($addon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件列表
|
||||
* @return Response
|
||||
|
||||
@ -43,6 +43,8 @@ Route::group(function () {
|
||||
//插件类型
|
||||
Route::get('addontype', 'addon.Addon/getType');
|
||||
|
||||
//卸载插件环境检测
|
||||
Route::get('addon/uninstall/check/:addon', 'addon.Addon/uninstallCheck');
|
||||
//卸载插件
|
||||
Route::post('addon/uninstall/:addon', 'addon.Addon/uninstall');
|
||||
//应用列表(...)
|
||||
|
||||
@ -100,6 +100,15 @@ class AddonService extends BaseAdminService
|
||||
return success('SUCCESS', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $addon
|
||||
* @return void
|
||||
*/
|
||||
public function uninstallCheck(string $addon) {
|
||||
$data = ( new CoreAddonInstallService($addon) )->uninstallCheck();
|
||||
return success('SUCCESS', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载插件
|
||||
* @param string $addon
|
||||
|
||||
@ -463,6 +463,43 @@ class CoreAddonInstallService extends CoreAddonBaseService
|
||||
(new CoreAddonCloudService())->cloudBuild($this->addon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件卸载环境检测
|
||||
* @param string $addon
|
||||
* @return void
|
||||
*/
|
||||
public function uninstallCheck() {
|
||||
$data = [
|
||||
// 目录检测
|
||||
'dir' => [
|
||||
// 要求可读权限
|
||||
'is_readable' => [],
|
||||
// 要求可写权限
|
||||
'is_write' => []
|
||||
]
|
||||
];
|
||||
|
||||
// 将要删除的根目录
|
||||
$to_admin_dir = $this->root_path . 'admin' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $this->addon . DIRECTORY_SEPARATOR;
|
||||
$to_web_dir = $this->root_path . 'web' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $this->addon . DIRECTORY_SEPARATOR;
|
||||
$to_wap_dir = $this->root_path . 'uni-app' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $this->addon . DIRECTORY_SEPARATOR;
|
||||
$to_resource_dir = public_path() . 'addon' . DIRECTORY_SEPARATOR . $this->addon . DIRECTORY_SEPARATOR;
|
||||
|
||||
if (is_dir($to_admin_dir)) $data['dir']['is_write'][] = ['dir' => str_replace(project_path(), '', $to_admin_dir), 'status' => is_write($to_admin_dir)];
|
||||
if (is_dir($to_web_dir)) $data['dir']['is_write'][] = ['dir' => str_replace(project_path(), '', $to_web_dir), 'status' => is_write($to_web_dir)];
|
||||
if (is_dir($to_wap_dir)) $data['dir']['is_write'][] = ['dir' => str_replace(project_path(), '', $to_wap_dir), 'status' => is_write($to_wap_dir)];
|
||||
if (is_dir($to_resource_dir)) $data['dir']['is_write'][] = ['dir' => str_replace(project_path(), '', $to_resource_dir), 'status' => is_write($to_resource_dir)];
|
||||
|
||||
$check_res = array_merge(
|
||||
array_column($data['dir']['is_readable'], 'status'),
|
||||
array_column($data['dir']['is_write'], 'status')
|
||||
);
|
||||
|
||||
// 是否通过校验
|
||||
$data['is_pass'] = !in_array(false, $check_res);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 卸载插件
|
||||
* @return true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user