Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ken678 committed Nov 28, 2024
2 parents f99b643 + 8878e55 commit f0a7d0c
Show file tree
Hide file tree
Showing 15 changed files with 180 additions and 126 deletions.
2 changes: 1 addition & 1 deletion app/admin/command/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ protected function execute(Input $input, Output $output)
$selectpageTable = substr($field, 0, strripos($field, '_'));
$selectpageField = '';
$selectpageController = str_replace('_', '.', $selectpageTable);
$attrArr['data-source'] = "admin/" . $selectpageController . "/index";
$attrArr['data-source'] = $selectpageController . "/index";
//如果是类型表需要特殊处理下
if ($selectpageController == 'admin') {
$attrArr['data-source'] = 'auth.manager/index';
Expand Down
4 changes: 2 additions & 2 deletions config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// +----------------------------------------------------------------------

return [
"yzncms_name" => "YznCMS内容管理系统", //产品名称
"yzncms_release" => 2024050401, //产品更新日期
"yzncms_name" => "YznCMS内容管理系统", //产品名称
"yzncms_release" => 2024112801, //产品更新日期
"yzncms_version" => "2.0.0", //产品版本号
];
2 changes: 1 addition & 1 deletion vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
'think\\trace\\' => array($vendorDir . '/topthink/think-trace/src'),
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/yzncms/think-addons/src'),
'think\\' => array($vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/yzncms/think-addons/src', $vendorDir . '/topthink/framework/src/think'),
'app\\' => array($baseDir . '/app'),
'addons\\' => array($baseDir . '/addons'),
'Yansongda\\Supports\\' => array($vendorDir . '/yansongda/supports/src'),
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ class ComposerStaticInitffa28be83109a2839afb98404bc826b6
),
'think\\' =>
array (
0 => __DIR__ . '/..' . '/topthink/framework/src/think',
1 => __DIR__ . '/..' . '/topthink/think-helper/src',
2 => __DIR__ . '/..' . '/topthink/think-orm/src',
3 => __DIR__ . '/..' . '/topthink/think-template/src',
4 => __DIR__ . '/..' . '/yzncms/think-addons/src',
0 => __DIR__ . '/..' . '/topthink/think-helper/src',
1 => __DIR__ . '/..' . '/topthink/think-orm/src',
2 => __DIR__ . '/..' . '/topthink/think-template/src',
3 => __DIR__ . '/..' . '/yzncms/think-addons/src',
4 => __DIR__ . '/..' . '/topthink/framework/src/think',
),
'app\\' =>
array (
Expand Down
14 changes: 7 additions & 7 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1521,17 +1521,17 @@
},
{
"name": "topthink/framework",
"version": "v8.1.0",
"version_normalized": "8.1.0.0",
"version": "v8.1.1",
"version_normalized": "8.1.1.0",
"source": {
"type": "git",
"url": "https://github.com/top-think/framework.git",
"reference": "d51fd2b96a8a5d030e08b4976dc6029684ad4403"
"reference": "d301115ea77f33745b8d6659c74740c34fe53e9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/top-think/framework/zipball/d51fd2b96a8a5d030e08b4976dc6029684ad4403",
"reference": "d51fd2b96a8a5d030e08b4976dc6029684ad4403",
"url": "https://api.github.com/repos/top-think/framework/zipball/d301115ea77f33745b8d6659c74740c34fe53e9b",
"reference": "d301115ea77f33745b8d6659c74740c34fe53e9b",
"shasum": ""
},
"require": {
Expand All @@ -1552,7 +1552,7 @@
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^9.5"
},
"time": "2024-11-21T05:43:58+00:00",
"time": "2024-11-26T05:57:55+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
Expand Down Expand Up @@ -1584,7 +1584,7 @@
],
"support": {
"issues": "https://github.com/top-think/framework/issues",
"source": "https://github.com/top-think/framework/tree/v8.1.0"
"source": "https://github.com/top-think/framework/tree/v8.1.1"
},
"install-path": "../topthink/framework"
},
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'c0f2929ac7bd3c9063b76b7440ff42ddbc4a0186',
'reference' => '25f620484de78bbb9b5badb9926ef7fbce0234a7',
'name' => 'topthink/think',
'dev' => true,
),
Expand Down Expand Up @@ -233,12 +233,12 @@
'dev_requirement' => true,
),
'topthink/framework' => array(
'pretty_version' => 'v8.1.0',
'version' => '8.1.0.0',
'pretty_version' => 'v8.1.1',
'version' => '8.1.1.0',
'type' => 'library',
'install_path' => __DIR__ . '/../topthink/framework',
'aliases' => array(),
'reference' => 'd51fd2b96a8a5d030e08b4976dc6029684ad4403',
'reference' => 'd301115ea77f33745b8d6659c74740c34fe53e9b',
'dev_requirement' => false,
),
'topthink/think' => array(
Expand All @@ -247,7 +247,7 @@
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'reference' => 'c0f2929ac7bd3c9063b76b7440ff42ddbc4a0186',
'reference' => '25f620484de78bbb9b5badb9926ef7fbce0234a7',
'dev_requirement' => false,
),
'topthink/think-captcha' => array(
Expand Down
2 changes: 1 addition & 1 deletion vendor/services.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2024-11-25 17:40:58
// This file is automatically generated at:2024-11-27 10:25:39
declare (strict_types = 1);
return array (
0 => 'think\\captcha\\CaptchaService',
Expand Down
13 changes: 7 additions & 6 deletions vendor/topthink/framework/src/think/Validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -1720,15 +1720,16 @@ protected function getDefaultRegexRule(string $rule): string

/**
* 获取错误信息
* @param string $field 验证字段
* @param bool $withKey 是否包含字段信息
* @return array|string
*/
public function getError(?string $field = null)
public function getError(bool $withKey = false)
{
if ($field) {
return $this->error[$field] ?? '';
}
return $this->error;
if ($withKey || count($this->error) > 1 ) {
// 批量验证
return $this->error;
}
return empty($this->error) ? '' : array_values($this->error)[0];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion vendor/topthink/framework/src/think/response/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function output($data): string
* @param string $name 模板变量
* @return mixed
*/
public function getVars(string $name = null)
public function getVars(?string $name = null)
{
if (is_null($name)) {
return $this->vars;
Expand Down
102 changes: 102 additions & 0 deletions vendor/topthink/framework/src/think/route/Dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
namespace think\route;

use Psr\Http\Message\ResponseInterface;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use think\App;
use think\Container;
use think\exception\HttpException;
use think\Request;
use think\Response;
use think\Validate;
Expand Down Expand Up @@ -133,6 +137,104 @@ protected function getActionBindVars(): array
};
}

/**
* 执行中间件调度
* @access public
* @param object $controller 控制器实例
* @return void
*/
protected function responseWithMiddlewarePipeline($instance, $action)
{
// 注册控制器中间件
$this->registerControllerMiddleware($instance);
return $this->app->middleware->pipeline('controller')
->send($this->request)
->then(function () use ($instance, $action) {
// 获取当前操作名
$suffix = $this->rule->config('action_suffix');
$action = $action . $suffix;

if (is_callable([$instance, $action])) {
$vars = $this->getActionBindVars();
try {
$reflect = new ReflectionMethod($instance, $action);
// 严格获取当前操作方法名
$actionName = $reflect->getName();
if ($suffix) {
$actionName = substr($actionName, 0, -strlen($suffix));
}

$this->request->setAction($actionName);
} catch (ReflectionException $e) {
$reflect = new ReflectionMethod($instance, '__call');
$vars = [$action, $vars];
$this->request->setAction($action);
}
} else {
// 操作不存在
throw new HttpException(404, 'method not exists:' . $instance::class . '->' . $action . '()');
}

$data = $this->app->invokeReflectMethod($instance, $reflect, $vars);

return $this->autoResponse($data);
});
}

/**
* 使用反射机制注册控制器中间件
* @access public
* @param object $controller 控制器实例
* @return void
*/
protected function registerControllerMiddleware($controller): void
{
$class = new ReflectionClass($controller);

if ($class->hasProperty('middleware')) {
$reflectionProperty = $class->getProperty('middleware');
$reflectionProperty->setAccessible(true);

$middlewares = $reflectionProperty->getValue($controller);
$action = $this->request->action(true);

foreach ($middlewares as $key => $val) {
if (!is_int($key)) {
$middleware = $key;
$options = $val;
} elseif (isset($val['middleware'])) {
$middleware = $val['middleware'];
$options = $val['options'] ?? [];
} else {
$middleware = $val;
$options = [];
}

if (isset($options['only']) && !in_array($action, $this->parseActions($options['only']))) {
continue;
} elseif (isset($options['except']) && in_array($action, $this->parseActions($options['except']))) {
continue;
}

if (is_string($middleware) && str_contains($middleware, ':')) {
$middleware = explode(':', $middleware);
if (count($middleware) > 1) {
$middleware = [$middleware[0], array_slice($middleware, 1)];
}
}

$this->app->middleware->controller($middleware);
}
}
}

protected function parseActions($actions)
{
return array_map(function ($item) {
return strtolower($item);
}, is_string($actions) ? explode(',', $actions) : $actions);
}

/**
* 路由绑定模型实例
* @access protected
Expand Down
4 changes: 4 additions & 0 deletions vendor/topthink/framework/src/think/route/RuleGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ public function auto(string $bind = '', string | array $middleware = '')
public function class(string $class)
{
$this->bind = '\\' . $class;
$this->prefix('\\' . $class . '@');
return $this;
}

Expand All @@ -430,6 +431,7 @@ public function class(string $class)
public function controller(string $controller)
{
$this->bind = '@' . $controller;
$this->prefix($controller . '/');
return $this;
}

Expand All @@ -442,6 +444,7 @@ public function controller(string $controller)
public function namespace(string $namespace)
{
$this->bind = ':' . $namespace;
$this->prefix($namespace . '\\');
return $this;
}

Expand All @@ -454,6 +457,7 @@ public function namespace(string $namespace)
public function layer(string $layer)
{
$this->bind = '/' . $layer;
$this->prefix($layer . '/');
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion vendor/topthink/framework/src/think/route/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ protected function parseUrl(string $url, string | bool &$domain): string
$path = explode('/', $url);
$action = array_pop($path);
$controller = empty($path) ? $controller : array_pop($path);
$url = str_replace('.', '/', $controller) . '/' . $action;
$url = $controller . '/' . $action;
$auto = $this->route->getName('__think_auto_route__');
if (!empty($auto) && !strpos($controller,'.')) {
$module = empty($path) ? $request->layer() : array_pop($path);
Expand Down
40 changes: 38 additions & 2 deletions vendor/topthink/framework/src/think/route/dispatch/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
// +----------------------------------------------------------------------
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------
declare(strict_types=1);
declare (strict_types = 1);

namespace think\route\dispatch;

use think\exception\ClassNotFoundException;
use think\route\Dispatch;

/**
Expand All @@ -22,8 +23,43 @@ class Callback extends Dispatch
public function exec()
{
// 执行回调方法
$vars = $this->getActionBindVars();
if (is_array($this->dispatch)) {
[$class, $action] = $this->dispatch;

// 设置当前请求的控制器、操作
$controllerLayer = $this->rule->config('controller_layer') ?: 'controller';
if (str_contains($class, '\\' . $controllerLayer . '\\')) {
[$layer, $controller] = explode('/' . $controllerLayer . '/', trim(str_replace('\\', '/', $class), '/'));
$layer = trim(str_replace('app', '', $layer), '/');
} else {
$layer = '';
$controller = trim(str_replace('\\', '/', $class), '/');
}

if ($layer && !empty($this->option['auto_middleware'])) {
// 自动为顶层layer注册中间件
$alias = $this->app->config->get('middleware.alias', []);

if (isset($alias[$layer])) {
$this->app->middleware->add($layer, 'route');
}
}

$this->request
->setLayer($layer)
->setController($controller)
->setAction($action);

if (class_exists($class)) {
$instance = $this->app->invokeClass($class);
} else {
throw new ClassNotFoundException('class not exists:' . $class, $class);
}

return $this->responseWithMiddlewarePipeline($instance, $action);
}

$vars = $this->getActionBindVars();
return $this->app->invoke($this->dispatch, $vars);
}
}
Loading

0 comments on commit f0a7d0c

Please sign in to comment.