@we-debug/miniprogram 0.50.0 → 0.51.0
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/CHANGELOG.md +18 -0
- package/dist/cell/index.wxss +1 -1
- package/dist/cell-item/index.wxss +1 -1
- package/dist/host-behavior.js +1 -0
- package/dist/host-empty/index.js +1 -0
- package/dist/host-empty/index.json +3 -0
- package/dist/host-empty/index.wxml +1 -0
- package/dist/index/index.js +130 -26
- package/dist/index/index.json +6 -0
- package/dist/index/index.wxml +61 -31
- package/dist/index/index.wxss +75 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/launcher/index.js +193 -0
- package/dist/launcher/index.json +4 -0
- package/dist/launcher/index.less +1 -0
- package/dist/launcher/index.wxml +17 -0
- package/dist/launcher/index.wxss +58 -0
- package/dist/less/_variable.less +8 -0
- package/dist/less/button.less +3 -3
- package/dist/less/cell-item.less +1 -1
- package/dist/less/cell.less +1 -1
- package/dist/less/index.less +90 -9
- package/dist/less/launcher.less +79 -0
- package/dist/less/mask.less +21 -4
- package/dist/less/rule.less +8 -8
- package/dist/mask/index.js +38 -3
- package/dist/mask/index.wxss +20 -4
- package/dist/rule/index.wxss +11 -11
- package/dist/ui-behavior.js +1 -0
- package/package.json +3 -3
- package/test/host-behavior.test.js +27 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import Debug from '@we-debug/core';
|
|
2
|
+
|
|
3
|
+
const store = Debug.store;
|
|
4
|
+
const { isFunc } = Debug.util;
|
|
5
|
+
|
|
6
|
+
// 与 less/launcher.less 中 @launcher-size 保持一致
|
|
7
|
+
const SIZE = 44;
|
|
8
|
+
const EDGE_GAP = 12;
|
|
9
|
+
const DEFAULT_BOTTOM = 20;
|
|
10
|
+
const IDLE_DELAY = 3000;
|
|
11
|
+
// 位移超过该值视为拖动,松手后不触发点击
|
|
12
|
+
const TAP_SLOP = 4;
|
|
13
|
+
|
|
14
|
+
const positionCache = Debug.createCache('__wedebug_launcher_position__');
|
|
15
|
+
|
|
16
|
+
const resolve = v => (isFunc(v) ? v() : v);
|
|
17
|
+
|
|
18
|
+
const clamp = (v, min, max) => Math.min(Math.max(v, min), Math.max(min, max));
|
|
19
|
+
|
|
20
|
+
const getWindow = () => {
|
|
21
|
+
try {
|
|
22
|
+
return wx.getWindowInfo ? wx.getWindowInfo() : wx.getSystemInfoSync();
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return store.sys.get();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const getTopRange = win => {
|
|
29
|
+
const { windowHeight, screenHeight, safeArea } = win;
|
|
30
|
+
const bottomInset = safeArea && screenHeight ? Math.max(0, screenHeight - safeArea.bottom) : 0;
|
|
31
|
+
return [EDGE_GAP, windowHeight - SIZE - EDGE_GAP - bottomInset];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Component({
|
|
35
|
+
properties: {
|
|
36
|
+
config: {
|
|
37
|
+
type: Object,
|
|
38
|
+
value: {}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
observers: {
|
|
42
|
+
'config.id'(id) {
|
|
43
|
+
this.removeListeners();
|
|
44
|
+
if (id !== undefined) {
|
|
45
|
+
this.addListeners(id);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
'config.show'(v) {
|
|
49
|
+
this.setData({ show: !!resolve(v) });
|
|
50
|
+
},
|
|
51
|
+
'config.position'() {
|
|
52
|
+
this.layout();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
data: {
|
|
56
|
+
show: false,
|
|
57
|
+
dot: false,
|
|
58
|
+
left: 0,
|
|
59
|
+
top: 0,
|
|
60
|
+
side: 'right',
|
|
61
|
+
idle: false,
|
|
62
|
+
dragging: false,
|
|
63
|
+
ready: false
|
|
64
|
+
},
|
|
65
|
+
methods: {
|
|
66
|
+
getInitialPosition(win) {
|
|
67
|
+
const cached = positionCache.get();
|
|
68
|
+
if (cached && cached.side) {
|
|
69
|
+
return cached;
|
|
70
|
+
}
|
|
71
|
+
const p = this.properties.config.position || {};
|
|
72
|
+
const left = resolve(p.left);
|
|
73
|
+
const top = resolve(p.top);
|
|
74
|
+
const bottom = resolve(p.bottom);
|
|
75
|
+
return {
|
|
76
|
+
side: left !== undefined ? 'left' : 'right',
|
|
77
|
+
top: top !== undefined ? top : win.windowHeight - SIZE - (bottom !== undefined ? bottom : DEFAULT_BOTTOM)
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
layout() {
|
|
81
|
+
const win = getWindow();
|
|
82
|
+
const { side, top } = this.getInitialPosition(win);
|
|
83
|
+
this.snapTo(side, top, win);
|
|
84
|
+
},
|
|
85
|
+
snapTo(side, top, win = getWindow()) {
|
|
86
|
+
const [minTop, maxTop] = getTopRange(win);
|
|
87
|
+
this.setData({
|
|
88
|
+
side,
|
|
89
|
+
top: Math.round(clamp(top, minTop, maxTop)),
|
|
90
|
+
left: side === 'left' ? EDGE_GAP : win.windowWidth - SIZE - EDGE_GAP,
|
|
91
|
+
dragging: false,
|
|
92
|
+
ready: true
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
wake() {
|
|
96
|
+
clearTimeout(this._idleTimer);
|
|
97
|
+
if (this.data.idle) {
|
|
98
|
+
this.setData({ idle: false });
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
scheduleIdle() {
|
|
102
|
+
clearTimeout(this._idleTimer);
|
|
103
|
+
this._idleTimer = setTimeout(() => this.setData({ idle: true }), IDLE_DELAY);
|
|
104
|
+
},
|
|
105
|
+
touchStartHandler(e) {
|
|
106
|
+
this.wake();
|
|
107
|
+
this._moved = false;
|
|
108
|
+
if (this.properties.config.draggable === false) {
|
|
109
|
+
this._touch = null;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const t = e.touches[0];
|
|
113
|
+
this._touch = { x: t.clientX, y: t.clientY, left: this.data.left, top: this.data.top, win: getWindow() };
|
|
114
|
+
},
|
|
115
|
+
touchMoveHandler(e) {
|
|
116
|
+
const start = this._touch;
|
|
117
|
+
if (!start) return;
|
|
118
|
+
const t = e.touches[0];
|
|
119
|
+
const dx = t.clientX - start.x;
|
|
120
|
+
const dy = t.clientY - start.y;
|
|
121
|
+
if (!this._moved && Math.abs(dx) < TAP_SLOP && Math.abs(dy) < TAP_SLOP) return;
|
|
122
|
+
this._moved = true;
|
|
123
|
+
const [minTop, maxTop] = getTopRange(start.win);
|
|
124
|
+
this.setData({
|
|
125
|
+
dragging: true,
|
|
126
|
+
left: clamp(start.left + dx, 0, start.win.windowWidth - SIZE),
|
|
127
|
+
top: clamp(start.top + dy, minTop, maxTop)
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
touchEndHandler() {
|
|
131
|
+
const start = this._touch;
|
|
132
|
+
this._touch = null;
|
|
133
|
+
if (start && this._moved) {
|
|
134
|
+
const side = this.data.left + SIZE / 2 < start.win.windowWidth / 2 ? 'left' : 'right';
|
|
135
|
+
this.snapTo(side, this.data.top, start.win);
|
|
136
|
+
positionCache.set({ side, top: this.data.top });
|
|
137
|
+
}
|
|
138
|
+
this.scheduleIdle();
|
|
139
|
+
},
|
|
140
|
+
tapHandler() {
|
|
141
|
+
if (this._moved) {
|
|
142
|
+
this._moved = false;
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const handler = this.properties.config.handler;
|
|
146
|
+
if (handler && isFunc(handler.bindTap)) {
|
|
147
|
+
handler.bindTap.call(this);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
emit(opt = {}) {
|
|
151
|
+
if (opt.show !== undefined) {
|
|
152
|
+
this.setData({ show: !!resolve(opt.show) });
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
setDot(dot) {
|
|
156
|
+
this.setData({ dot });
|
|
157
|
+
},
|
|
158
|
+
addListeners(id) {
|
|
159
|
+
this._emitKey = `debug:badge-${id}:emit`;
|
|
160
|
+
this._onEmit = this.emit.bind(this);
|
|
161
|
+
store.event.on(this._emitKey, this._onEmit);
|
|
162
|
+
},
|
|
163
|
+
removeListeners() {
|
|
164
|
+
if (this._onEmit) {
|
|
165
|
+
store.event.off(this._emitKey, this._onEmit);
|
|
166
|
+
this._onEmit = null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
lifetimes: {
|
|
171
|
+
attached() {
|
|
172
|
+
this.layout();
|
|
173
|
+
this.scheduleIdle();
|
|
174
|
+
this.setDot(Debug.hasLauncherDot());
|
|
175
|
+
this._onDotUpdate = this.setDot.bind(this);
|
|
176
|
+
store.event.on(Debug.LAUNCHER_DOT_UPDATE, this._onDotUpdate);
|
|
177
|
+
},
|
|
178
|
+
detached() {
|
|
179
|
+
clearTimeout(this._idleTimer);
|
|
180
|
+
this.removeListeners();
|
|
181
|
+
store.event.off(Debug.LAUNCHER_DOT_UPDATE, this._onDotUpdate);
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
pageLifetimes: {
|
|
185
|
+
// 其他页面可能拖动过悬浮球,回到本页时以缓存为准
|
|
186
|
+
show() {
|
|
187
|
+
this.layout();
|
|
188
|
+
},
|
|
189
|
+
resize() {
|
|
190
|
+
this.snapTo(this.data.side, this.data.top);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import "../less/launcher.less";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<view
|
|
2
|
+
wx:if="{{show}}"
|
|
3
|
+
class="w-launcher is-{{side}} {{idle ? 'is-idle' : ''}} {{dragging ? 'is-dragging' : ''}} {{ready ? '' : 'is-hidden'}}"
|
|
4
|
+
style="left: {{left}}px; top: {{top}}px;"
|
|
5
|
+
bindtouchstart="touchStartHandler"
|
|
6
|
+
catchtouchmove="touchMoveHandler"
|
|
7
|
+
bindtouchend="touchEndHandler"
|
|
8
|
+
bindtouchcancel="touchEndHandler"
|
|
9
|
+
bindtap="tapHandler"
|
|
10
|
+
aria-role="button"
|
|
11
|
+
aria-label="打开调试面板"
|
|
12
|
+
>
|
|
13
|
+
<view class="w-launcher__body" hover-class="is-pressed" hover-stay-time="80">
|
|
14
|
+
<view class="w-launcher__icon"></view>
|
|
15
|
+
</view>
|
|
16
|
+
<view wx:if="{{dot}}" class="w-launcher__dot"></view>
|
|
17
|
+
</view>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
.w-launcher {
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: 999990;
|
|
4
|
+
width: 44px;
|
|
5
|
+
height: 44px;
|
|
6
|
+
transition: left 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
|
|
7
|
+
}
|
|
8
|
+
.w-launcher.is-dragging {
|
|
9
|
+
transition: none;
|
|
10
|
+
}
|
|
11
|
+
.w-launcher.is-hidden {
|
|
12
|
+
opacity: 0;
|
|
13
|
+
}
|
|
14
|
+
.w-launcher.is-idle .w-launcher__body {
|
|
15
|
+
opacity: 0.5;
|
|
16
|
+
}
|
|
17
|
+
.w-launcher.is-idle.is-left {
|
|
18
|
+
transform: translateX(-50%);
|
|
19
|
+
}
|
|
20
|
+
.w-launcher.is-idle.is-right {
|
|
21
|
+
transform: translateX(50%);
|
|
22
|
+
}
|
|
23
|
+
.w-launcher__body {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
border-radius: 50%;
|
|
30
|
+
background-color: #4d4fec;
|
|
31
|
+
box-shadow: inset 0 0 0 3px #4d4fec, inset 0 0 0 4px rgba(255, 255, 255, 0.85), 0 4px 12px rgba(77, 79, 236, 0.35);
|
|
32
|
+
transition: transform 0.15s, background-color 0.15s, opacity 0.3s;
|
|
33
|
+
}
|
|
34
|
+
.w-launcher__body.is-pressed {
|
|
35
|
+
transform: scale(0.9);
|
|
36
|
+
background-color: #282be8;
|
|
37
|
+
}
|
|
38
|
+
.w-launcher__icon {
|
|
39
|
+
width: 20px;
|
|
40
|
+
height: 20px;
|
|
41
|
+
background: center / contain no-repeat url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAA2CAYAAABjhwHjAAADuUlEQVR4nN2aW6hNURSGv71s99goxyWXeJGUB50XHSWFcn2RROHBA08UyQMlItLxIpcSioQUiSIpxMmlhFwe5EVEchzHLbfDGZo1trZtzbnWvqy59/LXau81L2Ouf425xhxjzJkREeoQPYCBQBb4CXwCPgKdpQjJUl84CeSU2CigJ5ABngLtwBdgH3AmjrBMHWhuOrASmFVCn05gEXADeFGv5F4BDUCXMvu3A7eAmWGVAbXBKp1qQyogZtAfmAHsB/pQDKM5z9cWSQbXi8fyPS2nAJdiausucBgYCayOKf8cMPfPnUeNNYhIq+PN/xCRixEymlRDLjTn2/skt9PxQGdFZGwJslZFvCSv5AY6HuZYmTLHi8hTi8xnpo0va3nUUt4CLC1T5gPgoKXOWOHGwJMr1ctStw3oqED2dmB3SHk3s376sJZjgPtKshCfQ9em0tEI3A5Zsw/7mpbFxFCXqxp4DrwMKV9cKw8lr7lq4A3wLqQ8qCW5xBGQfjQAff9XciM09ivGif+B3C5L+ZG0k5sATAwp/w60pplcDrhmqTPR+Z20kpsBvAd6W+rn1WOCKMoRMNdDYJij3Tr1O1NBbp1+W5OBQRFtvwLH8zf1Tm4HsDZm27fA0EJHvBRyJjVwtcDDvwBsIFmsiNnupVrNvyKMbIzVf7YlbjJT5bUl5PCFb6rdrcCPf2ojslQdzmyFyK8YEfMYS9/5Mfq2OMZ+LSJdXf3DlgITYzUD62NoNumlZBKwBvigoc0WNTCjNdp2B7pFbHuIyDmpIFdYZc1VdAUhGxHmG4ubI5xGHSNb8H8TMMfRtkUTpSYVngpk9XdUhFnfq3PfWCfSRm6PxTi0AguAKxWMUTP/NQCGqyMahv0VEqPU3dBqk8s5iCXtgSRO7mFIuUlmXiblCCzlxnCcJuUIHHUdHsZIFIGHMWpqUJLGeGpIrtOyS9JUpTFOWKa8OTiTOLkllsDU7J5UiibL7PiigW+yEJHhDq+/qULP3Oxxh+GJjx1dRCRwPESbki9H+CPHS8v5IBfoN3fAotgBwBPbCR0HTgHjLHUXNPhMHhIvpDc4r1oMC+0D1cZMEfkaIWeBD61J0SEbkwy6p+kxG4yWrwNtmpDpVlA+FegX8S6Xq8/qBZkCcnk801M71cZmYCMekQkhl9M8fDWxDDiEZwQhZR90ulUjH/lYs1XeiRlEHdUwgexNYHCJRwc71GIupIbIRJArzC436om4WY4wqVn3xo77cK+IQLmHbMy5Y9Mx/9tddzPrCr8BHpP/X5iF5c0AAAAASUVORK5CYII=');
|
|
42
|
+
}
|
|
43
|
+
.w-launcher__dot {
|
|
44
|
+
position: absolute;
|
|
45
|
+
top: 0;
|
|
46
|
+
width: 12px;
|
|
47
|
+
height: 12px;
|
|
48
|
+
box-sizing: border-box;
|
|
49
|
+
border: 1.5px solid #fff;
|
|
50
|
+
border-radius: 50%;
|
|
51
|
+
background-color: #e05d44;
|
|
52
|
+
}
|
|
53
|
+
.w-launcher.is-right .w-launcher__dot {
|
|
54
|
+
left: 0;
|
|
55
|
+
}
|
|
56
|
+
.w-launcher.is-left .w-launcher__dot {
|
|
57
|
+
right: 0;
|
|
58
|
+
}
|
package/dist/less/_variable.less
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
@gray-8: #323233;
|
|
27
27
|
|
|
28
28
|
@border-color: #d7d7d7;
|
|
29
|
+
@brand-color: rgb(77, 79, 236);
|
|
29
30
|
|
|
30
31
|
// Component Colors
|
|
31
32
|
@text-color: @gray-8;
|
|
@@ -68,6 +69,13 @@
|
|
|
68
69
|
@mask-background: fade(@black, 50);
|
|
69
70
|
@mask-modal-background: @white;
|
|
70
71
|
@mask-modal-title-color: fade(@black, 80);
|
|
72
|
+
@mask-modal-top-gap: 56px;
|
|
73
|
+
@mask-modal-body-height: 60vh;
|
|
74
|
+
@mask-modal-max-width: 669px;
|
|
75
|
+
@mask-modal-short-height: 500px;
|
|
76
|
+
@mask-modal-short-top-gap: 16px;
|
|
77
|
+
@mask-modal-min-bottom-gap: 16px;
|
|
78
|
+
@mask-modal-group-fade-width: 32px;
|
|
71
79
|
|
|
72
80
|
// Z-index list
|
|
73
81
|
@zindex-ui-check: 999900;
|
package/dist/less/button.less
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
@import './_variable.less';
|
|
2
2
|
|
|
3
3
|
.@{prefix}-btn {
|
|
4
|
-
width:
|
|
5
|
-
height:
|
|
4
|
+
width: 50px;
|
|
5
|
+
height: 26px;
|
|
6
6
|
text-align: center;
|
|
7
|
-
line-height:
|
|
7
|
+
line-height: 26px;
|
|
8
8
|
font-weight: @font-weight-bold;
|
|
9
9
|
border-radius: @padding-base;
|
|
10
10
|
color: @white;
|
package/dist/less/cell-item.less
CHANGED
package/dist/less/cell.less
CHANGED
package/dist/less/index.less
CHANGED
|
@@ -16,10 +16,35 @@
|
|
|
16
16
|
align-items: center;
|
|
17
17
|
color: @mask-modal-title-color;
|
|
18
18
|
font-size: @font-size-lg;
|
|
19
|
-
height:
|
|
19
|
+
height: 40px;
|
|
20
20
|
overflow: hidden;
|
|
21
|
+
flex-shrink: 0;
|
|
22
|
+
}
|
|
23
|
+
&__modal-body {
|
|
24
|
+
position: relative;
|
|
25
|
+
flex: 0 1 auto;
|
|
26
|
+
min-height: 0;
|
|
27
|
+
height: @mask-modal-body-height;
|
|
28
|
+
|
|
29
|
+
&--spaced {
|
|
30
|
+
margin-top: 12px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 内容区被 flex 压缩后,子组件的 height: 100% 仍需拿到压缩后的实际高度
|
|
34
|
+
&-inner {
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: 0;
|
|
37
|
+
right: 0;
|
|
38
|
+
bottom: 0;
|
|
39
|
+
left: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
&__panel-host {
|
|
43
|
+
display: block;
|
|
44
|
+
height: 100%;
|
|
21
45
|
}
|
|
22
46
|
&__modal-search {
|
|
47
|
+
flex-shrink: 0;
|
|
23
48
|
position: relative;
|
|
24
49
|
display: flex;
|
|
25
50
|
justify-content: center;
|
|
@@ -58,6 +83,8 @@
|
|
|
58
83
|
}
|
|
59
84
|
}
|
|
60
85
|
&__modal-content {
|
|
86
|
+
height: 100%;
|
|
87
|
+
|
|
61
88
|
&--empty {
|
|
62
89
|
width: 100%;
|
|
63
90
|
height: 100%;
|
|
@@ -69,17 +96,38 @@
|
|
|
69
96
|
}
|
|
70
97
|
}
|
|
71
98
|
&__modal-logo {
|
|
72
|
-
height:
|
|
99
|
+
height: 88px;
|
|
100
|
+
}
|
|
101
|
+
&__modal-group-scroll {
|
|
102
|
+
height: 100%;
|
|
103
|
+
width: 100%;
|
|
104
|
+
white-space: nowrap;
|
|
105
|
+
|
|
106
|
+
&.is-fade-left {
|
|
107
|
+
-webkit-mask-image: linear-gradient(to right, transparent, #000 @mask-modal-group-fade-width);
|
|
108
|
+
mask-image: linear-gradient(to right, transparent, #000 @mask-modal-group-fade-width);
|
|
109
|
+
}
|
|
110
|
+
&.is-fade-right {
|
|
111
|
+
-webkit-mask-image: linear-gradient(to left, transparent, #000 @mask-modal-group-fade-width);
|
|
112
|
+
mask-image: linear-gradient(to left, transparent, #000 @mask-modal-group-fade-width);
|
|
113
|
+
}
|
|
114
|
+
&.is-fade-left.is-fade-right {
|
|
115
|
+
@gradient: linear-gradient(
|
|
116
|
+
to right,
|
|
117
|
+
transparent,
|
|
118
|
+
#000 @mask-modal-group-fade-width,
|
|
119
|
+
#000 calc(~'100% - @{mask-modal-group-fade-width}'),
|
|
120
|
+
transparent
|
|
121
|
+
);
|
|
122
|
+
-webkit-mask-image: @gradient;
|
|
123
|
+
mask-image: @gradient;
|
|
124
|
+
}
|
|
73
125
|
}
|
|
74
126
|
&__modal-group {
|
|
127
|
+
flex-shrink: 0;
|
|
75
128
|
position: relative;
|
|
76
|
-
display:flex;
|
|
77
|
-
justify-content: center;
|
|
78
|
-
flex-direction: row;
|
|
79
|
-
align-items: center;
|
|
80
129
|
height: 38px;
|
|
81
130
|
width: 100%;
|
|
82
|
-
white-space: nowrap;
|
|
83
131
|
|
|
84
132
|
&::before {
|
|
85
133
|
position: absolute;
|
|
@@ -104,9 +152,42 @@
|
|
|
104
152
|
align-self: center;
|
|
105
153
|
|
|
106
154
|
&.actived{
|
|
107
|
-
background-color:
|
|
108
|
-
color:
|
|
155
|
+
background-color: fade(@brand-color, 5%);
|
|
156
|
+
color: @brand-color;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
&.has-dot {
|
|
160
|
+
position: relative;
|
|
161
|
+
|
|
162
|
+
&::after {
|
|
163
|
+
position: absolute;
|
|
164
|
+
top: 2px;
|
|
165
|
+
right: 6px;
|
|
166
|
+
width: 6px;
|
|
167
|
+
height: 6px;
|
|
168
|
+
border-radius: 50%;
|
|
169
|
+
background-color: @red;
|
|
170
|
+
content: '';
|
|
171
|
+
}
|
|
109
172
|
}
|
|
110
173
|
}
|
|
111
174
|
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
@media (max-height: @mask-modal-short-height) {
|
|
178
|
+
.@{prefix}-mask__modal-header {
|
|
179
|
+
height: 32px;
|
|
180
|
+
}
|
|
181
|
+
.@{prefix}-mask__modal-logo {
|
|
182
|
+
height: 70px;
|
|
183
|
+
}
|
|
184
|
+
.@{prefix}-mask__modal-search input {
|
|
185
|
+
margin: 6px 14px;
|
|
186
|
+
}
|
|
187
|
+
.@{prefix}-mask__modal-body {
|
|
188
|
+
height: 100vh;
|
|
189
|
+
}
|
|
190
|
+
.@{prefix}-mask__modal-body--spaced {
|
|
191
|
+
margin-top: 6px;
|
|
192
|
+
}
|
|
112
193
|
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
@import './_variable.less';
|
|
2
|
+
|
|
3
|
+
@launcher-size: 44px;
|
|
4
|
+
@launcher-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
5
|
+
|
|
6
|
+
.@{prefix}-launcher {
|
|
7
|
+
position: fixed;
|
|
8
|
+
z-index: @zindex-badge;
|
|
9
|
+
width: @launcher-size;
|
|
10
|
+
height: @launcher-size;
|
|
11
|
+
transition: left 0.3s @launcher-ease, top 0.3s @launcher-ease, transform 0.3s @launcher-ease, opacity 0.3s;
|
|
12
|
+
|
|
13
|
+
&.is-dragging {
|
|
14
|
+
transition: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&.is-hidden {
|
|
18
|
+
opacity: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 闲置时半透明并向所在边缘缩进一半,减少对页面的遮挡
|
|
22
|
+
// 只淡化球体,红点保持醒目
|
|
23
|
+
&.is-idle &__body {
|
|
24
|
+
opacity: 0.5;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.is-idle {
|
|
28
|
+
&.is-left {
|
|
29
|
+
transform: translateX(-50%);
|
|
30
|
+
}
|
|
31
|
+
&.is-right {
|
|
32
|
+
transform: translateX(50%);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__body {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
width: 100%;
|
|
41
|
+
height: 100%;
|
|
42
|
+
border-radius: 50%;
|
|
43
|
+
background-color: @brand-color;
|
|
44
|
+
// 与面板 logo 一致:主色圆底 + 一圈细白内环
|
|
45
|
+
box-shadow: inset 0 0 0 3px @brand-color, inset 0 0 0 4px fade(@white, 85%), 0 4px 12px fade(@brand-color, 35%);
|
|
46
|
+
transition: transform 0.15s, background-color 0.15s, opacity 0.3s;
|
|
47
|
+
|
|
48
|
+
&.is-pressed {
|
|
49
|
+
transform: scale(0.9);
|
|
50
|
+
background-color: darken(@brand-color, 8%);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&__icon {
|
|
55
|
+
width: 20px;
|
|
56
|
+
height: 20px;
|
|
57
|
+
background: center / contain no-repeat
|
|
58
|
+
url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADcAAAA2CAYAAABjhwHjAAADuUlEQVR4nN2aW6hNURSGv71s99goxyWXeJGUB50XHSWFcn2RROHBA08UyQMlItLxIpcSioQUiSIpxMmlhFwe5EVEchzHLbfDGZo1trZtzbnWvqy59/LXau81L2Ouf425xhxjzJkREeoQPYCBQBb4CXwCPgKdpQjJUl84CeSU2CigJ5ABngLtwBdgH3AmjrBMHWhuOrASmFVCn05gEXADeFGv5F4BDUCXMvu3A7eAmWGVAbXBKp1qQyogZtAfmAHsB/pQDKM5z9cWSQbXi8fyPS2nAJdiausucBgYCayOKf8cMPfPnUeNNYhIq+PN/xCRixEymlRDLjTn2/skt9PxQGdFZGwJslZFvCSv5AY6HuZYmTLHi8hTi8xnpo0va3nUUt4CLC1T5gPgoKXOWOHGwJMr1ctStw3oqED2dmB3SHk3s376sJZjgPtKshCfQ9em0tEI3A5Zsw/7mpbFxFCXqxp4DrwMKV9cKw8lr7lq4A3wLqQ8qCW5xBGQfjQAff9XciM09ivGif+B3C5L+ZG0k5sATAwp/w60pplcDrhmqTPR+Z20kpsBvAd6W+rn1WOCKMoRMNdDYJij3Tr1O1NBbp1+W5OBQRFtvwLH8zf1Tm4HsDZm27fA0EJHvBRyJjVwtcDDvwBsIFmsiNnupVrNvyKMbIzVf7YlbjJT5bUl5PCFb6rdrcCPf2ojslQdzmyFyK8YEfMYS9/5Mfq2OMZ+LSJdXf3DlgITYzUD62NoNumlZBKwBvigoc0WNTCjNdp2B7pFbHuIyDmpIFdYZc1VdAUhGxHmG4ubI5xGHSNb8H8TMMfRtkUTpSYVngpk9XdUhFnfq3PfWCfSRm6PxTi0AguAKxWMUTP/NQCGqyMahv0VEqPU3dBqk8s5iCXtgSRO7mFIuUlmXiblCCzlxnCcJuUIHHUdHsZIFIGHMWpqUJLGeGpIrtOyS9JUpTFOWKa8OTiTOLkllsDU7J5UiibL7PiigW+yEJHhDq+/qULP3Oxxh+GJjx1dRCRwPESbki9H+CPHS8v5IBfoN3fAotgBwBPbCR0HTgHjLHUXNPhMHhIvpDc4r1oMC+0D1cZMEfkaIWeBD61J0SEbkwy6p+kxG4yWrwNtmpDpVlA+FegX8S6Xq8/qBZkCcnk801M71cZmYCMekQkhl9M8fDWxDDiEZwQhZR90ulUjH/lYs1XeiRlEHdUwgexNYHCJRwc71GIupIbIRJArzC436om4WY4wqVn3xo77cK+IQLmHbMy5Y9Mx/9tddzPrCr8BHpP/X5iF5c0AAAAASUVORK5CYII=');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 红点压在朝向屏幕内侧的圆边上,闲置缩进时也不会被裁掉
|
|
62
|
+
&__dot {
|
|
63
|
+
position: absolute;
|
|
64
|
+
top: 0;
|
|
65
|
+
width: 12px;
|
|
66
|
+
height: 12px;
|
|
67
|
+
box-sizing: border-box;
|
|
68
|
+
border: 1.5px solid @white;
|
|
69
|
+
border-radius: 50%;
|
|
70
|
+
background-color: @red;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&.is-right &__dot {
|
|
74
|
+
left: 0;
|
|
75
|
+
}
|
|
76
|
+
&.is-left &__dot {
|
|
77
|
+
right: 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
package/dist/less/mask.less
CHANGED
|
@@ -19,16 +19,33 @@
|
|
|
19
19
|
left: 0;
|
|
20
20
|
right: 0;
|
|
21
21
|
bottom: 0;
|
|
22
|
+
// 宽屏下白底收窄居中;不能用 transform 居中,弹出动画占用了 transform
|
|
23
|
+
max-width: @mask-modal-max-width;
|
|
24
|
+
margin: 0 auto;
|
|
22
25
|
z-index: @zindex-modal;
|
|
23
|
-
padding-bottom:
|
|
24
|
-
padding-bottom:
|
|
26
|
+
padding-bottom: @mask-modal-min-bottom-gap;
|
|
27
|
+
padding-bottom: ~'max(@{mask-modal-min-bottom-gap}, constant(safe-area-inset-bottom))'; /* iOS < 11.2 */
|
|
28
|
+
padding-bottom: ~'max(@{mask-modal-min-bottom-gap}, env(safe-area-inset-bottom))'; /* iOS >= 11.2 */
|
|
29
|
+
box-sizing: border-box;
|
|
30
|
+
max-height: calc(~'100% - @{mask-modal-top-gap}');
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
-webkit-text-size-adjust: 100%;
|
|
35
|
+
text-size-adjust: 100%;
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
&__modal-title {
|
|
28
39
|
color: @mask-modal-title-color;
|
|
29
40
|
font-size: @font-size-lg;
|
|
30
|
-
line-height:
|
|
31
|
-
height:
|
|
41
|
+
line-height: 33px;
|
|
42
|
+
height: 33px;
|
|
32
43
|
text-align: center;
|
|
33
44
|
}
|
|
34
45
|
}
|
|
46
|
+
|
|
47
|
+
@media (max-height: @mask-modal-short-height) {
|
|
48
|
+
.@{prefix}-mask__modal {
|
|
49
|
+
max-height: calc(~'100% - @{mask-modal-short-top-gap}');
|
|
50
|
+
}
|
|
51
|
+
}
|
package/dist/less/rule.less
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
@import "./button.less";
|
|
3
3
|
|
|
4
4
|
.@{prefix}-switch {
|
|
5
|
-
margin:
|
|
5
|
+
margin: 8px -4px 0 0;
|
|
6
6
|
&[disabled]{
|
|
7
7
|
opacity: 0.4;
|
|
8
8
|
}
|
|
@@ -37,21 +37,21 @@
|
|
|
37
37
|
&-major {
|
|
38
38
|
&__meta {
|
|
39
39
|
display: inline-block;
|
|
40
|
-
padding: 0
|
|
41
|
-
margin-left:
|
|
42
|
-
min-width:
|
|
43
|
-
height:
|
|
40
|
+
padding: 0 4px;
|
|
41
|
+
margin-left: 8px;
|
|
42
|
+
min-width: 16px;
|
|
43
|
+
height: 16px;
|
|
44
44
|
text-align: center;
|
|
45
|
-
line-height:
|
|
45
|
+
line-height: 16px;
|
|
46
46
|
color: @white;
|
|
47
47
|
background-color: @red;
|
|
48
|
-
border-radius:
|
|
48
|
+
border-radius: 16px;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
&-minor {
|
|
53
53
|
color: #9d9d9d;
|
|
54
54
|
font-size: @font-size-sm;
|
|
55
|
-
margin-top:
|
|
55
|
+
margin-top: 3px;
|
|
56
56
|
}
|
|
57
57
|
}
|
package/dist/mask/index.js
CHANGED
|
@@ -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
|
});
|