@mpxjs/webpack-plugin 2.7.0-alpha.0 → 2.7.0-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/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/AppEntryDependency.js +2 -0
- package/lib/dependencies/CommonJsAsyncDependency.js +51 -0
- package/lib/dependencies/CommonJsVariableDependency.js +13 -6
- package/lib/dependencies/DynamicEntryDependency.js +85 -41
- package/lib/dependencies/FlagPluginDependency.js +1 -0
- package/lib/dependencies/RecordIndependentDependency.js +44 -0
- package/lib/dependencies/RecordResourceMapDependency.js +62 -0
- package/lib/dependencies/RemoveEntryDependency.js +40 -0
- package/lib/dependencies/ResolveDependency.js +11 -6
- package/lib/extractor.js +17 -7
- package/lib/file-loader.js +2 -2
- package/lib/helpers.js +6 -12
- package/lib/independent-loader.js +52 -0
- package/lib/index.js +595 -304
- package/lib/json-compiler/helper.js +36 -32
- package/lib/json-compiler/index.js +119 -66
- package/lib/json-compiler/plugin.js +23 -7
- package/lib/loader.js +135 -90
- package/lib/native-loader.js +37 -69
- package/lib/parser.js +1 -2
- package/lib/partial-compile/index.js +35 -0
- package/lib/platform/json/wx/index.js +8 -3
- package/lib/platform/template/normalize-component-rules.js +2 -3
- package/lib/platform/template/wx/component-config/button.js +17 -5
- 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/navigator.js +1 -1
- 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 +2 -2
- package/lib/resolve-loader.js +4 -1
- 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 +51 -45
- package/lib/runtime/components/web/mpx-image.vue +20 -5
- package/lib/runtime/components/web/mpx-keep-alive.vue +4 -1
- package/lib/runtime/components/web/mpx-movable-view.vue +6 -2
- package/lib/runtime/components/web/mpx-swiper.vue +37 -8
- package/lib/runtime/components/web/mpx-tab-bar-container.vue +2 -2
- package/lib/runtime/components/web/mpx-textarea.vue +1 -1
- package/lib/runtime/i18n.wxs +28 -8
- package/lib/runtime/optionProcessor.js +50 -20
- package/lib/runtime/optionProcessor.tenon.js +386 -0
- package/lib/runtime/stringify.wxs +6 -4
- package/lib/selector.js +23 -5
- package/lib/style-compiler/index.js +12 -13
- 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 +19 -12
- package/lib/template-compiler/bind-this.js +4 -4
- package/lib/template-compiler/compiler.js +172 -62
- package/lib/template-compiler/index.js +8 -9
- package/lib/template-compiler/trans-dynamic-class-expr.js +32 -22
- 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/utils/const.js +6 -1
- package/lib/utils/eval-json-js.js +31 -0
- package/lib/utils/get-entry-name.js +3 -3
- package/lib/utils/get-json-content.js +42 -0
- package/lib/utils/get-relative-path.js +25 -0
- package/lib/utils/match-condition.js +4 -1
- package/lib/utils/normalize.js +4 -2
- package/lib/utils/resolve.js +13 -0
- package/lib/web/processJSON.js +113 -144
- package/lib/web/processScript.js +45 -38
- package/lib/web/processTemplate.js +56 -41
- package/lib/wxml/loader.js +1 -6
- package/lib/wxs/WxsModuleIdsPlugin.js +11 -14
- package/lib/wxs/i18n-loader.js +5 -4
- package/lib/wxs/loader.js +87 -56
- package/lib/wxs/pre-loader.js +30 -10
- package/lib/wxss/loader.js +3 -3
- package/lib/wxss/processCss.js +135 -131
- package/package.json +23 -17
- package/lib/built-in-loader.js +0 -49
- package/lib/dependencies/RecordStaticResourceDependency.js +0 -47
- package/lib/utils/get-main-compilation.js +0 -6
- package/lib/utils/read-json-for-src.js +0 -34
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isEmptyObject } from './util'
|
|
2
|
+
const isTouchDevice = 'ontouchstart' in document.documentElement
|
|
2
3
|
|
|
3
4
|
function processModel (listeners, context) {
|
|
4
5
|
// 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
|
|
@@ -54,58 +55,63 @@ function processTap (listeners, context) {
|
|
|
54
55
|
})
|
|
55
56
|
if (isEmptyObject(listenerMap)) return
|
|
56
57
|
context.__mpxTapInfo = context.__mpxTapInfo || {}
|
|
57
|
-
let events
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
let events
|
|
59
|
+
if (isTouchDevice) {
|
|
60
|
+
events = {
|
|
61
|
+
touchstart (e) {
|
|
62
|
+
context.__mpxTapInfo.detail = {
|
|
63
|
+
x: e.changedTouches[0].pageX,
|
|
64
|
+
y: e.changedTouches[0].pageY
|
|
65
|
+
}
|
|
66
|
+
context.__mpxTapInfo.startTimer = null
|
|
67
|
+
context.__mpxTapInfo.needTap = true
|
|
68
|
+
if (listenerMap.longpress || listenerMap.longtap) {
|
|
69
|
+
context.__mpxTapInfo.startTimer = setTimeout(() => {
|
|
70
|
+
context.__mpxTapInfo.needTap = false
|
|
71
|
+
if (listenerMap.longpress) {
|
|
72
|
+
const re = inheritEvent('longpress', e, context.__mpxTapInfo.detail)
|
|
73
|
+
context.$emit('longpress', re)
|
|
74
|
+
}
|
|
75
|
+
if (listenerMap.longtap) {
|
|
76
|
+
const re = inheritEvent('longtap', e, context.__mpxTapInfo.detail)
|
|
77
|
+
context.$emit('longtap', re)
|
|
78
|
+
}
|
|
79
|
+
}, 350)
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
touchmove (e) {
|
|
83
|
+
const tapDetailInfo = context.__mpxTapInfo.detail || {}
|
|
84
|
+
const currentPageX = e.changedTouches[0].pageX
|
|
85
|
+
const currentPageY = e.changedTouches[0].pageY
|
|
86
|
+
if (Math.abs(currentPageX - tapDetailInfo.x) > 1 || Math.abs(currentPageY - tapDetailInfo.y) > 1) {
|
|
68
87
|
context.__mpxTapInfo.needTap = false
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const re = inheritEvent('longtap', e, context.__mpxTapInfo.detail)
|
|
75
|
-
context.$emit('longtap', re)
|
|
76
|
-
}
|
|
77
|
-
}, 350)
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
touchmove (e) {
|
|
81
|
-
const tapDetailInfo = context.__mpxTapInfo.detail || {}
|
|
82
|
-
const currentPageX = e.changedTouches[0].pageX
|
|
83
|
-
const currentPageY = e.changedTouches[0].pageY
|
|
84
|
-
if (Math.abs(currentPageX - tapDetailInfo.x) > 1 || Math.abs(currentPageY - tapDetailInfo.y) > 1) {
|
|
85
|
-
context.__mpxTapInfo.needTap = false
|
|
88
|
+
context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
|
|
89
|
+
context.__mpxTapInfo.startTimer = null
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
touchend (e) {
|
|
86
93
|
context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
|
|
87
|
-
context.__mpxTapInfo.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
context.__mpxTapInfo.startTimer && clearTimeout(context.__mpxTapInfo.startTimer)
|
|
92
|
-
if (listenerMap.tap && context.__mpxTapInfo.needTap) {
|
|
93
|
-
const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
|
|
94
|
-
context.$emit('tap', re)
|
|
94
|
+
if (listenerMap.tap && context.__mpxTapInfo.needTap) {
|
|
95
|
+
const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
|
|
96
|
+
context.$emit('tap', re)
|
|
97
|
+
}
|
|
95
98
|
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
events = {
|
|
102
|
+
click (e) {
|
|
103
|
+
if (listenerMap.tap) {
|
|
104
|
+
context.__mpxTapInfo.detail = {
|
|
105
|
+
x: e.pageX,
|
|
106
|
+
y: e.pageY
|
|
107
|
+
}
|
|
108
|
+
const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
|
|
109
|
+
context.$emit('tap', re)
|
|
102
110
|
}
|
|
103
|
-
const re = inheritEvent('tap', e, context.__mpxTapInfo.detail)
|
|
104
|
-
context.$emit('tap', re)
|
|
105
111
|
}
|
|
106
|
-
context.__mpxTapInfo.hadTouch = false
|
|
107
112
|
}
|
|
108
113
|
}
|
|
114
|
+
|
|
109
115
|
mergeListeners(listeners, events, {
|
|
110
116
|
force: true
|
|
111
117
|
})
|
|
@@ -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
|
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { inBrowser } from '../../../utils/env'
|
|
3
|
+
|
|
3
4
|
function isDef (v) {
|
|
4
5
|
return v !== undefined && v !== null
|
|
5
6
|
}
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
|
|
31
32
|
function getVnodeKey (vnode) {
|
|
32
33
|
if (vnode && vnode.componentOptions) {
|
|
33
|
-
return vnode.
|
|
34
|
+
return vnode.componentOptions.Ctor.cid + (vnode.componentOptions.tag ? ('::' + (vnode.componentOptions.tag)) : '')
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -73,6 +74,8 @@
|
|
|
73
74
|
const current = stack[i - 1]
|
|
74
75
|
if (current.vnode && current.vnodeKey === vnodeKey && current.vnode.componentInstance) {
|
|
75
76
|
vnode.componentInstance = current.vnode.componentInstance
|
|
77
|
+
// 避免组件实例复用但是vnode.key不一致带来的bad case
|
|
78
|
+
vnode.key = current.vnode.key
|
|
76
79
|
break
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -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
|
|
@@ -36,11 +36,14 @@
|
|
|
36
36
|
easingFunction: {
|
|
37
37
|
type: String,
|
|
38
38
|
default: 'default'
|
|
39
|
-
}
|
|
39
|
+
},
|
|
40
|
+
scrollOptions: Object
|
|
40
41
|
},
|
|
41
42
|
data () {
|
|
42
43
|
return {
|
|
43
|
-
currentIndex: this.current
|
|
44
|
+
currentIndex: this.current,
|
|
45
|
+
currentChildLength: 0,
|
|
46
|
+
lastChildLength: 0
|
|
44
47
|
}
|
|
45
48
|
},
|
|
46
49
|
computed: {
|
|
@@ -80,6 +83,9 @@
|
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
},
|
|
86
|
+
updated () {
|
|
87
|
+
this.currentChildLength = this.$children && this.$children.length
|
|
88
|
+
},
|
|
83
89
|
watch: {
|
|
84
90
|
current (val) {
|
|
85
91
|
if (this.bs) {
|
|
@@ -88,13 +94,32 @@
|
|
|
88
94
|
}
|
|
89
95
|
this.changeSource = ''
|
|
90
96
|
this.goto(val)
|
|
97
|
+
},
|
|
98
|
+
currentChildLength(val) {
|
|
99
|
+
if (val < this.lastChildLength && val < this.currentIndex) {
|
|
100
|
+
this.goto(0, 0)
|
|
101
|
+
}
|
|
102
|
+
if (this.lastChildLength || (!this.lastChildLength && !this.autoplay)) {
|
|
103
|
+
this.bs && this.bs.refresh()
|
|
104
|
+
}
|
|
105
|
+
this.lastChildLength = val
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
activated () {
|
|
109
|
+
if (this.bs && this.autoplay) {
|
|
110
|
+
this.bs.startPlay()
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
deactivated () {
|
|
114
|
+
if (this.bs && this.autoplay) {
|
|
115
|
+
this.bs.pausePlay()
|
|
91
116
|
}
|
|
92
117
|
},
|
|
93
118
|
beforeCreate () {
|
|
94
119
|
this.itemIds = []
|
|
95
120
|
},
|
|
96
121
|
mounted () {
|
|
97
|
-
|
|
122
|
+
const originBsOptions = {
|
|
98
123
|
scrollX: !this.vertical,
|
|
99
124
|
scrollY: this.vertical,
|
|
100
125
|
slide: {
|
|
@@ -103,14 +128,17 @@
|
|
|
103
128
|
speed: this.duration,
|
|
104
129
|
easing: this.easing,
|
|
105
130
|
interval: this.interval,
|
|
106
|
-
autoplay: this.autoplay
|
|
131
|
+
autoplay: this.autoplay,
|
|
132
|
+
startPageXIndex: this.vertical ? 0 : this.current,
|
|
133
|
+
startPageYIndex: this.vertical? this.current : 0
|
|
107
134
|
},
|
|
108
135
|
momentum: false,
|
|
109
136
|
bounce: false,
|
|
110
137
|
probeType: 3,
|
|
111
138
|
stopPropagation: true
|
|
112
|
-
}
|
|
113
|
-
|
|
139
|
+
}
|
|
140
|
+
const bsOptions = Object.assign({}, originBsOptions, this.scrollOptions)
|
|
141
|
+
this.bs = new BScroll(this.$refs.wrapper, bsOptions)
|
|
114
142
|
this.bs.on('slideWillChange', (page) => {
|
|
115
143
|
this.currentIndex = this.vertical ? page.pageY : page.pageX
|
|
116
144
|
this.$emit('change', getCustomEvent('change', {
|
|
@@ -153,10 +181,11 @@
|
|
|
153
181
|
refresh () {
|
|
154
182
|
this.bs && this.bs.refresh()
|
|
155
183
|
},
|
|
156
|
-
goto (index) {
|
|
184
|
+
goto (index, time) {
|
|
157
185
|
const x = this.vertical ? 0 : index
|
|
158
186
|
const y = this.vertical ? index : 0
|
|
159
|
-
|
|
187
|
+
const speed = time === 0 ? 0 : this.duration
|
|
188
|
+
this.bs && this.bs.goToPage(x, y, speed)
|
|
160
189
|
}
|
|
161
190
|
},
|
|
162
191
|
render (createElement) {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
'mpx-tab-bar': tabBarPagesMap['mpx-tab-bar']
|
|
16
16
|
}
|
|
17
17
|
tabBar.list.forEach(({ pagePath }) => {
|
|
18
|
-
const name = pagePath.replace(
|
|
18
|
+
const name = pagePath.replace(/\//g, '-')
|
|
19
19
|
const page = tabBarPagesMap[pagePath]
|
|
20
20
|
if (page) {
|
|
21
21
|
components[name] = page
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
currentComponent () {
|
|
40
40
|
const index = this.currentIndex
|
|
41
41
|
const tabItem = tabBar.list[index]
|
|
42
|
-
return tabItem.pagePath.replace(
|
|
42
|
+
return tabItem.pagePath.replace(/\//g, '-')
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
watch: {
|
package/lib/runtime/i18n.wxs
CHANGED
|
@@ -6,7 +6,6 @@ function genRegExp (str, flags) {
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
function likeArray (arr) {
|
|
11
10
|
if (!__mpx_wxs__) {
|
|
12
11
|
return Array.isArray(arr)
|
|
@@ -23,7 +22,6 @@ function isDef (v) {
|
|
|
23
22
|
return v !== undefined && v !== null
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
27
25
|
var RE_TOKEN_LIST_VALUE = genRegExp('^[0-9]+')
|
|
28
26
|
var RE_TOKEN_NAMED_VALUE = genRegExp('^[A-Za-z0-9_]+')
|
|
29
27
|
|
|
@@ -40,7 +38,10 @@ function parseMessage (format) {
|
|
|
40
38
|
var char = format[position++]
|
|
41
39
|
if (char === '{') {
|
|
42
40
|
if (text) {
|
|
43
|
-
tokens.push({
|
|
41
|
+
tokens.push({
|
|
42
|
+
type: 'text',
|
|
43
|
+
value: text
|
|
44
|
+
})
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
text = ''
|
|
@@ -56,7 +57,10 @@ function parseMessage (format) {
|
|
|
56
57
|
: isClosed && RE_TOKEN_NAMED_VALUE.test(sub)
|
|
57
58
|
? 'named'
|
|
58
59
|
: 'unknown'
|
|
59
|
-
tokens.push({
|
|
60
|
+
tokens.push({
|
|
61
|
+
value: sub,
|
|
62
|
+
type: type
|
|
63
|
+
})
|
|
60
64
|
} else if (char === '%') {
|
|
61
65
|
// when found rails i18n syntax, skip text capture
|
|
62
66
|
if (format[(position)] !== '{') {
|
|
@@ -67,7 +71,10 @@ function parseMessage (format) {
|
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
text && tokens.push({
|
|
74
|
+
text && tokens.push({
|
|
75
|
+
type: 'text',
|
|
76
|
+
value: text
|
|
77
|
+
})
|
|
71
78
|
|
|
72
79
|
return tokens
|
|
73
80
|
}
|
|
@@ -263,6 +270,11 @@ function exist (messages, locale, key) {
|
|
|
263
270
|
var messages = {}
|
|
264
271
|
var dateTimeFormats = {}
|
|
265
272
|
var numberFormats = {}
|
|
273
|
+
var locale = 'zh-CN'
|
|
274
|
+
|
|
275
|
+
function getLocale () {
|
|
276
|
+
return __mpx_locale__ || locale
|
|
277
|
+
}
|
|
266
278
|
|
|
267
279
|
function getMessages () {
|
|
268
280
|
// __mpx_messages__会在编译时通过lib/wxs/i18n-loader注入
|
|
@@ -339,7 +351,15 @@ module.exports = {
|
|
|
339
351
|
}
|
|
340
352
|
|
|
341
353
|
if (!__mpx_wxs__) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
354
|
+
if (!global.i18n) {
|
|
355
|
+
global.i18n = {
|
|
356
|
+
locale: getLocale(),
|
|
357
|
+
version: 0
|
|
358
|
+
}
|
|
359
|
+
global.i18nMethods = Object.assign(module.exports, {
|
|
360
|
+
__getMessages: getMessages,
|
|
361
|
+
__getDateTimeFormats: getDateTimeFormats,
|
|
362
|
+
__getNumberFormats: getNumberFormats
|
|
363
|
+
})
|
|
364
|
+
}
|
|
345
365
|
}
|
|
@@ -4,7 +4,7 @@ export default function processOption (
|
|
|
4
4
|
option,
|
|
5
5
|
ctorType,
|
|
6
6
|
firstPage,
|
|
7
|
-
|
|
7
|
+
outputPath,
|
|
8
8
|
pageConfig,
|
|
9
9
|
pagesMap,
|
|
10
10
|
componentsMap,
|
|
@@ -25,23 +25,6 @@ export default function processOption (
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// 注册v-ex-classes自定义指令处理externalClasses
|
|
29
|
-
Vue.directive('ex-classes', (el, binding, vnode) => {
|
|
30
|
-
const context = vnode.context
|
|
31
|
-
if (context) {
|
|
32
|
-
const externalClasses = context.$options.externalClasses || []
|
|
33
|
-
const classList = el.classList
|
|
34
|
-
binding.value.forEach((className) => {
|
|
35
|
-
const actualExternalClassNames = context.$attrs[className]
|
|
36
|
-
if (externalClasses.indexOf(className) !== -1 && actualExternalClassNames) {
|
|
37
|
-
classList.remove(className)
|
|
38
|
-
actualExternalClassNames.split(/\s+/).forEach((actualExternalClassName) => {
|
|
39
|
-
if (actualExternalClassName) classList.add(actualExternalClassName)
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
28
|
Vue.directive('animation', (el, binding) => {
|
|
46
29
|
const newActions = binding && binding.value && binding.value.actions
|
|
47
30
|
if (el.actions === newActions) {
|
|
@@ -102,6 +85,51 @@ export default function processOption (
|
|
|
102
85
|
}
|
|
103
86
|
})
|
|
104
87
|
|
|
88
|
+
Vue.filter('transRpxStyle', style => {
|
|
89
|
+
const defaultTransRpxFn = function (match, $1) {
|
|
90
|
+
const rpx2vwRatio = +(100 / 750).toFixed(8)
|
|
91
|
+
return '' + ($1 * rpx2vwRatio) + 'vw'
|
|
92
|
+
}
|
|
93
|
+
const transRpxFn = global.__mpxTransRpxFn || defaultTransRpxFn
|
|
94
|
+
const parsedStyleObj = {}
|
|
95
|
+
const rpxRegExpG = /\b(\d+(\.\d+)?)rpx\b/g
|
|
96
|
+
const parseStyleText = (cssText) => {
|
|
97
|
+
const listDelimiter = /;(?![^(]*\))/g
|
|
98
|
+
const propertyDelimiter = /:(.+)/
|
|
99
|
+
if (typeof cssText === 'string') {
|
|
100
|
+
cssText.split(listDelimiter).forEach((item) => {
|
|
101
|
+
if (item) {
|
|
102
|
+
var tmp = item.split(propertyDelimiter)
|
|
103
|
+
tmp.length > 1 && (parsedStyleObj[tmp[0].trim()] = tmp[1].trim())
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
} else if (typeof cssText === 'object') {
|
|
107
|
+
if (Array.isArray(cssText)) {
|
|
108
|
+
cssText.forEach(cssItem => {
|
|
109
|
+
parseStyleText(cssItem)
|
|
110
|
+
})
|
|
111
|
+
} else {
|
|
112
|
+
Object.assign(parsedStyleObj, cssText)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const transRpxStyleFn = (val) => {
|
|
117
|
+
if (typeof val === 'string' && val.indexOf('rpx') > 0) {
|
|
118
|
+
return val.replace(rpxRegExpG, transRpxFn).replace(/"/g, '')
|
|
119
|
+
}
|
|
120
|
+
return val
|
|
121
|
+
}
|
|
122
|
+
if (style) {
|
|
123
|
+
style.forEach(item => {
|
|
124
|
+
parseStyleText(item)
|
|
125
|
+
for (let key in parsedStyleObj) {
|
|
126
|
+
parsedStyleObj[key] = transRpxStyleFn(parsedStyleObj[key])
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
return parsedStyleObj
|
|
131
|
+
})
|
|
132
|
+
|
|
105
133
|
const routes = []
|
|
106
134
|
|
|
107
135
|
for (const pagePath in pagesMap) {
|
|
@@ -121,7 +149,9 @@ export default function processOption (
|
|
|
121
149
|
redirect: '/' + firstPage
|
|
122
150
|
})
|
|
123
151
|
}
|
|
152
|
+
const webRouteConfig = global.__mpx.config.webRouteConfig
|
|
124
153
|
global.__mpxRouter = option.router = new VueRouter({
|
|
154
|
+
...webRouteConfig,
|
|
125
155
|
routes: routes
|
|
126
156
|
})
|
|
127
157
|
global.__mpxRouter.stack = []
|
|
@@ -354,8 +384,8 @@ registered in parent context!`)
|
|
|
354
384
|
option.mixins = [mixin]
|
|
355
385
|
}
|
|
356
386
|
|
|
357
|
-
if (
|
|
358
|
-
option.componentPath = '/' +
|
|
387
|
+
if (outputPath) {
|
|
388
|
+
option.componentPath = '/' + outputPath
|
|
359
389
|
}
|
|
360
390
|
|
|
361
391
|
return option
|