@mpxjs/webpack-plugin 2.10.3-beta.13 → 2.10.3-beta.15

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,48 +128,49 @@ 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('page', { }, [
127
- h('div', { class: 'mpx-titlebar-wrapper' }, [
128
- // fixed titlebar
131
+ // top-level wrapper: contains fixed titlebar and page content wrapper
132
+ return h('div', { class: 'mpx-page-warp', style: this.warpStyle }, [
129
133
  h('div', {
130
134
  class: ['mpx-titlebar', { 'mpx-titlebar--hidden': this.hidden }],
131
135
  style: this.rootStyle
132
136
  }, [
133
137
  h('div', { class: 'mpx-titlebar__safe', style: this.safeStyle }, [
134
138
  h('div', { class: 'mpx-titlebar__inner', style: this.innerStyle }, [
135
- h('div', { class: 'mpx-titlebar__left', on: { click: this.onLeftClick } }, leftChildren),
136
- h('div', { class: 'mpx-titlebar__center' }, centerChildren),
137
- h('div', { class: 'mpx-titlebar__right' }, [])
139
+ h('div', { class: 'mpx-titlebar__left', on: { click: this.onLeftClick } }, leftChildren),
140
+ h('div', { class: 'mpx-titlebar__center' }, centerChildren),
141
+ h('div', { class: 'mpx-titlebar__right' }, [])
138
142
  ])
139
143
  ])
140
144
  ]),
141
-
142
- // page content wrapper: default slot is page content
143
- h('div', { class: 'mpx-titlebar__content' }, [
144
- h('div', { class: 'mpx-titlebar__scroll' }, this.$slots.default || [])
145
- ])
145
+ h('page', {}, [this.$slots.default])
146
146
  ])
147
- ])
148
-
149
147
  }
150
148
  }
151
149
  </script>
152
150
 
153
151
  <style scoped>
154
- .mpx-titlebar {
155
- width: 100%;
156
- box-sizing: border-box;
157
- -webkit-font-smoothing: antialiased;
152
+ .mpx-page-warp {
153
+ width: '100%';
154
+ box-sizing: 'border-box';
155
+ position: 'relative'
156
+ }
157
+
158
+ /* 防止margin溢出合并 */
159
+ .mpx-page-warp::before {
160
+ content: '';
161
+ display: table
158
162
  }
163
+
159
164
  .mpx-titlebar--hidden {
160
165
  display: none;
161
166
  }
167
+
162
168
  .mpx-titlebar__safe {
163
169
  /* safe area handled by padding-top; include both env and constant for broader iOS support */
164
170
  padding-top: env(safe-area-inset-top, 0px);
165
171
  padding-top: constant(safe-area-inset-top, 0px);
166
172
  }
173
+
167
174
  .mpx-titlebar__inner {
168
175
  display: flex;
169
176
  align-items: center;
@@ -171,6 +178,7 @@ export default {
171
178
  padding: 0 12px;
172
179
  box-sizing: border-box;
173
180
  }
181
+
174
182
  .mpx-titlebar__left,
175
183
  .mpx-titlebar__right {
176
184
  flex: 0 0 auto;
@@ -178,6 +186,7 @@ export default {
178
186
  display: flex;
179
187
  align-items: center;
180
188
  }
189
+
181
190
  .mpx-titlebar__center {
182
191
  flex: 1 1 auto;
183
192
  display: flex;
@@ -186,6 +195,7 @@ export default {
186
195
  overflow: hidden;
187
196
  padding: 0 8px;
188
197
  }
198
+
189
199
  .mpx-titlebar__title {
190
200
  font-size: 17px;
191
201
  white-space: nowrap;
@@ -193,6 +203,7 @@ export default {
193
203
  overflow: hidden;
194
204
  font-weight: 500;
195
205
  }
206
+
196
207
  .mpx-titlebar__back {
197
208
  background: none;
198
209
  border: none;
@@ -202,17 +213,17 @@ export default {
202
213
  cursor: pointer;
203
214
  }
204
215
 
205
- /* wrapper and content layout */
206
- .mpx-titlebar-wrapper {
207
- position: relative;
208
- width: 100vw;
209
- height: 100vh;
210
- display: flex;
211
- flex-direction: column;
212
- }
213
-
214
216
  .mpx-titlebar {
215
- flex-shrink: 0;
217
+ /* flex-shrink: 0; */
218
+ height: calc(env(safe-area-inset-top, 0px) + 44px);
219
+ width: 100%;
220
+ box-sizing: border-box;
221
+ -webkit-font-smoothing: antialiased;
222
+ position: fixed;
223
+ top: 0;
224
+ left: 0;
225
+ right: 0;
226
+ z-index: 99999;
216
227
  }
217
228
 
218
229
  .mpx-titlebar__content {
@@ -233,6 +244,7 @@ export default {
233
244
  width: 20px;
234
245
  height: 20px;
235
246
  }
247
+
236
248
  .mpx-titlebar__back path {
237
249
  stroke: currentColor;
238
250
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.3-beta.13",
3
+ "version": "2.10.3-beta.15",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"