fixed conflict

This commit is contained in:
jaguarjack 2020-02-21 22:34:33 +08:00
commit 91d4f4a54d
12 changed files with 1264 additions and 598 deletions

View File

@ -1,5 +1,6 @@
## CatchAdmin ## CatchAdmin
- 该项目采用前后端分离,所以 PHP 作为 API 开发vue 作为后台开发,两个项目是分开的,单独部署。 - 该项目采用`前后端分离`,所以 PHP 作为 API 开发vue 作为后台开发
- 两个项目是分开的,单独部署。
## 这是 vue 分支 开发中 ## 这是 vue 分支 开发中
- [vue 项目地址](https://github.com/yanwenwu/catch-admin-vue) - [vue 项目地址](https://github.com/yanwenwu/catch-admin-vue)
@ -37,6 +38,14 @@
请大家不要随意添加数据,因为没有意义,只看 `catchadmin` 的文档就可以了。 请大家不要随意添加数据,因为没有意义,只看 `catchadmin` 的文档就可以了。
如果有太多脏数据的话,我会关闭该账号。 如果有太多脏数据的话,我会关闭该账号。
### 系列文章
如果是刚开始使用 thinkphp6, 以下文章可能会对你有些许帮助,文章基于 RC3 版本。整体架构是不变的。
- [启动分析](https://www.kancloud.cn/akasishikelu/thinkphp6/1129385)
- [Request 解析](https://www.kancloud.cn/akasishikelu/thinkphp6/1134496)
- [应用初始化](https://www.kancloud.cn/akasishikelu/thinkphp6/1130427)
- [中间件分析](https://www.kancloud.cn/akasishikelu/thinkphp6/1136616)
- [请求流程](https://www.kancloud.cn/akasishikelu/thinkphp6/1136608)
### Talking ### Talking
- [论坛讨论](http://bbs.catchadmin.com) - [论坛讨论](http://bbs.catchadmin.com)
- 可以提 ISSUE请按照 issue 模板提问 - 可以提 ISSUE请按照 issue 模板提问

View File

@ -1,4 +1,4 @@
<?php <?php
return [ return [
\catchAdmin\CatchAdminService::class, \catcher\CatchAdminService::class,
]; ];

View File

@ -1,11 +1,4 @@
<?php <?php
# 登陆页面
$router->get('login', '\catchAdmin\login\controller\Index@index');
# 登入 # 登入
$router->post('login', '\catchAdmin\login\controller\Index@login'); $router->post('login', '\catchAdmin\login\controller\Index@login');
# 登出
$router->post('logout', '\catchAdmin\login\controller\Index@logout');
# 验证码
$router->get('catch/captcha/[:config]','\catchAdmin\login\controller\Index@captcha');

View File

@ -23,7 +23,8 @@
"topthink/think-migration": "^3.0", "topthink/think-migration": "^3.0",
"thans/tp-jwt-auth": "^1.0", "thans/tp-jwt-auth": "^1.0",
"workerman/workerman": "^3.5", "workerman/workerman": "^3.5",
"jaguarjack/think-filesystem-cloud": "dev-master" "jaguarjack/think-filesystem-cloud": "dev-master",
"overtrue/wechat": "^4.2"
}, },
"require-dev": { "require-dev": {
"symfony/var-dumper": "^4.2", "symfony/var-dumper": "^4.2",

1191
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,9 @@
<?php <?php
use catchAdmin\login\LoginLogListener;
use catchAdmin\permissions\OperateLogListener;
use catcher\event\LoadModuleRoutes;
return [ return [
/** /**
* set domain if you need * set domain if you need
@ -62,6 +67,31 @@ return [
'upload' => [ 'upload' => [
'image' => 'fileSize:' . 1024 * 1024 * 5 . '|fileExt:jpg,png,gif,jpeg', 'image' => 'fileSize:' . 1024 * 1024 * 5 . '|fileExt:jpg,png,gif,jpeg',
'file' => 'fileSize:' . 1024 * 1024 * 10 . '|fileExt:txt,pdf,xlsx,xls,html' 'file' => 'fileSize:' . 1024 * 1024 * 10 . '|fileExt:txt,pdf,xlsx,xls,html'
] ],
/**
* 路由中间件
*
*/
'route_middleware' => [
\catchAdmin\user\AuthTokenMiddleware::class,
\catchAdmin\permissions\PermissionsMiddleware::class,
],
/**
* 后台事件
*
*/
'events' => [
// 登录日志
'loginLog' => [
LoginLogListener::class,
],
// 操作日志
'operateLog' => [
OperateLogListener::class,
],
// 路由加载
'RouteLoaded' => [
LoadModuleRoutes::class
],
],
]; ];

View File

@ -1,13 +1,6 @@
<?php <?php
namespace catchAdmin; namespace catcher;
use catchAdmin\login\LoginLogListener;
use catchAdmin\permissions\OperateLogListener;
use catchAdmin\permissions\PermissionsMiddleware;
use catchAdmin\system\event\LoginLogEvent;
use catchAdmin\system\event\OperateLogEvent;
use catcher\CatchExceptionHandle;
use catcher\CatchQuery;
use catcher\command\BackupCommand; use catcher\command\BackupCommand;
use catcher\command\CompressPackageCommand; use catcher\command\CompressPackageCommand;
use catcher\command\CreateModuleCommand; use catcher\command\CreateModuleCommand;
@ -19,8 +12,6 @@ use catcher\command\ModelGeneratorCommand;
use catcher\command\ModuleCacheCommand; use catcher\command\ModuleCacheCommand;
use catcher\command\SeedRunCommand; use catcher\command\SeedRunCommand;
use catcher\command\worker\WsWorkerCommand; use catcher\command\worker\WsWorkerCommand;
use catcher\event\LoadModuleRoutes;
use catcher\validates\Sometimes;
use think\exception\Handle; use think\exception\Handle;
use think\facade\Validate; use think\facade\Validate;
use think\Service; use think\Service;
@ -99,9 +90,7 @@ class CatchAdminService extends Service
*/ */
protected function registerMiddleWares(): void protected function registerMiddleWares(): void
{ {
$this->app->middleware->import([ // todo
'catch_check_permission' => PermissionsMiddleware::class,
], 'route');
} }
/** /**
@ -112,20 +101,16 @@ class CatchAdminService extends Service
*/ */
protected function registerListeners(): void protected function registerListeners(): void
{ {
$this->app->event->listenEvents([ $this->app->event->listenEvents(config('catch.events'));
'loginLog' => [
LoginLogListener::class,
],
'operateLog' => [
OperateLogListener::class,
],
'RouteLoaded' => [
LoadModuleRoutes::class
],
]);
} }
protected function registerQuery() /**
* register query
*
* @time 2020年02月20日
* @return void
*/
protected function registerQuery(): void
{ {
$connections = $this->app->config->get('database.connections'); $connections = $this->app->config->get('database.connections');
@ -136,7 +121,13 @@ class CatchAdminService extends Service
], 'database'); ], 'database');
} }
protected function registerExceptionHandle() /**
* register exception
*
* @time 2020年02月20日
* @return void
*/
protected function registerExceptionHandle(): void
{ {
$this->app->bind(Handle::class, CatchExceptionHandle::class); $this->app->bind(Handle::class, CatchExceptionHandle::class);
} }

View File

@ -1,433 +0,0 @@
<?php
namespace catcher;
/**
* Class CatchForm
* @package catcher
*
*
* @method CatchForm text($column, $label = '', $required = false)
* @method CatchForm image($column, $label = '', $required = false)
* @method CatchForm radio($column, $label = '', $required = false)
* @method CatchForm select($column, $label = '', $required = false)
* @method CatchForm textarea($column, $label = '', $required = false)
* @method CatchForm password($column, $label = '', $required = false)
* @method CatchForm hidden($column, $label = '', $required = false)
* @method CatchForm dom($column, $label = '', $required = false)
*
*/
class CatchForm
{
protected $name;
private $fields = [];
protected $action;
protected $method;
protected $enctype;
protected $formId;
protected $btn;
/**
*
* @time 2019年12月10日
* @param $acton
* @return CatchForm
*/
public function action($acton): CatchForm
{
$this->action = $acton;
return $this;
}
/**
*
* @time 2019年12月10日
* @param $method
* @return CatchForm
*/
public function method($method): CatchForm
{
$this->method = $method;
return $this;
}
/**
*
* @time 2019年12月10日
* @param $formId
* @return CatchForm
*/
public function formId($formId): CatchForm
{
$this->formId = $formId;
return $this;
}
/**
*
* @time 2019年12月10日
* @param string $enctype
* @return CatchForm
*/
public function enctype($enctype ="multipart/form-data"): CatchForm
{
$this->enctype = $enctype;
return $this;
}
/**
*
* @time 2019年12月10日
* @param $id
* @return CatchForm
*/
public function id($id): CatchForm
{
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'id' => sprintf('id="%s"', $id),
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @param string $class
* @param string $labelClass
* @param string $inlineClass
* @return CatchForm
*/
public function class($class='', $labelClass = '', $inlineClass = ''): CatchForm
{
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'class' => $class,
'labelClass' => $labelClass,
'inlineClass' => $inlineClass,
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @param array $options
* @return CatchForm
*/
public function options(array $options): CatchForm
{
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'options' => $options,
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @param $value
* @return CatchForm
*/
public function default($value): CatchForm
{
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'default' => $value,
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @return CatchForm
*/
public function disabled(): CatchForm
{
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'disabled' => '',
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @param $content
* @return CatchForm
*/
public function placeholder($content): CatchForm
{
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'placeholder' => 'placeholder='.$content,
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @return CatchForm
*/
public function readonly(): CatchForm
{
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'readonly' => 'readonly',
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @return string
*/
public function render(): string
{
$form = sprintf('<form id="%s" lay-filter="%s" class="layui-form model-form">', $this->formId, $this->formId);
foreach ($this->fields as $field) {
$form .= in_array($field['type'], ['hidden']) ?
$this->{$field['type'].'Field'}($field)
: sprintf($this->baseField(),
$field['labelClass'] ?? '',
$field['label'],
$field['inlineClass'] ?? '',
$this->{$field['type'].'Field'}($field));
}
return $form . $this->btn. '</form>';
}
/**
*
* @time 2019年12月10日
* @param $append
* @return CatchForm
*/
public function append($append): CatchForm
{
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'append' => $append,
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @param $method
* @param $arguments
* @return $this
*/
public function __call($method, $arguments)
{
// TODO: Implement __call() method.
$this->name = $arguments[0] ?? '';
$label = $arguments[1] ?? '';
$required = $arguments[2] ?? false;
$this->fields[$this->name] = [
'name' => $this->name,
'type' => $method,
'label' => $required ? '<i style="color:red">*</i> '.$label : $label,
'inline' => false,
];
return $this;
}
/**
*
* @time 2019年12月10日
* @return CatchForm
*/
protected function inline(): CatchForm
{
$this->fields[] = array_merge($this->fields, [
'inline' => true,
]);
return $this;
}
/**
*
* @time 2019年12月10日
* @return string
*/
private function baseField(): string
{
return
'<div class="layui-form-item">
<label class="layui-form-label%s">%s: </label>
<div class="layui-input-block%s">
%s
</div>
</div>';
}
/**
* form btn
*
* @time 2019年12月06日
* @param $filter
* @param string $position
* @return CatchForm
*/
public function formBtn($filter, $position = 'text-right'): CatchForm
{
$this->btn = sprintf('<div class="layui-form-item %s">
<button class="layui-btn layui-btn-primary" type="button" ew-event="closePageDialog">取消</button>
<button class="layui-btn" lay-filter="%s" lay-submit>保存</button>
</div>', $position, $filter);
return $this;
}
/**
*
* @time 2019年12月10日
* @param $rule
* @param array $equalTo
* @return CatchForm
*/
public function verify($rule, $equalTo = []): CatchForm
{
if (empty($equalTo)) {
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'verify' => sprintf('lay-verType="tips" lay-verify="%s"', $rule),
]);
} else {
[$id, $msg] = $equalTo;
$this->fields[$this->name] = array_merge($this->fields[$this->name], [
'verify' => sprintf(' lay-verType="tips" lay-verify="%s" lay-equalTo="#%s"
lay-equalToText="%s" ', $rule, $id, $msg),
]);
}
return $this;
}
/**
*
* @time 2019年12月10日
* @param $field
* @return string
*/
private function textField($field)
{
return
sprintf('<input name="%s" class="layui-input %s" %s value="%s" type="text" %s %s %s%s>',
$field['name'],
$field['id'] ?? '',
$field['class'] ?? '',
$field['default'] ?? '',
$field['readonly'] ?? '',
$field['placeholder'] ?? '',
$field['disabled'] ?? '',
$field['verify'] ?? ''
);
}
/**
*
* @time 2019年12月10日
* @param $field
* @return string
*/
private function selectField($field)
{
$select = sprintf('<select name="%s" %s>', $field['name'], $field['verify'] ?? '');
$default = $field['default'] ?? '';
foreach ($field['options'] as $key => $option) {
$select .= sprintf('<option value="%s"%s>%s</option>', $option['value'], $default == $key ? ' selected' : '',$option['title']);
}
return $select . '</select>';
}
/**
*
* @time 2019年12月10日
* @param $field
* @return string
*/
private function passwordField($field)
{
return sprintf('<input name="%s" class="layui-input" %s type="password" %s %s>',
$field['name'],
$field['id'] ?? '',
$field['verify'] ?? '',
$field['placeholder'] ?? ''
);
}
private function radioField($field)
{
$radio = '';
foreach ($field['options'] as $option) {
$radio .= sprintf('<input name="%s" type="radio" value="%s" title="%s" %s/>',
$field['name'], $option['value'], $option['title'], $option['value'] == $field['default'] ? 'checked' : ''
);
}
return $radio;
}
/**
*
* @time 2019年12月09日
* @param $field
* @return string
*/
private function textareaField($field): string
{
return sprintf('<textarea name="%s" %s class="layui-textarea">%s</textarea>',
$field['name'],
$field['placeholder'] ?? '',
$field['default'] ?? ''
);
}
private function domField($field)
{
return $field['name'];
}
/**
*
* @time 2019年12月10日
* @param $field
* @return string
*/
private function hiddenField($field): string
{
return sprintf('<input name="%s" value="%s" type="hidden">',
$field['name'], $field['default']
);
}
private function imageField()
{}
}

View File

@ -129,11 +129,17 @@ class InstallCommand extends Command
$prefix = $this->output->ask($this->input, '👉 please input table prefix, default (null):') ? : ''; $prefix = $this->output->ask($this->input, '👉 please input table prefix, default (null):') ? : '';
$username = $this->output->ask($this->input, '👉 please input database username default (root): ') ? : 'root'; $username = $this->output->ask($this->input, '👉 please input database username default (root): ') ? : 'root';
$password = ''; $password = '';
$tryTimes = 0;
while (!$password) { while (!$password) {
$password = $this->output->ask($this->input, '👉 please input database password: '); $password = $this->output->ask($this->input, '👉 please input database password: ');
if ($password) { if ($password) {
break; break;
} }
// 尝试三次以上未填写,视为密码空
$tryTimes++;
if (!$password && $tryTimes > 2) {
break;
}
} }
$this->databaseLink = [$host, $database, $username, $password, $port, $charset, $prefix]; $this->databaseLink = [$host, $database, $username, $password, $port, $charset, $prefix];

View File

@ -3,6 +3,7 @@ declare (strict_types = 1);
namespace catcher\event; namespace catcher\event;
use catchAdmin\permissions\PermissionsMiddleware;
use catchAdmin\user\AuthTokenMiddleware; use catchAdmin\user\AuthTokenMiddleware;
use catcher\CatchAdmin; use catcher\CatchAdmin;
use think\Route; use think\Route;
@ -23,18 +24,20 @@ class LoadModuleRoutes
$routes = CatchAdmin::getRoutes(); $routes = CatchAdmin::getRoutes();
$routeMiddleware = config('catch.route_middleware');
if ($domain) { if ($domain) {
$router->domain($domain, function () use ($router, $routes) { $router->domain($domain, function () use ($router, $routes) {
foreach ($routes as $route) { foreach ($routes as $route) {
include $route; include $route;
} }
})->middleware([AuthTokenMiddleware::class]); })->middleware($routeMiddleware);
} else { } else {
$router->group(function () use ($router, $routes) { $router->group(function () use ($router, $routes) {
foreach ($routes as $route) { foreach ($routes as $route) {
include $route; include $route;
} }
})->middleware([AuthTokenMiddleware::class]); })->middleware($routeMiddleware);
} }
// 单独加载登录 // 单独加载登录

View File

@ -5,4 +5,5 @@
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,PT,L] RewriteRule ^(.*)$ index.php [QSA,PT,L]
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule> </IfModule>