Xiaopeng Zhang hai 3 meses
pai
achega
79c02ef250
Modificáronse 12 ficheiros con 229 adicións e 91 borrados
  1. 44 9
      src/AI.js
  2. 10 4
      src/AIService.js
  3. 11 10
      src/App2.js
  4. 10 2
      src/AuthService.js
  5. 3 2
      src/Djcs3.js
  6. 50 12
      src/Home2.js
  7. 3 2
      src/Qufei.js
  8. 4 2
      src/Rcjhz.js
  9. 17 8
      src/Service.js
  10. 15 2
      src/Signin.js
  11. 59 36
      src/SimpleService.js
  12. 3 2
      src/Zjcs2.js

+ 44 - 9
src/AI.js

@@ -1,8 +1,9 @@
 import * as React from 'react';
 import * as React from 'react';
-
+import Menu from '@mui/material/Menu';
 import AIService from './AIService';
 import AIService from './AIService';
 import Service from './Service';
 import Service from './Service';
 import SimpleService from './SimpleService';
 import SimpleService from './SimpleService';
+import AuthService from './AuthService';
 import {useNavigate, useLocation} from "react-router";
 import {useNavigate, useLocation} from "react-router";
 import ArrowRightIcon from '@rsuite/icons/ArrowRight';
 import ArrowRightIcon from '@rsuite/icons/ArrowRight';
 import ArrowDownIcon from '@rsuite/icons/ArrowDown';
 import ArrowDownIcon from '@rsuite/icons/ArrowDown';
@@ -263,7 +264,7 @@ export default function AI() {
 
 
     React.useEffect(
     React.useEffect(
       () => {
       () => {
-         AIService.statistics("").then(x=>{
+         AIService.statistics("", navigate).then(x=>{
           let t = [];
           let t = [];
           for (let i = 1; i < x.length; i++) {
           for (let i = 1; i < x.length; i++) {
             t.push({label: x[i][0], value: x[i][1]});
             t.push({label: x[i][0], value: x[i][1]});
@@ -405,7 +406,7 @@ export default function AI() {
     } else if (lb == '建筑与装饰工程') {
     } else if (lb == '建筑与装饰工程') {
       //console.log('建筑与装饰工程');
       //console.log('建筑与装饰工程');
       setCjloading(true);
       setCjloading(true);
-      AIService.statistics("建筑与装饰工程").then(x=>{
+      AIService.statistics("建筑与装饰工程", navigate).then(x=>{
         let t = [];
         let t = [];
           for (let i = 1; i < x.length; i++) {
           for (let i = 1; i < x.length; i++) {
             t.push({label: x[i][0], value: x[i][1]});
             t.push({label: x[i][0], value: x[i][1]});
@@ -417,7 +418,7 @@ export default function AI() {
    
    
     } else if (lb == '仿古建筑') {
     } else if (lb == '仿古建筑') {
       setCjloading(true);
       setCjloading(true);
-      AIService.statistics("仿古建筑").then(x=>{
+      AIService.statistics("仿古建筑", navigate).then(x=>{
         let t = [];
         let t = [];
           for (let i = 1; i < x.length; i++) {
           for (let i = 1; i < x.length; i++) {
             t.push({label: x[i][0], value: x[i][1]});
             t.push({label: x[i][0], value: x[i][1]});
@@ -428,7 +429,7 @@ export default function AI() {
     
     
     } else if (lb == '安装工程') {
     } else if (lb == '安装工程') {
       setCjloading(true);
       setCjloading(true);
-      AIService.statistics("安装工程").then(x=>{
+      AIService.statistics("安装工程", navigate).then(x=>{
         let t = [];
         let t = [];
           for (let i = 1; i < x.length; i++) {
           for (let i = 1; i < x.length; i++) {
             t.push({label: x[i][0], value: x[i][1]});
             t.push({label: x[i][0], value: x[i][1]});
@@ -440,7 +441,7 @@ export default function AI() {
    
    
     } else if (lb == '市政工程') {
     } else if (lb == '市政工程') {
       setCjloading(true);
       setCjloading(true);
-      AIService.statistics("市政工程").then(x=>{
+      AIService.statistics("市政工程", navigate).then(x=>{
         let t = [];
         let t = [];
           for (let i = 1; i < x.length; i++) {
           for (let i = 1; i < x.length; i++) {
             t.push({label: x[i][0], value: x[i][1]});
             t.push({label: x[i][0], value: x[i][1]});
@@ -452,7 +453,7 @@ export default function AI() {
     
     
     } else if (lb == '园林绿化工程') {
     } else if (lb == '园林绿化工程') {
       setCjloading(true);
       setCjloading(true);
-      AIService.statistics("园林绿化工程").then(x=>{
+      AIService.statistics("园林绿化工程", navigate).then(x=>{
         let t = [];
         let t = [];
           for (let i = 1; i < x.length; i++) {
           for (let i = 1; i < x.length; i++) {
             t.push({label: x[i][0], value: x[i][1]});
             t.push({label: x[i][0], value: x[i][1]});
@@ -548,7 +549,22 @@ function FolderArrow({ node }) {
     </span>
     </span>
   );
   );
 }
 }
-
+  const [anchorEl, setAnchorEl] = React.useState();
+  const accountOpen = Boolean(anchorEl);
+  const handleAccountClose = () => {
+    setAnchorEl(null);
+  };
+  const handleLogout = () => {
+    localStorage.setItem("token", "");
+    AIService.setToken("");
+    Service.setToken("");
+    SimpleService.setToken("");
+    AuthService.setToken("");
+    navigate("/editor/signin");
+  };
+ const handleAccountClick = (event) => {
+    setAnchorEl(event.currentTarget.children[0]);
+  };
 
 
     return (
     return (
       <Box sx={{ display: 'flex' }}>
       <Box sx={{ display: 'flex' }}>
@@ -599,13 +615,32 @@ function FolderArrow({ node }) {
               size="large"
               size="large"
               edge="end"
               edge="end"
               aria-label="account of current user"
               aria-label="account of current user"
-              
+              onClick={handleAccountClick}
               aria-haspopup="true"
               aria-haspopup="true"
               
               
               color="inherit"
               color="inherit"
             >
             >
               <AccountCircle />
               <AccountCircle />
             </IconButton>
             </IconButton>
+            <Menu
+                id="menu-appbar"
+                anchorReference={"anchorPosition"}
+                anchorPosition={{left: document.documentElement.clientWidth, top: 60}}
+                open={accountOpen}
+                onClose={handleAccountClose}
+                anchorOrigin={{
+                 vertical: 'top',
+                 horizontal: 'right',
+               }}
+               keepMounted
+               transformOrigin={{
+                 vertical: 'top',
+                 horizontal: 'left',
+               }}
+              >
+                <MenuItem onClick={handleLogout}>登出</MenuItem>
+              </Menu>
+
           </Box>
           </Box>
           </Toolbar>
           </Toolbar>
         </AppBar>
         </AppBar>

+ 10 - 4
src/AIService.js

@@ -3,6 +3,7 @@ import { v4 as uuidv4 } from 'uuid';
 class AIService{
 class AIService{
     
     
     constructor() {
     constructor() {
+        this.token_ = localStorage.getItem('token');
         this.footprint = [];
         this.footprint = [];
         this.cache = [];
         this.cache = [];
         this.memory = [];
         this.memory = [];
@@ -33,6 +34,9 @@ class AIService{
         //return "/api"//return "http://127.0.0.1:8000"
         //return "/api"//return "http://127.0.0.1:8000"
         return "http://127.0.0.1:1313/api"
         return "http://127.0.0.1:1313/api"
     }
     }
+    setToken(token) {
+        this.token_ = token;
+    }
 
 
     clearCache() {//set qufei will clear cache
     clearCache() {//set qufei will clear cache
         this.cache = [];
         this.cache = [];
@@ -46,11 +50,12 @@ class AIService{
 
 
    
    
 
 
-    async statistics(query) {
+    async statistics(query, navigate) {
         const response = await fetch(this.ip().concat( "/statistics/"), {
         const response = await fetch(this.ip().concat( "/statistics/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body: JSON.stringify(
             body: JSON.stringify(
                 {
                 {
@@ -60,8 +65,9 @@ class AIService{
             )
             )
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+               navigate("/editor/signin");
+           }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;

+ 11 - 10
src/App2.js

@@ -57,6 +57,7 @@ import IconButton from '@mui/material/IconButton';
 import CloseIcon from '@mui/icons-material/Close';
 import CloseIcon from '@mui/icons-material/Close';
 import SearchIcon from '@mui/icons-material/Search';
 import SearchIcon from '@mui/icons-material/Search';
 import Button from '@mui/material/Button';
 import Button from '@mui/material/Button';
+import { useNavigate } from "react-router";
 
 
 
 
 import Tooltip from '@mui/material/Tooltip';
 import Tooltip from '@mui/material/Tooltip';
@@ -192,7 +193,7 @@ function a11yProps(index) {
       {field: '人材机类别', headerName: '人材机类别', sortable: false},
       {field: '人材机类别', headerName: '人材机类别', sortable: false},
     ];
     ];
     let location = useParams();
     let location = useParams();
-
+    const navigate = useNavigate();
 
 
     const [acvalue, setAcvalue] = React.useState('');
     const [acvalue, setAcvalue] = React.useState('');
     const [acinputvalue, setAcinputvalue] = React.useState('');
     const [acinputvalue, setAcinputvalue] = React.useState('');
@@ -757,7 +758,7 @@ function a11yProps(index) {
         if (itemId.includes("bao jia hui zong")) {
         if (itemId.includes("bao jia hui zong")) {
           let regex = /[0-9]*/; 
           let regex = /[0-9]*/; 
           let id = itemId.match(regex)[0];     
           let id = itemId.match(regex)[0];     
-          SimpleService.generateBaojiahuizong2(location["id"], id).then(x=>{
+          SimpleService.generateBaojiahuizong2(location["id"], id, navigate).then(x=>{
                   setBjhzData(x);
                   setBjhzData(x);
                   setNest(true);
                   setNest(true);
                   setQingdan(false);
                   setQingdan(false);
@@ -779,7 +780,7 @@ function a11yProps(index) {
         else if (itemId.includes("gui fei shui jin")) {
         else if (itemId.includes("gui fei shui jin")) {
           let regex = /[0-9]*/; 
           let regex = /[0-9]*/; 
           let id = itemId.match(regex)[0];     
           let id = itemId.match(regex)[0];     
-          SimpleService.generateGuifeishuijin2(location["id"], id).then(x=>{
+          SimpleService.generateGuifeishuijin2(location["id"], id, navigate).then(x=>{
                   setGfsjData(x);
                   setGfsjData(x);
                   setNest(true);
                   setNest(true);
                   setQingdan(false);
                   setQingdan(false);
@@ -812,7 +813,7 @@ function a11yProps(index) {
               }
               }
             }
             }
           }    
           }    
-          SimpleService.generateQingdanxiangmu2(location["id"], id).then(x=>{
+          SimpleService.generateQingdanxiangmu2(location["id"], id, navigate).then(x=>{
                   setValue("1");
                   setValue("1");
                   setNest(false);
                   setNest(false);
                   setQingdan(true);
                   setQingdan(true);
@@ -862,7 +863,7 @@ function a11yProps(index) {
           
           
           setValue("1");
           setValue("1");
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
-          SimpleService.generateQitaxiangmu2(location["id"], id).then(x=>{
+          SimpleService.generateQitaxiangmu2(location["id"], id, navigate).then(x=>{
                   //setNestDetail(x);
                   //setNestDetail(x);
                   setQtxmData(x);
                   setQtxmData(x);
                   setNest(true);
                   setNest(true);
@@ -1008,7 +1009,7 @@ function a11yProps(index) {
           let id = itemId.match(regex)[0];     
           let id = itemId.match(regex)[0];     
           setValue("1");
           setValue("1");
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
-          //Service.generateRencaijihuizong2(location["id"], id).then(x=>{
+          //Service.generateRencaijihuizong2(location["id"], id, navigate).then(x=>{
                   //setDetail(x);
                   //setDetail(x);
                   setRcjhz(true);
                   setRcjhz(true);
                   setNest(false);
                   setNest(false);
@@ -1031,7 +1032,7 @@ function a11yProps(index) {
 
 
         }
         }
         else if (itemId.includes("TouBiaoXx")) {
         else if (itemId.includes("TouBiaoXx")) {
-            SimpleService.generateDetail2(location["id"]).then(x=>{
+            SimpleService.generateDetail2(location["id"], navigate).then(x=>{
             setQingdan(false);
             setQingdan(false);
             setCuoshi(false);
             setCuoshi(false);
             setTbxxData(x);
             setTbxxData(x);
@@ -1055,7 +1056,7 @@ function a11yProps(index) {
     React.useEffect(
     React.useEffect(
       () => {
       () => {
         console.log(location);
         console.log(location);
-        SimpleService.generateQufei(location["id"]).then(x=>{
+        SimpleService.generateQufei(location["id"], navigate).then(x=>{
 
 
           Service.setQufei(x);
           Service.setQufei(x);
           });
           });
@@ -1063,7 +1064,7 @@ function a11yProps(index) {
 
 
             Service.setJiagongcai(x);
             Service.setJiagongcai(x);
             });
             });
-        SimpleService.generateOutline2(location["id"]).then(x=>{
+        SimpleService.generateOutline2(location["id"], navigate).then(x=>{
           outlineRef.current = x;
           outlineRef.current = x;
           let y = x.map(z=>{
           let y = x.map(z=>{
             z['key'] = z['id'];
             z['key'] = z['id'];
@@ -1104,7 +1105,7 @@ function a11yProps(index) {
           });
           });
         setOutline(y2);
         setOutline(y2);
         });
         });
-        SimpleService.generateDetail2(location['id']).then(x=>{
+        SimpleService.generateDetail2(location['id'], navigate).then(x=>{
 
 
         setTbxxData(x);
         setTbxxData(x);
         setTbxx(true);
         setTbxx(true);

+ 10 - 2
src/AuthService.js

@@ -4,6 +4,7 @@ class AuthService{
     
     
     constructor() {
     constructor() {
         this.footprint = [];
         this.footprint = [];
+        this.token_ = localStorage.getItem('token');
         this.cache = [];
         this.cache = [];
         this.memory = [];
         this.memory = [];
         this.mem_pointer = -1;
         this.mem_pointer = -1;
@@ -28,6 +29,10 @@ class AuthService{
         };
         };
         
         
     }
     }
+
+    setToken(token) {
+       this.token_ = token;
+    }
     
     
     ip() {
     ip() {
         //return "/api"//return "http://127.0.0.1:8000"
         //return "/api"//return "http://127.0.0.1:8000"
@@ -47,9 +52,10 @@ class AuthService{
    
    
 
 
 
 
-    async token(query) {
+    async token(query, navigate) {
         const response = await fetch(this.ip().concat( "/token/"), {
         const response = await fetch(this.ip().concat( "/token/"), {
             method : "POST",
             method : "POST",
+            redirect: 'manual',
             headers: {
             headers: {
                 "Content-type": "application/json"
                 "Content-type": "application/json"
             },
             },
@@ -63,7 +69,9 @@ class AuthService{
         });
         });
         if (!response.ok) {
         if (!response.ok) {
             //const error = await response.json();
             //const error = await response.json();
-            console.error('error');
+           if (response.status==401) { 
+              navigate("/editor/index.html");
+           }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;

+ 3 - 2
src/Djcs3.js

@@ -20,6 +20,7 @@ import {extractFuzhu, match_target} from './utils';
 import Button from '@mui/material/Button';
 import Button from '@mui/material/Button';
 import {shanchu_djcs, undo_djcs, redo_djcs, danxiangdinge_djcs, updateDercj_djcs, changguidinge_djcs, handleBeizhu_djcs, huan, updateShuliang_djcs, azfy_djcs_eligible, azfy_djcs} from './editor';
 import {shanchu_djcs, undo_djcs, redo_djcs, danxiangdinge_djcs, updateDercj_djcs, changguidinge_djcs, handleBeizhu_djcs, huan, updateShuliang_djcs, azfy_djcs_eligible, azfy_djcs} from './editor';
 import {copy} from './utils';
 import {copy} from './utils';
+import { useNavigate } from "react-router";
 
 
 const {Column, HeaderCell, Cell} = Table;
 const {Column, HeaderCell, Cell} = Table;
 
 
@@ -31,7 +32,7 @@ function number_equal(a, b) {
      return false;
      return false;
 }
 }
 export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, clickCallback, loadingCallback, dingeclick, azfycallback, azfySelect, azfyConfirm}) {
 export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, clickCallback, loadingCallback, dingeclick, azfycallback, azfySelect, azfyConfirm}) {
-
+     const navigate = useNavigate();
     
     
      var editCheck = function(cell){
      var editCheck = function(cell){
           //cell - the cell component for the editable cell
           //cell - the cell component for the editable cell
@@ -519,7 +520,7 @@ export default function Djcs3({name, bh, rgde, jxde, clde, beizhu, beizhuFK, cli
 
 
 
 
       myTable.current.on("tableBuilt", () => {
       myTable.current.on("tableBuilt", () => {
-          Service.generateDjcs(name, bh).then(x=>{
+          Service.generateDjcs(name, bh, navigate).then(x=>{
                myTable.current.replaceData(x);
                myTable.current.replaceData(x);
                });
                });
         });
         });

+ 50 - 12
src/Home2.js

@@ -1,6 +1,9 @@
 import * as React from 'react';
 import * as React from 'react';
-
+import Menu from '@mui/material/Menu';
+import MenuItem from '@mui/material/MenuItem';
 import Service from './Service';
 import Service from './Service';
+import AuthService from './AuthService';
+import AIService from './AIService';
 import SimpleService from './SimpleService';
 import SimpleService from './SimpleService';
 import {useNavigate, useLocation} from "react-router";
 import {useNavigate, useLocation} from "react-router";
 //registerAllModules();
 //registerAllModules();
@@ -39,15 +42,14 @@ import TipsAndUpdatesIcon from '@mui/icons-material/TipsAndUpdates';
 export default function Home2() {
 export default function Home2() {
   const drawerWidth = 240;
   const drawerWidth = 240;
   const theme = useTheme();
   const theme = useTheme();
-
   const deleteItem = React.useCallback(
   const deleteItem = React.useCallback(
-    (id) => () => {
+    (id, navigate) => () => {
 
 
       itemRef.current = id;
       itemRef.current = id;
       /*
       /*
       console.log(id);
       console.log(id);
       SimpleService.deleteFiles(id).then(x=> {
       SimpleService.deleteFiles(id).then(x=> {
-        SimpleService.generateFiles2().then(x=>{
+        SimpleService.generateFiles2(navigate).then(x=>{
           setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
           setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
         });
         });
       });*/
       });*/
@@ -117,6 +119,7 @@ export default function Home2() {
   }
   }
   
   
  
  
+    const navigate = useNavigate();
   const columns = React.useMemo(
   const columns = React.useMemo(
     () => [
     () => [
       { field: 'ID', headerName: 'ID', width: 250 },
       { field: 'ID', headerName: 'ID', width: 250 },
@@ -131,7 +134,7 @@ export default function Home2() {
           <GridActionsCellItem
           <GridActionsCellItem
             icon={<DeleteIcon />}
             icon={<DeleteIcon />}
             label="删除"
             label="删除"
-            onClick={deleteItem(params.id)}
+            onClick={deleteItem(params.id, navigate)}
           />,
           />,
        
        
       
       
@@ -151,7 +154,6 @@ export default function Home2() {
     });
     });
 
 
     const itemRef = React.useRef(null);
     const itemRef = React.useRef(null);
-    const navigate = useNavigate();
     const [detail, setDetail] = React.useState([]);
     const [detail, setDetail] = React.useState([]);
     const [open, setOpen] = React.useState(false);
     const [open, setOpen] = React.useState(false);
     const [dopen, setDopen] = React.useState(false);
     const [dopen, setDopen] = React.useState(false);
@@ -163,7 +165,7 @@ export default function Home2() {
          fd.append('file', event.target.files[0]);
          fd.append('file', event.target.files[0]);
          SimpleService.uploadFile(fd).then(x=>{
          SimpleService.uploadFile(fd).then(x=>{
             console.log("uploaded");
             console.log("uploaded");
-            SimpleService.generateFiles2().then(x=>{
+            SimpleService.generateFiles2(navigate).then(x=>{
               setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
               setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
             });
             });
 
 
@@ -174,7 +176,7 @@ export default function Home2() {
 
 
     React.useEffect(
     React.useEffect(
       () => {
       () => {
-         SimpleService.generateFiles2().then(x=>{
+         SimpleService.generateFiles2(navigate).then(x=>{
            setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
            setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
          });
          });
       }, []
       }, []
@@ -257,13 +259,31 @@ export default function Home2() {
 
 
   const handleDelete = () => {
   const handleDelete = () => {
     SimpleService.deleteFiles(itemRef.current).then(x=> {
     SimpleService.deleteFiles(itemRef.current).then(x=> {
-      SimpleService.generateFiles2().then(x=>{
+      SimpleService.generateFiles2(navigate).then(x=>{
         setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
         setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
       });
       });
     });
     });
     setDopen(false);
     setDopen(false);
   };
   };
 
 
+  const [anchorEl, setAnchorEl] = React.useState(null);
+  const accountOpen = Boolean(anchorEl);
+  const handleAccountClose = () => {
+    setAnchorEl(null);
+  };
+  const handleLogout = () => {
+    localStorage.setItem("token", "");
+    AIService.setToken("");
+    AuthService.setToken("");
+    Service.setToken("");
+    SimpleService.setToken("");
+    navigate("/editor/signin");
+  };
+
+
+  const handleAccountClick = (event) => {
+    setAnchorEl(event.currentTarget.children[0]);
+  };
 
 
     return (
     return (
       <Box sx={{ display: 'flex' }}>
       <Box sx={{ display: 'flex' }}>
@@ -292,17 +312,35 @@ export default function Home2() {
           <Box sx={{ flexGrow: 1 }} />
           <Box sx={{ flexGrow: 1 }} />
           <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
           <Box sx={{ display: { xs: 'none', md: 'flex' } }}>
            
            
-            <IconButton
+            <IconButton onClick={handleAccountClick}
               size="large"
               size="large"
               edge="end"
               edge="end"
               aria-label="account of current user"
               aria-label="account of current user"
-              
               aria-haspopup="true"
               aria-haspopup="true"
-              
+              aria-controls='menu-appbar'
               color="inherit"
               color="inherit"
             >
             >
               <AccountCircle />
               <AccountCircle />
             </IconButton>
             </IconButton>
+              <Menu
+                id="menu-appbar"
+                anchorEl={anchorEl}
+                anchorReference={"anchorPosition"}
+                anchorPosition={{left: document.documentElement.clientWidth, top: 60}}
+                open={accountOpen}
+                onClose={handleAccountClose}
+                anchorOrigin={{
+                 vertical: 'top',
+                 horizontal: 'right',
+               }}
+               keepMounted
+               transformOrigin={{
+                 vertical: 'top',
+                 horizontal: 'left',
+               }}
+              >
+                <MenuItem onClick={handleLogout}>登出</MenuItem>
+              </Menu>
           </Box>
           </Box>
           </Toolbar>
           </Toolbar>
         </AppBar>
         </AppBar>

+ 3 - 2
src/Qufei.js

@@ -3,6 +3,7 @@ import Box from "@mui/material/Box";
 
 
 import Service from './Service';
 import Service from './Service';
 import SimpleService from './SimpleService';
 import SimpleService from './SimpleService';
+import { useNavigate } from "react-router";
 
 
 import Button from '@mui/material/Button';
 import Button from '@mui/material/Button';
 import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator library
 import {TabulatorFull as Tabulator} from "tabulator-tables"; //import Tabulator library
@@ -12,7 +13,7 @@ import {copy} from './utils';
 export default function Qufei({id, qufeiCallback}) {
 export default function Qufei({id, qufeiCallback}) {
     
     
   const [detail, setDetail] = React.useState([]);
   const [detail, setDetail] = React.useState([]);
-
+  const navigate = useNavigate();
 const myRef = React.useRef();
 const myRef = React.useRef();
 const myTable = React.useRef(null);
 const myTable = React.useRef(null);
 
 
@@ -595,7 +596,7 @@ React.useEffect(
 
 
 
 
   myTable.current.on("tableBuilt", () => {
   myTable.current.on("tableBuilt", () => {
-    SimpleService.generateQufei(id).then(x=>{
+    SimpleService.generateQufei(id, navigate).then(x=>{
 
 
       console.log(x);
       console.log(x);
       let y = x.map(z=>{
       let y = x.map(z=>{

+ 4 - 2
src/Rcjhz.js

@@ -2,6 +2,7 @@ import * as React from 'react';
 
 
 import Service from './Service';
 import Service from './Service';
 import { v4 as uuidv4 } from 'uuid';
 import { v4 as uuidv4 } from 'uuid';
+import { useNavigate } from "react-router";
 
 
 
 
 import {copy} from './utils';
 import {copy} from './utils';
@@ -11,6 +12,7 @@ export default function Rcjhz({id, bh, tiaojiaCallback, updatetime}) {
   const myTable = React.useRef(null);
   const myTable = React.useRef(null);
   const myRef = React.useRef(null);
   const myRef = React.useRef(null);
   const [detail, setDetail] = React.useState([]);
   const [detail, setDetail] = React.useState([]);
+  const navigate = useNavigate();
  
  
   var editCheckRcj = function(cell){
   var editCheckRcj = function(cell){
     //cell - the cell component for the editable cell
     //cell - the cell component for the editable cell
@@ -141,7 +143,7 @@ export default function Rcjhz({id, bh, tiaojiaCallback, updatetime}) {
 
 
 
 
      myTable.current.on("tableBuilt", () => {
      myTable.current.on("tableBuilt", () => {
-         Service.generateRencaijihuizong2(id, bh).then(x=>{
+         Service.generateRencaijihuizong2(id, bh, navigate).then(x=>{
               myTable.current.replaceData(x);
               myTable.current.replaceData(x);
               });
               });
        });
        });
@@ -155,4 +157,4 @@ export default function Rcjhz({id, bh, tiaojiaCallback, updatetime}) {
 
 
 
 
     );
     );
-}
+}

+ 17 - 8
src/Service.js

@@ -5,6 +5,7 @@ class Service{
     constructor() {
     constructor() {
         this.footprint = [];
         this.footprint = [];
         this.cache = [];
         this.cache = [];
+        this.token_ = localStorage.getItem('token');
         this.memory = [];
         this.memory = [];
         this.mem_pointer = -1;
         this.mem_pointer = -1;
         this.cache_djcs = [];
         this.cache_djcs = [];
@@ -28,6 +29,9 @@ class Service{
         };
         };
         
         
     }
     }
+    setToken(token) {
+       this.token_ = token;
+    }
     
     
     ip() {
     ip() {
         //return "/api"//return "http://127.0.0.1:8000"
         //return "/api"//return "http://127.0.0.1:8000"
@@ -159,11 +163,13 @@ class Service{
 
 
 
 
 
 
-    async generateRencaijihuizong2(name, id) {
+    async generateRencaijihuizong2(name, id, navigate) {
         const response = await fetch(this.ip().concat( "/rencaijihuizong2/"), {
         const response = await fetch(this.ip().concat( "/rencaijihuizong2/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
+
             },
             },
             body: JSON.stringify({
             body: JSON.stringify({
                 name: name,
                 name: name,
@@ -171,8 +177,9 @@ class Service{
             })
             })
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+            if (response.status == 401) {
+                 navigate("/editor/signin");
+            }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             let result = [];
             let result = [];
@@ -299,12 +306,13 @@ class Service{
 
 
 /////////////////////////////end of qingdan////////////////////////////////////
 /////////////////////////////end of qingdan////////////////////////////////////
 
 
-    async generateDjcs(name, bh) {
+    async generateDjcs(name, bh, navigate) {
         if (this.cache_djcs.length == 0 || this.cache_djcs[0]["biao_id"] != name || this.cache_djcs[0]["Dwgcbh"] != bh) {
         if (this.cache_djcs.length == 0 || this.cache_djcs[0]["biao_id"] != name || this.cache_djcs[0]["Dwgcbh"] != bh) {
         const response = await fetch(this.ip().concat( "/djcs/"), {
         const response = await fetch(this.ip().concat( "/djcs/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body: JSON.stringify(
             body: JSON.stringify(
                 {
                 {
@@ -314,8 +322,9 @@ class Service{
             )
             )
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+            if (response.status == 401) {
+               navigate("/editor/signin");
+            }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             this.processDjcsmingxi(data);
             this.processDjcsmingxi(data);

+ 15 - 2
src/Signin.js

@@ -14,6 +14,11 @@ import Container from '@mui/material/Container';
 import { createTheme, ThemeProvider } from '@mui/material/styles';
 import { createTheme, ThemeProvider } from '@mui/material/styles';
 import {useSearchParams} from 'react-router-dom';
 import {useSearchParams} from 'react-router-dom';
 import AuthService from './AuthService';
 import AuthService from './AuthService';
+import AIService from './AIService';
+import Service from './Service';
+import SimpleService from './SimpleService';
+import {useNavigate, useLocation} from "react-router";
+
 function Copyright(props) {
 function Copyright(props) {
   return (
   return (
     <Typography variant="body2" color="text.secondary" align="center" {...props}>
     <Typography variant="body2" color="text.secondary" align="center" {...props}>
@@ -31,6 +36,8 @@ const theme = createTheme();
 
 
 
 
 export default function SignIn() {
 export default function SignIn() {
+  const navigate = useNavigate();
+
   let [searchParams] = useSearchParams();
   let [searchParams] = useSearchParams();
   let code = searchParams.get("code");
   let code = searchParams.get("code");
   const handleSubmit = (event) => {
   const handleSubmit = (event) => {
@@ -65,9 +72,15 @@ export default function SignIn() {
       document.body.appendChild(script);
       document.body.appendChild(script);
     } else {
     } else {
        console.log(code);
        console.log(code);
-       AuthService.token(code).then(x=>{
+       AuthService.token(code, navigate).then(x=>{
           console.log(x);
           console.log(x);
-       });
+          localStorage.setItem('token', x['token']);
+          AuthService.setToken(x['token']);
+          AIService.setToken(x['token']);
+          Service.setToken(x['token']);
+          SimpleService.setToken(x['token']);
+          navigate("/editor/index.html");
+       }).catch((e)=>{});
     }
     }
     }, []);
     }, []);
 
 

+ 59 - 36
src/SimpleService.js

@@ -5,6 +5,7 @@ class SimpleService{
     constructor() {
     constructor() {
         this.footprint = [];
         this.footprint = [];
         this.cache = [];
         this.cache = [];
+        this.token_ = localStorage.getItem('token');
         this.memory = [];
         this.memory = [];
         this.mem_pointer = -1;
         this.mem_pointer = -1;
         this.cache_djcs = [];
         this.cache_djcs = [];
@@ -28,6 +29,10 @@ class SimpleService{
         };
         };
         
         
     }
     }
+
+    setToken(token) {
+       this.token_ = token;
+    }
     
     
     ip() {
     ip() {
         //return "/api"//return "http://127.0.0.1:8000"
         //return "/api"//return "http://127.0.0.1:8000"
@@ -66,37 +71,41 @@ class SimpleService{
         }
         }
     }
     }
 
 
-    async generateQufei(name) {
+    async generateQufei(name, navigate) {
         const response = await fetch(this.ip().concat("/qufei/"), {
         const response = await fetch(this.ip().concat("/qufei/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body : JSON.stringify({
             body : JSON.stringify({
                 "name": name
                 "name": name
             })
             })
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+          if (response.status == 401) {
+             navigate("/editor/signin");
+          }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;
         }
         }
     }
     }
-    async generateOutline2(name) {
+    async generateOutline2(name, navigate) {
         const response = await fetch(this.ip().concat( "/outline2"), {
         const response = await fetch(this.ip().concat( "/outline2"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body : JSON.stringify({
             body : JSON.stringify({
                 "name": name
                 "name": name
             })
             })
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+               navigate("/editor/signin");
+           }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;
@@ -104,30 +113,33 @@ class SimpleService{
     }
     }
 
 
 
 
-    async generateDetail2(name) {
+    async generateDetail2(name, navigate) {
         const response = await fetch(this.ip().concat("/detail2"), {
         const response = await fetch(this.ip().concat("/detail2"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body : JSON.stringify({
             body : JSON.stringify({
                 "name": name
                 "name": name
             })
             })
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+            if (response.status == 401) {
+                navigate("/editor/signin");
+            }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;
         }
         }
     }
     }
 
 
-    async generateBaojiahuizong2(name, id) {
+    async generateBaojiahuizong2(name, id, navigate) {
         const response = await fetch(this.ip().concat(  "/baojiahuizong2/"), {
         const response = await fetch(this.ip().concat(  "/baojiahuizong2/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             }, 
             }, 
             body: JSON.stringify({
             body: JSON.stringify({
                 name: name,
                 name: name,
@@ -135,19 +147,21 @@ class SimpleService{
             })
             })
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+          if (response.status == 401) {
+             navigate("/editor/signin");
+          }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;
         }
         }
     }
     }
 
 
-    async generateGuifeishuijin2(name, id) {
+    async generateGuifeishuijin2(name, id, navigate) {
         const response = await fetch(this.ip().concat( "/guifeishuijin2/"), {
         const response = await fetch(this.ip().concat( "/guifeishuijin2/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body: JSON.stringify({
             body: JSON.stringify({
                 name: name,
                 name: name,
@@ -155,8 +169,9 @@ class SimpleService{
             })
             })
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+              navigate("/editor/signin");
+           }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;
@@ -165,11 +180,12 @@ class SimpleService{
 
 
 
 
 
 
-    async generateQitaxiangmu2(name, id) {
+    async generateQitaxiangmu2(name, id, navigate) {
         const response = await fetch(this.ip().concat( "/qitaxiangmu2/"), {
         const response = await fetch(this.ip().concat( "/qitaxiangmu2/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body: JSON.stringify({
             body: JSON.stringify({
                 name: name,
                 name: name,
@@ -177,8 +193,9 @@ class SimpleService{
             })
             })
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+               navigate("/editor/signin");
+           }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;
@@ -294,11 +311,12 @@ class SimpleService{
         }
         }
     }
     }
 
 
-    async generateQingdanxiangmu2(name, id) {
+    async generateQingdanxiangmu2(name, id, navigate) {
         const response = await fetch(this.ip().concat( "/qingdanxiangmu2/"), {
         const response = await fetch(this.ip().concat( "/qingdanxiangmu2/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body: JSON.stringify({
             body: JSON.stringify({
                 name: name,
                 name: name,
@@ -306,8 +324,9 @@ class SimpleService{
             })
             })
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+          if (response.status == 401) {
+             navigate("/editor/signin");
+          }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;
@@ -359,11 +378,12 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         return data;
         return data;
     }
     }
 }
 }
-    async generateZjcs(name, bh) {
+    async generateZjcs(name, bh, navigate) {
         const response = await fetch(this.ip().concat( "/zjcs/"), {
         const response = await fetch(this.ip().concat( "/zjcs/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             },
             body: JSON.stringify(
             body: JSON.stringify(
                 {
                 {
@@ -373,8 +393,9 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             )
             )
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+              navigate("/editor/signin");
+           }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;
@@ -382,16 +403,18 @@ async generateQingdanTuijian(name, bh, bt, bm) {
     }
     }
 
 
 
 
-    async generateFiles2() {
+    async generateFiles2(navigate) {
         const response = await fetch(this.ip().concat( "/files2/"), {
         const response = await fetch(this.ip().concat( "/files2/"), {
             method : "POST",
             method : "POST",
             headers: {
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             }
             }
         });
         });
         if (!response.ok) {
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+              navigate("/editor/signin");
+           }
         } else {
         } else {
             const data = await response.json();
             const data = await response.json();
             return data;
             return data;

+ 3 - 2
src/Zjcs2.js

@@ -9,6 +9,7 @@ import Select from '@mui/material/Select';
 import MenuItem from '@mui/material/MenuItem';
 import MenuItem from '@mui/material/MenuItem';
 import { v4 as uuidv4 } from 'uuid';
 import { v4 as uuidv4 } from 'uuid';
 import {copy} from './utils';
 import {copy} from './utils';
+import { useNavigate } from "react-router";
 
 
 import TabContext from "@mui/lab/TabContext";
 import TabContext from "@mui/lab/TabContext";
 import TabList from "@mui/lab/TabList";
 import TabList from "@mui/lab/TabList";
@@ -35,7 +36,7 @@ export default function Zjcs2({name, bh, zjcsCallback}) {
     const cankaoTable = React.useRef(null);
     const cankaoTable = React.useRef(null);
     const hotRef = React.useRef(null);
     const hotRef = React.useRef(null);
     const allRef = React.useRef([]);
     const allRef = React.useRef([]);
-
+    const navigate = useNavigate();
     const [value, setValue] = React.useState(10);
     const [value, setValue] = React.useState(10);
     const [valueTab, setValueTab] = React.useState("1");
     const [valueTab, setValueTab] = React.useState("1");
     React.useEffect(
     React.useEffect(
@@ -90,7 +91,7 @@ export default function Zjcs2({name, bh, zjcsCallback}) {
         
         
 
 
 
 
-          SimpleService.generateZjcs(name, bh).then(x=>{
+          SimpleService.generateZjcs(name, bh, navigate).then(x=>{
             let addedkey = x.map(y=>{
             let addedkey = x.map(y=>{
               y['key'] = uuidv4();
               y['key'] = uuidv4();
               if (y.hasOwnProperty('_children')) {
               if (y.hasOwnProperty('_children')) {