@mpxjs/webpack-plugin 2.6.113 → 2.6.114-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependency/AddEntryDependency.js +24 -0
- package/lib/dependency/ResolveDependency.js +4 -0
- package/lib/index.js +44 -3
- package/lib/json-compiler/index.js +3 -0
- package/lib/loader.js +43 -2
- package/lib/path-loader.js +4 -1
- package/lib/platform/template/wx/component-config/button.js +14 -2
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +4 -0
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +5 -0
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +117 -1
- package/lib/runtime/components/tenon/getInnerListeners.js +308 -0
- package/lib/runtime/components/tenon/tenon-button.vue +305 -0
- package/lib/runtime/components/tenon/tenon-image.vue +61 -0
- package/lib/runtime/components/tenon/tenon-input.vue +99 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +21 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +124 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +91 -0
- package/lib/runtime/components/tenon/tenon-text-area.vue +64 -0
- package/lib/runtime/components/tenon/tenon-text.vue +64 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- package/lib/runtime/components/tenon/util.js +44 -0
- package/lib/runtime/optionProcessor.tenon.js +386 -0
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/template-compiler/compiler.js +11 -2
- package/lib/template-compiler/trans-dynamic-class-expr.js +1 -1
- package/lib/tenon/index.js +108 -0
- package/lib/tenon/processJSON.js +361 -0
- package/lib/tenon/processScript.js +260 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +133 -0
- package/lib/utils/get-relative-path.js +24 -0
- package/package.json +7 -3
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { h } from "@hummer/tenon-vue";
|
|
3
|
+
import getInnerListeners from "./getInnerListeners";
|
|
4
|
+
export default {
|
|
5
|
+
name: "mpx-input",
|
|
6
|
+
props: {
|
|
7
|
+
name: String,
|
|
8
|
+
value: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: "",
|
|
11
|
+
},
|
|
12
|
+
type: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: "text",
|
|
15
|
+
},
|
|
16
|
+
password: Boolean,
|
|
17
|
+
placeholder: String,
|
|
18
|
+
disabled: Boolean,
|
|
19
|
+
maxlength: {
|
|
20
|
+
type: Number,
|
|
21
|
+
default: 140,
|
|
22
|
+
},
|
|
23
|
+
autoFocus: Boolean,
|
|
24
|
+
focus: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
},
|
|
28
|
+
cursor: {
|
|
29
|
+
type: Number,
|
|
30
|
+
default: -1,
|
|
31
|
+
},
|
|
32
|
+
selectionStart: {
|
|
33
|
+
type: Number,
|
|
34
|
+
default: -1,
|
|
35
|
+
},
|
|
36
|
+
selectionEnd: {
|
|
37
|
+
type: Number,
|
|
38
|
+
default: -1,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
computed: {
|
|
42
|
+
originRef() {
|
|
43
|
+
return this.$refs["mpx-input"]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
render() {
|
|
47
|
+
let inputType = "";
|
|
48
|
+
if (this.password) {
|
|
49
|
+
inputType = "password";
|
|
50
|
+
} else {
|
|
51
|
+
switch (this.type) {
|
|
52
|
+
case "text":
|
|
53
|
+
inputType = "default";
|
|
54
|
+
break;
|
|
55
|
+
case "number":
|
|
56
|
+
inputType = "number";
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
inputType = "text";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const data = {
|
|
64
|
+
class: "mpx-input",
|
|
65
|
+
value: this.value,
|
|
66
|
+
focus: this.focus,
|
|
67
|
+
ref: "mpx-input",
|
|
68
|
+
placeholder: this.placeholder,
|
|
69
|
+
maxLength: this.maxLength,
|
|
70
|
+
type: inputType,
|
|
71
|
+
disabled: this.disabled,
|
|
72
|
+
...getInnerListeners(this),
|
|
73
|
+
};
|
|
74
|
+
return h("input", data, []);
|
|
75
|
+
// return '123'
|
|
76
|
+
},
|
|
77
|
+
data() {
|
|
78
|
+
return {};
|
|
79
|
+
},
|
|
80
|
+
pageConfig: {
|
|
81
|
+
canScroll: false,
|
|
82
|
+
},
|
|
83
|
+
methods: {},
|
|
84
|
+
};
|
|
85
|
+
</script>
|
|
86
|
+
<style lang="stylus">
|
|
87
|
+
.mpx-input
|
|
88
|
+
cursor auto
|
|
89
|
+
width 100%
|
|
90
|
+
padding 0
|
|
91
|
+
border 0
|
|
92
|
+
font inherit
|
|
93
|
+
display block
|
|
94
|
+
text-overflow clip
|
|
95
|
+
overflow hidden
|
|
96
|
+
white-space nowrap
|
|
97
|
+
font-family UICTFontTextStyleBody
|
|
98
|
+
|
|
99
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import getInnerListeners from './getInnerListeners'
|
|
3
|
+
import { h } from '@hummer/tenon-vue'
|
|
4
|
+
export default {
|
|
5
|
+
name: 'mpx-rich-text',
|
|
6
|
+
props: {
|
|
7
|
+
richText: {
|
|
8
|
+
type: Object,
|
|
9
|
+
value: {}
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
render () {
|
|
13
|
+
|
|
14
|
+
const data = {
|
|
15
|
+
richText: this.richText,
|
|
16
|
+
...getInnerListeners(this)
|
|
17
|
+
}
|
|
18
|
+
return h('text', data)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import getInnerListeners, { getCustomEvent } from "./getInnerListeners";
|
|
3
|
+
import { processSize } from "./util";
|
|
4
|
+
import { h } from "@hummer/tenon-vue";
|
|
5
|
+
export default {
|
|
6
|
+
name: "mpx-scroll-view",
|
|
7
|
+
props: {
|
|
8
|
+
// 允许横向滚动
|
|
9
|
+
scrollX: Boolean,
|
|
10
|
+
// 允许纵向滚动
|
|
11
|
+
scrollY: Boolean,
|
|
12
|
+
// 滚动方向
|
|
13
|
+
scrollDirection: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "horizontal",
|
|
16
|
+
},
|
|
17
|
+
// 距顶部/左边多远时,触发 scrolltoupper 事件
|
|
18
|
+
upperThreshold: {
|
|
19
|
+
type: [Number, String],
|
|
20
|
+
default: 50,
|
|
21
|
+
},
|
|
22
|
+
// 距底部/右边多远时,触发 scrolltolower 事件
|
|
23
|
+
lowerThreshold: {
|
|
24
|
+
type: [Number, String],
|
|
25
|
+
default: 50,
|
|
26
|
+
},
|
|
27
|
+
// 设置竖向滚动条位置
|
|
28
|
+
scrollTop: {
|
|
29
|
+
type: [Number, String],
|
|
30
|
+
default: 0,
|
|
31
|
+
},
|
|
32
|
+
// 设置横向滚动条位置
|
|
33
|
+
scrollLeft: {
|
|
34
|
+
type: [Number, String],
|
|
35
|
+
default: 0,
|
|
36
|
+
},
|
|
37
|
+
scrollOptions: Object,
|
|
38
|
+
// 更新refresh
|
|
39
|
+
updateRefresh: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: true,
|
|
42
|
+
},
|
|
43
|
+
// 值应为某子元素id(id不能以数字开头)。设置哪个方向可滚动,则在哪个方向滚动到该元素
|
|
44
|
+
scrollIntoView: String,
|
|
45
|
+
// 在设置滚动条位置时使用动画过渡
|
|
46
|
+
scrollWithAnimation: Boolean,
|
|
47
|
+
// 启用 flexbox 布局。开启后,当前节点声明了 display: flex 就会成为 flex container,并作用于其孩子节点。
|
|
48
|
+
enableFlex: Boolean,
|
|
49
|
+
// 启用 scroll-view 增强特性,启用后可通过 ScrollViewContext 操作 scroll-view
|
|
50
|
+
enhanced: Boolean,
|
|
51
|
+
// 开启自定义下拉刷新
|
|
52
|
+
refresherEnabled: Boolean,
|
|
53
|
+
// 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
|
|
54
|
+
refresherTriggered: Boolean,
|
|
55
|
+
// 设置自定义下拉刷新阈值
|
|
56
|
+
refresherThreshold: {
|
|
57
|
+
type: Number,
|
|
58
|
+
default: 45,
|
|
59
|
+
},
|
|
60
|
+
// 设置自定义下拉刷新默认样式,支持设置 black | white | none, none 表示不使用默认样式
|
|
61
|
+
refresherDefaultStyle: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: "black",
|
|
64
|
+
},
|
|
65
|
+
// 设置自定义下拉刷新区域背景颜色
|
|
66
|
+
refresherBackground: {
|
|
67
|
+
type: String,
|
|
68
|
+
default: "",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
data() {
|
|
72
|
+
return {};
|
|
73
|
+
},
|
|
74
|
+
computed: {
|
|
75
|
+
_scrollTop() {
|
|
76
|
+
// return 1
|
|
77
|
+
return processSize(this.scrollTop);
|
|
78
|
+
},
|
|
79
|
+
_scrollLeft() {
|
|
80
|
+
// return 1
|
|
81
|
+
return processSize(this.scrollLeft);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
mounted() {
|
|
85
|
+
if (this.scrollTop) {
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
this.$refs.scroll && this.$refs.scroll.scrollTo(0, this._scrollTop);
|
|
88
|
+
}, 100);
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
if (this.scrollLeft) {
|
|
92
|
+
setTimeout(() => {
|
|
93
|
+
this.$refs.scroll && this.$refs.scroll.scrollTo(this._scrollLeft, 0);
|
|
94
|
+
}, 100);
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
watch: {
|
|
98
|
+
_scrollTop(val) {
|
|
99
|
+
console.log('触发')
|
|
100
|
+
this.$refs.scroll && this.$refs.scroll.scrollTo(0, val);
|
|
101
|
+
},
|
|
102
|
+
_scrollLeft(val) {
|
|
103
|
+
this.$refs.scroll && this.$refs.scroll.scrollTo(val, 0);
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
methods: {},
|
|
107
|
+
render() {
|
|
108
|
+
let scrollDirection = this.scrollDirection;
|
|
109
|
+
if (!this.scrollY && this.scrollX) {
|
|
110
|
+
scrollDirection = "horizontal";
|
|
111
|
+
}
|
|
112
|
+
return h(
|
|
113
|
+
"scroller",
|
|
114
|
+
{
|
|
115
|
+
ref: "scroll",
|
|
116
|
+
scrollDirection,
|
|
117
|
+
showScrollBar: false,
|
|
118
|
+
...getInnerListeners(this, {})
|
|
119
|
+
},
|
|
120
|
+
this.$slots.default()
|
|
121
|
+
);
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
</script>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getCustomEvent } from "./getInnerListeners";
|
|
3
|
+
import { h } from "@hummer/tenon-vue";
|
|
4
|
+
export default {
|
|
5
|
+
name: "mpx-switch",
|
|
6
|
+
props: {
|
|
7
|
+
name: String,
|
|
8
|
+
type: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: "switch",
|
|
11
|
+
},
|
|
12
|
+
checked: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false,
|
|
15
|
+
},
|
|
16
|
+
disabled: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false,
|
|
19
|
+
},
|
|
20
|
+
color: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: "#04BE02",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
watch: {
|
|
26
|
+
checked(newVal) {
|
|
27
|
+
this.switchChecked = newVal;
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
data() {
|
|
31
|
+
return {
|
|
32
|
+
switchChecked: this.checked,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
render() {
|
|
36
|
+
let children = [];
|
|
37
|
+
|
|
38
|
+
const switchElem = h("switch", {
|
|
39
|
+
value: this.switchChecked,
|
|
40
|
+
class: [
|
|
41
|
+
"mpx-switch-label",
|
|
42
|
+
this.switchChecked ? "checked-switch-label" : "uncheck-switch-label",
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
children.push(switchElem);
|
|
46
|
+
|
|
47
|
+
// children.push(...(this.$slots.default() || []));
|
|
48
|
+
const data = {
|
|
49
|
+
class: ["mpx-switch-wrap"],
|
|
50
|
+
ref: "switch",
|
|
51
|
+
onClick: (e) => {
|
|
52
|
+
if (this.disabled) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.switchChecked = !this.switchChecked;
|
|
56
|
+
this.notifyChange();
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
return h("view", data, children);
|
|
60
|
+
},
|
|
61
|
+
methods: {
|
|
62
|
+
getValue() {
|
|
63
|
+
return this.switchChecked;
|
|
64
|
+
},
|
|
65
|
+
setValue(value) {
|
|
66
|
+
this.switchChecked = value;
|
|
67
|
+
},
|
|
68
|
+
notifyChange(value) {
|
|
69
|
+
if (value !== undefined) {
|
|
70
|
+
this.setValue(value);
|
|
71
|
+
} else {
|
|
72
|
+
value = this.getValue();
|
|
73
|
+
}
|
|
74
|
+
this.$emit(
|
|
75
|
+
"change",
|
|
76
|
+
getCustomEvent("change", { value }, this.$refs.switch)
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<style lang="stylus">
|
|
84
|
+
.mpx-switch-wrap
|
|
85
|
+
.mpx-switch-label
|
|
86
|
+
border-radius 16hm
|
|
87
|
+
width 52hm
|
|
88
|
+
height 32hm
|
|
89
|
+
border none
|
|
90
|
+
|
|
91
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
<script>
|
|
3
|
+
import { h } from "@hummer/tenon-vue";
|
|
4
|
+
import getInnerListeners from "./getInnerListeners";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
name: "mpx-textarea",
|
|
8
|
+
props: {
|
|
9
|
+
name: String,
|
|
10
|
+
value: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: "",
|
|
13
|
+
},
|
|
14
|
+
placeholder: String,
|
|
15
|
+
disabled: Boolean,
|
|
16
|
+
maxlength: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 140,
|
|
19
|
+
},
|
|
20
|
+
autoFocus: Boolean,
|
|
21
|
+
focus: Boolean,
|
|
22
|
+
cursor: {
|
|
23
|
+
type: Number,
|
|
24
|
+
default: -1,
|
|
25
|
+
},
|
|
26
|
+
selectionStart: {
|
|
27
|
+
type: Number,
|
|
28
|
+
default: -1,
|
|
29
|
+
},
|
|
30
|
+
selectionEnd: {
|
|
31
|
+
type: Number,
|
|
32
|
+
default: -1,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
render() {
|
|
37
|
+
const data = {
|
|
38
|
+
class: "mpx-textarea",
|
|
39
|
+
value: this.value,
|
|
40
|
+
focus: this.focus,
|
|
41
|
+
placeholder: this.placeholder,
|
|
42
|
+
maxLength: this.maxLength,
|
|
43
|
+
disabled: this.disabled,
|
|
44
|
+
...getInnerListeners(this),
|
|
45
|
+
};
|
|
46
|
+
return h("textarea", data);
|
|
47
|
+
},
|
|
48
|
+
pageConfig: {
|
|
49
|
+
canScroll: false,
|
|
50
|
+
},
|
|
51
|
+
methods: {},
|
|
52
|
+
};
|
|
53
|
+
</script>
|
|
54
|
+
<style lang="stylus">
|
|
55
|
+
.mpx-textarea
|
|
56
|
+
font inherit
|
|
57
|
+
cursor auto
|
|
58
|
+
width 300hm
|
|
59
|
+
height 150hm
|
|
60
|
+
display block
|
|
61
|
+
position relative
|
|
62
|
+
resize none
|
|
63
|
+
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
<script>
|
|
3
|
+
import { h } from "@hummer/tenon-vue";
|
|
4
|
+
import getInnerListeners from "./getInnerListeners";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
name: "mpx-text",
|
|
8
|
+
props: {
|
|
9
|
+
selectable: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false,
|
|
12
|
+
},
|
|
13
|
+
space: {
|
|
14
|
+
type: String,
|
|
15
|
+
},
|
|
16
|
+
decode: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: false,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
render() {
|
|
22
|
+
let text = "";
|
|
23
|
+
let classNames = ["mpx-text"];
|
|
24
|
+
const nodes = this.$slots.default && this.$slots.default() || []
|
|
25
|
+
nodes.forEach((item) => {
|
|
26
|
+
if (item.shapeFlag === 8 && item.children) {
|
|
27
|
+
text += item.children;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
// hummer不支持 暂时注释
|
|
31
|
+
// switch (this.space) {
|
|
32
|
+
// case "ensp":
|
|
33
|
+
// case "emsp":
|
|
34
|
+
// case "nbsp":
|
|
35
|
+
// text = text.replace(/ /g, `&${this.space};`);
|
|
36
|
+
// break;
|
|
37
|
+
// }
|
|
38
|
+
return h(
|
|
39
|
+
"text",
|
|
40
|
+
{
|
|
41
|
+
class: classNames,
|
|
42
|
+
...getInnerListeners(this),
|
|
43
|
+
},
|
|
44
|
+
text
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
data() {
|
|
48
|
+
return {};
|
|
49
|
+
},
|
|
50
|
+
beforeCreate() {},
|
|
51
|
+
pageConfig: {
|
|
52
|
+
canScroll: false,
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
</script>
|
|
58
|
+
<style lang="stylus">
|
|
59
|
+
.mpx-text
|
|
60
|
+
user-select none
|
|
61
|
+
&.selectable
|
|
62
|
+
user-select text
|
|
63
|
+
|
|
64
|
+
</style>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { h } from "@hummer/tenon-vue";
|
|
3
|
+
import getInnerListeners from "./getInnerListeners";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
name: "mpx-view",
|
|
7
|
+
props: {
|
|
8
|
+
hoverClass: {
|
|
9
|
+
type: String,
|
|
10
|
+
default: "none",
|
|
11
|
+
},
|
|
12
|
+
hoverStopPropagation: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: false,
|
|
15
|
+
},
|
|
16
|
+
hoverStartTime: {
|
|
17
|
+
type: Number,
|
|
18
|
+
default: 50,
|
|
19
|
+
},
|
|
20
|
+
hoverStayTime: {
|
|
21
|
+
type: Number,
|
|
22
|
+
default: 400,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
render() {
|
|
26
|
+
let mergeAfter;
|
|
27
|
+
if (this.hoverClass && this.hoverClass !== "none") {
|
|
28
|
+
mergeAfter = {
|
|
29
|
+
listeners: {
|
|
30
|
+
onTouchstart: this.handleTouchstart,
|
|
31
|
+
onTouchend: this.handleTouchend,
|
|
32
|
+
},
|
|
33
|
+
force: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return h(
|
|
37
|
+
"view",
|
|
38
|
+
{
|
|
39
|
+
class: this.className,
|
|
40
|
+
...getInnerListeners(this, { mergeAfter }),
|
|
41
|
+
ref: "mpx-view"
|
|
42
|
+
},
|
|
43
|
+
this.$slots.default && this.$slots.default() || ''
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
data() {
|
|
47
|
+
return {
|
|
48
|
+
hover: false,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
computed: {
|
|
52
|
+
className() {
|
|
53
|
+
let result = {};
|
|
54
|
+
if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
|
|
55
|
+
result = {
|
|
56
|
+
"mpx-view": true,
|
|
57
|
+
[this.hoverClass]: true,
|
|
58
|
+
};
|
|
59
|
+
} else {
|
|
60
|
+
result = {
|
|
61
|
+
"mpx-view": true,
|
|
62
|
+
[this.hoverClass]: false,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return result;
|
|
66
|
+
},
|
|
67
|
+
originRef() {
|
|
68
|
+
return this.$refs["mpx-view"]
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
pageConfig: {
|
|
72
|
+
canScroll: false,
|
|
73
|
+
},
|
|
74
|
+
methods: {
|
|
75
|
+
handleTouchstart(e) {
|
|
76
|
+
if (e.__hoverStopPropagation) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
e.__hoverStopPropagation = this.hoverStopPropagation;
|
|
80
|
+
clearTimeout(this.startTimer);
|
|
81
|
+
this.startTimer = setTimeout(() => {
|
|
82
|
+
this.hover = true;
|
|
83
|
+
}, this.hoverStartTime);
|
|
84
|
+
},
|
|
85
|
+
handleTouchend() {
|
|
86
|
+
clearTimeout(this.endTimer);
|
|
87
|
+
this.endTimer = setTimeout(() => {
|
|
88
|
+
this.hover = false;
|
|
89
|
+
}, this.hoverStayTime);
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
@file web运行时组件抹平中需要用到的一些工具方法
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 处理字符串类型的宽高数值,兼容rpx
|
|
7
|
+
* @param {object | number} size 宽高
|
|
8
|
+
* @param {object} option 配置项,目前仅支持配置默认值
|
|
9
|
+
* @param {number} option.default 默认值,当传入的size有问题时返回
|
|
10
|
+
* @returns {number} 处理后的数字宽高,单位px
|
|
11
|
+
*/
|
|
12
|
+
export function processSize (size, option = {}) {
|
|
13
|
+
const defaultValue = option.default || 0
|
|
14
|
+
if (typeof size === 'number') {
|
|
15
|
+
return size
|
|
16
|
+
} else if (typeof size === 'string') {
|
|
17
|
+
const rs = parseInt(size, 10)
|
|
18
|
+
if (size.indexOf('rpx') !== -1) {
|
|
19
|
+
// 计算rpx折算回px
|
|
20
|
+
const width = window.screen.width
|
|
21
|
+
const finalRs = Math.floor(rs / 750 * width)
|
|
22
|
+
return finalRs
|
|
23
|
+
} else {
|
|
24
|
+
return isNaN(rs) ? defaultValue : rs
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
return defaultValue
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 判断对象类型
|
|
32
|
+
export function type (n) {
|
|
33
|
+
return Object.prototype.toString.call(n).slice(8, -1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isEmptyObject (obj) {
|
|
37
|
+
if (!obj) {
|
|
38
|
+
return true
|
|
39
|
+
}
|
|
40
|
+
for (let key in obj) {
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
43
|
+
return true
|
|
44
|
+
}
|