@mpxjs/webpack-plugin 2.10.3-beta.14 → 2.10.3-beta.16

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.
@@ -16,32 +16,32 @@ export default {
16
16
  },
17
17
  computed: {
18
18
  // 合并全局 window 配置与页面配置(页面配置覆盖全局配置)
19
- cfg () {
19
+ cfg() {
20
20
  return Object.assign({}, this.windowConfig || {}, this.pageConfig || {})
21
21
  },
22
22
  // 标题文本(兼容常见字段名)
23
- titleText () {
23
+ titleText() {
24
24
  return this.cfg.navigationBarTitleText || this.cfg.title || ''
25
25
  },
26
26
  // 背景色(兼容常见字段)
27
- backgroundColor () {
27
+ backgroundColor() {
28
28
  return this.cfg.navigationBarBackgroundColor || '#ffffff'
29
29
  },
30
30
  // 文本颜色,微信小程序中 navigationBarTextStyle 为 white 或 black
31
- textColor () {
31
+ textColor() {
32
32
  const style = this.cfg.navigationBarTextStyle || 'black'
33
33
  return style === 'white' ? '#ffffff' : '#000000'
34
34
  },
35
35
  // navigationStyle: 'default' | 'custom',custom 表示需要自定义绘制
36
- navigationStyle () {
36
+ navigationStyle() {
37
37
  return this.cfg.navigationStyle || 'default'
38
38
  },
39
39
  // 是否隐藏(navigationStyle 为 'custom' 时也应隐藏)
40
- hidden () {
40
+ hidden() {
41
41
  return mpx.config?.webConfig?.enableTitleBar !== true || this.navigationStyle === 'custom'
42
42
  },
43
43
  // 是否展示返回按钮:根据浏览器历史判断(不依赖额外 page 配置)
44
- showBack () {
44
+ showBack() {
45
45
  console.log('showBack', this.$router.stack.length)
46
46
  try {
47
47
  return this.$router.stack.length > 1
@@ -50,24 +50,30 @@ export default {
50
50
  }
51
51
  },
52
52
  // safe area 顶部 padding,使用 env(safe-area-inset-top)
53
- safeStyle () {
53
+ safeStyle() {
54
54
  // 多数浏览器支持 env(), 为兼容也使用 constant() 备选(旧 iOS Safari)
55
55
  return {
56
56
  paddingTop: 'env(safe-area-inset-top, 0px)'
57
57
  }
58
58
  },
59
+ warpStyle() {
60
+ return {
61
+ // marginTop: this.hidden ? '0' : 'calc(env(safe-area-inset-top, 0px) + 44px)',
62
+ height: this.hidden ? '100%' : 'calc(100% - env(safe-area-inset-top, 0px) - 44px)'
63
+ }
64
+ },
59
65
  // 内部标题栏高度(遵循小程序常见平台差异)
60
- innerHeight () {
66
+ innerHeight() {
61
67
  const isIOS = /iP(hone|od|ad)/.test(navigator.userAgent)
62
68
  return (isIOS ? 44 : 48) + 'px'
63
69
  },
64
- rootStyle () {
70
+ rootStyle() {
65
71
  return {
66
72
  background: this.backgroundColor,
67
73
  color: this.textColor
68
74
  }
69
75
  },
70
- innerStyle () {
76
+ innerStyle() {
71
77
  return {
72
78
  height: this.innerHeight
73
79
  }
@@ -75,14 +81,14 @@ export default {
75
81
  },
76
82
  methods: {
77
83
  // 左侧点击:派发事件并在可回退时回退
78
- onLeftClick (e) {
84
+ onLeftClick(e) {
79
85
  this.$emit('click-left', e)
80
86
  if (this.showBack) {
81
- try { window.history.back() } catch (err) {}
87
+ try { window.history.back() } catch (err) { }
82
88
  }
83
89
  }
84
90
  },
85
- render (h) {
91
+ render(h) {
86
92
  const leftChildren = []
87
93
 
88
94
  // default back button (SVG) — no left slot support
@@ -122,38 +128,50 @@ export default {
122
128
  h('div', { class: 'mpx-titlebar__title', style: { color: this.textColor } }, [this.titleText])
123
129
  ]
124
130
 
125
- // top-level wrapper: contains fixed titlebar and page content wrapper
126
- return h('div', { class: 'page-wrapper' }, [
127
- h('div', {
128
- class: ['mpx-titlebar', { 'mpx-titlebar--hidden': this.hidden }],
129
- style: this.rootStyle
130
- }, [
131
- h('div', { class: 'mpx-titlebar__safe', style: this.safeStyle }, [
132
- h('div', { class: 'mpx-titlebar__inner', style: this.innerStyle }, [
131
+ // top-level wrapper: contains fixed titlebar and page content wrapper
132
+ return h('div', { class: 'mpx-page-warp', style: this.warpStyle }, [
133
+ h('div', { style: { width: '100%', height: this.hidden ? '0' : 'calc(env(safe-area-inset-top, 0px) + 44px)' } }),
134
+ h('div', {
135
+ class: ['mpx-titlebar', { 'mpx-titlebar--hidden': this.hidden }],
136
+ style: this.rootStyle
137
+ }, [
138
+ h('div', { class: 'mpx-titlebar__safe', style: this.safeStyle }, [
139
+ h('div', { class: 'mpx-titlebar__inner', style: this.innerStyle }, [
133
140
  h('div', { class: 'mpx-titlebar__left', on: { click: this.onLeftClick } }, leftChildren),
134
141
  h('div', { class: 'mpx-titlebar__center' }, centerChildren),
135
142
  h('div', { class: 'mpx-titlebar__right' }, [])
143
+ ])
136
144
  ])
137
- ])
138
- ]),
139
- h('page', {}, [ this.$slots.default ])
140
- ])
145
+ ]),
146
+ h('page', {}, [this.$slots.default])
147
+ ])
141
148
  }
142
149
  }
143
150
  </script>
144
151
 
145
152
  <style scoped>
146
- .page-wrapper {
147
- padding-top: calc(env(safe-area-inset-top, 0px) + 44px);
153
+ .mpx-page-warp {
154
+ width: 100%;
155
+ box-sizing: border-box;
156
+ position: relative
157
+ }
158
+
159
+ /* 防止margin溢出合并 */
160
+ .mpx-page-warp::before {
161
+ content: '';
162
+ display: table
148
163
  }
164
+
149
165
  .mpx-titlebar--hidden {
150
166
  display: none;
151
167
  }
168
+
152
169
  .mpx-titlebar__safe {
153
170
  /* safe area handled by padding-top; include both env and constant for broader iOS support */
154
171
  padding-top: env(safe-area-inset-top, 0px);
155
172
  padding-top: constant(safe-area-inset-top, 0px);
156
173
  }
174
+
157
175
  .mpx-titlebar__inner {
158
176
  display: flex;
159
177
  align-items: center;
@@ -161,6 +179,7 @@ export default {
161
179
  padding: 0 12px;
162
180
  box-sizing: border-box;
163
181
  }
182
+
164
183
  .mpx-titlebar__left,
165
184
  .mpx-titlebar__right {
166
185
  flex: 0 0 auto;
@@ -168,6 +187,7 @@ export default {
168
187
  display: flex;
169
188
  align-items: center;
170
189
  }
190
+
171
191
  .mpx-titlebar__center {
172
192
  flex: 1 1 auto;
173
193
  display: flex;
@@ -176,6 +196,7 @@ export default {
176
196
  overflow: hidden;
177
197
  padding: 0 8px;
178
198
  }
199
+
179
200
  .mpx-titlebar__title {
180
201
  font-size: 17px;
181
202
  white-space: nowrap;
@@ -183,6 +204,7 @@ export default {
183
204
  overflow: hidden;
184
205
  font-weight: 500;
185
206
  }
207
+
186
208
  .mpx-titlebar__back {
187
209
  background: none;
188
210
  border: none;
@@ -223,6 +245,7 @@ export default {
223
245
  width: 20px;
224
246
  height: 20px;
225
247
  }
248
+
226
249
  .mpx-titlebar__back path {
227
250
  stroke: currentColor;
228
251
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.3-beta.14",
3
+ "version": "2.10.3-beta.16",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"