Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pptist
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
pptist
Commits
2f961453
Commit
2f961453
authored
Jun 07, 2024
by
罗超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复ERP 无法使用加密函数问题
parent
c9a3731b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
index.vue
src/components/CloudDisk/index.vue
+24
-24
No files found.
src/components/CloudDisk/index.vue
View file @
2f961453
...
...
@@ -195,33 +195,29 @@ const insertImageElement = async (files: FileList) => {
text
:
'正在上传图'
,
lock
:
true
})
let
hash
=
''
try
{
hash
=
await
calculateFileHash
(
files
[
0
])
}
catch
(
error
){}
if
(
!
hash
||
hash
==
''
)
{
ElMessage
.
error
({
message
:
'文件校验失败,请重试'
})
loadingObj
.
close
()
return
;
const
hash
=
await
calculateFileHash
(
files
[
0
])
if
(
hash
!=
''
)
{
await
checkedUploadFileExsit
(
files
[
0
],
hash
)
}
else
{
await
uoloadFileToService
(
files
[
0
])
}
loadingObj
.
close
()
}
const
checkedUploadFileExsit
=
async
(
file
:
File
,
hash
:
any
)
=>
{
let
parms
=
{
fname
:
file
s
[
0
]
.
name
,
fname
:
file
.
name
,
gid
:
queryObj
.
CloudGroupId
,
hi
:
hash
}
le
t
dataRes
=
await
CloudDiskService
.
CheckCloudInfo
(
parms
)
cons
t
dataRes
=
await
CloudDiskService
.
CheckCloudInfo
(
parms
)
if
(
dataRes
.
data
.
resultCode
==
ApiResult
.
SUCCESS
)
{
queryObj
.
CloudGroupId
=
''
queryObj
.
FileName
=
dataRes
.
data
.
data
.
SourceFileName
Search
()
}
else
{
//TODO: 实现校验HASH值是否存在,如果不存在,才调用下面的这个方法。
if
(
dataRes
.
data
.
message
==
'不存在此文件!'
)
await
uoloadFileToService
(
files
[
0
])
}
else
{
if
(
dataRes
.
data
.
message
==
'不存在此文件!'
)
await
uoloadFileToService
(
file
)
}
// await uoloadFileToService(files[0])
loadingObj
.
close
()
}
const
uoloadFileToService
=
async
(
file
:
File
)
=>
{
let
parms
=
{
isppt
:
'1'
,
...
...
@@ -239,15 +235,19 @@ const calculateFileHash = (file:File, algorithm = 'SHA-256') => {
reader
.
onload
=
(
event
)
=>
{
if
(
event
&&
event
.
target
&&
event
.
target
.
result
){
const
buffer
:
any
=
event
.
target
.
result
;
crypto
.
subtle
.
digest
(
algorithm
,
buffer
)
.
then
(
hashBuffer
=>
{
const
hashArray
=
Array
.
from
(
new
Uint8Array
(
hashBuffer
));
const
hashHex
=
hashArray
.
map
(
b
=>
b
.
toString
(
16
).
padStart
(
2
,
'0'
)).
join
(
''
);
resolve
(
hashHex
);
})
.
catch
(
error
=>
reject
(
error
));
if
(
crypto
&&
crypto
.
subtle
&&
crypto
.
subtle
.
digest
){
crypto
.
subtle
.
digest
(
algorithm
,
buffer
)
.
then
(
hashBuffer
=>
{
const
hashArray
=
Array
.
from
(
new
Uint8Array
(
hashBuffer
));
const
hashHex
=
hashArray
.
map
(
b
=>
b
.
toString
(
16
).
padStart
(
2
,
'0'
)).
join
(
''
);
resolve
(
hashHex
);
})
.
catch
(
error
=>
resolve
(
''
));
}
else
{
resolve
(
''
)
}
}
else
{
re
ject
(
''
)
re
solve
(
''
)
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment