hy-app 0.2.9 → 0.2.10

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/common/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './versionControl'
2
2
  export * from './shakeService'
3
+ export * from './queue'
@@ -0,0 +1,34 @@
1
+ /*
2
+ * @Author: weisheng
3
+ * @Date: 2023-07-02 22:51:06
4
+ * @LastEditTime: 2024-03-16 19:59:07
5
+ * @LastEditors: weisheng
6
+ * @Description:
7
+ * @FilePath: /wot-design-uni/src/uni_modules/wot-design-uni/components/common/clickoutside.ts
8
+ * 记得注释
9
+ */
10
+ let queue: any[] = []
11
+
12
+ export function pushToQueue(comp: any) {
13
+ queue.push(comp)
14
+ }
15
+
16
+ export function removeFromQueue(comp: any) {
17
+ queue = queue.filter((item) => {
18
+ return item.$.uid !== comp.$.uid
19
+ })
20
+ }
21
+
22
+ export function closeOther(comp: any) {
23
+ queue.forEach((item) => {
24
+ if (item.$.uid !== comp.$.uid) {
25
+ item.$.exposed.close()
26
+ }
27
+ })
28
+ }
29
+
30
+ export function closeOutside() {
31
+ queue.forEach((item) => {
32
+ item.$.exposed.close()
33
+ })
34
+ }
@@ -111,6 +111,7 @@ import defaultProps from './props'
111
111
  import IProps, { type PopoverExpose } from './typing'
112
112
  import { isArray } from '../../utils'
113
113
  import { type Queue, queueKey, usePopover } from '../../composables'
114
+ import { closeOther, pushToQueue, removeFromQueue } from '../../common'
114
115
 
115
116
  // 组件
116
117
  import HyIcon from '../hy-icon/hy-icon.vue'
@@ -157,8 +158,11 @@ watch(
157
158
  (newValue) => {
158
159
  if (newValue) {
159
160
  popover.control(placement.value, props.offset)
161
+ // provide/inject在微信小程序不能使用,所以执行两个保存方法
160
162
  if (queue && queue.closeOther) {
161
163
  queue.closeOther(proxy)
164
+ } else {
165
+ closeOther(proxy)
162
166
  }
163
167
  }
164
168
  popover.showStyle.value = newValue ? 'display: inline-block;' : 'display: none;'
@@ -174,6 +178,8 @@ onMounted(() => {
174
178
  onBeforeMount(() => {
175
179
  if (queue && queue.pushToQueue) {
176
180
  queue.pushToQueue(proxy)
181
+ } else {
182
+ pushToQueue(proxy)
177
183
  }
178
184
  popover.showStyle.value = showPopover.value ? 'opacity: 1;' : 'opacity: 0;'
179
185
  })
@@ -181,6 +187,8 @@ onBeforeMount(() => {
181
187
  onBeforeUnmount(() => {
182
188
  if (queue && queue.removeFromQueue) {
183
189
  queue.removeFromQueue(proxy)
190
+ } else {
191
+ removeFromQueue(proxy)
184
192
  }
185
193
  })
186
194
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hy-app",
3
- "version": "0.2.9",
4
- "description": "fix: 气泡组件在小程序列表不默认关闭",
3
+ "version": "0.2.10",
4
+ "description": "fix: 微信小程序气泡组件在小程序列表不默认关闭",
5
5
  "main": "./index.ts",
6
6
  "private": false,
7
7
  "scripts": {},