update niucloud

This commit is contained in:
全栈小学生 2023-10-28 12:25:45 +08:00
parent 1b4cf3d88c
commit 699f744183
8 changed files with 59 additions and 20 deletions

View File

@ -15,6 +15,7 @@ use app\dict\addon\AddonDict;
use app\service\admin\addon\AddonService;
use app\service\core\addon\CoreAddonService;
use core\base\BaseAdminController;
use think\App;
use think\facade\Cache;
use think\Response;
@ -72,7 +73,17 @@ class Addon extends BaseAdminController
*/
public function installCheck($addon)
{
return (new AddonService())->installCheck($addon);
return success(data:(new AddonService())->installCheck($addon));
}
/**
* 取消安装
* @param $addon
* @return mixed
*/
public function cancleInstall($addon)
{
return success(data:(new AddonService())->cancleInstall($addon));
}
/**
@ -92,7 +103,7 @@ class Addon extends BaseAdminController
*/
public function uninstallCheck($addon)
{
return (new AddonService())->uninstallCheck($addon);
return success(data:(new AddonService())->uninstallCheck($addon));
}
/**

View File

@ -51,6 +51,8 @@ Route::group(function () {
Route::get('app/list', 'addon.App/getAppList');
//已安装有效应用
Route::get('app/getAddonList', 'addon.Addon/getAddonList');
// 取消安装任务
Route::put('addon/install/cancel/:addon', 'addon.Addon/cancleInstall');
/******************************************************************开发插件 *******************************************************/
//开发插件列表

View File

@ -6,7 +6,7 @@ return [
'menu_type' => 0,
'icon' => 'element-Monitor',
'api_url' => '',
'router_path' => 'app_manage',
'router_path' => 'app_manage',
'view_path' => '',
'methods' => '',
'sort' => 99,
@ -1470,7 +1470,7 @@ return [
'menu_type' => 1,
'icon' => 'iconfont-iconcaidan',
'api_url' => 'sys/menu',
'router_path' => 'admin',
'router_path' => 'menu',
'view_path' => 'auth/menu',
'methods' => 'get',
'sort' => 30,

View File

@ -240,6 +240,10 @@ return [
'ADDON_KEY_IS_EXIST' => '已存在相同插件标识的应用',
'ADDON_IS_INSTALLED_NOT_ALLOW_DEL' => '已安装的插件不允许删除',
'ADDON_ZIP_ERROR' => '插件压缩失败',
'ADMIN_DIR_NOT_EXIST' => '未找到admin源码所在目录',
'WEB_DIR_NOT_EXIST' => '未找到web源码所在目录',
'UNIAPP_DIR_NOT_EXIST' => '未找到uni-app源码所在目录',
// 云服务
'CLOUD_WEAPP_COMPILE_NOT_EXIST' => '未找到微信小程序编译包',

View File

@ -96,8 +96,17 @@ class AddonService extends BaseAdminService
*/
public function installCheck(string $addon)
{
$data = ( new CoreAddonInstallService($addon) )->installCheck();
return success('SUCCESS', $data);
return ( new CoreAddonInstallService($addon) )->installCheck();
}
/**
* 取消安装任务
* @param string $addon
* @return Response
*/
public function cancleInstall(string $addon)
{
return ( new CoreAddonInstallService($addon) )->cancleInstall();
}
/**
@ -105,8 +114,7 @@ class AddonService extends BaseAdminService
* @return void
*/
public function uninstallCheck(string $addon) {
$data = ( new CoreAddonInstallService($addon) )->uninstallCheck();
return success('SUCCESS', $data);
return ( new CoreAddonInstallService($addon) )->uninstallCheck();
}
/**

View File

@ -122,6 +122,10 @@ class CoreAddonInstallService extends CoreAddonBaseService
$to_resource_dir = public_path() . 'addon' . DIRECTORY_SEPARATOR . $this->addon . DIRECTORY_SEPARATOR;
if (!is_dir($this->root_path . 'admin' . DIRECTORY_SEPARATOR)) throw new CommonException('ADMIN_DIR_NOT_EXIST');
if (!is_dir($this->root_path . 'web' . DIRECTORY_SEPARATOR)) throw new CommonException('WEB_DIR_NOT_EXIST');
if (!is_dir($this->root_path . 'uni-app' . DIRECTORY_SEPARATOR)) throw new CommonException('UNIAPP_DIR_NOT_EXIST');
// 配置文件
$package_path = $this->install_addon_path . 'package' . DIRECTORY_SEPARATOR;
$package_file = [];
@ -145,10 +149,10 @@ class CoreAddonInstallService extends CoreAddonBaseService
if (is_dir($from_wap_dir)) $data['dir']['is_readable'][] = ['dir' => str_replace(project_path(), '', $from_wap_dir), 'status' => is_readable($from_wap_dir)];
if (is_dir($from_resource_dir)) $data['dir']['is_readable'][] = ['dir' => str_replace(project_path(), '', $from_resource_dir), 'status' => is_readable($from_resource_dir)];
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)];
$data['dir']['is_write'][] = ['dir' => str_replace(project_path(), '', $to_admin_dir), 'status' => is_dir($to_admin_dir) ? is_write($to_admin_dir) : mkdir($to_admin_dir, 0777, true)];
$data['dir']['is_write'][] = ['dir' => str_replace(project_path(), '', $to_web_dir), 'status' => is_dir($to_web_dir) ? is_write($to_web_dir) : mkdir($to_web_dir, 0777, true)];
$data['dir']['is_write'][] = ['dir' => str_replace(project_path(), '', $to_wap_dir), 'status' => is_dir($to_wap_dir) ? is_write($to_wap_dir) : mkdir($to_wap_dir, 0777, true)];
$data['dir']['is_write'][] = ['dir' => str_replace(project_path(), '', $to_resource_dir), 'status' => is_dir($to_resource_dir) ? is_write($to_resource_dir) : mkdir($to_resource_dir, 0777, true)];
$check_res = array_merge(
array_column($data['dir']['is_readable'], 'status'),
@ -204,10 +208,10 @@ class CoreAddonInstallService extends CoreAddonBaseService
foreach ($install_step as $step) {
$this->install_task['step'][] = $step;
$this->$step();
if ($step != 'handleAddonInstall') Cache::set('install_task', $this->install_task);
}
if ($mode == 'cloud') {
Cache::set('install_task', $this->install_task);
} else {
if ($mode != 'cloud') {
// 配置文件
$package_path = $this->install_addon_path . 'package' . DIRECTORY_SEPARATOR;
$package_file = [];
@ -246,11 +250,20 @@ class CoreAddonInstallService extends CoreAddonBaseService
@$this->uninstallWap();
}
if ($install_task['mode'] == 'cloud') {
$this->revertFrontendBackup();
if (in_array('backupFrontend', $install_task['step'])) {
@$this->revertFrontendBackup();
}
Cache::set('install_task', null);
Cache::set($this->cache_key . '_install_check', null);
}
/**
* 取消安装任务
* @return void
*/
public function cancleInstall() {
if (Cache::get('install_task')) $this->installExceptionHandle();
}
/**
@ -399,6 +412,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
}
// 清除插件安装中标识
Cache::delete('install_task');
Cache::delete($this->cache_key . '_install_check');
return true;
}

View File

@ -63,7 +63,7 @@ class CorePayChannelService extends BaseCoreService
$pay_type_list = PayDict::getPayType($temp_channel_pay_list);
}
$pay_type_list = array_values(array_filter(event('AllowPayTypeByTrade', [ 'channel' => $channel, 'trade_type' => $trade_type, 'pay_type_list' => $pay_type_list ])))[ 0 ] ?? [];
$pay_type_list = array_values(array_filter(event('AllowPayTypeByTrade', [ 'channel' => $channel, 'trade_type' => $trade_type, 'pay_type_list' => $pay_type_list ])))[ 0 ] ?? $pay_type_list;
// 线下支付做处理
if (!empty($pay_type_list) && isset($pay_type_list[ PayDict::OFFLINEPAY ])) {
$temp_channel_pay_list = array_column($channel_pay_list, null, 'type');

View File

@ -77,7 +77,7 @@ class Local extends BaseUpload
public function base64(string $content, ?string $key = null)
{
mkdirs_or_notexist($key);
mkdirs_or_notexist(dirname($key));
file_put_contents(url_to_path($key), base64_decode($content));
return true;
}
@ -214,4 +214,4 @@ class Local extends BaseUpload
return $file_path;
}
}
}
}