Commit d8f53be4 authored by 前端-黄佳鑫's avatar 前端-黄佳鑫

feat: 系统管理新增解密密匙页面

parent 4008df94
...@@ -79,6 +79,12 @@ const AuthConfigRoute: RouterChild = { ...@@ -79,6 +79,12 @@ const AuthConfigRoute: RouterChild = {
}, },
] ]
}, },
/** 密钥管理 */
{
path: '/memberCenter/systemSetting/key',
name: '密钥管理',
component: '@/pages/systemSetting/key',
},
// 收藏管理 // 收藏管理
{ {
path: '/memberCenter/systemSetting/collection', path: '/memberCenter/systemSetting/collection',
......
...@@ -61,6 +61,7 @@ const memberCenterRoute = { ...@@ -61,6 +61,7 @@ const memberCenterRoute = {
// // 合同能力 // // 合同能力
// contracRoute, // contracRoute,
//... //...
// AuthConfigRoute,
...asyncRoutes, ...asyncRoutes,
{ {
path: '/memberCenter/noAuth', path: '/memberCenter/noAuth',
......
import React, { useEffect, useState } from 'react';
import { Card, Row, Col, Button, Typography } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { PublicApi } from '@/services/api';
const Key = () => {
const [key, setKey] = useState<string>('');
const [fmt, setFmt] = useState<string>('');
const countTime = () => {
//获取当前时间
const date = new Date();
const now = date.getTime();
//设置截止时间
const end = Number(sessionStorage.getItem('time'));
//时间差
const leftTime = end - now;
//定义变量 d,h,m,s保存倒计时的时间
let d, h, m, s;
if (leftTime >= 0) {
d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
m = Math.floor(leftTime / 1000 / 60 % 60);
s = Math.floor(leftTime / 1000 % 60);
}
//递归每秒调用countTime方法,显示动态时间效果
setFmt(`${d}${h}小时${m}${s}秒`);
setTimeout(countTime, 1000);
}
const getSecretKey = async () => {
await PublicApi.getManageSecretKeyGetSecretKey().then((res: any) => {
if (res.code !== 1000) {
return
}
const { data } = res;
setKey(data.secretKey);
sessionStorage.setItem('time', data.effectiveTime)
})
}
useEffect(() => {
getSecretKey();
}, [])
useEffect(() => {
if (sessionStorage.getItem('time')) {
countTime()
}
}, [sessionStorage.getItem('time')])
return (
<PageHeaderWrapper>
<Card>
<Row>
<Col span={24} style={{ margin: '10px' }}>
<Typography.Text style={{ display: 'flex', alignItems: 'center' }}>
解密密钥:
<Typography.Paragraph
style={{ marginBottom: '0', marginLeft: '24px' }}
strong
copyable={{
icon: [<Button style={{ marginLeft: '24px' }}>复制密钥</Button>, <Button style={{ marginLeft: '24px' }} type='primary'>复制密钥</Button>]
}}
>
{key}
</Typography.Paragraph>
</Typography.Text>
</Col>
<Col span={24} style={{ margin: '10px' }}>
<Typography.Text>{`当前解密密钥有效时间:${fmt}`}</Typography.Text>
</Col>
<Col span={24} style={{ margin: '10px' }}>
<Typography.Text>到期后系统将自动重置解密密钥</Typography.Text>
</Col>
</Row>
</Card>
</PageHeaderWrapper>
)
}
export default Key
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment