@we-debug/miniprogram 0.50.0 → 0.51.1

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.
@@ -10,6 +10,33 @@ const animateClassName = {
10
10
  slideOutDown: 'slideOutDown'
11
11
  };
12
12
 
13
+ // 与 less/_variable.less 中 @mask-modal-* 保持一致
14
+ const MODAL_MAX_WIDTH = 669;
15
+ const MODAL_TOP_GAP = 56;
16
+ const MODAL_SHORT_TOP_GAP = 16;
17
+ const MODAL_SHORT_HEIGHT = 500;
18
+ const MODAL_MIN_BOTTOM_GAP = 16;
19
+
20
+ const getWindowHeight = () => {
21
+ try {
22
+ return (wx.getWindowInfo ? wx.getWindowInfo() : wx.getSystemInfoSync()).windowHeight;
23
+ } catch (e) {
24
+ return 0;
25
+ }
26
+ };
27
+
28
+ // page-container 只能通过 custom-style 定制白底,无法用 less 里的媒体查询
29
+ const getPageContainerStyle = (windowHeight = getWindowHeight()) => {
30
+ const topGap = windowHeight && windowHeight <= MODAL_SHORT_HEIGHT ? MODAL_SHORT_TOP_GAP : MODAL_TOP_GAP;
31
+ return (
32
+ `padding: 12px 24px ${MODAL_MIN_BOTTOM_GAP}px 24px;` +
33
+ `padding-bottom: max(${MODAL_MIN_BOTTOM_GAP}px, constant(safe-area-inset-bottom));` +
34
+ `padding-bottom: max(${MODAL_MIN_BOTTOM_GAP}px, env(safe-area-inset-bottom));` +
35
+ `box-sizing: border-box;max-height: calc(100vh - ${topGap}px);display: flex;flex-direction: column;overflow: hidden;` +
36
+ `left: 0;right: 0;max-width: ${MODAL_MAX_WIDTH}px;margin: 0 auto;`
37
+ );
38
+ };
39
+
13
40
  Component({
14
41
  properties: {
15
42
  show: {
@@ -39,8 +66,7 @@ Component({
39
66
  },
40
67
  styles: {
41
68
  zIndex: 999991,
42
- customStyle:
43
- 'padding: 12px 24px 24px 24px;padding-bottom: constant(safe-area-inset-bottom);padding-bottom: env(safe-area-inset-bottom);'
69
+ customStyle: getPageContainerStyle()
44
70
  },
45
71
  // eslint-disable-next-line no-undef
46
72
  useCustomMask: true
@@ -72,7 +98,7 @@ Component({
72
98
  modal: animateClassName.slideInUp
73
99
  }
74
100
  }
75
- : {}),
101
+ : { 'styles.customStyle': getPageContainerStyle() }),
76
102
  showMask: true
77
103
  });
78
104
  },
@@ -165,5 +191,14 @@ Component({
165
191
  },
166
192
  detached() {
167
193
  this.removeListeners();
194
+ },
195
+ pageLifetimes: {
196
+ resize(res) {
197
+ const windowHeight = res && res.size && res.size.windowHeight;
198
+ const customStyle = getPageContainerStyle(windowHeight || undefined);
199
+ if (customStyle !== this.data.styles.customStyle) {
200
+ this.setData({ 'styles.customStyle': customStyle });
201
+ }
202
+ }
168
203
  }
169
204
  });
@@ -66,16 +66,32 @@
66
66
  left: 0;
67
67
  right: 0;
68
68
  bottom: 0;
69
+ max-width: 669px;
70
+ margin: 0 auto;
69
71
  z-index: 999992;
70
- padding-bottom: constant(safe-area-inset-bottom);
72
+ padding-bottom: 16px;
73
+ padding-bottom: max(16px, constant(safe-area-inset-bottom));
71
74
  /* iOS < 11.2 */
72
- padding-bottom: env(safe-area-inset-bottom);
75
+ padding-bottom: max(16px, env(safe-area-inset-bottom));
73
76
  /* iOS >= 11.2 */
77
+ box-sizing: border-box;
78
+ max-height: calc(100% - 56px);
79
+ display: flex;
80
+ flex-direction: column;
81
+ overflow: hidden;
82
+ -webkit-text-size-adjust: 100%;
83
+ -moz-text-size-adjust: 100%;
84
+ text-size-adjust: 100%;
74
85
  }
75
86
  .w-mask__modal-title {
76
87
  color: rgba(0, 0, 0, 0.8);
77
88
  font-size: 16px;
78
- line-height: 66rpx;
79
- height: 66rpx;
89
+ line-height: 33px;
90
+ height: 33px;
80
91
  text-align: center;
81
92
  }
93
+ @media (max-height: 500px) {
94
+ .w-mask__modal {
95
+ max-height: calc(100% - 16px);
96
+ }
97
+ }
@@ -1,8 +1,8 @@
1
1
  .w-btn {
2
- width: 100rpx;
3
- height: 52rpx;
2
+ width: 50px;
3
+ height: 26px;
4
4
  text-align: center;
5
- line-height: 52rpx;
5
+ line-height: 26px;
6
6
  font-weight: 500;
7
7
  border-radius: 4px;
8
8
  color: #fff;
@@ -43,24 +43,24 @@
43
43
  opacity: 0.5;
44
44
  }
45
45
  .w-switch {
46
- margin: 15rpx -8rpx 0 0;
46
+ margin: 8px -4px 0 0;
47
47
  }
48
48
  .w-switch[disabled] {
49
49
  opacity: 0.4;
50
50
  }
51
+ .w-arrow {
52
+ display: flex;
53
+ align-items: center;
54
+ margin-right: -4px;
55
+ white-space: nowrap;
56
+ }
51
57
  .w-arrow-name {
52
- position: absolute;
53
- right: 28px;
54
- top: 50%;
55
- transform: translateY(-50%);
56
58
  font-size: 12px;
57
59
  color: #808080;
58
60
  }
59
61
  .w-arrow .arrow-icon {
60
- position: absolute;
61
- right: 12px;
62
- top: 50%;
63
- transform: translateY(-50%);
62
+ flex-shrink: 0;
63
+ margin-left: 2px;
64
64
  width: 14px;
65
65
  height: 14px;
66
66
  background-size: cover;
@@ -71,18 +71,18 @@
71
71
  }
72
72
  .cell-body-major__meta {
73
73
  display: inline-block;
74
- padding: 0 8rpx;
75
- margin-left: 16rpx;
76
- min-width: 32rpx;
77
- height: 32rpx;
74
+ padding: 0 4px;
75
+ margin-left: 8px;
76
+ min-width: 16px;
77
+ height: 16px;
78
78
  text-align: center;
79
- line-height: 32rpx;
79
+ line-height: 16px;
80
80
  color: #fff;
81
81
  background-color: #e05d44;
82
- border-radius: 32rpx;
82
+ border-radius: 16px;
83
83
  }
84
84
  .cell-body-minor {
85
85
  color: #9d9d9d;
86
86
  font-size: 12px;
87
- margin-top: 6rpx;
87
+ margin-top: 3px;
88
88
  }
@@ -0,0 +1 @@
1
+ module.exports=Behavior({properties:{props:{type:Object,value:{}}},methods:{close(e){this.triggerEvent("close",{result:e})}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@we-debug/miniprogram",
3
- "version": "0.50.0",
3
+ "version": "0.51.1",
4
4
  "description": "we-debug miniprogram component",
5
5
  "author": {
6
6
  "name": "dlhandsome"
@@ -26,10 +26,10 @@
26
26
  },
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
- "@we-debug/core": "0.50.0"
29
+ "@we-debug/core": "0.51.0"
30
30
  },
31
31
  "readme": "ERROR: No README data found!",
32
32
  "_id": "@we-debug/core@0.3.5",
33
33
  "_commitid": "6c3f04b",
34
- "gitHead": "2304486ada029231f6e93b89f7491fe0e5d298c6"
34
+ "gitHead": "12d7e9b6e6681d6959b2e9dc3198815900714147"
35
35
  }
@@ -0,0 +1,27 @@
1
+ /* eslint-env jest */
2
+ const mockDebug = {
3
+ event: {
4
+ on: jest.fn(),
5
+ off: jest.fn()
6
+ },
7
+ releasePageOverlays: jest.fn(),
8
+ getPageOverlays: jest.fn(() => [])
9
+ };
10
+
11
+ jest.mock('@we-debug/core', () => ({ default: mockDebug }));
12
+
13
+ test('缺少 getPageId 时警告且不注册或释放浮层监听', () => {
14
+ const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
15
+ global.Behavior = jest.fn(options => options);
16
+ const behavior = require('../src/host-behavior');
17
+ const host = { data: { mode: 'overlay' } };
18
+
19
+ behavior.lifetimes.attached.call(host);
20
+ behavior.lifetimes.detached.call(host);
21
+
22
+ expect(warn).toHaveBeenCalledWith('[we-debug] 当前基础库不支持 getPageId,插件浮层不可用');
23
+ expect(mockDebug.event.on).not.toHaveBeenCalled();
24
+ expect(mockDebug.event.off).not.toHaveBeenCalled();
25
+ expect(mockDebug.releasePageOverlays).not.toHaveBeenCalled();
26
+ warn.mockRestore();
27
+ });