From 13ea8b334572c2423abb8d156fd8428f8d074172 Mon Sep 17 00:00:00 2001 From: zhang <zc857179121@qq.com> Date: 星期四, 03 七月 2025 08:24:58 +0800 Subject: [PATCH] 1 --- zy-acs-flow/src/map/header/FakeFab.jsx | 47 +++++++++++++++++++++++++++++++---------------- 1 files changed, 31 insertions(+), 16 deletions(-) diff --git a/zy-acs-flow/src/map/header/FakeFab.jsx b/zy-acs-flow/src/map/header/FakeFab.jsx index 010b52c..eb3f593 100644 --- a/zy-acs-flow/src/map/header/FakeFab.jsx +++ b/zy-acs-flow/src/map/header/FakeFab.jsx @@ -1,26 +1,43 @@ import React, { useState, useRef, useEffect, useMemo } from "react"; +import { useTranslate } from "react-admin"; import { - Select, - MenuItem, - Button, - Box, - useTheme, Fab, } from '@mui/material'; import LensBlurIcon from '@mui/icons-material/LensBlur'; -import { getFakeSign } from "../http"; +import { getFakeSign, setFakeSign } from "../http"; +import { VERIFY_PASSWORD } from '@/config/setting'; const FakeFab = (props) => { + const translate = useTranslate(); const [fakeRun, setFakeRun] = useState(false); - const querySign = () => { - getFakeSign(null, (data) => { + useEffect(() => { + getFakeSign(null, (res) => { + setFakeRun(res); + }); + }, [props]); + + const handleToggle = () => { + getFakeSign(null, (res) => { + let pass = true; + if (!res) { + const pwd = prompt("please enter password:"); + if (pwd === VERIFY_PASSWORD) { + pass = true; + } else { + pass = false; + if (pwd) { + alert('Incorrect password'); + } + } + } + if (pass) { + setFakeSign(!res, (updatedSign) => { + setFakeRun(updatedSign); + }); + } }); } - - useEffect(() => { - querySign(); - }, []); return ( <> @@ -28,12 +45,10 @@ variant="extended" color={fakeRun ? 'primary' : 'default'} size="small" - onClick={() => { - setFakeRun(!fakeRun); - }} + onClick={handleToggle} > <LensBlurIcon /> - {/* {translate('page.map.action.adapt')} */} + {translate('page.map.action.fake')} </Fab> </> ) -- Gitblit v1.9.1