Bladeren bron

增加检查获取数据上传权限,未获取权限进行上传操作进行提示

HuangKai 1 week geleden
bovenliggende
commit
c4aacf205d
2 gewijzigde bestanden met toevoegingen van 22 en 1 verwijderingen
  1. 21 0
      src/model/AccountAuth.js
  2. 1 1
      src/view/Body.js

+ 21 - 0
src/model/AccountAuth.js

@@ -22,6 +22,7 @@ class AccountAuth {
         this._socket.on('disconnect', this.onDisconnect);
 
         this.authed = false;
+        this.sqlauthed = false;
     }
     
     onConnect = () => {
@@ -37,9 +38,17 @@ class AccountAuth {
             }, (data) => {
                 // console.log("OK, got into login-callback");
                 // console.log(JSON.stringify(data));
+                this.sqlauthed = true;
             }
         );
 
+        setTimeout(() => {
+            console.log("检查获取数据上传权限 ", this.sqlauthed);
+            if(!this.sqlauthed){
+                alert("获取数据上传权限失败!")
+            }
+        }, 5000);
+
         setTimeout(() => {
             let token = localStorage.getItem("user_token");
             if(token){
@@ -223,6 +232,10 @@ class AccountAuth {
     }
 
     cteateMapData(user_id, map_name = 'map'){
+        if(!this.sqlauthed){ 
+            console.log("未获取数据上传权限!");
+            alert("未获取数据上传权限!");
+        }
         var sql = `INSERT INTO 
                     medba.dat_map 
                         (map_name, map_data, user_id, update_time, create_time, map_uuid) 
@@ -247,6 +260,10 @@ class AccountAuth {
     }
 
     updateMapData(data){
+        if(!this.sqlauthed){ 
+            console.log("未获取数据上传权限!");
+            alert("未获取数据上传权限!");
+        }
         var sql = `UPDATE medba.dat_map 
                     SET 
                         map_data  = '${data.map_data}',
@@ -292,6 +309,10 @@ class AccountAuth {
     }
 
     deleteMapData(map_id){
+        if(!this.sqlauthed){ 
+            console.log("未获取数据上传权限!");
+            alert("未获取数据上传权限!");
+        }
         var sql = `DELETE FROM medba.dat_map 
                     WHERE  
                         map_id = ${map_id}`;

+ 1 - 1
src/view/Body.js

@@ -32,7 +32,7 @@ import PubSub from 'pubsub-js';
 import RightPanel from './RightPanel';
 import Row from 'react-bootstrap/Row';
 import Toolbar from './Toolbar';
-import DataReciever from '../model/DataReciever';
+// import DataReciever from '../model/DataReciever';
 // import { LatLng } from 'leaflet';
 
 const LOCATOR_OVERLAY_ID = "mapbox_locator_overlay";