remove static files
This commit is contained in:
parent
c908243e79
commit
bff987c68f
|
|
@ -15,7 +15,7 @@ use Beike\Models\Plugin;
|
||||||
use Beike\Plugin\Manager;
|
use Beike\Plugin\Manager;
|
||||||
use Beike\Plugin\Plugin as BPlugin;
|
use Beike\Plugin\Plugin as BPlugin;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Http\File;
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
class PluginRepo
|
class PluginRepo
|
||||||
{
|
{
|
||||||
|
|
@ -53,19 +53,20 @@ class PluginRepo
|
||||||
$path = $bPlugin->getPath();
|
$path = $bPlugin->getPath();
|
||||||
$staticPath = $path . '/static';
|
$staticPath = $path . '/static';
|
||||||
if (is_dir($staticPath)) {
|
if (is_dir($staticPath)) {
|
||||||
\Illuminate\Support\Facades\File::copyDirectory($staticPath, public_path('plugin/' . $code));
|
File::copyDirectory($staticPath, public_path('plugin/' . $code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从系统卸载插件: 删除数据
|
* 从系统卸载插件: 删除数据
|
||||||
* @param $plugin
|
* @param BPlugin $bPlugin
|
||||||
*/
|
*/
|
||||||
public static function uninstallPlugin($plugin)
|
public static function uninstallPlugin(BPlugin $bPlugin)
|
||||||
{
|
{
|
||||||
$type = $plugin->type;
|
self::removeStaticFiles($bPlugin);
|
||||||
$code = $plugin->code;
|
$type = $bPlugin->type;
|
||||||
|
$code = $bPlugin->code;
|
||||||
Plugin::query()
|
Plugin::query()
|
||||||
->where('type', $type)
|
->where('type', $type)
|
||||||
->where('code', $code)
|
->where('code', $code)
|
||||||
|
|
@ -73,6 +74,21 @@ class PluginRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 public 删除静态资源
|
||||||
|
* @param BPlugin $bPlugin
|
||||||
|
*/
|
||||||
|
public static function removeStaticFiles(BPlugin $bPlugin)
|
||||||
|
{
|
||||||
|
$code = $bPlugin->code;
|
||||||
|
$path = $bPlugin->getPath();
|
||||||
|
$staticPath = $path . '/static';
|
||||||
|
if (is_dir($staticPath)) {
|
||||||
|
File::deleteDirectory(public_path('plugin/' . $code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断插件是否安装
|
* 判断插件是否安装
|
||||||
*
|
*
|
||||||
|
|
@ -86,6 +102,11 @@ class PluginRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有已安装插件列表
|
||||||
|
*
|
||||||
|
* @return Plugin[]|Collection
|
||||||
|
*/
|
||||||
public static function allPlugins()
|
public static function allPlugins()
|
||||||
{
|
{
|
||||||
if (self::$installedPlugins !== null) {
|
if (self::$installedPlugins !== null) {
|
||||||
|
|
@ -109,7 +130,7 @@ class PluginRepo
|
||||||
/**
|
/**
|
||||||
* 获取所有配送方式
|
* 获取所有配送方式
|
||||||
*/
|
*/
|
||||||
public static function getShippingMethods()
|
public static function getShippingMethods(): Collection
|
||||||
{
|
{
|
||||||
$allPlugins = self::allPlugins();
|
$allPlugins = self::allPlugins();
|
||||||
return $allPlugins->where('type', 'shipping')->filter(function ($item) {
|
return $allPlugins->where('type', 'shipping')->filter(function ($item) {
|
||||||
|
|
@ -125,7 +146,7 @@ class PluginRepo
|
||||||
/**
|
/**
|
||||||
* 获取所有支付方式
|
* 获取所有支付方式
|
||||||
*/
|
*/
|
||||||
public static function getPaymentMethods()
|
public static function getPaymentMethods(): Collection
|
||||||
{
|
{
|
||||||
$allPlugins = self::allPlugins();
|
$allPlugins = self::allPlugins();
|
||||||
return $allPlugins->where('type', 'payment')->filter(function ($item) {
|
return $allPlugins->where('type', 'payment')->filter(function ($item) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue