kuaifan 5 éve
szülő
commit
18abf1f9db

+ 4 - 1
app/Http/Controllers/IndexController.php

@@ -20,7 +20,10 @@ class IndexController extends Controller
         if ($action) {
             $app .= "__" . $action;
         }
-        return (method_exists($this, $app)) ? $this->$app($child) : Base::ajaxError("404 not found (" . str_replace("__", "/", $app) . ").");
+        if (!method_exists($this, $app)) {
+            $app = 'main';
+        }
+        return $this->$app($child);
     }
 
     /**

+ 1 - 1
package.json

@@ -1,5 +1,5 @@
 {
-    "version": "1.4.7",
+    "version": "1.4.8",
     "name": "wookteam",
     "private": true,
     "scripts": {

+ 9 - 35
resources/assets/js/common.js

@@ -658,46 +658,20 @@
         },
 
         /**
-         * hash数组拼接
-         * @param obj
-         * @param filtrate
-         * @returns {*}
-         */
-        hashSplice(obj, filtrate) {
-            if (typeof obj !== 'object') {
-                return obj;
-            }
-            let sObj = Object.keys(obj).sort(),
-                text = "",
-                sFiltrate = "," + filtrate + ",";
-            for (let prop in sObj) {
-                if (sObj.hasOwnProperty(prop)) {
-                    if (!$A.strExists(sFiltrate, "," + sObj[prop] + ",")) {
-                        if (text) text += "&";
-                        text += sObj[prop] + "=" + obj[sObj[prop]];
-                    }
-                }
-            }
-            return text;
-        },
-
-        /**
-         * 指定键获取hash参数
+         * 指定键获取url参数
          * @param key
          * @returns {*}
          */
-        hashParameter(key) {
-            let params = this.hashParameterAll();
-            return params[key];
+        urlParameter(key) {
+            let params = this.urlParameterAll();
+            return typeof key === "undefined" ? params : params[key];
         },
 
-        hashParameterAll() {
-            let hash = location.hash || "";
-            let arr;
-            if (this.strExists(hash, "?")) {
-                arr = this.getMiddle(hash, "?").split("&");
-            }else{
-                arr = this.getMiddle(hash, "#").split("&");
+        urlParameterAll() {
+            let search = window.location.search || "";
+            let arr = [];
+            if (this.strExists(search, "?")) {
+                arr = this.getMiddle(search, "?").split("&");
             }
             let params = {};
             for (let i = 0; i < arr.length; i++) {

+ 29 - 14
resources/assets/js/main/App.vue

@@ -21,25 +21,23 @@
             }
         },
         mounted() {
-            let token = $A.hashParameter("token");
-            if ($A.count(token) > 10) {
-                $.setToken(token);
-                $A.getUserInfo(true);
-                let path = $A.removeURLParameter(window.location.href,'token');
-                if ($A.strExists(path, "#")) {
-                    this.goForward({path: $A.getMiddle(path, '#')}, true);
-                }
-            }
-            //
-            this.sessionStorage('/', 1);
+            this.checkToken();
             //
             let hash = window.location.hash;
             if (hash.indexOf("#") === 0) {
                 hash = hash.substr(1);
-                if (hash !== '/' && this.sessionStorage(hash) === 0) {
-                    this.sessionStorage(hash, this.sessionStorage('::count') + 1);
+                if (hash) {
+                    this.$nextTick(() => {
+                        hash = $A.removeURLParameter(hash, 'token');
+                        this.goForward({path: hash});
+                    });
                 }
             }
+            this.sessionStorage('/', 1);
+            let pathname = window.location.pathname;
+            if (pathname && this.sessionStorage(pathname) === 0) {
+                this.sessionStorage(pathname, this.sessionStorage('::count') + 1);
+            }
             //
             setInterval(() => {
                 this.searchEnter();
@@ -57,10 +55,27 @@
                 if (typeof To.name === 'undefined' || typeof From.name === 'undefined') {
                     return;
                 }
-                this.slideType(To, From)
+                this.slideType(To, From);
             }
         },
         methods: {
+            checkToken() {
+                let token = $A.urlParameter("token");
+                if ($A.count(token) > 10) {
+                    $.setToken(decodeURIComponent(token));
+                    $A.getUserInfo(true);
+                    let path = $A.removeURLParameter(window.location.href, 'token');
+                    let uri = document.createElement('a');
+                    uri.href = path;
+                    if (uri.pathname) {
+                        let query = $A.urlParameterAll();
+                        if (typeof query['token'] !== "undefined") delete query['token'];
+                        this.$nextTick(() => {
+                            this.goForward({path: uri.pathname, query}, true);
+                        });
+                    }
+                }
+            },
             slideType(To, From) {
                 let isBack = this.$router.isBack;
                 this.$router.isBack = false;

+ 2 - 2
resources/assets/js/main/components/WHeader.vue

@@ -428,7 +428,7 @@
             //
             this.tabActive = this.$route.meta.tabActive;
             //
-            if ($A.hashParameter("open") === 'chat' && $A.getToken() !== false) {
+            if ($A.urlParameter("open") === 'chat' && $A.getToken() !== false) {
                 this.chatDrawerShow = true;
             }
         },
@@ -437,7 +437,7 @@
                 this.tabActive = this.$route.meta.tabActive;
                 this.systemDrawerShow = false;
                 this.userDrawerShow = false;
-                if ($A.hashParameter("open") === 'chat' && $A.getToken() !== false) {
+                if ($A.urlParameter("open") === 'chat' && $A.getToken() !== false) {
                     this.chatDrawerShow = true;
                 }
             }

+ 6 - 4
routes/web.php

@@ -32,9 +32,11 @@ Route::prefix('api')->middleware(ApiMiddleware::class)->group(function () {
  * 页面
  */
 Route::middleware(ApiMiddleware::class)->group(function () {
-    Route::any('/',                                 'IndexController');
-    Route::any('/{method}',                         'IndexController');
-    Route::any('/{method}/{action}',                'IndexController');
-    Route::any('/{method}/{action}/{child}',        'IndexController');
+    Route::any('/',                                     'IndexController');
+    Route::any('/{method}',                             'IndexController');
+    Route::any('/{method}/{action}',                    'IndexController');
+    Route::any('/{method}/{action}/{child}',            'IndexController');
+    Route::any('/{method}/{action}/{child}/{n}',        'IndexController');
+    Route::any('/{method}/{action}/{child}/{n}/{c}',    'IndexController');
 });