Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
admin-fe
Commits
69fe4d1e
Commit
69fe4d1e
authored
7 years ago
by
Pan
Browse files
Options
Downloads
Patches
Plain Diff
refine imageCropper fetch
parent
0476f25e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/ImageCropper/index.vue
+14
-34
14 additions, 34 deletions
src/components/ImageCropper/index.vue
with
14 additions
and
34 deletions
src/components/ImageCropper/index.vue
+
14
−
34
View file @
69fe4d1e
...
...
@@ -105,6 +105,7 @@
<
script
>
/* eslint-disable */
import
{
effectRipple
,
data2blob
}
from
'
./utils
'
;
import
fetch
from
'
utils/fetch
'
;
import
langBag
from
'
./lang
'
;
const
mimes
=
{
'
jpg
'
:
'
image/jpeg
'
,
...
...
@@ -659,7 +660,8 @@
})
}
// 监听进度回调
const
uploadProgress
=
function
(
event
)
{
function
uploadProgress
(
event
)
{
console
.
log
(
event
)
if
(
event
.
lengthComputable
)
{
that
.
progress
=
100
*
Math
.
round
(
event
.
loaded
)
/
event
.
total
;
}
...
...
@@ -669,43 +671,21 @@
that
.
loading
=
1
;
that
.
setStep
(
3
);
that
.
$emit
(
'
crop-success
'
,
createImgUrl
,
field
,
ki
);
new
Promise
(
function
(
resolve
,
reject
)
{
let
client
=
new
XMLHttpRequest
();
client
.
open
(
'
POST
'
,
url
,
true
);
client
.
onreadystatechange
=
function
()
{
if
(
this
.
readyState
!==
4
)
{
return
;
}
if
(
this
.
status
===
200
)
{
resolve
(
JSON
.
parse
(
this
.
responseText
));
}
else
{
reject
(
this
.
status
);
}
};
client
.
upload
.
addEventListener
(
"
progress
"
,
uploadProgress
,
false
);
//监听进度
// 设置header
if
(
typeof
headers
==
'
object
'
&&
headers
)
{
Object
.
keys
(
headers
).
forEach
((
k
)
=>
{
client
.
setRequestHeader
(
k
,
headers
[
k
]);
})
}
client
.
send
(
fmData
);
}).
then
(
// 上传成功
function
(
resData
)
{
that
.
loading
=
2
;
that
.
$emit
(
'
crop-upload-success
'
,
resData
);
},
// 上传失败
function
(
sts
)
{
if
(
that
.
value
)
{
fetch
({
url
,
method
:
'
post
'
,
data
:
fmData
}).
then
(
resData
=>
{
that
.
loading
=
2
;
that
.
$emit
(
'
crop-upload-success
'
,
resData
.
data
);
}).
catch
(
err
=>
{
if
(
that
.
value
)
{
that
.
loading
=
3
;
that
.
hasError
=
true
;
that
.
errorMsg
=
lang
.
fail
;
that
.
$emit
(
'
crop-upload-fail
'
,
sts
,
field
,
ki
);
that
.
$emit
(
'
crop-upload-fail
'
,
err
,
field
,
ki
);
}
}
);
});
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment