Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
03382e2d
提交
03382e2d
authored
5月 24, 2022
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
解决北电科防火墙问题 把接口数据转成文件
上级
ca1a4b12
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
132 行增加
和
22 行删除
+132
-22
index.jsx
one_stop_public/Base16/index.jsx
+89
-2
queryConfig.js
one_stop_public/utils/queryConfig.js
+1
-2
request.js
one_stop_public/utils/request.js
+28
-18
token.js
one_stop_public/utils/token.js
+14
-0
没有找到文件。
one_stop_public/Base16/index.jsx
浏览文件 @
03382e2d
import
baseX
from
'base-x'
;
import
baseX
from
'base-x'
;
import
{
apiRequest
}
from
'../utils/request'
;
import
{
apiRequest
}
from
'../utils/request'
;
import
{
isJSON
}
from
'@/webPublic/zyd_public/utils/utils'
;
import
{
isJSON
}
from
'@/webPublic/zyd_public/utils/utils'
;
import
{
uploadFile
}
from
'@/webPublic/one_stop_public/libs/PictureSignature/ShowItem'
;
import
{
queryApiActionPath
,
queryIsSafe
}
from
'@/webPublic/one_stop_public/utils/queryConfig'
;
import
{
getToken
,
getUserInfo
}
from
'@/webPublic/one_stop_public/utils/token'
;
var
BASE16
=
'0123456789abcdef'
;
var
BASE16
=
'0123456789abcdef'
;
var
bs16
=
baseX
(
BASE16
);
var
bs16
=
baseX
(
BASE16
);
...
@@ -39,6 +42,9 @@ const encryptApiList = [
...
@@ -39,6 +42,9 @@ const encryptApiList = [
api
:
'DataColumnApi/getOptions'
,
api
:
'DataColumnApi/getOptions'
,
key
:
[
'filterSql'
],
key
:
[
'filterSql'
],
},
},
{
api
:
'UnifiedServicePatternApi/updateForm'
,
},
{
{
api
:
'DataColumnApi/getLabels'
,
api
:
'DataColumnApi/getLabels'
,
key
:
[
'allValues'
],
key
:
[
'allValues'
],
...
@@ -162,7 +168,86 @@ const countAllValues = async (datas, item) => {
...
@@ -162,7 +168,86 @@ const countAllValues = async (datas, item) => {
};
};
export
function
requestFileInfo
(
url
,
datas
){
const
formData
=
new
FormData
();
if
(
getToken
()){
datas
.
token
=
getToken
();
}
for
(
let
key
in
datas
){
formData
.
append
(
key
,
datas
[
key
]);
}
return
fetch
(
queryApiActionPath
()
+
url
,
{
headers
:
{
Accept
:
'application/json'
,
// Authorization: `bearer ${getToken()}`,
},
method
:
'POST'
,
credentials
:
'omit'
,
mode
:
'cors'
,
body
:
formData
,
}).
then
((
res
)
=>
{
return
res
.
json
();
}).
then
((
res
)
=>
{
// console.log(res);
return
res
;
});
}
function
giveFilePostData
(
datas
,
url
){
url
=
url
.
replaceAll
(
'
\
/
\
/'
,
'
\
/'
);
if
(
url
&&
typeof
url
===
'string'
)
{
// const roleGroup = getUserInfo().groupsId;
// url = url.replace(url, `/safe/${roleGroup}/` + url);
// url = url.replaceAll('//', '/');
// console.table({datas, url});
// let file = new File([JSON.stringify(datas)], "fileParams.txt", {
// type: "text/plain",
// });
// datas = {
// fileParams: file,
// }
// return new Promise((resolve, reject) => {
// resolve({
// datas,
// url,
// });
// });
for
(
let
item
of
encryptApiList
)
{
if
(
url
.
indexOf
(
item
.
api
)
>
-
1
)
{
const
roleGroup
=
getUserInfo
().
groupsId
;
url
=
url
.
replace
(
url
,
`/safe/
${
roleGroup
}
/`
+
url
);
url
=
url
.
replaceAll
(
'//'
,
'/'
);
console
.
table
(
datas
);
let
file
=
new
File
([
JSON
.
stringify
(
datas
)],
"fileParams.jpg"
,
{
type
:
"text/plain"
,
});
// uploadFile(file);
datas
=
{
fileParams
:
file
,
}
return
new
Promise
((
resolve
,
reject
)
=>
{
resolve
({
datas
,
url
,
});
});
}
}
}
return
new
Promise
((
resolve
,
reject
)
=>
{
resolve
(
datas
);
return
datas
;
});
}
export
async
function
giveBase16EnCode
(
datas
,
url
)
{
// 全局加解密函数.
export
async
function
giveBase16EnCode
(
datas
,
url
)
{
// 全局加解密函数.
if
(
queryIsSafe
()){
return
giveFilePostData
(
datas
,
url
);
}
if
(
!
checkOpenBase16
())
{
if
(
!
checkOpenBase16
())
{
return
datas
;
return
datas
;
}
}
...
@@ -191,9 +276,9 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
...
@@ -191,9 +276,9 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
}
}
}
}
if
(
item
.
yinShe
)
{
// 映射参数字段.
if
(
item
.
yinShe
)
{
// 映射参数字段.
datas
.
isBase
=
true
;
datas
.
isBase
=
true
;
for
(
let
oldKey
in
item
.
yinShe
)
{
for
(
let
oldKey
in
item
.
yinShe
)
{
let
newKey
=
item
.
yinShe
[
oldKey
];
let
newKey
=
item
.
yinShe
[
oldKey
];
// if(typeof datas[oldKey] !== 'undefined'){
// if(typeof datas[oldKey] !== 'undefined'){
datas
[
newKey
]
=
datas
[
oldKey
];
datas
[
newKey
]
=
datas
[
oldKey
];
...
@@ -207,3 +292,5 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
...
@@ -207,3 +292,5 @@ export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
}
}
return
datas
;
return
datas
;
}
}
one_stop_public/utils/queryConfig.js
浏览文件 @
03382e2d
...
@@ -135,7 +135,6 @@ export const queryCheckPath = () => queryConfig('CHECK_PATH');
...
@@ -135,7 +135,6 @@ export const queryCheckPath = () => queryConfig('CHECK_PATH');
export
const
queryLoginRedirect
=
()
=>
queryConfig
(
'LOGIN_REDIRECT'
);
export
const
queryLoginRedirect
=
()
=>
queryConfig
(
'LOGIN_REDIRECT'
);
export
const
queryApiVersion
=
()
=>
queryConfig
(
'apiVersion'
);
export
const
queryApiVersion
=
()
=>
queryConfig
(
'apiVersion'
);
export
const
queryUiaApi
=
()
=>
queryConfig
(
'oauthServer'
);
export
const
queryUiaApi
=
()
=>
queryConfig
(
'oauthServer'
);
export
const
queryIsSafe
=
()
=>
queryConfig
(
'IS_SAFE'
);
// 是否开启文件上传加密 2022年5月24日 钟是志 解决北电科安全防火墙bug
export
default
queryConfig
;
export
default
queryConfig
;
one_stop_public/utils/request.js
浏览文件 @
03382e2d
...
@@ -14,7 +14,7 @@ import {
...
@@ -14,7 +14,7 @@ import {
import
{
openToast
}
from
'../location/Notification'
;
import
{
openToast
}
from
'../location/Notification'
;
import
{
showToast
}
from
'../location/Toast'
;
import
{
showToast
}
from
'../location/Toast'
;
import
{
offline
}
from
'../location/Toast'
;
import
{
offline
}
from
'../location/Toast'
;
import
{
giveBase16EnCode
}
from
"@/webPublic/one_stop_public/Base16"
;
import
{
giveBase16EnCode
,
requestFileInfo
}
from
'@/webPublic/one_stop_public/Base16'
;
import
objectToFormData
from
'@/webPublic/zyd_public/utils/object-to-formdata-custom'
;
import
objectToFormData
from
'@/webPublic/zyd_public/utils/object-to-formdata-custom'
;
const
codeMessage
=
{
const
codeMessage
=
{
...
@@ -42,7 +42,11 @@ const codeMessage = {
...
@@ -42,7 +42,11 @@ const codeMessage = {
* return URL参数字符串
* return URL参数字符串
*/
*/
const
qqCw
=
({
title
=
'请求错误'
,
msg
=
''
,
customErrMsg
=
''
})
=>
{
const
qqCw
=
({
title
=
'请求错误'
,
msg
=
''
,
customErrMsg
=
''
,
})
=>
{
// 请求错误 增加自定义错误提示信息 customErrMsg 从发起 接口那里自定义
// 请求错误 增加自定义错误提示信息 customErrMsg 从发起 接口那里自定义
// 禅道bug 11794
// 禅道bug 11794
notification
.
error
({
notification
.
error
({
...
@@ -118,11 +122,14 @@ const loginUmiRequest = extend({
...
@@ -118,11 +122,14 @@ const loginUmiRequest = extend({
const
getUrl
=
url
=>
(
url
.
startsWith
(
'/'
)
?
url
:
'/'
+
url
);
const
getUrl
=
url
=>
(
url
.
startsWith
(
'/'
)
?
url
:
'/'
+
url
);
export
const
request
=
(
url
,
data
,
options
=
{})
=>
{
export
const
request
=
(
url
,
data
,
options
=
{})
=>
{
return
giveBase16EnCode
(
data
,
url
).
then
((
newData
)
=>
{
return
giveBase16EnCode
(
data
,
url
)
// console.log(newData);
.
then
((
newData
)
=>
{
if
(
typeof
newData
===
'object'
&&
newData
.
url
){
return
requestFileInfo
(
newData
.
url
,
newData
.
datas
,
options
);
}
return
requestOrigin
(
url
,
newData
,
options
);
return
requestOrigin
(
url
,
newData
,
options
);
});
});
}
}
;
export
const
requestOrigin
=
(
url
,
data
,
options
=
{})
=>
{
export
const
requestOrigin
=
(
url
,
data
,
options
=
{})
=>
{
...
@@ -158,8 +165,8 @@ export const requestOrigin = (url, data, options = {}) => {
...
@@ -158,8 +165,8 @@ export const requestOrigin = (url, data, options = {}) => {
})
})
.
then
(
response
=>
{
.
then
(
response
=>
{
// console.log(response);
// console.log(response);
if
(
response
&&
response
.
errMsg
)
{
if
(
response
&&
response
.
errMsg
)
{
response
.
errMsg
=
response
.
errMsg
.
slice
(
0
,
50
);
response
.
errMsg
=
response
.
errMsg
.
slice
(
0
,
50
);
}
}
if
(
response
.
errCode
&&
response
.
errCode
==
'10000'
)
{
if
(
response
.
errCode
&&
response
.
errCode
==
'10000'
)
{
const
ul
=
window
.
location
.
href
;
const
ul
=
window
.
location
.
href
;
...
@@ -241,9 +248,10 @@ export const requestOrigin = (url, data, options = {}) => {
...
@@ -241,9 +248,10 @@ export const requestOrigin = (url, data, options = {}) => {
requestType
:
'form'
,
requestType
:
'form'
,
...
options
,
...
options
,
}).
then
(
response
=>
{
})
if
(
response
&&
response
.
errMsg
){
.
then
(
response
=>
{
response
.
errMsg
=
response
.
errMsg
.
slice
(
0
,
30
)
+
'...'
;
if
(
response
&&
response
.
errMsg
)
{
response
.
errMsg
=
response
.
errMsg
.
slice
(
0
,
30
)
+
'...'
;
}
}
if
(
response
&&
response
.
errCode
&&
response
.
errCode
==
'10000'
)
{
if
(
response
&&
response
.
errCode
&&
response
.
errCode
==
'10000'
)
{
const
ul
=
window
.
location
.
href
;
const
ul
=
window
.
location
.
href
;
...
@@ -350,26 +358,28 @@ export const getUiaRequest = (data) => { // 2.0的登录接口
...
@@ -350,26 +358,28 @@ export const getUiaRequest = (data) => { // 2.0的登录接口
return
fetch
(
queryUiaApi
()
+
'/oauth/token'
,
{
return
fetch
(
queryUiaApi
()
+
'/oauth/token'
,
{
credentials
:
'omit'
,
credentials
:
'omit'
,
mode
:
'cors'
,
mode
:
'cors'
,
headers
:{
headers
:
{
Accept
:
'application/json'
,
Accept
:
'application/json'
,
// 'Content-Type': 'multipart/form-data',
// 'Content-Type': 'multipart/form-data',
},
},
method
:
'POST'
,
method
:
'POST'
,
body
:
objectToFormData
(
data
),
body
:
objectToFormData
(
data
),
}).
then
(
response
=>
{
})
.
then
(
response
=>
{
return
response
.
json
();
return
response
.
json
();
}).
then
((
g
)
=>
{
})
if
(
g
&&
g
.
access_token
){
.
then
((
g
)
=>
{
if
(
g
&&
g
.
access_token
)
{
g
.
token
=
g
.
access_token
;
g
.
token
=
g
.
access_token
;
return
g
;
return
g
;
}
else
{
}
else
{
if
(
g
&&
g
.
message
)
{
if
(
g
&&
g
.
message
)
{
message
.
warn
(
g
.
message
);
message
.
warn
(
g
.
message
);
}
}
return
false
;
return
false
;
}
}
})
});
}
}
;
// export const testGetUiaRequest = (data) => { // 2.0的登录接口
// export const testGetUiaRequest = (data) => { // 2.0的登录接口
...
...
one_stop_public/utils/token.js
浏览文件 @
03382e2d
/**
/**
* 设置token
* 设置token
* */
* */
import
{
isJSON
}
from
'@/webPublic/one_stop_public/copy'
;
export
const
setToken
=
(
value
,
time
)
=>
{
export
const
setToken
=
(
value
,
time
)
=>
{
localStorage
.
setItem
(
'antd-pro-token-onestop'
,
value
);
localStorage
.
setItem
(
'antd-pro-token-onestop'
,
value
);
localStorage
.
setItem
(
'antd-pro-token'
,
value
);
localStorage
.
setItem
(
'antd-pro-token'
,
value
);
...
@@ -31,3 +33,15 @@ export const delToken = () => {
...
@@ -31,3 +33,15 @@ export const delToken = () => {
localStorage
.
removeItem
(
'antd-pro-token'
);
localStorage
.
removeItem
(
'antd-pro-token'
);
localStorage
.
removeItem
(
'wisdom-school-token'
);
localStorage
.
removeItem
(
'wisdom-school-token'
);
}
}
export
const
getUserInfo
=
()
=>
{
let
x
=
localStorage
.
getItem
(
'user'
);
if
(
isJSON
(
x
)){
x
=
JSON
.
parse
(
x
);
return
x
;
}
else
{
return
{
groupsId
:
'pub'
,
};
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论