@mpxjs/webpack-plugin 2.6.115 → 2.7.0-alpha
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/LICENSE +433 -0
- package/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/AppEntryDependency.js +58 -0
- package/lib/dependencies/CommonJsAsyncDependency.js +51 -0
- package/lib/dependencies/CommonJsVariableDependency.js +81 -0
- package/lib/dependencies/DynamicEntryDependency.js +171 -0
- package/lib/dependencies/FlagPluginDependency.js +24 -0
- package/lib/dependencies/InjectDependency.js +43 -0
- package/lib/dependencies/RecordGlobalComponentsDependency.js +50 -0
- package/lib/dependencies/RecordIndependentDependency.js +44 -0
- package/lib/dependencies/RecordResourceMapDependency.js +62 -0
- package/lib/dependencies/RemoveEntryDependency.js +40 -0
- package/lib/{dependency → dependencies}/ReplaceDependency.js +19 -2
- package/lib/dependencies/ResolveDependency.js +88 -0
- package/lib/extractor.js +82 -178
- package/lib/file-loader.js +7 -19
- package/lib/helpers.js +39 -334
- package/lib/independent-loader.js +52 -0
- package/lib/index.js +889 -525
- package/lib/json-compiler/helper.js +156 -0
- package/lib/json-compiler/index.js +245 -451
- package/lib/json-compiler/plugin.js +150 -0
- package/lib/json-compiler/{theme-loader.js → theme.js} +5 -3
- package/lib/loader.js +178 -241
- package/lib/native-loader.js +71 -133
- package/lib/parser.js +1 -2
- package/lib/partial-compile/index.js +35 -0
- package/lib/platform/json/wx/index.js +1 -1
- package/lib/platform/template/normalize-component-rules.js +2 -3
- 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 +149 -3
- package/lib/record-loader.js +11 -0
- package/lib/resolve-loader.js +6 -0
- package/lib/resolver/AddEnvPlugin.js +4 -3
- package/lib/resolver/AddModePlugin.js +4 -3
- package/lib/resolver/FixDescriptionInfoPlugin.js +28 -0
- package/lib/resolver/PackageEntryPlugin.js +23 -36
- package/lib/runtime/base.styl +5 -0
- package/lib/runtime/components/tenon/getInnerListeners.js +317 -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/components/web/getInnerListeners.js +1 -3
- package/lib/runtime/components/web/mpx-image.vue +20 -5
- package/lib/runtime/components/web/mpx-movable-view.vue +6 -2
- package/lib/runtime/components/web/mpx-swiper.vue +18 -3
- package/lib/runtime/i18n.wxs +31 -11
- package/lib/runtime/optionProcessor.js +48 -3
- package/lib/runtime/optionProcessor.tenon.js +386 -0
- package/lib/selector.js +29 -10
- package/lib/style-compiler/index.js +16 -24
- package/lib/style-compiler/load-postcss-config.js +3 -1
- package/lib/style-compiler/plugins/conditional-strip.js +68 -65
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/style-compiler/plugins/rpx.js +43 -37
- package/lib/style-compiler/plugins/scope-id.js +79 -72
- package/lib/style-compiler/plugins/trans-special.js +25 -18
- package/lib/style-compiler/plugins/trim.js +13 -7
- package/lib/style-compiler/plugins/vw.js +22 -16
- package/lib/template-compiler/compiler.js +106 -199
- package/lib/template-compiler/index.js +52 -139
- package/lib/template-compiler/trans-dynamic-class-expr.js +18 -13
- package/lib/tenon/index.js +105 -0
- package/lib/tenon/processJSON.js +356 -0
- package/lib/tenon/processScript.js +261 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +133 -0
- package/lib/url-loader.js +11 -29
- package/lib/utils/add-query.js +1 -1
- package/lib/utils/const.js +10 -0
- package/lib/utils/emit-file.js +10 -0
- package/lib/utils/eval-json-js.js +31 -0
- package/lib/utils/get-entry-name.js +13 -0
- package/lib/utils/get-json-content.js +42 -0
- package/lib/utils/get-relative-path.js +25 -0
- package/lib/utils/is-url-request.js +10 -1
- package/lib/utils/match-condition.js +4 -1
- package/lib/utils/normalize.js +4 -15
- package/lib/utils/parse-request.js +3 -3
- package/lib/utils/resolve.js +13 -0
- package/lib/utils/set.js +47 -0
- package/lib/utils/stringify-loaders-resource.js +25 -0
- package/lib/utils/stringify-query.js +4 -0
- package/lib/web/processJSON.js +113 -144
- package/lib/web/processScript.js +47 -34
- package/lib/web/processTemplate.js +57 -40
- package/lib/wxml/{wxml-loader.js → loader.js} +21 -62
- package/lib/wxs/WxsModuleIdsPlugin.js +29 -0
- package/lib/wxs/WxsParserPlugin.js +2 -2
- package/lib/wxs/WxsPlugin.js +4 -8
- package/lib/wxs/WxsTemplatePlugin.js +46 -92
- package/lib/wxs/{wxs-i18n-loader.js → i18n-loader.js} +5 -4
- package/lib/wxs/loader.js +142 -0
- package/lib/wxs/{wxs-pre-loader.js → pre-loader.js} +20 -5
- package/lib/wxss/loader.js +31 -43
- package/lib/wxss/localsLoader.js +1 -5
- package/lib/wxss/processCss.js +107 -103
- package/package.json +21 -18
- package/lib/built-in-loader.js +0 -49
- package/lib/content-loader.js +0 -13
- package/lib/dependency/ChildCompileDependency.js +0 -24
- package/lib/dependency/InjectDependency.js +0 -26
- package/lib/dependency/RemovedModuleDependency.js +0 -23
- package/lib/dependency/ResolveDependency.js +0 -49
- package/lib/path-loader.js +0 -3
- package/lib/plugin-loader.js +0 -287
- package/lib/staticConfig.js +0 -4
- package/lib/utils/get-main-compilation.js +0 -6
- package/lib/utils/read-json-for-src.js +0 -34
- package/lib/utils/try-require.js +0 -16
- package/lib/wxs/wxs-loader.js +0 -117
- package/lib/wxss/getImportPrefix.js +0 -30
|
@@ -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" scoped>
|
|
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" scoped>
|
|
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" scoped>
|
|
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" scoped>
|
|
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
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { isEmptyObject } from './util'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const isTouchDevice = inBrowser && ('ontouchstart' in document.documentElement)
|
|
2
|
+
const isTouchDevice = 'ontouchstart' in document.documentElement
|
|
5
3
|
|
|
6
4
|
function processModel (listeners, context) {
|
|
7
5
|
// 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import getInnerListeners from './getInnerListeners'
|
|
2
|
+
import getInnerListeners, { extendEvent } from './getInnerListeners'
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
name: 'mpx-image',
|
|
@@ -23,6 +23,13 @@
|
|
|
23
23
|
beforeCreate () {
|
|
24
24
|
this.image = new Image()
|
|
25
25
|
this.image.onload = (e) => {
|
|
26
|
+
extendEvent(e, {
|
|
27
|
+
detail: {
|
|
28
|
+
width: this.image.width,
|
|
29
|
+
height: this.image.height
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
26
33
|
this.$emit('load', e)
|
|
27
34
|
}
|
|
28
35
|
this.image.onerror = (e) => {
|
|
@@ -38,14 +45,22 @@
|
|
|
38
45
|
}
|
|
39
46
|
},
|
|
40
47
|
render (createElement) {
|
|
41
|
-
if (this.mode === 'widthFix') {
|
|
48
|
+
if (this.mode === 'widthFix' || this.mode === 'heightFix') {
|
|
49
|
+
let style
|
|
50
|
+
if (this.mode === 'widthFix') {
|
|
51
|
+
style = {
|
|
52
|
+
height: 'auto'
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
style = {
|
|
56
|
+
width: 'auto'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
42
59
|
const domProps = {}
|
|
43
60
|
if (this.src) domProps.src = this.src
|
|
44
61
|
return createElement('img', {
|
|
45
62
|
domProps,
|
|
46
|
-
style
|
|
47
|
-
height: 'auto'
|
|
48
|
-
},
|
|
63
|
+
style,
|
|
49
64
|
class: ['mpx-image'],
|
|
50
65
|
on: getInnerListeners(this, { ignoredListeners: ['load', 'error'] })
|
|
51
66
|
})
|
|
@@ -85,6 +85,10 @@
|
|
|
85
85
|
animation: {
|
|
86
86
|
type: Boolean,
|
|
87
87
|
default: true
|
|
88
|
+
},
|
|
89
|
+
speed: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: 1000
|
|
88
92
|
}
|
|
89
93
|
},
|
|
90
94
|
watch: {
|
|
@@ -96,7 +100,7 @@
|
|
|
96
100
|
if (newVal < this.bs.maxScrollX) {
|
|
97
101
|
newVal = this.bs.maxScrollX
|
|
98
102
|
}
|
|
99
|
-
this.bs.scrollTo(newVal, this.bs.y)
|
|
103
|
+
this.bs.scrollTo(newVal, this.bs.y, this.speed)
|
|
100
104
|
},
|
|
101
105
|
y (newVal) {
|
|
102
106
|
this.source = ''
|
|
@@ -106,7 +110,7 @@
|
|
|
106
110
|
if (newVal < this.bs.maxScrollY) {
|
|
107
111
|
newVal = this.bs.maxScrollY
|
|
108
112
|
}
|
|
109
|
-
this.bs.scrollTo(this.bs.x, newVal)
|
|
113
|
+
this.bs.scrollTo(this.bs.x, newVal, this.speed)
|
|
110
114
|
},
|
|
111
115
|
scaleValue (newVal) {
|
|
112
116
|
this.isZooming = true
|