Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
anyefeiyu
uni-app
提交
ad81ca68
U
uni-app
项目概览
anyefeiyu
/
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,发现更多精彩内容 >>
提交
ad81ca68
编写于
2月 07, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: canvas 支持 hidpi 属性控制是否启用高清处理
上级
b1132900
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
22 addition
and
13 deletion
+22
-13
src/core/helpers/hidpi.js
src/core/helpers/hidpi.js
+7
-5
src/core/view/components/canvas/index.vue
src/core/view/components/canvas/index.vue
+12
-5
src/platforms/app-plus/service/api/device/add-phone-contact.js
...latforms/app-plus/service/api/device/add-phone-contact.js
+3
-3
未找到文件。
src/core/helpers/hidpi.js
浏览文件 @
ad81ca68
...
@@ -105,6 +105,7 @@ if (pixelRatio !== 1) {
...
@@ -105,6 +105,7 @@ if (pixelRatio !== 1) {
args
[
1
]
*=
pixelRatio
args
[
1
]
*=
pixelRatio
args
[
2
]
*=
pixelRatio
args
[
2
]
*=
pixelRatio
args
[
3
]
*=
pixelRatio
// Safari 重新设置部分属性会导致其他值恢复默认,需获取原始值
// Safari 重新设置部分属性会导致其他值恢复默认,需获取原始值
var
font
=
this
.
__font__
||
this
.
font
var
font
=
this
.
__font__
||
this
.
font
...
@@ -130,6 +131,7 @@ if (pixelRatio !== 1) {
...
@@ -130,6 +131,7 @@ if (pixelRatio !== 1) {
args
[
1
]
*=
pixelRatio
// x
args
[
1
]
*=
pixelRatio
// x
args
[
2
]
*=
pixelRatio
// y
args
[
2
]
*=
pixelRatio
// y
args
[
3
]
*=
pixelRatio
// y
// Safari 重新设置部分属性会导致其他值恢复默认,需获取原始值
// Safari 重新设置部分属性会导致其他值恢复默认,需获取原始值
var
font
=
this
.
__font__
||
this
.
font
var
font
=
this
.
__font__
||
this
.
font
...
@@ -157,11 +159,11 @@ if (pixelRatio !== 1) {
...
@@ -157,11 +159,11 @@ if (pixelRatio !== 1) {
})(
proto
.
drawImage
)
})(
proto
.
drawImage
)
}
}
export
function
wrapper
(
canvas
)
{
export
function
wrapper
(
canvas
,
hidpi
=
true
)
{
canvas
.
width
=
canvas
.
offsetWidth
*
pixelRatio
canvas
.
width
=
canvas
.
offsetWidth
*
(
hidpi
?
pixelRatio
:
1
)
canvas
.
height
=
canvas
.
offsetHeight
*
pixelRatio
canvas
.
height
=
canvas
.
offsetHeight
*
(
hidpi
?
pixelRatio
:
1
)
canvas
.
__hidpi__
=
true
canvas
.
__hidpi__
=
hidpi
// 避免低版本安卓上 context 实例被回收
// 避免低版本安卓上 context 实例被回收
canvas
.
__context2d__
=
canvas
.
getContext
(
'
2d
'
)
canvas
.
__context2d__
=
canvas
.
getContext
(
'
2d
'
)
canvas
.
__context2d__
.
__hidpi__
=
true
canvas
.
__context2d__
.
__hidpi__
=
hidpi
}
}
src/core/view/components/canvas/index.vue
浏览文件 @
ad81ca68
...
@@ -78,6 +78,10 @@ export default {
...
@@ -78,6 +78,10 @@ export default {
disableScroll
:
{
disableScroll
:
{
type
:
[
Boolean
,
String
],
type
:
[
Boolean
,
String
],
default
:
false
default
:
false
},
hidpi
:
{
type
:
Boolean
,
default
:
true
}
}
},
},
data
()
{
data
()
{
...
@@ -110,6 +114,9 @@ export default {
...
@@ -110,6 +114,9 @@ export default {
$listeners
[
event
]
=
eventHandler
$listeners
[
event
]
=
eventHandler
})
})
return
$listeners
return
$listeners
},
pixelRatio
()
{
return
this
.
hidpi
?
pixelRatio
:
1
}
}
},
},
created
()
{
created
()
{
...
@@ -135,15 +142,15 @@ export default {
...
@@ -135,15 +142,15 @@ export default {
},
},
_resize
(
size
)
{
_resize
(
size
)
{
var
canvas
=
this
.
$refs
.
canvas
var
canvas
=
this
.
$refs
.
canvas
var
hasChanged
=
!
size
||
(
canvas
.
width
!==
Math
.
floor
(
size
.
width
*
pixelRatio
)
||
canvas
.
height
!==
Math
.
floor
(
size
.
height
*
pixelRatio
))
var
hasChanged
=
!
size
||
(
canvas
.
width
!==
Math
.
floor
(
size
.
width
*
this
.
pixelRatio
)
||
canvas
.
height
!==
Math
.
floor
(
size
.
height
*
this
.
pixelRatio
))
if
(
!
hasChanged
)
return
if
(
!
hasChanged
)
return
if
(
canvas
.
width
>
0
&&
canvas
.
height
>
0
)
{
if
(
canvas
.
width
>
0
&&
canvas
.
height
>
0
)
{
var
context
=
canvas
.
getContext
(
'
2d
'
)
var
context
=
canvas
.
getContext
(
'
2d
'
)
var
imageData
=
context
.
getImageData
(
0
,
0
,
canvas
.
width
,
canvas
.
height
)
var
imageData
=
context
.
getImageData
(
0
,
0
,
canvas
.
width
,
canvas
.
height
)
wrapper
(
canvas
)
wrapper
(
canvas
,
this
.
hidpi
)
context
.
putImageData
(
imageData
,
0
,
0
)
context
.
putImageData
(
imageData
,
0
,
0
)
}
else
{
}
else
{
wrapper
(
canvas
)
wrapper
(
canvas
,
this
.
hidpi
)
}
}
},
},
_touchmove
(
event
)
{
_touchmove
(
event
)
{
...
@@ -377,8 +384,8 @@ export default {
...
@@ -377,8 +384,8 @@ export default {
height
=
height
?
Math
.
min
(
height
,
maxHeight
)
:
maxHeight
height
=
height
?
Math
.
min
(
height
,
maxHeight
)
:
maxHeight
if
(
!
hidpi
)
{
if
(
!
hidpi
)
{
if
(
!
destWidth
&&
!
destHeight
)
{
if
(
!
destWidth
&&
!
destHeight
)
{
destWidth
=
Math
.
round
(
width
*
pixelRatio
)
destWidth
=
Math
.
round
(
width
*
this
.
pixelRatio
)
destHeight
=
Math
.
round
(
height
*
pixelRatio
)
destHeight
=
Math
.
round
(
height
*
this
.
pixelRatio
)
}
else
if
(
!
destWidth
)
{
}
else
if
(
!
destWidth
)
{
destWidth
=
Math
.
round
(
width
/
height
*
destHeight
)
destWidth
=
Math
.
round
(
width
/
height
*
destHeight
)
}
else
if
(
!
destHeight
)
{
}
else
if
(
!
destHeight
)
{
...
...
src/platforms/app-plus/service/api/device/add-phone-contact.js
浏览文件 @
ad81ca68
...
@@ -6,7 +6,7 @@ const schema = {
...
@@ -6,7 +6,7 @@ const schema = {
name
:
{
name
:
{
givenName
:
'
firstName
'
,
givenName
:
'
firstName
'
,
middleName
:
'
middleName
'
,
middleName
:
'
middleName
'
,
familyName
:
'
lastName
'
,
familyName
:
'
lastName
'
},
},
nickname
:
'
nickName
'
,
nickname
:
'
nickName
'
,
photos
:
{
photos
:
{
...
@@ -84,7 +84,7 @@ const schema = {
...
@@ -84,7 +84,7 @@ const schema = {
const
keepFields
=
[
'
type
'
,
'
preferred
'
]
const
keepFields
=
[
'
type
'
,
'
preferred
'
]
function
buildContact
(
contact
,
data
,
schema
)
{
function
buildContact
(
contact
,
data
,
schema
)
{
let
hasValue
=
0
let
hasValue
=
0
Object
.
keys
(
schema
).
forEach
(
contactKey
=>
{
Object
.
keys
(
schema
).
forEach
(
contactKey
=>
{
const
dataKey
=
schema
[
contactKey
]
const
dataKey
=
schema
[
contactKey
]
...
@@ -127,7 +127,7 @@ function buildContact(contact, data, schema) {
...
@@ -127,7 +127,7 @@ function buildContact(contact, data, schema) {
return
hasValue
return
hasValue
}
}
export
function
addPhoneContact
(
data
,
callbackId
)
{
export
function
addPhoneContact
(
data
,
callbackId
)
{
plus
.
contacts
.
getAddressBook
(
plus
.
contacts
.
ADDRESSBOOK_PHONE
,
(
addressbook
)
=>
{
plus
.
contacts
.
getAddressBook
(
plus
.
contacts
.
ADDRESSBOOK_PHONE
,
(
addressbook
)
=>
{
!
data
.
photoFilePath
&&
(
data
.
photoFilePath
=
''
)
!
data
.
photoFilePath
&&
(
data
.
photoFilePath
=
''
)
const
contact
=
addressbook
.
create
()
const
contact
=
addressbook
.
create
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录