index.jsx 2.25 KB
Newer Older
mayongxin's avatar
mayongxin committed
1 2 3
import React, { useEffect, useState } from 'react'
import PageContainer from '@/components/BasePageContainer';
import { Card, Form, Input, Button, Switch, message } from 'antd'
mayongxin's avatar
mayongxin committed
4
import { GetAuthSet, AuthSetting } from '@/services/database/api'
mayongxin's avatar
mayongxin committed
5 6 7
import styles from './index.less'
const AuthControl = () => {

mayongxin's avatar
mayongxin committed
8 9 10
    const [flag,setFlag] = useState(0)
    const [auChecked, setAuChecked] = useState()
    const [cacheChecked, setCacheAuChecked] = useState()
mayongxin's avatar
mayongxin committed
11 12

    useEffect(() => {
mayongxin's avatar
mayongxin committed
13 14 15
        GetAuthSet().then(
            res => {
                if (res.code === 0) {
mayongxin's avatar
mayongxin committed
16 17
                    setAuChecked(res.data.IsOpenAuth)
                    setCacheAuChecked(res.data.IsUseCache)
mayongxin's avatar
mayongxin committed
18 19 20
                }
            }
        )
mayongxin's avatar
mayongxin committed
21

mayongxin's avatar
mayongxin committed
22
    }, [flag])
mayongxin's avatar
mayongxin committed
23 24 25
    const loadConfig = () => {

    }
mayongxin's avatar
mayongxin committed
26 27 28 29 30 31 32 33 34 35 36
    const operateControl = value => {
        AuthSetting({
            IsOpenAuth:value
        }).then(
            res =>{
                if(res.code === 0){
                    setFlag(flag + 1)
                    message.success("设置成功!")
                }
            }
        )
mayongxin's avatar
mayongxin committed
37 38 39 40 41

    }
    return (
        <>
            <PageContainer>
mayongxin's avatar
mayongxin committed
42 43 44 45 46 47 48
                <div style={{display:"flex",flexWrap:"wrap"}}>
                    <Card title="数据管理" style={{ width: 350, marginLeft: 15 }}>
                        <div className={styles.auth_container}>
                            <div className={styles.operate_item}>
                                <div>数据库鉴权</div>
                                <Switch checkedChildren='开启' unCheckedChildren='关闭' checked={auChecked} onChange={operateControl} />
                            </div>
mayongxin's avatar
mayongxin committed
49
                        </div>
mayongxin's avatar
mayongxin committed
50 51 52 53 54 55 56 57 58 59
                    </Card>
                    <Card title="缓存管理" style={{ width: 350, marginLeft: 15 }}>
                        <div className={styles.auth_container}>
                            <div className={styles.operate_item}>
                                <div>开启缓存</div>
                                <Switch checkedChildren='开启' unCheckedChildren='关闭' checked={cacheChecked} disabled={true} />
                            </div>
                        </div>
                    </Card>
                </div>
mayongxin's avatar
mayongxin committed
60 61 62 63 64
            </PageContainer>
        </>
    )
}
export default AuthControl;