import { FC, useEffect, useState } from 'react';
import { history, useLocation, useParams } from 'umi';
import ButtonComp from '@/components/ButtonComp';
import ClearInfoDialog from '@/components/ClearInfoDialog';
import NodeInitWrap from '@/components/NodeInitWrap';
import ContentWarp from '@/components/ContentWarp';
import { Button, ConfigProvider, Form, Input, Modal, Radio, Checkbox, message, Space,Select } from 'antd';

import DEV from '@/utils/env/dev';
import { countType,sysType } from '@/utils/sysType';

interface PageProps {

}

const NodeInitTool: FC<PageProps> = ({ }) => {
  const urlParams = useParams();
  const [authOpen, setAuthOpen] = useState(true);
  const [noticeOpen,setNoticeOpen] = useState(false)
 
  let sysInfo = localStorage.getItem(`${urlParams?.fileType}`);
  let info = sysInfo ? JSON.parse(sysInfo) : null;

  useEffect(() => {
    installSuccess()
    setAuthOpen(true)
  }, [])


  // 在指定的目录下安装快捷方式
  const installSuccess = async () => {
    try {
      const response = await fetch('http://localhost:3001/createShortcut', {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        mode: "cors",
        body: JSON.stringify({
          folderPath: `${DEV.FILE_URL}/${countType[urlParams?.fileType]}`,
          shortcutName: 'MMD063',
          shortcutURL: `${DEV.LOCAL_URL}/identifier/${urlParams?.fileType}?sysType=${encodeURIComponent(sysType[urlParams?.fileType] + 'hx')}`
        }),
      });
    } catch (error) {
      message.error(error); // 处理请求错误
    }
  }


  return (
    <section>
      <Modal
        title="XXX服务器"
        open={authOpen}
        centered
        footer={null}
        maskClosable={false}
        onCancel={() => {
          setAuthOpen(false)
        }}
      >
        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-start' }}>
          <div style={{ marginRight: '10px' }}>输入口令</div>
          <div style={{ flex: 1 }}><Input /></div>
        </div>

        <div className='flex_jE_AC mt30' >
          <ButtonComp type={'confirm'} text={'确定'} onClick={() => {
            setAuthOpen(false)
            setNoticeOpen(true)
          }} />
        </div>
      </Modal>
      <Modal
        title="XXX服务器"
        open={noticeOpen}
        centered
        footer={null}
        maskClosable={false}
        onCancel={() => {
          setAuthOpen(false)
        }}
      >
        <div>
          <div style={{ marginRight: '10px' }}>系统自检</div>
          <div>进度条</div>
          <div>提示文案</div>
        </div>

        <div className='flex_jE_AC mt30' >
          <ButtonComp type={'confirm'} text={'确定'} onClick={() => {
            setNoticeOpen(false)
          }} />
        </div>
      </Modal>
    </section>
  )

}

export default NodeInitTool