@mpxjs/webpack-plugin 2.10.3-beta.14 → 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,38 +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('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', {
134
+ class: ['mpx-titlebar', { 'mpx-titlebar--hidden': this.hidden }],
135
+ style: this.rootStyle
136
+ }, [
137
+ h('div', { class: 'mpx-titlebar__safe', style: this.safeStyle }, [
138
+ h('div', { class: 'mpx-titlebar__inner', style: this.innerStyle }, [
133
139
  h('div', { class: 'mpx-titlebar__left', on: { click: this.onLeftClick } }, leftChildren),
134
140
  h('div', { class: 'mpx-titlebar__center' }, centerChildren),
135
141
  h('div', { class: 'mpx-titlebar__right' }, [])
142
+ ])
136
143
  ])
137
- ])
138
- ]),
139
- h('page', {}, [ this.$slots.default ])
140
- ])
144
+ ]),
145
+ h('page', {}, [this.$slots.default])
146
+ ])
141
147
  }
142
148
  }
143
149
  </script>
144
150
 
145
151
  <style scoped>
146
- .page-wrapper {
147
- padding-top: calc(env(safe-area-inset-top, 0px) + 44px);
152
+ .mpx-page-warp {
153
+ width: '100%';
154
+ box-sizing: 'border-box';
155
+ position: 'relative'
148
156
  }
157
+
158
+ /* 防止margin溢出合并 */
159
+ .mpx-page-warp::before {
160
+ content: '';
161
+ display: table
162
+ }
163
+
149
164
  .mpx-titlebar--hidden {
150
165
  display: none;
151
166
  }
167
+
152
168
  .mpx-titlebar__safe {
153
169
  /* safe area handled by padding-top; include both env and constant for broader iOS support */
154
170
  padding-top: env(safe-area-inset-top, 0px);
155
171
  padding-top: constant(safe-area-inset-top, 0px);
156
172
  }
173
+
157
174
  .mpx-titlebar__inner {
158
175
  display: flex;
159
176
  align-items: center;
@@ -161,6 +178,7 @@ export default {
161
178
  padding: 0 12px;
162
179
  box-sizing: border-box;
163
180
  }
181
+
164
182
  .mpx-titlebar__left,
165
183
  .mpx-titlebar__right {
166
184
  flex: 0 0 auto;
@@ -168,6 +186,7 @@ export default {
168
186
  display: flex;
169
187
  align-items: center;
170
188
  }
189
+
171
190
  .mpx-titlebar__center {
172
191
  flex: 1 1 auto;
173
192
  display: flex;
@@ -176,6 +195,7 @@ export default {
176
195
  overflow: hidden;
177
196
  padding: 0 8px;
178
197
  }
198
+
179
199
  .mpx-titlebar__title {
180
200
  font-size: 17px;
181
201
  white-space: nowrap;
@@ -183,6 +203,7 @@ export default {
183
203
  overflow: hidden;
184
204
  font-weight: 500;
185
205
  }
206
+
186
207
  .mpx-titlebar__back {
187
208
  background: none;
188
209
  border: none;
@@ -223,6 +244,7 @@ export default {
223
244
  width: 20px;
224
245
  height: 20px;
225
246
  }
247
+
226
248
  .mpx-titlebar__back path {
227
249
  stroke: currentColor;
228
250
  }
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.15",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"