Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MuGuiLin
uni-app
提交
83718ec9
U
uni-app
项目概览
MuGuiLin
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
83718ec9
编写于
12月 19, 2018
作者:
郭
郭胜强
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 解决canvas组件大小变化导致的异常以及跨域图像导出问题
上级
e5887b95
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
153 addition
and
15 deletion
+153
-15
src/core/helpers/tags.js
src/core/helpers/tags.js
+2
-1
src/core/view/components/canvas/index.vue
src/core/view/components/canvas/index.vue
+21
-14
src/core/view/components/resize-sensor/index.vue
src/core/view/components/resize-sensor/index.vue
+130
-0
未找到文件。
src/core/helpers/tags.js
浏览文件 @
83718ec9
...
...
@@ -10,6 +10,7 @@ module.exports = [
'
uni-modal
'
,
'
uni-picker
'
,
'
uni-toast
'
,
'
uni-resize-sensor
'
,
'
uni-ad
'
,
'
uni-audio
'
,
...
...
@@ -51,4 +52,4 @@ module.exports = [
'
uni-video
'
,
'
uni-view
'
,
'
uni-web-view
'
]
]
src/core/view/components/canvas/index.vue
浏览文件 @
83718ec9
...
...
@@ -8,6 +8,9 @@
:height=
"height"
@
touchmove=
"_touchmove"
/>
<v-uni-resize-sensor
initial
@
resize=
"_resize"
/>
</uni-canvas>
</
template
>
<
script
>
...
...
@@ -50,11 +53,6 @@ export default {
this
.
_actionsDefer
=
[]
this
.
_images
=
{}
},
mounted
()
{
var
canvas
=
this
.
$refs
.
canvas
this
.
width
=
canvas
.
offsetWidth
this
.
height
=
canvas
.
offsetHeight
},
methods
:
{
_handleSubscribe
({
type
,
...
...
@@ -65,6 +63,10 @@ export default {
method
(
data
)
}
},
_resize
({
width
,
height
})
{
this
.
width
=
width
this
.
height
=
height
},
_touchmove
(
event
)
{
if
(
this
.
disableScroll
)
{
event
.
preventDefault
()
...
...
@@ -236,7 +238,7 @@ export default {
* @param {Blob} blob
*/
function
loadBlob
(
blob
)
{
sefl
.
_images
[
src
].
src
=
window
.
URL
.
createObjectURL
(
blob
)
sefl
.
_images
[
src
].
src
=
(
window
.
URL
||
window
.
webkitURL
)
.
createObjectURL
(
blob
)
}
/**
* 从本地文件加载
...
...
@@ -263,6 +265,8 @@ export default {
},
function
(
d
,
status
)
{
if
(
status
===
200
)
{
loadFile
(
d
.
filename
)
}
else
{
sefl
.
_images
[
src
].
src
=
src
}
}).
start
()
}
...
...
@@ -274,20 +278,23 @@ export default {
loadBlob
(
this
.
response
)
}
}
xhr
.
onerror
=
plusDownload
xhr
.
onerror
=
window
.
plus
?
plusDownload
:
function
()
{
sefl
.
_images
[
src
].
src
=
src
}
xhr
.
send
()
}
// 解决 plus-app wkwebview 图像跨域问题
if
(
window
.
plus
&&
window
.
webkit
&&
window
.
webkit
.
messageHandlers
)
{
if
(
src
.
indexOf
(
'
http://
'
)
===
0
||
src
.
indexOf
(
'
https://
'
)
===
0
)
{
loadUrl
(
src
)
if
(
window
.
plus
&&
(
!
window
.
webkit
||
!
window
.
webkit
.
messageHandlers
))
{
sefl
.
_images
[
src
].
src
=
src
}
else
{
// 解决 PLUS-APP(wkwebview)以及 H5 图像跨域问题(H5图像响应头需包含access-control-allow-origin)
if
(
window
.
plus
&&
src
.
indexOf
(
'
http://
'
)
!==
0
&&
src
.
indexOf
(
'
https://
'
)
!==
0
)
{
loadFile
(
src
)
}
else
if
(
/^data:
[
a-z-
]
+
\/[
a-z-
]
+;base64,/
.
test
(
src
))
{
sefl
.
_images
[
src
].
src
=
src
}
else
{
load
File
(
src
)
load
Url
(
src
)
}
}
else
{
sefl
.
_images
[
src
].
src
=
src
}
}
})
...
...
src/core/view/components/resize-sensor/index.vue
0 → 100644
浏览文件 @
83718ec9
<
script
>
export
default
{
name
:
'
ResizeSensor
'
,
props
:
{
initial
:
{
type
:
[
Boolean
,
String
],
default
:
false
}
},
data
:
function
()
{
return
{
size
:
{
width
:
0
,
height
:
0
}
}
},
watch
:
{
size
:
{
deep
:
true
,
handler
:
function
(
size
)
{
this
.
reset
()
this
.
$emit
(
'
resize
'
,
Object
.
assign
({},
size
))
}
}
},
beforeDestroy
:
function
()
{
this
.
$emit
(
'
resize
'
,
{
width
:
0
,
height
:
0
})
this
.
$emit
(
'
resizeSensorBeforeDestroy
'
)
},
mounted
:
function
()
{
if
(
this
.
initial
===
true
)
{
this
.
$nextTick
(
this
.
update
)
}
if
(
this
.
$el
.
offsetParent
!==
this
.
$el
.
parentNode
)
{
this
.
$el
.
parentNode
.
style
.
position
=
'
relative
'
}
if
(
'
attachEvent
'
in
this
.
$el
&&
!
(
'
AnimationEvent
'
in
window
))
{
var
onresizeHandler
=
function
()
{
this
.
update
()
removeOnresizeEvent
()
}.
bind
(
this
)
var
removeOnresizeEvent
=
function
()
{
this
.
$el
.
detachEvent
(
'
onresize
'
,
onresizeHandler
)
this
.
$off
(
'
resizeSensorBeforeDestroy
'
,
removeOnresizeEvent
)
}.
bind
(
this
)
this
.
$el
.
attachEvent
(
'
onresize
'
,
onresizeHandler
)
this
.
$on
(
'
resizeSensorBeforeDestroy
'
,
removeOnresizeEvent
)
this
.
reset
()
}
},
methods
:
{
reset
:
function
()
{
var
expand
=
this
.
$el
.
firstChild
var
shrink
=
this
.
$el
.
lastChild
expand
.
scrollLeft
=
100000
expand
.
scrollTop
=
100000
shrink
.
scrollLeft
=
100000
shrink
.
scrollTop
=
100000
},
update
:
function
()
{
this
.
size
.
width
=
this
.
$el
.
offsetWidth
this
.
size
.
height
=
this
.
$el
.
offsetHeight
}
},
render
:
function
(
create
)
{
return
create
(
'
uni-resize-sensor
'
,
{
on
:
{
'
~animationstart
'
:
this
.
update
}
},
[
create
(
'
div
'
,
{
on
:
{
scroll
:
this
.
update
}
},
[
create
(
'
div
'
)
]),
create
(
'
div
'
,
{
on
:
{
scroll
:
this
.
update
}
},
[
create
(
'
div
'
)
])
])
}
}
</
script
>
<
style
>
@keyframes
resizeSensorVisibility
{
from
{
top
:
0
;
}
}
uni-resize-sensor
,
uni-resize-sensor
>
div
{
position
:
absolute
;
left
:
0
;
top
:
0
;
right
:
0
;
bottom
:
0
;
overflow
:
hidden
;
}
uni-resize-sensor
{
display
:
block
;
z-index
:
-1
;
visibility
:
hidden
;
animation-name
:
resizeSensorVisibility
;
}
uni-resize-sensor
>
div
>
div
{
position
:
absolute
;
left
:
0
;
top
:
0
;
}
uni-resize-sensor
>
div
:first-child
>
div
{
width
:
100000px
;
height
:
100000px
;
}
uni-resize-sensor
>
div
:last-child
>
div
{
width
:
200%
;
height
:
200%
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录