提交 1f186a3a authored 作者: 钟是志's avatar 钟是志

优化代码

上级 bbb06a13
/**
* 判断是否为JSON文本
* @param {string} str 是否为json文本
*/
export function isJSON(str) {
if (typeof str == 'string') {
try {
JSON.parse(str);
if (typeof JSON.parse(str) === 'number') {
return false;
}
return true;
} catch (e) {
return false;
}
}
}
/**
* 2022年7月19日
* 钟是志
* 一站式接口为了应付北电科的鉴权 按欢哥搞的 把接口地址进行一次转换
* 禅道 28321 一站式接口越权处理
* */
import { getToken } from '@/webPublic/one_stop_public/utils/getToken';
import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON';
export function getTransformApi(url = '') {
let t = getToken();
if (!t || t.length < 11) {
return new Promise((resolve, reject) => {
resolve(false);
});
}else{
let storage = localStorage.getItem('oneStopTransformApi');
// if(storage && isJSON()){
//
// }
}
}
export function setTransformApi(api = '', transformApi = '') {
const data = get;
}
......@@ -3,6 +3,9 @@ import { message } from 'antd';
import baseClone from './deepclone/baseClone';
import empty from './deepclone/isEmpty';
import intersection from './deepclone/intersection';
import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON';
export { isJSON };
/**
* 校验 开始时间必须在结束时间之前的函数
* */
......@@ -71,23 +74,7 @@ export function randomStr() {
.toString(36)
.substr(2);
}
/**
* 判断是否为JSON文本
* @param {string} str 是否为json文本
*/
export function isJSON(str) {
if (typeof str == 'string') {
try {
JSON.parse(str);
if (typeof JSON.parse(str) === 'number') {
return false;
}
return true;
} catch (e) {
return false;
}
}
}
/**
* 随机生成数字
* @param {最小数} minNum
......
......@@ -4,6 +4,7 @@ import moment from 'moment';
import { isNaN } from 'lodash';
import React from 'react';
import config from '@/webPublic/one_stop_public/config';
import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON';
const codeMessage = {
200: '服务器成功返回请求的数据。',
......@@ -197,24 +198,7 @@ const getRender = (com, props) => {
}
};
/**
* 判断传入值是否为JSON文本
*/
const isJSON = str => {
if (typeof str == 'string') {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
} else {
return false;
}
} catch (e) {
console.log('error:' + str + '!!!' + e);
return false;
}
}
};
const ShowComName = ({ json = {} }) => <span
style={{ display: 'none' }}
......
import { setCookie } from '@/webPublic/one_stop_public/utils/cookie';
/**
* 获取token
* */
export function getToken() {
const x = localStorage.getItem('antd-pro-token-onestop');
if (x && x.length > 11) {
setCookie('token', x, 1);
return x;
}
const y = localStorage.getItem('antd-pro-token');
if (y && y.length > 11) {
setCookie('token', x, 1);
return y;
}
return null;
}
......@@ -4,7 +4,7 @@
import { isJSON } from '@/webPublic/one_stop_public/copy';
import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils';
import { delCookie, setCookie } from '@/webPublic/one_stop_public/utils/cookie';
export { getToken } from './getToken';
......@@ -26,24 +26,7 @@ export function setToken(value, time) {
}
}
/**
* 获取token
* */
export function getToken() {
const x = localStorage.getItem('antd-pro-token-onestop');
if (x && x.length > 11) {
setCookie('token', x, 1);
return x;
}
const y = localStorage.getItem('antd-pro-token');
if (y && y.length > 11) {
setCookie('token', x, 1);
return y;
}
return null;
}
/**
* 删除token
......
......@@ -3,25 +3,10 @@ import { message, Icon, Spin } from 'antd';
import QRCode from 'qrcode.react';
import fetch from 'dva/fetch';
import FormdataWrapper from '../utils/object-to-formdata-custom';
import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON';
let ws = null;
/**
* 判断是否为JSON文本
* @param {string} str 是否为json文本
*/
function isJSON(str) {
if (typeof str == 'string') {
try {
JSON.parse(str);
if (typeof JSON.parse(str) === 'number') {
return false;
}
return true;
} catch (e) {
return false;
}
}
}
/**
* props{
* url: 二维码url
......
......@@ -6,8 +6,9 @@ import React from 'react';
import moment from 'moment';
import { Icon, message, notification } from 'antd';
import { getOneStopActiveMenus, getOnestopKey } from '../../Services';
import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON';
let messageTime = new Date().getTime() - 3000;
export { isJSON };
/**
* 校验 开始时间必须在结束时间之前的函数
* */
......@@ -142,19 +143,7 @@ export function randomStr() {
.substr(2);
}
export function isJSON(str) {
if (typeof str == 'string') {
try {
JSON.parse(str);
if (typeof JSON.parse(str) === 'number') {
return false;
}
return true;
} catch (e) {
return false;
}
}
}
export function checkMustHaveValue(configFileds, data) {
for (let item of configFileds) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论