Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
0fa8d221
Commit
0fa8d221
authored
Apr 17, 2017
by
zhangbobell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(png): png export use xhr due to bos restrict
parent
e18b3d18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
3 deletions
+37
-3
png.js
src/protocol/png.js
+37
-3
No files found.
src/protocol/png.js
View file @
0fa8d221
...
...
@@ -25,6 +25,42 @@ define(function(require, exports, module) {
image
.
src
=
info
.
url
;
});
}
/**
* xhrLoadImage: 通过 xhr 加载保存在 BOS 上的图片
* @note: BOS 上的 CORS 策略是取 headers 里面的 Origin 字段进行判断
* 而通过 image 的 src 的方式是无法传递 origin 的,因此需要通过 xhr 进行
*/
function
xhrLoadImage
(
info
,
callback
)
{
return
Promise
(
function
(
resolve
,
reject
)
{
var
xmlHttp
=
new
XMLHttpRequest
();
xmlHttp
.
open
(
'GET'
,
info
.
url
,
true
);
xmlHttp
.
responseType
=
'blob'
;
xmlHttp
.
onreadystatechange
=
function
()
{
if
(
xmlHttp
.
readyState
===
4
&&
xmlHttp
.
status
===
200
)
{
var
blob
=
xmlHttp
.
response
;
var
image
=
document
.
createElement
(
'img'
);
image
.
src
=
DomURL
.
createObjectURL
(
blob
);
image
.
onload
=
function
()
{
DomURL
.
revokeObjectURL
(
image
.
src
);
resolve
({
element
:
image
,
x
:
info
.
x
,
y
:
info
.
y
,
width
:
info
.
width
,
height
:
info
.
height
});
};
}
};
xmlHttp
.
send
();
});
}
function
getSVGInfo
(
minder
)
{
var
paper
=
minder
.
getPaper
(),
paperTransform
,
...
...
@@ -123,8 +159,6 @@ define(function(require, exports, module) {
var
resultCallback
;
var
Promise
=
kityminder
.
Promise
;
/* 绘制 PNG 的画布及上下文 */
var
canvas
=
document
.
createElement
(
'canvas'
);
var
ctx
=
canvas
.
getContext
(
'2d'
);
...
...
@@ -171,7 +205,7 @@ define(function(require, exports, module) {
// 加载节点上的图片
function
loadImages
(
imagesInfo
)
{
var
imagePromises
=
imagesInfo
.
map
(
function
(
imageInfo
)
{
return
l
oadImage
(
imageInfo
);
return
xhrL
oadImage
(
imageInfo
);
});
return
Promise
.
all
(
imagePromises
);
...
...
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