| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | 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"; |
| | | |
| | | const FakeFab = (props) => { |
| | | const [fakeRun, setFakeRun] = useState(false); |
| | | |
| | | const querySign = () => { |
| | | getFakeSign(null, (data) => { |
| | | useEffect(() => { |
| | | getFakeSign(null, (res) => { |
| | | setFakeRun(res); |
| | | }); |
| | | }, [props]); |
| | | |
| | | const handleToggle = () => { |
| | | getFakeSign(null, (res) => { |
| | | setFakeSign(!res, (updatedSign) => { |
| | | setFakeRun(updatedSign); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | useEffect(() => { |
| | | querySign(); |
| | | }, []); |
| | | |
| | | return ( |
| | | <> |
| | |
| | | variant="extended" |
| | | color={fakeRun ? 'primary' : 'default'} |
| | | size="small" |
| | | onClick={() => { |
| | | setFakeRun(!fakeRun); |
| | | }} |
| | | onClick={handleToggle} |
| | | > |
| | | <LensBlurIcon /> |
| | | {/* {translate('page.map.action.adapt')} */} |
| | |
| | | } |
| | | |
| | | export const getFakeSign = async (param, callback) => { |
| | | await request.get('/fake/sign').then((res) => { |
| | | await request.get('/fake/sign/get').then((res) => { |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | if (callback) { |
| | |
| | | console.error(error.message); |
| | | }) |
| | | } |
| | | |
| | | export const setFakeSign = async (param, callback) => { |
| | | await request.post('/fake/sign/set', { |
| | | sign: param, |
| | | }, { |
| | | headers: { 'Content-Type': 'application/x-www-form-urlencoded' } |
| | | }).then((res) => { |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | if (data) { |
| | | notify.success(msg); |
| | | } |
| | | if (callback) { |
| | | callback(data) |
| | | } |
| | | } else { |
| | | notify.error(msg); |
| | | } |
| | | }).catch((error) => { |
| | | notify.error(error.message); |
| | | console.error(error.message); |
| | | }) |
| | | } |
| | |
| | | package com.zy.acs.manager.fake; |
| | | |
| | | import com.zy.acs.framework.common.BaseRes; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * Created by vincent on 11/9/2024 |
| | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @GetMapping("/sign") |
| | | public R sign() { |
| | | @GetMapping("/sign/get") |
| | | public R getSign() { |
| | | return R.ok().add(configService.getVal("fakeSign", Boolean.class)); |
| | | } |
| | | |
| | | @PostMapping("/sign/set") |
| | | public synchronized R setSign(@RequestParam(required = false) Boolean sign) { |
| | | if (Cools.isEmpty(sign)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | boolean res = configService.setVal("fakeSign", sign); |
| | | if (!res) { |
| | | return R.error(); |
| | | } |
| | | return R.ok().add(configService.getVal("fakeSign", Boolean.class)); |
| | | } |
| | | |