Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
H5Public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
CI / CD
CI / CD
流水线
作业
日程
统计图
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
H5Public
Commits
d86ca888
提交
d86ca888
authored
8月 30, 2022
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
移动端解决增加二进制加解密
上级
77f41269
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
376 行增加
和
91 行删除
+376
-91
binaryToStr.js
utils/Base16/binaryToStr.js
+17
-0
encryptApiList.js
utils/Base16/encryptApiList.js
+160
-0
index.jsx
utils/Base16/index.jsx
+163
-88
strToBinary.js
utils/Base16/strToBinary.js
+19
-0
request.js
utils/request.js
+17
-3
没有找到文件。
utils/Base16/binaryToStr.js
0 → 100644
浏览文件 @
d86ca888
/**
* 二进制字符串转JSON字符串
* */
export
function
binaryToStr
(
binaryStr
=
''
)
{
let
res
=
''
;
if
(
binaryStr
)
{
binaryStr
=
binaryStr
.
replaceAll
(
'.'
,
'1'
);
binaryStr
=
binaryStr
.
replaceAll
(
'-'
,
'0'
);
let
strListArr
=
binaryStr
.
split
(
'_'
);
for
(
let
i
=
0
;
i
<
strListArr
.
length
;
i
++
)
{
let
item
=
strListArr
[
i
];
res
+=
String
.
fromCharCode
(
parseInt
(
item
,
2
));
}
}
return
res
;
}
utils/Base16/encryptApiList.js
0 → 100644
浏览文件 @
d86ca888
const
encryptApiList
=
[
{
api
:
'DataColumnApi/getOptions'
,
key
:
[
'filterSql'
],
},
{
api
:
'UnifiedServicePatternApi/updateForm'
,
},
{
api
:
'getApis'
,
},
{
api
:
'UnifiedServicePatternApi/getDetail'
,
},
{
api
:
'SqlManageEntityApi/add'
,
},
{
api
:
'SqlManageEntityApi/find'
,
},
{
api
:
'DataObjApi/addFormData'
,
},
{
api
:
'DataObjApi/exportCurr'
,
},
{
api
:
'DataColumnApi/add'
,
},
{
api
:
'UnifiedAppApi/getDetail'
,
},
{
api
:
'UnifiedServiceApi/getDetail'
,
},
{
api
:
'UnifiedAppFormApi/getFormDetail'
,
},
{
api
:
'/CmsApi/'
,
},
{
api
:
'DataColumnApi/getLabels'
,
key
:
[
'allValues'
],
filterEmpty
:
[
'allValues'
],
setNull
:
true
,
// 置空这个字段
},
{
api
:
'DataColumnApi/getSqlOptions'
,
key
:
[
'allValues'
,
'sqlKey'
],
filterEmpty
:
[
'allValues'
],
query
:
true
,
// 调另外一个接口查询这个的替换值
},
{
api
:
'DataColumnApi/getSqlLabels'
,
key
:
[
'allValues'
],
filterEmpty
:
[
'allValues'
],
query
:
true
,
},
{
api
:
'DataColumnApi/getSqlData'
,
key
:
[
'allValues'
,
'sqlKey'
],
filterEmpty
:
[
'sqlKey'
],
query
:
true
,
},
{
api
:
'DataColumnApi/getSqlColumn'
,
key
:
[
'json'
],
},
{
api
:
'DataRightApi/add'
,
key
:
[
'filterSql'
],
// filterEmpty: ['filterSql'],
},
{
api
:
'DataRightApi/addBatch'
,
key
:
[
'filterSql'
],
},
{
api
:
'DataObjApi/add'
,
key
:
[
'sqlScript'
],
},
{
api
:
'DataObjApi/getFormDataList'
,
key
:
[
'custom'
],
},
{
api
:
'DataObjApi/exportWord'
,
key
:
[
'params'
],
},
{
api
:
'DataObjApi/getFormDataPage'
,
key
:
[
'sql'
,
'custom'
],
filterEmpty
:
[
'sql'
,
'custom'
],
yinShe
:
{
sql
:
's'
,
query
:
'chaxun'
,
querys
:
'chaxuns'
,
sorter
:
'paixu'
,
orders
:
'paixus'
,
},
},
{
api
:
'UserApi/getPage'
,
key
:
[
'addSignSql'
],
},
{
api
:
'UnifiedAppFormApi/examineProcess'
,
key
:
[
'taskForm'
],
},
{
api
:
'UnifiedAppFormApi/saveDraft'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/startProcess'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/startProcessByService'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/getHandleUser'
,
key
:
[
'content'
],
},
{
api
:
'SqlManageEntityApi/findParamsKey'
,
key
:
[
'sqlKey'
],
},
{
api
:
'UnifiedServiceApi/config'
,
// 禅道 25034 宿舍管理/宿舍维修审核,2021030576L 加个字段 做个字段排序
key
:
[
'config'
],
},
];
const
resBinaryApiList
=
[
{
api
:
'UnifiedAppApi/getDetail'
,
},
{
api
:
'UnifiedServiceApi/getDetail'
,
},
{
api
:
'UnifiedAppFormApi/getFormDetail'
,
},
{
api
:
'UnifiedServicePatternApi/getDetail'
,
},
{
api
:
'SqlManageEntityApi/find'
,
},
{
api
:
'getApis'
,
},
];
export
{
resBinaryApiList
};
export
default
encryptApiList
;
utils/Base16/index.jsx
浏览文件 @
d86ca888
import
{
isJSON
}
from
'../authority'
;
import
{
getToken
,
isJSON
}
from
'../authority'
;
import
request
from
'../request'
;
import
{
getHeaders
}
from
'../2022new/getHeaders'
;
import
{
Toast
}
from
'antd-mobile'
;
import
{
binaryToStr
}
from
'./binaryToStr'
;
import
{
getUserInfo
}
from
'../2022new/currentUser'
;
import
{
strToBinary
}
from
'./strToBinary'
;
import
encryptApiList
,{
resBinaryApiList
}
from
'./encryptApiList'
;
const
baseX
=
require
(
'./basx-x'
);
var
BASE16
=
'0123456789abcdef'
;
...
...
@@ -43,90 +49,9 @@ const giveKey = (key, datas) => {
};
const
encryptApiList
=
[
{
api
:
'DataColumnApi/getOptions'
,
key
:
[
'filterSql'
],
},
{
api
:
'DataColumnApi/getLabels'
,
key
:
[
'allValues'
],
filterEmpty
:
[
'allValues'
],
setNull
:
true
,
},
{
api
:
'DataColumnApi/getSqlOptions'
,
key
:
[
'allValues'
],
filterEmpty
:
[
'allValues'
],
query
:
true
,
},
{
api
:
'DataColumnApi/getSqlLabels'
,
key
:
[
'allValues'
],
filterEmpty
:
[
'allValues'
],
query
:
true
,
},
{
api
:
'DataColumnApi/getSqlData'
,
key
:
[
'allValues'
,
'sqlKey'
],
filterEmpty
:
[
'sqlKey'
],
query
:
true
,
},
{
api
:
'DataColumnApi/getSqlColumn'
,
key
:
[
'json'
],
},
{
api
:
'DataRightApi/add'
,
key
:
[
'filterSql'
],
// filterEmpty: ['filterSql'],
},
{
api
:
'DataRightApi/addBatch'
,
key
:
[
'filterSql'
],
},
{
api
:
'DataObjApi/add'
,
key
:
[
'sqlScript'
],
},
{
api
:
'DataObjApi/getFormDataList'
,
key
:
[
'custom'
],
},
{
api
:
'DataObjApi/getFormDataPage'
,
key
:
[
'sql'
,
'custom'
],
filterEmpty
:
[
'sql'
,
'custom'
],
},
{
api
:
'UserApi/getPage'
,
key
:
[
'addSignSql'
],
},
{
api
:
'UnifiedAppFormApi/examineProcess'
,
key
:
[
'taskForm'
],
},
{
api
:
'UnifiedAppFormApi/saveDraft'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/startProcess'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/startProcessByService'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/getHandleUser'
,
key
:
[
'content'
],
},
{
api
:
'SqlManageEntityApi/findParamsKey'
,
key
:
[
'sqlKey'
],
},
];
const
countAllValues
=
async
(
datas
,
item
)
=>
{
if
(
item
.
setNull
)
{
...
...
@@ -166,8 +91,6 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
for
(
let
g
of
item
.
key
)
{
if
(
g
===
'allValues'
&&
typeof
datas
[
g
]
!==
'undefined'
)
{
datas
=
await
countAllValues
(
datas
,
item
);
// 循环中 不要写await 为什么?
// https://www.bilibili.com/video/BV1G5411o73g
datas
=
giveKey
(
'allValues'
,
datas
);
}
else
{
...
...
@@ -181,3 +104,155 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
}
return
datas
;
}
export
async
function
giveFilePostData
(
datas
,
url
)
{
for
(
let
i
in
datas
)
{
if
(
datas
[
i
]
===
null
||
(
Array
.
isArray
(
datas
[
i
])
&&
datas
[
i
].
length
===
0
)
||
datas
[
i
]
===
undefined
)
{
delete
datas
[
i
];
}
}
if
(
url
&&
typeof
url
===
'string'
)
{
for
(
let
item
of
encryptApiList
)
{
if
((
window
.
CONFIG
?.
ALLBIN
&&
url
.
indexOf
(
'/onestop/'
)
>
-
1
)
||
url
.
indexOf
(
item
.
api
)
>
-
1
)
{
const
roleGroup
=
getUserInfo
().
groupsId
;
if
(
url
.
indexOf
(
'http'
)
>
-
1
)
{
url
=
url
.
replace
(
'/onestop/'
,
`/onestop/safe/
${
roleGroup
}
/`
);
}
else
{
url
=
url
.
replace
(
url
,
`/safe/
${
roleGroup
}
/`
+
url
);
url
=
url
.
replaceAll
(
'//'
,
'/'
);
}
datas
=
await
countAllValues
(
datas
,
item
);
return
new
Promise
((
resolve
,
reject
)
=>
{
resolve
({
datas
:
formatDatas
(
datas
,
url
),
url
,
});
});
}
}
}
return
new
Promise
((
resolve
,
reject
)
=>
{
resolve
(
datas
);
return
datas
;
});
}
let
time
=
new
Date
().
getTime
();
export
const
qqCw
=
({
title
=
'请求错误'
,
msg
=
''
,
customErrMsg
=
''
,
})
=>
{
let
nowX
=
new
Date
().
getTime
()
-
time
;
if
(
nowX
<
3000
)
{
return
false
;
}
time
=
new
Date
().
getTime
();
// 请求错误 增加自定义错误提示信息 customErrMsg 从发起 接口那里自定义
// 禅道bug 11794
Toast
.
info
(
title
);
return
undefined
;
};
export
async
function
requestFileInfo
(
url
,
datas
)
{
// for (let i = 0; i < 100; i++) {
// datas = await testPromise(datas);
// }
const
formData
=
new
FormData
();
// if (getVisitorToken()) {
// datas.token = getVisitorToken();
// }
datas
.
token
=
getToken
();
for
(
let
key
in
datas
)
{
formData
.
append
(
key
,
datas
[
key
]);
}
if
(
!
url
||
typeof
url
!==
'string'
)
{
return
false
;
}
return
fetch
(
url
,
{
headers
:
{
Accept
:
'application/json'
,
...
getHeaders
().
headers
,
},
method
:
'POST'
,
credentials
:
'omit'
,
mode
:
'cors'
,
body
:
formData
,
})
.
then
((
res
)
=>
{
if
(
res
.
status
===
401
)
{
qqCw
({
title
:
'登录过期401'
,
customErrMsg
:
'登录已过期,请重新登录'
,
});
return
false
;
}
if
(
res
.
status
===
404
)
{
qqCw
({
title
:
'http404报错'
,
customErrMsg
:
'请联系系统管理员'
,
});
return
false
;
}
return
res
.
json
();
})
.
then
((
res
)
=>
{
if
(
res
&&
typeof
res
===
'object'
&&
res
.
rbin
)
{
res
=
binaryToStr
(
res
.
rbin
);
if
(
isJSON
(
res
))
{
res
=
JSON
.
parse
(
res
);
}
}
if
(
res
&&
res
.
errCode
)
{
qqCw
({
msg
:
res
.
errMsg
||
res
.
message
,
customErrMsg
:
res
.
customErrMsg
,
});
return
false
;
}
return
res
;
});
}
function
formatDatas
(
datas
,
url
=
''
)
{
if
(
url
&&
url
.
indexOf
(
'getSqlData'
)
>
-
1
&&
window
.
smartFormGlobalProps
?.
data
)
{
// 按欢哥的要求 getSqlData 接口要加上appId 参数
// 解决北电科接口越权的问题.
datas
.
appId
=
window
.
smartFormGlobalProps
?.
data
.
appId
||
window
.
smartFormGlobalProps
?.
data
.
id
;
console
.
log
(
'getSqlData,AppId'
,
datas
.
appId
);
}
let
datasCode
=
JSON
.
stringify
(
datas
);
const
openIsBinary
=
window
.
CONFIG
?.
IS_BINARY
;
if
(
openIsBinary
)
{
datasCode
=
strToBinary
(
datasCode
);
}
let
file
=
new
File
([
datasCode
],
'fileParams.jpeg'
,
{
type
:
'image/jpeg'
,
});
let
datasTrue
=
{
fileParams
:
file
,
};
if
(
openIsBinary
)
{
datasTrue
.
bin
=
true
;
if
(
window
.
CONFIG
?.
ALL_R_BIN
)
{
datasTrue
.
rbin
=
true
;
}
else
{
let
findIndexA
=
resBinaryApiList
.
findIndex
((
g
)
=>
{
return
url
.
includes
(
g
.
api
);
});
if
(
findIndexA
>=
0
)
{
datasTrue
.
rbin
=
true
;
}
}
}
return
datasTrue
;
}
utils/Base16/strToBinary.js
0 → 100644
浏览文件 @
d86ca888
/**
* 字符串转二进制
* */
export
function
strToBinary
(
str
)
{
let
result
=
[];
let
list
=
str
.
split
(
''
);
for
(
let
i
=
0
;
i
<
list
.
length
;
i
++
)
{
if
(
i
!==
0
)
{
result
.
push
(
'_'
);
}
let
item
=
list
[
i
];
let
binaryStr
=
item
.
charCodeAt
()
.
toString
(
2
);
result
.
push
(
binaryStr
);
}
let
resultStr
=
result
.
join
(
''
);
resultStr
=
resultStr
.
replaceAll
(
'0'
,
'-'
).
replaceAll
(
'1'
,
'.'
);
return
resultStr
;
}
utils/request.js
浏览文件 @
d86ca888
...
...
@@ -2,11 +2,10 @@
import
{
stringify
}
from
'qs'
;
import
{
Toast
,
Modal
}
from
'antd-mobile'
;
import
router
from
'umi/router'
;
import
{
routerRedux
}
from
'dva/router'
;
import
store
from
'dva'
;
import
FormdataWrapper
from
'./object-to-formdata-custom'
;
import
{
getToken
,
clearToken
,
getIsBei_Dian
}
from
'./authority'
;
import
{
getHeaders
}
from
'@/H5Public/utils/2022new/getHeaders'
;
import
{
giveFilePostData
,
requestFileInfo
}
from
'./Base16'
;
const
codeMessage
=
{
200
:
'服务器成功返回请求的数据。'
,
...
...
@@ -46,13 +45,28 @@ function checkStatus(response) {
* @param {object} [options] The options we want to pass to "fetch"
* @return {object} An object containing either "data" or "err"
*/
export
default
function
request
(
url
,
options
,
config
=
{
enableLoading
:
true
})
{
export
default
async
function
request
(
url
,
options
,
config
=
{
enableLoading
:
true
}){
if
(
window
.
CONFIG
?.
IS_SAFE
&&
options
.
body
){
let
newData
=
await
giveFilePostData
(
options
.
body
,
url
);
if
(
typeof
newData
===
'object'
&&
newData
.
url
&&
newData
.
datas
)
{
options
.
body
=
newData
.
datas
;
return
requestFileInfo
(
newData
.
url
,
newData
.
datas
);
}
}
return
requestOrigin
(
url
,
options
,
config
);
}
export
function
requestOrigin
(
url
,
options
,
config
=
{
enableLoading
:
true
})
{
const
{
errorHandle
}
=
config
;
// 错误弹窗 回调
const
defaultOptions
=
{
credentials
:
getIsBei_Dian
()
?
'include'
:
'omit'
,
mode
:
'cors'
,
};
const
newOptions
=
{
...
defaultOptions
,
...
options
};
if
(
getToken
()
&&
(
url
.
indexOf
(
'/third/token'
)
<=
-
1
&&
url
.
indexOf
(
'wxConfigApi/getConfig'
)
<=
-
1
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论