Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
Chameleon
提交
2aa504f6
C
Chameleon
项目概览
DiDi
/
Chameleon
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Chameleon
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2aa504f6
编写于
7月 03, 2019
作者:
J
JiM-W
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
event-args
上级
2d418987
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
108 addition
and
10 deletion
+108
-10
packages/chameleon-mixins/px2cpx.js
packages/chameleon-mixins/px2cpx.js
+51
-0
packages/chameleon-mixins/web-mixins.js
packages/chameleon-mixins/web-mixins.js
+9
-9
packages/chameleon-mixins/wx-alipay-common-mixins.js
packages/chameleon-mixins/wx-alipay-common-mixins.js
+32
-1
packages/chameleon-template-parse/src/common/cml-map.js
packages/chameleon-template-parse/src/common/cml-map.js
+7
-0
packages/chameleon-template-parse/test/parser/cml.test.js
packages/chameleon-template-parse/test/parser/cml.test.js
+9
-0
未找到文件。
packages/chameleon-mixins/px2cpx.js
0 → 100644
浏览文件 @
2aa504f6
const
_
=
module
.
exports
=
{};
const
platform
=
process
.
env
.
platform
;
_
.
webPx2Cpx
=
function
(
px
)
{
function
getViewportSize
()
{
let
viewportWidth
;
let
viewportHeight
;
if
(
window
.
innerWidth
)
{
viewportWidth
=
window
.
innerWidth
;
viewportHeight
=
window
.
innerHeight
;
}
else
if
(
document
.
documentElement
&&
document
.
documentElement
.
clientWidth
||
document
.
body
&&
document
.
body
.
clientWidth
)
{
viewportWidth
=
document
.
documentElement
&&
document
.
documentElement
.
clientWidth
||
document
.
body
&&
document
.
body
.
clientWidth
;
viewportHeight
=
document
.
documentElement
&&
document
.
documentElement
.
clientHeight
||
document
.
body
&&
document
.
body
.
clientHeight
;
}
return
{
viewportWidth
:
viewportWidth
,
viewportHeight
:
viewportHeight
};
}
const
{
viewportWidth
}
=
getViewportSize
();
const
cpx
=
+
(
750
/
viewportWidth
*
px
).
toFixed
(
3
);
return
cpx
;
}
_
.
miniappPx2Cpx
=
function
(
px
,
platform
)
{
function
getViewportSize
()
{
if
(
platform
===
'
wx
'
)
{
const
{
windowWidth
}
=
wx
.
getSystemInfoSync
();
return
windowWidth
;
}
if
(
platform
===
'
baidu
'
)
{
const
{
windowWidth
}
=
swan
.
getSystemInfoSync
();
return
windowWidth
;
}
if
(
platform
===
'
alipay
'
)
{
const
{
windowWidth
}
=
my
.
getSystemInfoSync
();
return
windowWidth
;
}
}
const
viewportWidth
=
getViewportSize
();
const
cpx
=
+
(
750
/
viewportWidth
*
px
).
toFixed
(
3
);
return
cpx
;
}
_
.
px2cpx
=
function
(
px
)
{
if
(
platform
===
'
web
'
)
{
return
_
.
webPx2Cpx
(
px
);
}
if
([
'
wx
'
,
'
baidu
'
,
'
alipay
'
].
includes
(
platform
))
{
return
_
.
miniappPx2Cpx
(
px
,
platform
);
}
}
packages/chameleon-mixins/web-mixins.js
浏览文件 @
2aa504f6
const
common
=
require
(
'
./common.js
'
);
const
webStyleHandle
=
require
(
'
chameleon-css-loader/proxy/proxyWeb.js
'
);
const
{
px2cpx
}
=
require
(
'
./px2cpx.js
'
);
const
_
=
module
.
exports
=
{};
common
.
merge
(
_
,
common
);
...
...
@@ -124,10 +124,10 @@ function getNewEvent(e) {
let
touch
=
touches
[
i
];
let
ret
=
{}
ret
.
identifier
=
touch
.
identifier
;
ret
.
pageX
=
p
arseInt
(
touch
.
pageX
);
ret
.
pageY
=
p
arseInt
(
touch
.
pageY
);
ret
.
clientX
=
p
arseInt
(
touch
.
clientX
);
ret
.
clientY
=
p
arseInt
(
touch
.
clientY
);
ret
.
pageX
=
p
x2cpx
(
parseInt
(
touch
.
pageX
,
10
)
);
ret
.
pageY
=
p
x2cpx
(
parseInt
(
touch
.
pageY
,
10
)
);
ret
.
clientX
=
p
x2cpx
(
parseInt
(
touch
.
clientX
,
10
)
);
ret
.
clientY
=
p
x2cpx
(
parseInt
(
touch
.
clientY
,
10
)
);
newEvent
.
touches
.
push
(
ret
);
}
}
...
...
@@ -138,10 +138,10 @@ function getNewEvent(e) {
let
touch
=
changedTouches
[
i
];
let
ret
=
{}
ret
.
identifier
=
touch
.
identifier
;
ret
.
pageX
=
p
arseInt
(
touch
.
pageX
);
ret
.
pageY
=
p
arseInt
(
touch
.
pageY
);
ret
.
clientX
=
p
arseInt
(
touch
.
clientX
);
ret
.
clientY
=
p
arseInt
(
touch
.
clientY
);
ret
.
pageX
=
p
x2cpx
(
parseInt
(
touch
.
pageX
,
10
)
);
ret
.
pageY
=
p
x2cpx
(
parseInt
(
touch
.
pageY
,
10
)
);
ret
.
clientX
=
p
x2cpx
(
parseInt
(
touch
.
clientX
,
10
)
);
ret
.
clientY
=
p
x2cpx
(
parseInt
(
touch
.
clientY
,
10
)
);
newEvent
.
changedTouches
.
push
(
ret
);
}
}
...
...
packages/chameleon-mixins/wx-alipay-common-mixins.js
浏览文件 @
2aa504f6
...
...
@@ -2,7 +2,8 @@
const
common
=
require
(
'
./common.js
'
);
const
wxStyleHandle
=
require
(
'
chameleon-css-loader/proxy/proxyMiniapp.js
'
)
const
utils
=
require
(
'
./utils.js
'
)
const
utils
=
require
(
'
./utils.js
'
);
const
{
px2cpx
}
=
require
(
'
./px2cpx.js
'
);
const
deepClone
=
function
(
obj
)
{
if
(
obj
.
toString
().
slice
(
8
,
-
1
)
!==
"
Object
"
)
{
return
obj
;
...
...
@@ -115,6 +116,36 @@ function getNewEvent(e) {
dataset
:
e
[
key
].
dataset
}
newEvent
[
key
]
=
newTarget
}
else
if
(
~
[
'
touches
'
,
'
changedTouches
'
].
indexOf
(
key
))
{
if
(
key
==
'
touches
'
)
{
let
touches
=
e
[
key
];
newEvent
.
touches
=
[];
for
(
let
i
=
0
;
i
<
touches
.
length
;
i
++
)
{
let
touch
=
touches
[
i
];
let
ret
=
{}
ret
.
identifier
=
touch
.
identifier
;
ret
.
pageX
=
px2cpx
(
parseInt
(
touch
.
pageX
,
10
));
ret
.
pageY
=
px2cpx
(
parseInt
(
touch
.
pageY
,
10
));
ret
.
clientX
=
px2cpx
(
parseInt
(
touch
.
clientX
,
10
));
ret
.
clientY
=
px2cpx
(
parseInt
(
touch
.
clientY
,
10
));
newEvent
.
touches
.
push
(
ret
);
}
}
if
(
key
==
'
changedTouches
'
)
{
let
changedTouches
=
e
[
key
]
newEvent
.
changedTouches
=
[];
for
(
let
i
=
0
;
i
<
changedTouches
.
length
;
i
++
)
{
let
touch
=
changedTouches
[
i
];
let
ret
=
{}
ret
.
identifier
=
touch
.
identifier
;
ret
.
pageX
=
px2cpx
(
parseInt
(
touch
.
pageX
,
10
));
ret
.
pageY
=
px2cpx
(
parseInt
(
touch
.
pageY
,
10
));
ret
.
clientX
=
px2cpx
(
parseInt
(
touch
.
clientX
,
10
));
ret
.
clientY
=
px2cpx
(
parseInt
(
touch
.
clientY
,
10
));
newEvent
.
changedTouches
.
push
(
ret
);
}
}
}
else
{
newEvent
[
key
]
=
e
[
key
]
}
...
...
packages/chameleon-template-parse/src/common/cml-map.js
浏览文件 @
2aa504f6
...
...
@@ -8,6 +8,13 @@ exports.tagMap = {
alipay
:
'
cover-view
'
,
baidu
:
'
cover-view
'
},
'
cover-image
'
:
{
wx
:
'
cover-image
'
,
web
:
'
img
'
,
weex
:
'
image
'
,
alipay
:
'
cover-image
'
,
baidu
:
'
cover-image
'
},
'
view
'
:
{
wx
:
'
view
'
,
web
:
'
div
'
,
...
...
packages/chameleon-template-parse/test/parser/cml.test.js
浏览文件 @
2aa504f6
...
...
@@ -47,6 +47,15 @@ describe('parse-template-cml-all', function() {
expect
(
compileTemplate
(
source
,
'
wx
'
,
options
).
source
).
to
.
equal
(
`<view class=" cml-base cml-view"><cml-buildin-button class=" cml-base cml-button"></cml-buildin-button><thirdComp1 class=" cml-view cml-thirdComp1"></thirdComp1><thirdComp2 class=" cml-view cml-thirdComp2"></thirdComp2></view>`
)
});
});
describe
(
'
parse-cover-tag-transform
'
,
function
()
{
let
source
=
`<view><cover-image></cover-image><cover-view></cover-view></view>`
;
it
(
'
test-cover-tag-transform-web
'
,
function
()
{
expect
(
compileTemplate
(
source
,
'
web
'
,
options
).
source
).
to
.
equal
(
`<div class=" cml-base cml-view"><img class=" cml-base cml-cover-image"></img><div class=" cml-base cml-cover-view"></div></div>`
);
});
it
(
'
test-cover-tag-transform-miniapp
'
,
function
()
{
expect
(
compileTemplate
(
source
,
'
wx
'
,
options
).
source
).
to
.
equal
(
`<view class=" cml-base cml-view"><cover-image class=" cml-base cml-cover-image"></cover-image><cover-view class=" cml-base cml-cover-view"></cover-view></view>`
);
});
});
// directive c-model
describe
(
'
parse-directive-transform
'
,
function
()
{
let
source
=
`<view><button c-model="{{ value1}}"></button></view>`
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录