You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xgd_system/src/pages/InitialSystem/PowerOnAuth/index.tsx

146 lines
5.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import { FC, useEffect, useState } from 'react';
import styles from './index.less';
import { Modal, message } from 'antd';
import ButtonComp from '@/components/ButtonComp';
import { college_table_query } from '@/services/api';
import { useParams } from 'umi';
import DEV from '@/utils/env/dev';
import { countType } from '@/utils/sysType';
interface PageProps {
}
const PowerOnAuth: FC<PageProps> = ({ }) => {
const urlParams = useParams();
const [visibility, setVisibility] = useState<boolean>(false);
const [deviceInfo, setDeviceInfo] = useState<any>({
"createTime": "",
"updateTime": "",
"secret": "",
"algorithm": "",
"selfInspectionCode": "",
"deviceName": "",
"initNumber": "",
"versionNumber": "",
"localNum": "",
"firmwareVersion": "",
"deviceStatus": "",
"fileName": null,
"dataInstalled": ""
});
const [isDeviceInit, setIsDeviceInit] = useState<boolean>(false);
let sysInfo = localStorage.getItem(`${urlParams?.fileType}`);
let info = sysInfo ? JSON.parse(sysInfo) : null;
useEffect(() => {
if (info?.deviceInit?.data && info?.deviceInit?.install) {
setIsDeviceInit(true);
college_table_query({}).then((res) => {
if (res?.result == "success" && res?.data.length > 0) {
if (!info?.powerOn) {
setVisibility(true);
localStorage.setItem(`${urlParams?.fileType}`, JSON.stringify({ ...info, powerOn: true }))
}
installSuccess()
setDeviceInfo(res?.data[0]);
} else {
message.error(res?.errorMsg);
}
})
}else {
setVisibility(true);
}
}, [])
const getName = () => {
return urlParams?.fileType == 'offLine' ? '离线版' : '在线版'
}
// 在指定的目录下安装快捷方式
const installSuccess = async () => {
try {
const response = await fetch('http://localhost:3000/createShortcut', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
mode: "cors",
body: JSON.stringify({
folderPath: `${DEV.FILE_URL}/${getName()}/${countType[urlParams?.fileType]}`,
shortcutName: '重启服务',
shortcutURL: `${DEV.LOCAL_URL}/restartService/${urlParams?.fileType}`
}),
});
} catch (error) {
message.error(error); // 处理请求错误
}
}
return (
<div className={styles.con_warp}>
<div style={{ padding: 30 }}>
<div className={styles.title1}></div>
<div className='mt30 mb30'>{deviceInfo.deviceName || '--'}</div>
<div className='mt30 mb30' style={{ display: 'flex' }}>
<div style={{ marginRight: 150 }}>{deviceInfo.deviceStatus || '--'}</div>
<div>{deviceInfo.initNumber || '--'}</div>
</div>
<div style={{ display: 'flex', marginBottom: 40 }}>
<div style={{ marginRight: 150 }}>{deviceInfo.firmwareVersion || '--'}</div>
<div>{deviceInfo.createTime || '--'}</div>
</div>
<div className={styles.title1}></div>
<div className={styles.flex}>
<div className='mr50'></div>
<div>
<div className='mb30'> <span className='ml50'>{deviceInfo.deviceStatus == '已开机' ? '无密钥' : '--'}</span></div>
<div> <span className='ml50'>{deviceInfo.deviceStatus == '已开机' ? '无密钥' : '--'}</span></div>
</div>
</div>
<div className={styles.flex}>
<div className='mr50'>VPN</div>
<div>
<div className='mb30'> <span className='ml50'>{deviceInfo.deviceStatus == '已开机' ? '无密钥' : '--'}</span></div>
<div> <span className='ml50'>{deviceInfo.deviceStatus == '已开机' ? '无密钥' : '--'}</span></div>
</div>
</div>
<div className={styles.flex}>
<div className='mr50'></div>
<div>
<div className='mb30'> <span className='ml50'>{deviceInfo.deviceStatus == '已开机' ? '无密钥' : '--'}</span></div>
<div> <span className='ml50'>{deviceInfo.deviceStatus == '已开机' ? '无密钥' : '--'}</span></div>
</div>
</div>
<div className={styles.flex}>
<div className='mr50'></div>
<div>
<div className='mb30'> <span className='ml50'>{deviceInfo.deviceStatus == '已开机' ? '无密钥' : '--'}</span></div>
<div> <span className='ml50'>{deviceInfo.deviceStatus == '已开机' ? '无密钥' : '--'}</span></div>
</div>
</div>
</div>
{/* 开机认证 */}
<Modal
title="开机认证"
open={visibility}
centered
width={380}
onCancel={() => setVisibility(false)}
footer={null}
maskClosable={false}
>
<div style={{ fontSize: 16 }}>
{isDeviceInit ? '开机认证成功!' :'开机认证失败,请先完成设备初装!'}
</div>
<div className='flex_jE mt20'>
<ButtonComp text={'确定'} onClick={() => setVisibility(false)} />
</div>
</Modal>
</div>
)
}
export default PowerOnAuth