删除冗余代码&修复bug

This commit is contained in:
JaguarJack
2020-07-14 17:35:16 +08:00
parent fc93826016
commit 8a901e89cb
6 changed files with 39 additions and 55 deletions

View File

@@ -1,10 +1,13 @@
<?php
namespace catchAdmin\permissions\model;
use catchAdmin\permissions\model\search\JobsSearch;
use catcher\base\CatchModel;
class Job extends CatchModel
{
use JobsSearch;
protected $name = 'jobs';
protected $field = [

View File

@@ -54,7 +54,7 @@ class CatchAdmin
*/
public static function cacheDirectory(): string
{
return self::makeDirectory(app()->getRuntimePath() . self::NAME . DIRECTORY_SEPARATOR);
return self::makeDirectory(app()->getRuntimePath() . self::$root . DIRECTORY_SEPARATOR);
}
/**
@@ -139,6 +139,7 @@ class CatchAdmin
/**
*
* @time 2019年12月12日
* @param bool $select
* @return array
*/
public static function getModulesInfo($select = true): array

View File

@@ -1,53 +1,7 @@
<?php
namespace catcher\base;
use catcher\CatchAdmin;
abstract class CatchController
{
/**public function __construct()
{
$this->loadConfig();
}*/
/**
*
*
* @time 2019年12月15日
* @return void
*/
protected function loadConfig(): void
{
$module = explode('\\', get_class($this))[1];
$moduleConfig = CatchAdmin::moduleDirectory($module) . 'config.php';
if (file_exists(CatchAdmin::moduleDirectory($module) . 'config.php')) {
app()->config->load($moduleConfig);
}
}
/**
*
* @time 2019年12月13日
* @param $name
* @param $value
* @return void
*/
public function __set($name, $value)
{
// TODO: Implement __set() method.
$this->{$name} = $value;
}
public function __get($name)
{
// TODO: Implement __get() method.
}
public function __isset($name)
{
// TODO: Implement __isset() method.
}
}

View File

@@ -3,6 +3,8 @@ namespace catcher\generate\factory;
use catcher\exceptions\FailedException;
use catcher\generate\template\Model as Template;
use catcher\Utils;
use Phinx\Util\Util;
use think\facade\Db;
use think\helper\Str;
@@ -52,7 +54,7 @@ class Model extends Factory
}
$content = $template->useTrait($extra['soft_delete']) .
$template->name($table) .
$template->name(str_replace(Utils::tablePrefix(), '', $table)) .
$template->field($this->parseField($table));
$class = $template->header() .

View File

@@ -4,9 +4,11 @@ namespace catcher\library;
use catcher\CatchAdmin;
use catcher\exceptions\FailedException;
use catcher\facade\Http;
use Doctrine\DBAL\Types\DateImmutableType;
use GuzzleHttp\Client;
use GuzzleHttp\TransferStats;
use Psr\Http\Message\ResponseInterface;
use function GuzzleHttp\Psr7\str;
use function GuzzleHttp\Psr7\stream_for;
class Compress
@@ -34,19 +36,41 @@ class Compress
throw new FailedException(sprintf('module 【%s】not found~', $moduleName));
}
// 获取模块内的所有文件
$files = $this->getFilesFromDir(CatchAdmin::directory() . $moduleName);
$packageZip = new \ZipArchive();
// zip 打包位置 默认打包在 catch 目录下
$zipPath = $zipPath ? : CatchAdmin::directory() . $moduleName . '.zip';
$this->dirToZip(CatchAdmin::directory() . $moduleName, $zipPath);
return true;
}
/**
* 打包 dir
*
* @time 2020年07月13日
* @param $dir
* @param $zipPath
* @return bool
*/
public function dirToZip($dir, $zipPath)
{
$packageZip = new \ZipArchive();
$files = $this->getFilesFromDir($dir);
$packageZip->open($zipPath, \ZipArchive::CREATE);
$packageZip->addEmptyDir($moduleName);
// 获取 dir 目录作为 zip 的根目录
$d = explode(DIRECTORY_SEPARATOR, rtrim($dir, DIRECTORY_SEPARATOR));
$packageZip->addEmptyDir(array_pop($d));
foreach ($files as $file) {
$baseName = basename($file);
$localName = str_replace([CatchAdmin::directory(), $baseName], ['', ''], $file);
$localName = str_replace([implode(DIRECTORY_SEPARATOR, $d), $baseName], ['', ''], $file);
$packageZip->addFile($file, $localName . $baseName);
}
$packageZip->close();
return true;