bge-ui 1.9.1 → 1.9.2
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/dist/index.js +11 -4
- package/package.json +1 -1
- package/src/tabs/index.vue +13 -5
package/dist/index.js
CHANGED
|
@@ -6648,6 +6648,7 @@ const _sfc_main$v = /* @__PURE__ */ defineComponent({
|
|
|
6648
6648
|
};
|
|
6649
6649
|
}
|
|
6650
6650
|
});
|
|
6651
|
+
const maxRetryCount = 3;
|
|
6651
6652
|
const tabsKey$1 = "bge-tabs-context";
|
|
6652
6653
|
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
6653
6654
|
...{
|
|
@@ -6679,6 +6680,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
6679
6680
|
const barStyle = ref();
|
|
6680
6681
|
const navOffset = ref(0);
|
|
6681
6682
|
const scrollable = ref(false);
|
|
6683
|
+
const updateRetryCount = ref(0);
|
|
6682
6684
|
const tabsRef = ref(null);
|
|
6683
6685
|
const navScrollRef = ref(null);
|
|
6684
6686
|
function addPane(pane) {
|
|
@@ -6727,9 +6729,12 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
6727
6729
|
if (!$el)
|
|
6728
6730
|
return false;
|
|
6729
6731
|
if ($el.clientWidth === 0 && index2 === 0) {
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6732
|
+
if (updateRetryCount.value < maxRetryCount) {
|
|
6733
|
+
updateRetryCount.value++;
|
|
6734
|
+
nextTick(() => {
|
|
6735
|
+
update();
|
|
6736
|
+
});
|
|
6737
|
+
}
|
|
6733
6738
|
return false;
|
|
6734
6739
|
}
|
|
6735
6740
|
if (tab.value !== props.modelValue) {
|
|
@@ -6739,6 +6744,7 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
6739
6744
|
tab.setActive(true);
|
|
6740
6745
|
offset2 = $el["offsetLeft"];
|
|
6741
6746
|
tabSize = $el["clientWidth"];
|
|
6747
|
+
updateRetryCount.value = 0;
|
|
6742
6748
|
return false;
|
|
6743
6749
|
});
|
|
6744
6750
|
} else {
|
|
@@ -6869,8 +6875,9 @@ const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
|
6869
6875
|
barStyle.value = getBarStyle();
|
|
6870
6876
|
getNavOffset();
|
|
6871
6877
|
};
|
|
6878
|
+
const debouncedUpdate = useDebounceFn(update, 100);
|
|
6872
6879
|
if (isBrowser) {
|
|
6873
|
-
useResizeObserver(tabsRef,
|
|
6880
|
+
useResizeObserver(tabsRef, debouncedUpdate);
|
|
6874
6881
|
}
|
|
6875
6882
|
onMounted(() => {
|
|
6876
6883
|
update();
|
package/package.json
CHANGED
package/src/tabs/index.vue
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
</div>
|
|
12
12
|
</template>
|
|
13
13
|
<script setup lang="ts">
|
|
14
|
-
import { useResizeObserver } from "@vueuse/core"
|
|
14
|
+
import { useResizeObserver, useDebounceFn } from "@vueuse/core"
|
|
15
15
|
import { provide, ref, onMounted, watch, computed, nextTick } from "vue"
|
|
16
16
|
|
|
17
17
|
// 检测是否在浏览器环境中
|
|
@@ -52,6 +52,8 @@ const panes = ref<TabPane[]>([])
|
|
|
52
52
|
const barStyle = ref<{ width: string; transform: string } | undefined>()
|
|
53
53
|
const navOffset = ref(0)
|
|
54
54
|
const scrollable = ref(false)
|
|
55
|
+
const updateRetryCount = ref(0)
|
|
56
|
+
const maxRetryCount = 3
|
|
55
57
|
|
|
56
58
|
// 引用
|
|
57
59
|
const tabsRef = ref<HTMLElement | null>(null)
|
|
@@ -114,9 +116,12 @@ const getBarStyle = (): { width: string; transform: string } => {
|
|
|
114
116
|
const $el = tab.ref
|
|
115
117
|
if (!$el) return false
|
|
116
118
|
if ($el.clientWidth === 0 && index === 0) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
if (updateRetryCount.value < maxRetryCount) {
|
|
120
|
+
updateRetryCount.value++
|
|
121
|
+
nextTick(() => {
|
|
122
|
+
update()
|
|
123
|
+
})
|
|
124
|
+
}
|
|
120
125
|
return false
|
|
121
126
|
}
|
|
122
127
|
if (tab.value !== props.modelValue) {
|
|
@@ -127,6 +132,7 @@ const getBarStyle = (): { width: string; transform: string } => {
|
|
|
127
132
|
tab.setActive(true)
|
|
128
133
|
offset = $el['offsetLeft']
|
|
129
134
|
tabSize = $el['clientWidth']
|
|
135
|
+
updateRetryCount.value = 0
|
|
130
136
|
return false
|
|
131
137
|
})
|
|
132
138
|
} else {
|
|
@@ -260,9 +266,11 @@ const update = () => {
|
|
|
260
266
|
getNavOffset()
|
|
261
267
|
}
|
|
262
268
|
|
|
269
|
+
const debouncedUpdate = useDebounceFn(update, 100)
|
|
270
|
+
|
|
263
271
|
// 仅在浏览器环境中使用 ResizeObserver
|
|
264
272
|
if (isBrowser) {
|
|
265
|
-
useResizeObserver(tabsRef,
|
|
273
|
+
useResizeObserver(tabsRef, debouncedUpdate)
|
|
266
274
|
}
|
|
267
275
|
|
|
268
276
|
onMounted(() => {
|