kuaifan 5 年 前
コミット
a7418f27ea

+ 7 - 2
.env.example

@@ -1,4 +1,4 @@
-APP_NAME=Laravel
+APP_NAME=Wookteam
 APP_ENV=local
 APP_KEY=
 APP_DEBUG=true
@@ -9,9 +9,10 @@ LOG_CHANNEL=stack
 DB_CONNECTION=mysql
 DB_HOST=127.0.0.1
 DB_PORT=3306
-DB_DATABASE=laravel
+DB_DATABASE=wookteam
 DB_USERNAME=root
 DB_PASSWORD=
+DB_PREFIX=pre_
 
 BROADCAST_DRIVER=log
 CACHE_DRIVER=file
@@ -44,3 +45,7 @@ PUSHER_APP_CLUSTER=mt1
 
 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
 MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+
+LARAVELS_LISTEN_IP=127.0.0.1
+LARAVELS_LISTEN_PORT=5200
+LARAVELS_PROXY_URL=ws://127.0.0.1:5200/

+ 1 - 0
.gitignore

@@ -14,3 +14,4 @@ Homestead.yaml
 npm-debug.log
 yarn-error.log
 public
+uploads/picture

+ 4 - 2
app/Http/Controllers/Api/ProjectController.php

@@ -1319,6 +1319,7 @@ class ProjectController extends Controller
             $user = $user['data'];
         }
         //
+        $act = trim(Request::input('act'));
         $taskid = intval(Request::input('taskid'));
         $task = Base::DBC2A(DB::table('project_task')
             ->where([
@@ -1334,7 +1335,9 @@ class ProjectController extends Controller
             if (Base::isError($inRes)) {
                 return $inRes;
             }
-            if (!$inRes['data']['isowner'] && $task['username'] != $user['username']) {
+            if (!$inRes['data']['isowner']
+                && $task['username'] != $user['username']
+                && !in_array($act, ['comment', 'attention'])) {
                 return Base::retError('此操作只允许项目管理员或者任务负责人!');
             }
         } else {
@@ -1343,7 +1346,6 @@ class ProjectController extends Controller
             }
         }
         //
-        $act = trim(Request::input('act'));
         $content = trim(Request::input('content'));
         $message = "";
         $upArray = [];

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

@@ -18,22 +18,12 @@ class IndexController extends Controller
 
     private $version = '100000';
 
-    public function __invoke($method, $action = '', $child = '', $name = '')
+    public function __invoke($method, $action = '', $child = '')
     {
         $app = $method ? $method : 'main';
-        if ($app == 'uploads') {
-            $child = $action . '/' . $child . '/' . $name;
-            $action = '';
-        }
         if ($action) {
             $app .= "__" . $action;
         }
-        @error_reporting(E_ALL & ~E_NOTICE);
-        if (Request::input('__Access-Control-Allow-Origin')) {
-            header('Access-Control-Allow-Origin:*');
-            header('Access-Control-Allow-Methods:GET,POST,PUT,DELETE,OPTIONS');
-            header('Access-Control-Allow-Headers:Content-Type, platform, platform-channel, token, release, Access-Control-Allow-Origin');
-        }
         return (method_exists($this, $app)) ? $this->$app($child) : Base::ajaxError("404 not found (" . str_replace("__", "/", $app) . ").");
     }
 

+ 5 - 1
app/Http/Middleware/ApiMiddleware.php

@@ -16,13 +16,17 @@ class ApiMiddleware
      */
     public function handle($request, Closure $next)
     {
-        error_reporting(E_ALL & ~E_NOTICE);
+        global $_A;
+        $_A = [];
+
+        @error_reporting(E_ALL & ~E_NOTICE);
 
         if (Request::input('__Access-Control-Allow-Origin') || Request::header('__Access-Control-Allow-Origin')) {
             header('Access-Control-Allow-Origin:*');
             header('Access-Control-Allow-Methods:GET,POST,PUT,DELETE,OPTIONS');
             header('Access-Control-Allow-Headers:Content-Type, platform, platform-channel, token, release, Access-Control-Allow-Origin');
         }
+
         return $next($request);
     }
 }

+ 3 - 3
app/Module/Base.php

@@ -1613,8 +1613,8 @@ class Base
                 $onlineip = getenv('REMOTE_ADDR');
             } elseif (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] and strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
                 $onlineip = $_SERVER['REMOTE_ADDR'];
-            } elseif (Request::header('X-Real-IP-Swoole-Y3MTXN')) {
-                $onlineip = Request::header('X-Real-IP-Swoole-Y3MTXN');
+            } elseif (Request::header('X-Real-IP')) {
+                $onlineip = Request::header('X-Real-IP');
             } else {
                 $onlineip = '0,0,0,0';
             }
@@ -1975,7 +1975,7 @@ class Base
                 $scaleName = md5_file($file) . $scaleName . '.' . $extension;
             }
             //
-            $file->move($param['path'], $fileName);
+            $file->move(public_path($param['path']), $fileName);
             //
             $array = [
                 "name" => $file->getClientOriginalName(),               //原文件名

+ 6 - 5
app/Module/Users.php

@@ -60,16 +60,17 @@ class Users
 
     /**
      * 临时身份标识
+     * @param int $length
      * @return mixed|string
      */
-    public static function tmpID()
+    public static function tmpID($length = 8)
     {
-        if (strlen(Request::input("tmpid")) == 16) {
+        if (strlen(Request::input("tmpid")) == $length) {
             return Request::input("tmpid");
         }
         $tmpID = Session::get('user::tmpID');
-        if (strlen($tmpID) != 16) {
-            $tmpID = Base::generatePassword(16);
+        if (strlen($tmpID) != $length) {
+            $tmpID = Base::generatePassword($length);
             Session::put('user::tmpID', $tmpID);
         }
         return $tmpID;
@@ -156,7 +157,7 @@ class Users
     }
 
     /**
-     * 用户身份认证, 身份丢失时exit输出(获取用户信息)
+     * 用户身份认证(获取用户信息)
      * @return array|mixed
      */
     public static function authE()

+ 5 - 0
app/Services/WebSocketService.php

@@ -97,6 +97,11 @@ class WebSocketService implements WebSocketHandlerInterface
      */
     public function onMessage(Server $server, Frame $frame)
     {
+        global $_A;
+        $_A = [
+            '__static_langdata' => [],
+        ];
+        //
         $data = Base::json2array($frame->data);
         $feedback = [
             'status' => 1,

+ 4 - 0
resources/assets/js/main/components/ImgUpload.vue

@@ -453,6 +453,10 @@
             handleBeforeUpload () {
                 //上传前判断
                 let check = this.uploadList.length < this.maxNum;
+                if (!check && this.uploadList.length == 1) {
+                    this.handleRemove(this.uploadList[0]);
+                    check = this.uploadList.length < this.maxNum;
+                }
                 if (!check) {
                     this.$Modal.warning({
                         title: this.$L('温馨提示'),

+ 6 - 0
resources/assets/js/main/components/chat/Index.vue

@@ -748,6 +748,12 @@
                 }
             },
 
+            openWindow(val) {
+                if (val) {
+                    $A.WS.connection();
+                }
+            },
+
             unreadTotal(val) {
                 if (val < 0) {
                     this.unreadTotal = 0;

+ 15 - 14
resources/assets/js/main/main.js

@@ -323,14 +323,16 @@ import '../../sass/main.scss';
             __instance: null,
             __connected: false,
             __callbackid: {},
+            __autoNum: 0,
             __autoLine() {
-                let tempId = $A.randomString(16);
-                this.__autoId = tempId;
-                console.log("[WS] Connection auto 30s ...");
+                let tempNum = this.__autoNum;
                 setTimeout(() => {
-                    if (this.__autoId === tempId) {
-                        console.log("[WS] Connection auto ...");
-                        this.connection();
+                    if (tempNum === this.__autoNum) {
+                        this.__autoNum++
+                        this.sendTo('refresh', (res) => {
+                            console.log("[WS] Connection " + (res.status ? 'success' : 'error'));
+                            this.__autoLine();
+                        });
                     }
                 }, 30 * 1000);
             },
@@ -342,12 +344,12 @@ import '../../sass/main.scss';
                 let url = $A.getObject(window.webSocketConfig, 'URL');
                 url += ($A.strExists(url, "?") ? "&" : "?") + "token=" + $A.getToken();
                 if (!$A.leftExists(url, "ws://") && !$A.leftExists(url, "wss://")) {
-                    console.log("[WS] Connection nourl ...");
+                    console.log("[WS] Connection noUrl ...");
                     return;
                 }
 
                 if ($A.getToken() === false) {
-                    console.log("[WS] Connection noid ...");
+                    console.log("[WS] Connection noToken ...");
                     return;
                 }
 
@@ -371,6 +373,7 @@ import '../../sass/main.scss';
                     if (msgDetail.messageType === 'open') {
                         console.log("[WS] Connection connected ...");
                         this.__connected = true;
+                        this.__autoLine();
                     }
                     if (msgDetail.messageType === 'feedback') {
                         typeof this.__callbackid[msgDetail.messageId] === "function" && this.__callbackid[msgDetail.messageId](msgDetail.content);
@@ -385,7 +388,6 @@ import '../../sass/main.scss';
                     console.log("[WS] Connection closed ...");
                     this.__connected = false;
                     this.__instance = null;
-                    this.__autoLine();
                 }
 
                 // 连接出错
@@ -393,7 +395,6 @@ import '../../sass/main.scss';
                     console.log("[WS] Connection error ...");
                     this.__connected = false;
                     this.__instance = null;
-                    this.__autoLine();
                 }
 
                 return this;
@@ -464,9 +465,9 @@ import '../../sass/main.scss';
                     typeof callback === "function" && callback({status: 0, message: '未连接成功'});
                     return;
                 }
-                if (['unread', 'read', 'user', 'team'].indexOf(type) === -1) {
-                    console.log("[WS] 错误的消息类型-" + type);
-                    typeof callback === "function" && callback({status: 0, message: '错误的消息类型-' + type});
+                if (['refresh', 'unread', 'read', 'user', 'team'].indexOf(type) === -1) {
+                    console.log("[WS] 错误的消息类型: " + type);
+                    typeof callback === "function" && callback({status: 0, message: '错误的消息类型: ' + type});
                     return;
                 }
                 let messageId = '';
@@ -499,7 +500,7 @@ import '../../sass/main.scss';
                     return;
                 }
                 this.__instance.close();
-            }
+            },
         }
     });
 

+ 3 - 1
resources/assets/js/main/pages/todo.vue

@@ -358,13 +358,15 @@
             }
         },
         mounted() {
-            this.refreshTask();
             this.userInfo = $A.getUserInfo((res, isLogin) => {
                 if (this.userInfo.id != res.id) {
                     this.userInfo = res;
                     isLogin && this.refreshTask();
                 }
             }, false);
+            if ($A.getToken() !== false) {
+                this.refreshTask();
+            }
             //
             $A.setOnTaskInfoListener('pages/todo',(act, detail) => {
                 if (detail.username != $A.getUserName()) {

+ 7 - 6
routes/web.php

@@ -31,9 +31,10 @@ Route::prefix('api')->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('/{method}/{action}/{child}/{n}',        'IndexController');
-Route::any('/{method}/{action}/{child}/{n}/{c}',    'IndexController');
+Route::middleware(ApiMiddleware::class)->group(function () {
+    Route::any('/',                                 'IndexController');
+    Route::any('/{method}',                         'IndexController');
+    Route::any('/{method}/{action}',                'IndexController');
+    Route::any('/{method}/{action}/{child}',        'IndexController');
+});
+