uni-oaview 1.1.2 → 1.1.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.
@@ -15,8 +15,18 @@
15
15
  <script lang="ts" setup>
16
16
  import { reactive, ref } from 'vue';
17
17
  import { OPEN_CONFIRM_BOX } from '../../constants';
18
+ import { onHide, onShow } from '@dcloudio/uni-app';
19
+
18
20
  const popupRef = ref();
21
+ const isPageAlive = ref(false);
22
+
19
23
  const isShow = ref(false);
24
+ onShow(() => {
25
+ isPageAlive.value = true;
26
+ });
27
+ onHide(() => {
28
+ isPageAlive.value = false;
29
+ });
20
30
  const state = reactive({
21
31
  title: '温馨提示',
22
32
  content: '请输入提醒内容',
@@ -30,6 +40,8 @@
30
40
  popupRef.value.close();
31
41
  };
32
42
  uni.$on(OPEN_CONFIRM_BOX, (params: any) => {
43
+ /** 如果页面非alive状态,则不执行操作 */
44
+ if (!isPageAlive.value) return;
33
45
  isShow.value = true;
34
46
  setTimeout(() => {
35
47
  const { title, content, confirmText, cancelText, callback } = params;
@@ -4,13 +4,13 @@
4
4
  <image :src="state.imagePath" style="width: 32px; height: 32px" />
5
5
  <span class="title">{{ state.title }}</span>
6
6
  <div class="content">{{ state.content }}</div>
7
- <div class="confirm-button" @click="() => popupRef.close()">{{ state.confirmText }}</div>
7
+ <div class="confirm-button" @click="submitClick">{{ state.confirmText }}</div>
8
8
  </view>
9
9
  </uni-popup>
10
10
  </template>
11
11
 
12
12
  <script lang="ts" setup>
13
- import { Prop, PropType, reactive, ref, nextTick } from 'vue';
13
+ import { reactive, ref } from 'vue';
14
14
  import successPath from '../../imgs/toast/success.svg';
15
15
  import warningPath from '../../imgs/toast/warning.svg';
16
16
  import { OPEN_TOAST } from '../../constants';
@@ -26,6 +26,12 @@
26
26
  imagePath: successPath,
27
27
  });
28
28
 
29
+ /** 接收外部的回调函数,用于给外部发事件 */
30
+ let innerCallback: any = null;
31
+ const submitClick = () => {
32
+ innerCallback?.();
33
+ popupRef.value.close();
34
+ };
29
35
  const open = () => {
30
36
  popupRef.value?.open('center');
31
37
  };
@@ -40,7 +46,8 @@
40
46
  if (!isPageAlive.value) return;
41
47
  isShow.value = true;
42
48
  setTimeout(() => {
43
- const { title, content, confirmText, type } = params;
49
+ const { title, content, confirmText, type, callback } = params;
50
+ innerCallback = callback;
44
51
  state.imagePath = type === 'success' ? successPath : warningPath;
45
52
  state.title = title || '请输入标题';
46
53
  state.content = content || '请输入内容';
@@ -71,6 +78,7 @@
71
78
  font-size: 16px;
72
79
  }
73
80
  & > .content {
81
+ box-sizing: border-box;
74
82
  text-align: center;
75
83
  padding: 12px 16px 16px;
76
84
  color: rgba(97, 105, 111, 1);
package/dist/index.d.ts CHANGED
@@ -25,14 +25,14 @@ declare const Message: {
25
25
  * @param content 内容
26
26
  * @param confirmText 确认按钮文本
27
27
  */
28
- success(title: string, content: string, confirmText?: string): void;
28
+ success(title: string, content: string, confirmText?: string): Promise<unknown>;
29
29
  /**
30
30
  * 警告弹框提醒
31
31
  * @param title 警告标题
32
32
  * @param content 警告内容
33
33
  * @param confirmText 警告按钮文本
34
34
  */
35
- warning(title: string, content: string, confirmText?: string): void;
35
+ warning(title: string, content: string, confirmText?: string): Promise<unknown>;
36
36
  /**
37
37
  * 确认弹窗
38
38
  * @param content 确认内容
package/dist/index.esm.js CHANGED
@@ -70,11 +70,14 @@ var Message = {
70
70
  * @param confirmText 确认按钮文本
71
71
  */
72
72
  success: function success(title, content, confirmText) {
73
- uni.$emit(OPEN_TOAST, {
74
- type: 'success',
75
- title: title,
76
- content: content,
77
- confirmText: confirmText
73
+ return new Promise(function (res) {
74
+ uni.$emit(OPEN_TOAST, {
75
+ type: 'success',
76
+ title: title,
77
+ content: content,
78
+ confirmText: confirmText,
79
+ callback: res
80
+ });
78
81
  });
79
82
  },
80
83
  /**
@@ -84,11 +87,14 @@ var Message = {
84
87
  * @param confirmText 警告按钮文本
85
88
  */
86
89
  warning: function warning(title, content, confirmText) {
87
- uni.$emit(OPEN_TOAST, {
88
- type: 'warning',
89
- title: title,
90
- content: content,
91
- confirmText: confirmText
90
+ return new Promise(function (res) {
91
+ uni.$emit(OPEN_TOAST, {
92
+ type: 'warning',
93
+ title: title,
94
+ content: content,
95
+ confirmText: confirmText,
96
+ callback: res
97
+ });
92
98
  });
93
99
  },
94
100
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uni-oaview",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "uniapp小程序组件库",
5
5
  "main": "dist/index.esm.js",
6
6
  "typings": "dist/index.d.ts",
@@ -29,11 +29,14 @@ export const Message = {
29
29
  * @param confirmText 确认按钮文本
30
30
  */
31
31
  success(title: string, content: string, confirmText?: string) {
32
- uni.$emit(OPEN_TOAST, {
33
- type: 'success',
34
- title,
35
- content,
36
- confirmText,
32
+ return new Promise((res) => {
33
+ uni.$emit(OPEN_TOAST, {
34
+ type: 'success',
35
+ title,
36
+ content,
37
+ confirmText,
38
+ callback: res,
39
+ });
37
40
  });
38
41
  },
39
42
  /**
@@ -43,11 +46,14 @@ export const Message = {
43
46
  * @param confirmText 警告按钮文本
44
47
  */
45
48
  warning(title: string, content: string, confirmText?: string) {
46
- uni.$emit(OPEN_TOAST, {
47
- type: 'warning',
48
- title,
49
- content,
50
- confirmText,
49
+ return new Promise((res) => {
50
+ uni.$emit(OPEN_TOAST, {
51
+ type: 'warning',
52
+ title,
53
+ content,
54
+ confirmText,
55
+ callback: res,
56
+ });
51
57
  });
52
58
  },
53
59
  /**