master_basic
parent
653a092c3f
commit
fffb8534e7
@ -1,28 +0,0 @@
|
||||
import ContentWarp from '@/components/ContentWarp';
|
||||
import styles from '../../index.less';
|
||||
import ButtonComp from '@/components/ButtonComp';
|
||||
import { useState } from 'react';
|
||||
|
||||
// 网络GLQ配置 --> 获取配置信息--> 网络配置信息
|
||||
export default function Page() {
|
||||
const [htmlText, setHtmlText] = useState('<div>文本内容</div>')
|
||||
|
||||
return (
|
||||
<div className={styles.params_warp}>
|
||||
<ContentWarp text={'获取网络配置'}>
|
||||
<div className='pd20'>被控端网络状态信息配置情况</div>
|
||||
<div className='line'></div>
|
||||
<div className='pd20 pb100'>
|
||||
<div className={styles.html_con}>
|
||||
<div style={{ padding: '20px 12px' }} dangerouslySetInnerHTML={{ __html: htmlText }}></div>
|
||||
</div>
|
||||
<div className={styles.btn_warp}>
|
||||
<ButtonComp style={{ marginRight: 20 }} text={'发送命令'} onClick={() => { }} />
|
||||
<ButtonComp style={{ marginRight: 20 }} type={'cancel'} text={'文件另存'} onClick={() => { }} />
|
||||
<ButtonComp type={'cancel'} text={'清空信息'} onClick={() => setHtmlText('')} />
|
||||
</div>
|
||||
</div>
|
||||
</ContentWarp>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,70 +1,3 @@
|
||||
export const rowClassName = (record:any, index: any) => {
|
||||
return index % 2 === 0 ? 'even-row' : 'odd-row';
|
||||
};
|
||||
|
||||
const parseParamsStr = (v: any, method?: string) => {
|
||||
const param: any = {};
|
||||
const p = Object.assign(true, v, {});
|
||||
const arr: any = [];
|
||||
Object.keys(p)
|
||||
.sort()
|
||||
.forEach(function (key) {
|
||||
p[key] = p[key] === true ? 'true' : p[key];
|
||||
p[key] = p[key] === false ? 'false' : p[key];
|
||||
if (method === 'GET') {
|
||||
if (p[key] !== null) {
|
||||
if (typeof p[key] === 'object') {
|
||||
param[key] = p[key];
|
||||
} else {
|
||||
param[key] = String(p[key]);
|
||||
}
|
||||
if (typeof p[key] === 'object' && p[key] == '') return;
|
||||
const _key = p[key] === null || p[key] === 'null' ? '' : p[key];
|
||||
arr.push(
|
||||
`${key}=${
|
||||
typeof _key === 'string' || typeof _key === 'number' ? _key : JSON.stringify(_key)
|
||||
}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const _key = p[key] === null || p[key] === 'null' ? '' : p[key];
|
||||
arr.push(
|
||||
`${key}=${
|
||||
typeof _key === 'string' || typeof _key === 'number' ? _key : JSON.stringify(_key)
|
||||
}`,
|
||||
);
|
||||
if (typeof p[key] === 'object') {
|
||||
param[key] = p[key];
|
||||
} else {
|
||||
param[key] = p[key];
|
||||
}
|
||||
}
|
||||
});
|
||||
return arr.join('&');
|
||||
};
|
||||
|
||||
const aKey = 'e83900ca9be33747397cc81a8f68ac11';
|
||||
const sKey = '6de3a75ae5718cde1e0907a593afd01f';
|
||||
|
||||
export const setHeader = (newOptions: any, url?: string) => {
|
||||
const timenow = Date.now();
|
||||
const stringToSign =
|
||||
'method=' +
|
||||
newOptions.method +
|
||||
'&' +
|
||||
(!!Object.keys(newOptions?.params || {})?.length
|
||||
? parseParamsStr(newOptions.params, newOptions.method) + '&'
|
||||
: '') +
|
||||
(!!Object.keys(newOptions?.body || {})?.length
|
||||
? parseParamsStr(JSON.parse(newOptions.body)) + '&'
|
||||
: '') +
|
||||
'ak=' +
|
||||
aKey +
|
||||
'&sk=' +
|
||||
sKey +
|
||||
'&time=' +
|
||||
timenow;
|
||||
|
||||
newOptions.headers['X-EDU-Timestamp'] = timenow;
|
||||
return newOptions;
|
||||
};
|
@ -0,0 +1,16 @@
|
||||
|
||||
// 校验端口
|
||||
export const validatePort = (_: any, value: any, callback: any) => {
|
||||
if (value && !/^\d+$/.test(value)) {
|
||||
return Promise.reject(new Error('请输入有效的端口号'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
// 校验ip
|
||||
export const validateIPAddress = (_: any, value: any) => {
|
||||
if (value && !/^(\d{1,3}\.){3}\d{1,3}$/.test(value)) {
|
||||
return Promise.reject(new Error('请输入正确的 IP 地址'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
};
|
Loading…
Reference in new issue