Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
745dfb91
提交
745dfb91
authored
3月 03, 2023
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2023年3月3日
* UC浏览器不支持 es6的 replaceAll方法 需要自己写一个
上级
54dd7273
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
209 行增加
和
180 行删除
+209
-180
binaryEncode.js
one_stop_public/Base16/binaryEncode.js
+194
-175
binaryToStr.js
one_stop_public/Base16/binaryToStr.js
+4
-3
strToBinary.js
one_stop_public/Base16/strToBinary.js
+4
-2
utils.js
one_stop_public/Base16/utils.js
+7
-0
没有找到文件。
one_stop_public/Base16/binaryEncode.js
浏览文件 @
745dfb91
import
encryptApiList
,
{
resBinaryApiList
,
resBinaryApiList
,
}
from
'@/webPublic/one_stop_public/Base16/encryptApiList'
;
import
{
getToken
,
getUserInfo
}
from
'@/webPublic/one_stop_public/utils/token'
;
import
{
queryApiActionPath
}
from
'@/webPublic/one_stop_public/utils/queryConfig'
;
...
...
@@ -12,196 +12,215 @@ import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/local
import
{
strToBinary
}
from
'./strToBinary'
;
// 字符串转二进制 混淆代码
import
{
binaryToStr
}
from
'./binaryToStr'
;
import
{
getVisitorToken
}
from
'@/webPublic/zyd_public/utils/getHeaders'
;
import
{
replaceAll
}
from
'@/webPublic/one_stop_public/Base16/utils'
;
const
test
=
!!
getUrlInfo
().
test
;
function
formatDatas
(
datas
,
url
=
''
)
{
if
(
url
&&
url
.
indexOf
(
'getSqlData'
)
>
-
1
&&
window
.
smartFormGlobalProps
?.
data
)
{
// 按欢哥的要求 getSqlData 接口要加上appId 参数
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 (test) {
// console.log(url, datas);
// }
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
;
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 (test) {
// console.log(url, datas);
// }
if
(
openIsBinary
)
{
datasCode
=
strToBinary
(
datasCode
);
}
let
file
=
new
File
([
datasCode
],
'fileParams.jpeg'
,
{
type
:
'image/jpeg'
,
});
let
datasTrue
=
{
fileParams
:
window
.
CONFIG
.
SAFE_TYPE
===
2
?
datasCode
:
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
;
}
export
async
function
giveFilePostData
(
datas
,
url
)
{
const
staticS
=
window
.
CONFIG
.
SAFE_TYPE
===
2
?
'interface'
:
'safe'
;
// console.log(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
)
{
console
.
log
(
url
);
url
=
url
.
replace
(
'/onestop/'
,
`/onestop/safe/
${
roleGroup
}
/`
);
url
=
url
.
replace
(
'/onestopapi/'
,
`/onestopapi/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
;
});
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/
${
staticS
}
/
${
roleGroup
}
/`
);
url
=
url
.
replace
(
'/onestopapi/'
,
`/onestopapi/
${
staticS
}
/
${
roleGroup
}
/`
);
}
else
{
url
=
url
.
replace
(
url
,
`/
${
staticS
}
/
${
roleGroup
}
/`
+
url
);
url
=
replaceAll
(
url
,
'//'
,
'/'
);
}
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
;
});
}
function
testPromise
(
d
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
resolve
(
d
);
});
return
new
Promise
((
resolve
,
reject
)
=>
{
resolve
(
d
);
});
}
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
();
}
for
(
let
key
in
datas
)
{
formData
.
append
(
key
,
datas
[
key
]);
}
if
(
!
url
||
typeof
url
!==
'string'
)
{
return
false
;
}
let
trueUrl
=
url
&&
url
.
indexOf
(
'http'
)
>
-
1
?
url
:
queryApiActionPath
()
+
url
;
const
{
transformApi
,
headersApi
}
=
await
getTransformApi
(
trueUrl
);
return
fetch
(
transformApi
,
{
headers
:
{
Accept
:
'application/json'
,
...
getHeaders
(
transformApi
).
headers
,
// apis: headersApi,
// axxx: `select * from user123 where id = 1`,
},
method
:
'POST'
,
credentials
:
'omit'
,
mode
:
'cors'
,
body
:
formData
,
})
.
then
((
res
)
=>
{
// console.log(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
);
const
staticS
=
window
.
CONFIG
.
SAFE_TYPE
===
2
?
'interface'
:
'safe'
;
// for (let i = 0; i < 100; i++) {
// datas = await testPromise(datas);
// }
const
formData
=
new
FormData
();
if
(
getVisitorToken
())
{
datas
.
token
=
getVisitorToken
();
}
else
{
datas
.
token
=
getToken
();
}
if
(
!
url
||
typeof
url
!==
'string'
)
{
return
false
;
}
let
trueUrl
=
url
&&
url
.
indexOf
(
'http'
)
>
-
1
?
url
:
queryApiActionPath
()
+
url
;
const
{
transformApi
,
headersApi
}
=
await
getTransformApi
(
trueUrl
);
let
urlSafe2
=
transformApi
;
if
(
window
.
CONFIG
.
SAFE_TYPE
===
2
)
{
urlSafe2
=
transformApi
.
split
(
'/'
);
let
findSafeIndex
=
urlSafe2
.
findIndex
(
g
=>
g
===
staticS
);
if
(
findSafeIndex
>=
1
)
{
let
path
=
urlSafe2
.
slice
(
findSafeIndex
+
2
).
join
(
'/'
);
urlSafe2
=
urlSafe2
.
slice
(
0
,
findSafeIndex
+
2
).
join
(
'/'
);
datas
.
path
=
'/'
+
path
;
}
}
for
(
let
key
in
datas
)
{
formData
.
append
(
key
,
datas
[
key
]);
}
return
fetch
(
urlSafe2
,
{
headers
:
{
Accept
:
'application/json'
,
...
getHeaders
(
transformApi
).
headers
,
ContentType
:
'multipart/form-data'
,
// apis: headersApi,
// axxx: `select * from user123 where id = 1`,
},
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
;
}
// if (test) {
// console.log({
// url,
// res,
// });
// }
return
res
;
});
}
if
(
res
&&
res
.
errCode
)
{
qqCw
({
msg
:
res
.
errMsg
||
res
.
message
,
customErrMsg
:
res
.
customErrMsg
,
});
return
false
;
}
// if (test) {
// console.log({
// url,
// res,
// });
// }
return
res
;
});
}
export
function
giveFilePostDataInfoForTrue
(
datas
,
url
)
{
if
(
!
window
.
CONFIG
?.
IS_SAFE
)
{
return
{
datas
,
url
,
};
}
datas
=
deepCopy
(
datas
);
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
)
{
const
roleGroup
=
getUserInfo
().
groupsId
;
if
(
url
.
indexOf
(
'http'
)
>
-
1
)
{
url
=
url
.
replace
(
'/onestop/'
,
`/onestop/safe/
${
roleGroup
}
/`
);
url
=
url
.
replace
(
'/onestopapi/'
,
`/onestopapi/safe/
${
roleGroup
}
/`
);
}
else
{
url
=
url
.
replace
(
url
,
`/safe/
${
roleGroup
}
/`
+
url
);
url
=
url
.
replaceAll
(
'//'
,
'/'
);
}
return
{
datas
:
formatDatas
(
datas
,
url
),
url
,
};
}
const
staticS
=
window
.
CONFIG
.
SAFE_TYPE
===
2
?
'interface'
:
'safe'
;
if
(
!
window
.
CONFIG
?.
IS_SAFE
)
{
return
{
datas
,
url
,
};
}
datas
=
deepCopy
(
datas
);
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
)
{
const
roleGroup
=
getUserInfo
().
groupsId
;
if
(
url
.
indexOf
(
'http'
)
>
-
1
)
{
url
=
url
.
replace
(
'/onestop/'
,
`/onestop/
${
staticS
}
/
${
roleGroup
}
/`
);
url
=
url
.
replace
(
'/onestopapi/'
,
`/onestopapi/
${
staticS
}
/
${
roleGroup
}
/`
);
}
else
{
url
=
url
.
replace
(
url
,
`/
${
staticS
}
/
${
roleGroup
}
/`
+
url
);
url
=
replaceAll
(
url
,
'//'
,
'/'
);
}
return
{
datas
:
formatDatas
(
datas
,
url
),
url
,
};
}
}
one_stop_public/Base16/binaryToStr.js
浏览文件 @
745dfb91
import
{
replaceAll
}
from
'@/webPublic/one_stop_public/Base16/utils'
;
/**
* 二进制字符串转JSON字符串
* */
export
function
binaryToStr
(
binaryStr
=
''
)
{
let
res
=
''
;
if
(
binaryStr
)
{
binaryStr
=
binaryStr
.
replaceAll
(
'
.'
,
'1'
);
binaryStr
=
binaryStr
.
replaceAll
(
'-'
,
'0'
);
binaryStr
=
replaceAll
(
binaryStr
,
'
\\
.'
,
'1'
);
binaryStr
=
replaceAll
(
binaryStr
,
'-'
,
'0'
);
let
strListArr
=
binaryStr
.
split
(
'_'
);
for
(
let
i
=
0
;
i
<
strListArr
.
length
;
i
++
)
{
let
item
=
strListArr
[
i
];
res
+=
String
.
fromCharCode
(
parseInt
(
item
,
2
));
...
...
one_stop_public/Base16/strToBinary.js
浏览文件 @
745dfb91
/**
* 字符串转二进制
* */
import
{
replaceAll
}
from
'@/webPublic/one_stop_public/Base16/utils'
;
export
function
strToBinary
(
str
)
{
let
result
=
[];
let
list
=
str
.
split
(
''
);
...
...
@@ -14,7 +16,7 @@ export function strToBinary(str) {
result
.
push
(
binaryStr
);
}
let
resultStr
=
result
.
join
(
''
);
resultStr
=
re
sultStr
.
replaceAll
(
'0'
,
'-'
).
replaceAll
(
'1'
,
'.
'
);
// console.log(resultStr
);
resultStr
=
re
placeAll
(
resultStr
,
'0'
,
'-
'
);
resultStr
=
replaceAll
(
resultStr
,
'1'
,
'.'
);
return
resultStr
;
}
one_stop_public/Base16/utils.js
0 → 100644
浏览文件 @
745dfb91
/**
* 2023年3月3日
* UC浏览器不支持 es6的 replaceAll方法 需要自己写一个
* */
export
function
replaceAll
(
str
,
before
,
after
)
{
return
str
.
replace
(
new
RegExp
(
before
,
'gm'
),
after
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论