Browse Source

ComposerUpdate&接口增加header获取token

Anyon 4 năm trước cách đây
mục cha
commit
624f924251

+ 8 - 6
app/data/controller/api/Auth.php

@@ -31,24 +31,26 @@ abstract class Auth extends Controller
      */
     protected $member;
 
-    /**
-     * 控制器初始化
-     */
     protected function initialize()
     {
-        $this->token = input('token', '');
+        $this->token = $this->request->request('token', '');
+        if (empty($this->token)) {
+            $this->token = $this->request->header('token', '');
+        }
+        if (empty($this->token)) {
+            $this->error('请求令牌不能为空!');
+        }
         $this->member = $this->getMember();
         $this->mid = $this->member['id'];
     }
 
     /**
      * 获取会员数据
-     * @return array
+     * @return array|void
      */
     protected function getMember()
     {
         try {
-            if (empty($this->token)) $this->error('请求令牌不能为空!');
             return UserService::instance()->get(['token' => $this->token]);
         } catch (HttpResponseException $exception) {
             throw $exception;

+ 2 - 2
vendor/composer/autoload_classmap.php

@@ -300,8 +300,8 @@ return array(
     'think\\admin\\helper\\SaveHelper' => $vendorDir . '/zoujingli/think-library/src/helper/SaveHelper.php',
     'think\\admin\\helper\\TokenHelper' => $vendorDir . '/zoujingli/think-library/src/helper/TokenHelper.php',
     'think\\admin\\helper\\ValidateHelper' => $vendorDir . '/zoujingli/think-library/src/helper/ValidateHelper.php',
-    'think\\admin\\multiple\\App' => $vendorDir . '/zoujingli/think-library/src/multiple/App.php',
-    'think\\admin\\multiple\\Url' => $vendorDir . '/zoujingli/think-library/src/multiple/Url.php',
+    'think\\admin\\multiple\\BuildUrl' => $vendorDir . '/zoujingli/think-library/src/multiple/BuildUrl.php',
+    'think\\admin\\multiple\\Multiple' => $vendorDir . '/zoujingli/think-library/src/multiple/Multiple.php',
     'think\\admin\\multiple\\command\\Build' => $vendorDir . '/zoujingli/think-library/src/multiple/command/Build.php',
     'think\\admin\\multiple\\command\\Clear' => $vendorDir . '/zoujingli/think-library/src/multiple/command/Clear.php',
     'think\\admin\\service\\AdminService' => $vendorDir . '/zoujingli/think-library/src/service/AdminService.php',

+ 2 - 2
vendor/composer/autoload_static.php

@@ -428,8 +428,8 @@ class ComposerStaticInit33b66ed99ea8fcca84c95dfb0e7ed409
         'think\\admin\\helper\\SaveHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/SaveHelper.php',
         'think\\admin\\helper\\TokenHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/TokenHelper.php',
         'think\\admin\\helper\\ValidateHelper' => __DIR__ . '/..' . '/zoujingli/think-library/src/helper/ValidateHelper.php',
-        'think\\admin\\multiple\\App' => __DIR__ . '/..' . '/zoujingli/think-library/src/multiple/App.php',
-        'think\\admin\\multiple\\Url' => __DIR__ . '/..' . '/zoujingli/think-library/src/multiple/Url.php',
+        'think\\admin\\multiple\\BuildUrl' => __DIR__ . '/..' . '/zoujingli/think-library/src/multiple/BuildUrl.php',
+        'think\\admin\\multiple\\Multiple' => __DIR__ . '/..' . '/zoujingli/think-library/src/multiple/Multiple.php',
         'think\\admin\\multiple\\command\\Build' => __DIR__ . '/..' . '/zoujingli/think-library/src/multiple/command/Build.php',
         'think\\admin\\multiple\\command\\Clear' => __DIR__ . '/..' . '/zoujingli/think-library/src/multiple/command/Clear.php',
         'think\\admin\\service\\AdminService' => __DIR__ . '/..' . '/zoujingli/think-library/src/service/AdminService.php',

+ 4 - 4
vendor/composer/installed.json

@@ -893,12 +893,12 @@
         "source": {
             "type": "git",
             "url": "https://github.com/zoujingli/ThinkLibrary.git",
-            "reference": "cfde47e55fbe2a0d6efb9a7aff91a5c1b11cdfa3"
+            "reference": "c5846d13a516a982f94b4d28ead23b515bd0fafc"
         },
         "dist": {
             "type": "zip",
-            "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cfde47e55fbe2a0d6efb9a7aff91a5c1b11cdfa3",
-            "reference": "cfde47e55fbe2a0d6efb9a7aff91a5c1b11cdfa3",
+            "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/c5846d13a516a982f94b4d28ead23b515bd0fafc",
+            "reference": "c5846d13a516a982f94b4d28ead23b515bd0fafc",
             "shasum": "",
             "mirrors": [
                 {
@@ -915,7 +915,7 @@
             "ext-mbstring": "*",
             "topthink/framework": "^6.0"
         },
-        "time": "2020-10-23T06:18:33+00:00",
+        "time": "2020-10-26T02:07:54+00:00",
         "type": "library",
         "extra": {
             "think": {

+ 1 - 1
vendor/services.php

@@ -1,5 +1,5 @@
 <?php 
-// This file is automatically generated at:2020-10-24 10:57:42
+// This file is automatically generated at:2020-10-26 10:23:32
 declare (strict_types = 1);
 return array (
   0 => 'think\\admin\\Library',

+ 4 - 4
vendor/zoujingli/think-library/src/Library.php

@@ -19,10 +19,10 @@ use think\admin\command\Database;
 use think\admin\command\Install;
 use think\admin\command\Queue;
 use think\admin\command\Version;
-use think\admin\multiple\App;
 use think\admin\multiple\command\Build;
 use think\admin\multiple\command\Clear;
-use think\admin\multiple\Url;
+use think\admin\multiple\Multiple;
+use think\admin\multiple\BuildUrl;
 use think\admin\service\AdminService;
 use think\admin\service\SystemService;
 use think\middleware\LoadLangPack;
@@ -50,14 +50,14 @@ class Library extends Service
     {
         // 多应用中间键处理
         $this->app->event->listen('HttpRun', function (Request $request) {
-            $this->app->middleware->add(App::class);
+            $this->app->middleware->add(Multiple::class);
             // 解决 HTTP 调用 Console 之后 URL 问题
             if (!$this->app->request->isCli()) {
                 $request->setHost($request->host());
             }
         });
         // 替换 ThinkPHP 地址
-        $this->app->bind('think\route\Url', Url::class);
+        $this->app->bind('think\route\Url', BuildUrl::class);
         // 替换 ThinkPHP 指令
         $this->commands(['build' => Build::class, 'clear' => Clear::class]);
         // 注册 ThinkAdmin 指令

+ 14 - 29
vendor/zoujingli/think-library/src/multiple/Url.php → vendor/zoujingli/think-library/src/multiple/BuildUrl.php

@@ -17,55 +17,46 @@ declare (strict_types=1);
 namespace think\admin\multiple;
 
 use think\helper\Str;
+use think\route\Url;
 
 /**
- * 多应用URL生成与解析
- * Class Url
+ * 多应用 URL 生成与解析
+ * Class BuildUrl
  * @package think\admin\multiple
  */
-class Url extends \think\route\Url
+class BuildUrl extends Url
 {
     /**
-     * 直接解析URL地址
-     * @access protected
+     * 直接解析 URL 地址
      * @param string $url URL
-     * @param string|bool $domain Domain
+     * @param string|boolean $domain Domain
      * @return string
      */
     protected function parseUrl(string $url, &$domain): string
     {
         $request = $this->app->request;
         if (0 === strpos($url, '/')) {
-            // 直接作为路由地址解析
             $url = substr($url, 1);
         } elseif (false !== strpos($url, '\\')) {
-            // 解析到类
             $url = ltrim(str_replace('\\', '/', $url), '/');
         } elseif (0 === strpos($url, '@')) {
-            // 解析到控制器
             $url = substr($url, 1);
         } elseif ('' === $url) {
             $url = $this->app->http->getName() . '/' . $request->controller() . '/' . $request->action();
         } else {
-            // 解析到 应用/控制器/操作
-            $controller = $request->controller();
-            $app = $this->app->http->getName();
             $path = explode('/', $url);
             $action = array_pop($path);
-            $controller = empty($path) ? $controller : array_pop($path);
-            $app = empty($path) ? $app : array_pop($path);
+            $controller = empty($path) ? $request->controller() : array_pop($path);
+            $app = empty($path) ? $this->app->http->getName() : array_pop($path);
             $url = Str::snake($controller) . '/' . $action;
             $bind = $this->app->config->get('app.domain_bind', []);
             if ($key = array_search($app, $bind)) {
                 isset($bind[$_SERVER['SERVER_NAME']]) && $domain = $_SERVER['SERVER_NAME'];
                 $domain = is_bool($domain) ? $key : $domain;
+            } elseif ($key = array_search($app, $this->app->config->get('app.app_map', []))) {
+                $url = $key . '/' . $url;
             } else {
-                $map = $this->app->config->get('app.app_map', []);
-                if ($key = array_search($app, $map)) {
-                    $url = $key . '/' . $url;
-                } else {
-                    $url = $app . '/' . $url;
-                }
+                $url = $app . '/' . $url;
             }
         }
         return $url;
@@ -103,26 +94,20 @@ class Url extends \think\route\Url
             }
         }
         if ($url) {
-            $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '');
             $checkDomain = $domain && is_string($domain) ? $domain : null;
+            $checkName = isset($name) ? $name : $url . (isset($info['query']) ? '?' . $info['query'] : '');
             $rule = $this->route->getName($checkName, $checkDomain);
             if (empty($rule) && isset($info['query'])) {
                 $rule = $this->route->getName($url, $checkDomain);
-                // 解析地址里面参数 合并到 vars
                 parse_str($info['query'], $params);
                 $vars = array_merge($params, $vars);
                 unset($info['query']);
             }
         }
         if (!empty($rule) && $match = $this->getRuleUrl($rule, $vars, $domain)) {
-            // 匹配路由命名标识
             $url = $match[0];
-            if ($domain && !empty($match[1])) {
-                $domain = $match[1];
-            }
-            if (!is_null($match[2])) {
-                $suffix = $match[2];
-            }
+            if ($domain && !empty($match[1])) $domain = $match[1];
+            if (!is_null($match[2])) $suffix = $match[2];
             if (!$this->app->http->isBind()) {
                 $url = $this->app->http->getName() . '/' . $url;
             }

+ 8 - 8
vendor/zoujingli/think-library/src/multiple/App.php → vendor/zoujingli/think-library/src/multiple/Multiple.php

@@ -17,20 +17,21 @@ declare (strict_types=1);
 namespace think\admin\multiple;
 
 use Closure;
+use think\App;
 use think\exception\HttpException;
 use think\Request;
 use think\Response;
 
 /**
  * 多应用支持组件
- * Class App
+ * Class Multiple
  * @package think\admin\multiple
  */
-class App
+class Multiple
 {
     /**
      * 应用实例
-     * @var \think\App
+     * @var App
      */
     protected $app;
 
@@ -48,9 +49,9 @@ class App
 
     /**
      * App constructor.
-     * @param \think\App $app
+     * @param App $app
      */
-    public function __construct(\think\App $app)
+    public function __construct(App $app)
     {
         $this->app = $app;
         $this->name = $this->app->http->getName();
@@ -93,13 +94,12 @@ class App
             $this->app->http->setBind();
         } else {
             // 自动多应用识别
-            $this->app->http->setBind(false);
             $appName = null;
+            $this->app->http->setBind(false);
             $bind = $this->app->config->get('app.domain_bind', []);
             if (!empty($bind)) {
-                // 获取当前子域名
-                $subDomain = $this->app->request->subDomain();
                 $domain = $this->app->request->host(true);
+                $subDomain = $this->app->request->subDomain();
                 if (isset($bind[$domain])) {
                     $appName = $bind[$domain];
                     $this->app->http->setBind();