uni-oaview 1.9.2 → 1.9.4
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.
|
@@ -5,9 +5,13 @@
|
|
|
5
5
|
<p class="subtitle">{{ state.subtitle }}</p>
|
|
6
6
|
<view class="divider" />
|
|
7
7
|
<view class="submit-buttons">
|
|
8
|
-
<view class="cancel-button" @click="submitClick('cancel')">
|
|
8
|
+
<view class="cancel-button" :style="{ color: state.cancelTextColor }" @click="submitClick('cancel')">
|
|
9
|
+
{{ state.cancelText }}
|
|
10
|
+
</view>
|
|
9
11
|
<view class="divider-vertical" />
|
|
10
|
-
<view class="confirm-button" @click="submitClick('confirm')">
|
|
12
|
+
<view class="confirm-button" :style="{ color: state.confirmTextColor }" @click="submitClick('confirm')">
|
|
13
|
+
{{ state.confirmText }}
|
|
14
|
+
</view>
|
|
11
15
|
</view>
|
|
12
16
|
</view>
|
|
13
17
|
</uni-popup>
|
|
@@ -27,6 +31,8 @@
|
|
|
27
31
|
subtitle: '',
|
|
28
32
|
confirmText: '确定',
|
|
29
33
|
cancelText: '取消',
|
|
34
|
+
confirmTextColor: '#3d73ff',
|
|
35
|
+
cancelTextColor: '#1c202b',
|
|
30
36
|
});
|
|
31
37
|
|
|
32
38
|
let innerCallback: any = null;
|
|
@@ -48,12 +54,14 @@
|
|
|
48
54
|
if (!isPageAlive.value) return;
|
|
49
55
|
isShow.value = true;
|
|
50
56
|
setTimeout(() => {
|
|
51
|
-
const { title, subtitle, confirmText, cancelText, callback } = params;
|
|
57
|
+
const { title, subtitle, confirmText, cancelText, confirmTextColor, cancelTextColor, callback } = params;
|
|
52
58
|
innerCallback = callback;
|
|
53
59
|
state.title = title || '';
|
|
54
60
|
state.subtitle = subtitle || '';
|
|
55
61
|
state.confirmText = confirmText || '确定';
|
|
56
62
|
state.cancelText = cancelText || '取消';
|
|
63
|
+
state.confirmTextColor = confirmTextColor || '#3d73ff';
|
|
64
|
+
state.cancelTextColor = cancelTextColor || '#1c202b';
|
|
57
65
|
popupRef.value?.open('center');
|
|
58
66
|
});
|
|
59
67
|
});
|
|
@@ -42,10 +42,17 @@
|
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
const formatStartTime = (timestamp: number): string => {
|
|
46
|
+
const date = new Date(timestamp);
|
|
47
|
+
return `${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(
|
|
48
|
+
date.getSeconds(),
|
|
49
|
+
).padStart(2, '0')}`;
|
|
50
|
+
};
|
|
51
|
+
|
|
45
52
|
const getTitle = (log: NativeEventLog): string => {
|
|
46
53
|
const { startTime, endTime, key } = log;
|
|
47
54
|
if (startTime && endTime) {
|
|
48
|
-
return `${key};${(endTime - startTime) / 1000}s`;
|
|
55
|
+
return `${formatStartTime(startTime)} ${key};${(endTime - startTime) / 1000}s`;
|
|
49
56
|
}
|
|
50
57
|
return key;
|
|
51
58
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -192,6 +192,27 @@ declare function createModal<E extends ModalBaseEvents = ModalBaseEvents>(compon
|
|
|
192
192
|
*/
|
|
193
193
|
declare function closeAllModals(): void;
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* 新版确认弹窗的按钮配置。
|
|
197
|
+
*/
|
|
198
|
+
interface MessageBoxConfirmOptions {
|
|
199
|
+
/**
|
|
200
|
+
* 确认按钮的展示文案。
|
|
201
|
+
*/
|
|
202
|
+
confirmText?: string;
|
|
203
|
+
/**
|
|
204
|
+
* 取消按钮的展示文案。
|
|
205
|
+
*/
|
|
206
|
+
cancelText?: string;
|
|
207
|
+
/**
|
|
208
|
+
* 确认按钮文案颜色,未传时使用组件默认颜色。
|
|
209
|
+
*/
|
|
210
|
+
confirmTextColor?: string;
|
|
211
|
+
/**
|
|
212
|
+
* 取消按钮文案颜色,未传时使用组件默认颜色。
|
|
213
|
+
*/
|
|
214
|
+
cancelTextColor?: string;
|
|
215
|
+
}
|
|
195
216
|
/**
|
|
196
217
|
* 新版确认弹窗(按Figma设计)
|
|
197
218
|
*
|
|
@@ -205,6 +226,12 @@ declare function closeAllModals(): void;
|
|
|
205
226
|
* import { MessageBox } from '@/uni-oaview/src/utils/message-box'
|
|
206
227
|
*
|
|
207
228
|
* MessageBox.confirm('删除音频', '删除后将不可恢复', '删除', '取消')
|
|
229
|
+
* MessageBox.confirm('删除音频', '删除后将不可恢复', {
|
|
230
|
+
* confirmText: '删除',
|
|
231
|
+
* confirmTextColor: '#ff4d4f',
|
|
232
|
+
* cancelText: '再想想',
|
|
233
|
+
* cancelTextColor: '#86909c',
|
|
234
|
+
* })
|
|
208
235
|
* .then(() => {
|
|
209
236
|
* console.log('用户点击了确定')
|
|
210
237
|
* })
|
|
@@ -218,11 +245,11 @@ declare const MessageBox: {
|
|
|
218
245
|
* 新版确认弹窗
|
|
219
246
|
* @param title 标题
|
|
220
247
|
* @param subtitle 副标题
|
|
221
|
-
* @param
|
|
248
|
+
* @param confirmTextOrOptions 确定按钮文本,或按钮配置
|
|
222
249
|
* @param cancelText 取消按钮文本,默认'取消'
|
|
223
250
|
* @returns Promise<string> 确定时resolve,取消时reject
|
|
224
251
|
*/
|
|
225
|
-
confirm(title: string, subtitle: string,
|
|
252
|
+
confirm(title: string, subtitle: string, confirmTextOrOptions?: string | MessageBoxConfirmOptions, cancelText?: string): Promise<unknown>;
|
|
226
253
|
};
|
|
227
254
|
|
|
228
255
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -823,6 +823,14 @@ function closeAllModals() {
|
|
|
823
823
|
});
|
|
824
824
|
}
|
|
825
825
|
|
|
826
|
+
/**
|
|
827
|
+
* 判断传入值是否为新版确认弹窗配置对象。
|
|
828
|
+
*
|
|
829
|
+
* 这里仅接受普通对象,避免把异常 truthy 值误判为配置对象。
|
|
830
|
+
*/
|
|
831
|
+
var isConfirmOptions = function isConfirmOptions(value) {
|
|
832
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
833
|
+
};
|
|
826
834
|
/**
|
|
827
835
|
* 新版确认弹窗(按Figma设计)
|
|
828
836
|
*
|
|
@@ -836,6 +844,12 @@ function closeAllModals() {
|
|
|
836
844
|
* import { MessageBox } from '@/uni-oaview/src/utils/message-box'
|
|
837
845
|
*
|
|
838
846
|
* MessageBox.confirm('删除音频', '删除后将不可恢复', '删除', '取消')
|
|
847
|
+
* MessageBox.confirm('删除音频', '删除后将不可恢复', {
|
|
848
|
+
* confirmText: '删除',
|
|
849
|
+
* confirmTextColor: '#ff4d4f',
|
|
850
|
+
* cancelText: '再想想',
|
|
851
|
+
* cancelTextColor: '#86909c',
|
|
852
|
+
* })
|
|
839
853
|
* .then(() => {
|
|
840
854
|
* console.log('用户点击了确定')
|
|
841
855
|
* })
|
|
@@ -849,12 +863,22 @@ var MessageBox = {
|
|
|
849
863
|
* 新版确认弹窗
|
|
850
864
|
* @param title 标题
|
|
851
865
|
* @param subtitle 副标题
|
|
852
|
-
* @param
|
|
866
|
+
* @param confirmTextOrOptions 确定按钮文本,或按钮配置
|
|
853
867
|
* @param cancelText 取消按钮文本,默认'取消'
|
|
854
868
|
* @returns Promise<string> 确定时resolve,取消时reject
|
|
855
869
|
*/
|
|
856
|
-
confirm: function confirm(title, subtitle,
|
|
870
|
+
confirm: function confirm(title, subtitle, confirmTextOrOptions, cancelText) {
|
|
857
871
|
return new Promise(function (res, rej) {
|
|
872
|
+
/**
|
|
873
|
+
* 统一兼容旧版字符串参数和新版对象参数,减少调用方迁移成本。
|
|
874
|
+
*/
|
|
875
|
+
var options = typeof confirmTextOrOptions === 'string' ? {
|
|
876
|
+
confirmText: confirmTextOrOptions,
|
|
877
|
+
cancelText: cancelText
|
|
878
|
+
} : isConfirmOptions(confirmTextOrOptions) ? confirmTextOrOptions : {};
|
|
879
|
+
/**
|
|
880
|
+
* 弹框关闭后通过回调通知调用方点击结果。
|
|
881
|
+
*/
|
|
858
882
|
var callback = function callback(type) {
|
|
859
883
|
if (type === 'confirm') {
|
|
860
884
|
res('');
|
|
@@ -865,8 +889,10 @@ var MessageBox = {
|
|
|
865
889
|
uni.$emit(OPEN_CONFIRM_BOX_NEW, {
|
|
866
890
|
title: title,
|
|
867
891
|
subtitle: subtitle,
|
|
868
|
-
confirmText: confirmText,
|
|
869
|
-
cancelText: cancelText,
|
|
892
|
+
confirmText: options.confirmText,
|
|
893
|
+
cancelText: options.cancelText,
|
|
894
|
+
confirmTextColor: options.confirmTextColor,
|
|
895
|
+
cancelTextColor: options.cancelTextColor,
|
|
870
896
|
callback: callback
|
|
871
897
|
});
|
|
872
898
|
});
|
package/package.json
CHANGED
package/src/utils/message-box.ts
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import { OPEN_CONFIRM_BOX_NEW } from '../../constants';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* 新版确认弹窗的按钮配置。
|
|
5
|
+
*/
|
|
6
|
+
interface MessageBoxConfirmOptions {
|
|
7
|
+
/**
|
|
8
|
+
* 确认按钮的展示文案。
|
|
9
|
+
*/
|
|
10
|
+
confirmText?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 取消按钮的展示文案。
|
|
14
|
+
*/
|
|
15
|
+
cancelText?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 确认按钮文案颜色,未传时使用组件默认颜色。
|
|
19
|
+
*/
|
|
20
|
+
confirmTextColor?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 取消按钮文案颜色,未传时使用组件默认颜色。
|
|
24
|
+
*/
|
|
25
|
+
cancelTextColor?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 判断传入值是否为新版确认弹窗配置对象。
|
|
30
|
+
*
|
|
31
|
+
* 这里仅接受普通对象,避免把异常 truthy 值误判为配置对象。
|
|
32
|
+
*/
|
|
33
|
+
const isConfirmOptions = (value: unknown): value is MessageBoxConfirmOptions => {
|
|
34
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
35
|
+
};
|
|
36
|
+
|
|
3
37
|
/**
|
|
4
38
|
* 新版确认弹窗(按Figma设计)
|
|
5
39
|
*
|
|
@@ -13,6 +47,12 @@ import { OPEN_CONFIRM_BOX_NEW } from '../../constants';
|
|
|
13
47
|
* import { MessageBox } from '@/uni-oaview/src/utils/message-box'
|
|
14
48
|
*
|
|
15
49
|
* MessageBox.confirm('删除音频', '删除后将不可恢复', '删除', '取消')
|
|
50
|
+
* MessageBox.confirm('删除音频', '删除后将不可恢复', {
|
|
51
|
+
* confirmText: '删除',
|
|
52
|
+
* confirmTextColor: '#ff4d4f',
|
|
53
|
+
* cancelText: '再想想',
|
|
54
|
+
* cancelTextColor: '#86909c',
|
|
55
|
+
* })
|
|
16
56
|
* .then(() => {
|
|
17
57
|
* console.log('用户点击了确定')
|
|
18
58
|
* })
|
|
@@ -26,12 +66,33 @@ export const MessageBox = {
|
|
|
26
66
|
* 新版确认弹窗
|
|
27
67
|
* @param title 标题
|
|
28
68
|
* @param subtitle 副标题
|
|
29
|
-
* @param
|
|
69
|
+
* @param confirmTextOrOptions 确定按钮文本,或按钮配置
|
|
30
70
|
* @param cancelText 取消按钮文本,默认'取消'
|
|
31
71
|
* @returns Promise<string> 确定时resolve,取消时reject
|
|
32
72
|
*/
|
|
33
|
-
confirm(
|
|
73
|
+
confirm(
|
|
74
|
+
title: string,
|
|
75
|
+
subtitle: string,
|
|
76
|
+
confirmTextOrOptions?: string | MessageBoxConfirmOptions,
|
|
77
|
+
cancelText?: string,
|
|
78
|
+
) {
|
|
34
79
|
return new Promise((res, rej) => {
|
|
80
|
+
/**
|
|
81
|
+
* 统一兼容旧版字符串参数和新版对象参数,减少调用方迁移成本。
|
|
82
|
+
*/
|
|
83
|
+
const options: MessageBoxConfirmOptions =
|
|
84
|
+
typeof confirmTextOrOptions === 'string'
|
|
85
|
+
? {
|
|
86
|
+
confirmText: confirmTextOrOptions,
|
|
87
|
+
cancelText,
|
|
88
|
+
}
|
|
89
|
+
: isConfirmOptions(confirmTextOrOptions)
|
|
90
|
+
? confirmTextOrOptions
|
|
91
|
+
: {};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 弹框关闭后通过回调通知调用方点击结果。
|
|
95
|
+
*/
|
|
35
96
|
const callback = (type: 'confirm' | 'cancel') => {
|
|
36
97
|
if (type === 'confirm') {
|
|
37
98
|
res('');
|
|
@@ -42,8 +103,10 @@ export const MessageBox = {
|
|
|
42
103
|
uni.$emit(OPEN_CONFIRM_BOX_NEW, {
|
|
43
104
|
title,
|
|
44
105
|
subtitle,
|
|
45
|
-
confirmText,
|
|
46
|
-
cancelText,
|
|
106
|
+
confirmText: options.confirmText,
|
|
107
|
+
cancelText: options.cancelText,
|
|
108
|
+
confirmTextColor: options.confirmTextColor,
|
|
109
|
+
cancelTextColor: options.cancelTextColor,
|
|
47
110
|
callback,
|
|
48
111
|
});
|
|
49
112
|
});
|