@tplc/wot 1.0.26 → 1.0.27

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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.27](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v1.0.26...v1.0.27) (2026-01-11)
6
+
7
+
8
+ ### ♻️ Code Refactoring | 代码重构
9
+
10
+ * **wd-tabs:** change font size and weight props to accept both numeric and string types ([169a4e5](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/169a4e56bb7d81e675bd9a2cfaded0e2a06272d8))
11
+
5
12
  ### [1.0.26](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.7.63...v1.0.26) (2026-01-11)
6
13
 
7
14
 
@@ -227,6 +227,37 @@ const state = reactive({
227
227
  scrollLeft: 0, // scroll-view偏移量
228
228
  })
229
229
 
230
+ const wait = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))
231
+
232
+ /**
233
+ * 小程序端首次渲染时,createSelectorQuery/boundingClientRect 可能拿到 0 宽度,
234
+ * 导致下划线/滚动定位初始化不准。这里做一次有限重试,确保布局稳定后再计算。
235
+ */
236
+ async function getNavLayoutWithRetry(retry: number = 6) {
237
+ for (let i = 0; i < retry; i++) {
238
+ try {
239
+ const [navItemsRects, navRect] = await Promise.all([
240
+ getRect($item, true, proxy),
241
+ getRect($container, false, proxy),
242
+ ])
243
+ const selectItem = (navItemsRects as any)?.[state.activeIndex]
244
+ if (
245
+ selectItem &&
246
+ Number(selectItem.width) > 0 &&
247
+ navRect &&
248
+ Number((navRect as any).width) > 0
249
+ ) {
250
+ return [navItemsRects, navRect]
251
+ }
252
+ } catch (e) {
253
+ // ignore and retry
254
+ }
255
+ await nextTick()
256
+ await wait(30)
257
+ }
258
+ return await Promise.all([getRect($item, true, proxy), getRect($container, false, proxy)])
259
+ }
260
+
230
261
  // map的开关
231
262
 
232
263
  const { children, linkChildren } = useChildren(TABS_KEY)
@@ -374,26 +405,34 @@ function toggleMap() {
374
405
  function updateLineStyle(animation: boolean = true) {
375
406
  if (!state.inited) return
376
407
  const { lineWidth, lineHeight } = props
377
- getRect($item, true, proxy).then((rects) => {
378
- const lineStyle: CSSProperties = {}
408
+ getNavLayoutWithRetry()
409
+ .then(([rects]) => {
410
+ const lineStyle: CSSProperties = {}
379
411
 
380
- if (isDef(lineWidth)) {
381
- lineStyle.width = addUnit(lineWidth)
382
- }
383
- if (isDef(lineHeight)) {
384
- lineStyle.height = addUnit(lineHeight)
385
- lineStyle.borderRadius = `calc(${addUnit(lineHeight)} / 2)`
386
- }
387
- const rect = rects[state.activeIndex]
388
- const left =
389
- rects.slice(0, state.activeIndex).reduce((prev, curr) => prev + Number(curr.width), 0) +
390
- Number(rect.width) / 2
391
- lineStyle.transform = `translateX(${left}px) translateX(-50%)`
392
- if (animation) {
393
- lineStyle.transition = 'width 300ms ease, transform 300ms ease'
394
- }
395
- state.lineStyle = objToStyle(lineStyle)
396
- })
412
+ if (isDef(lineWidth)) {
413
+ lineStyle.width = addUnit(lineWidth)
414
+ }
415
+ if (isDef(lineHeight)) {
416
+ lineStyle.height = addUnit(lineHeight)
417
+ lineStyle.borderRadius = `calc(${addUnit(lineHeight)} / 2)`
418
+ }
419
+ const rect = (rects as any)?.[state.activeIndex]
420
+ if (!rect || Number(rect.width) <= 0) return
421
+
422
+ const left =
423
+ (rects as any)
424
+ .slice(0, state.activeIndex)
425
+ .reduce((prev: number, curr: any) => prev + Number(curr.width), 0) +
426
+ Number(rect.width) / 2
427
+ lineStyle.transform = `translateX(${left}px) translateX(-50%)`
428
+ if (animation) {
429
+ lineStyle.transition = 'width 300ms ease, transform 300ms ease'
430
+ }
431
+ state.lineStyle = objToStyle(lineStyle)
432
+ })
433
+ .catch(() => {
434
+ // ignore measure failure
435
+ })
397
436
  }
398
437
  /**
399
438
  * @description 通过控制tab的active来展示选定的tab
@@ -413,8 +452,8 @@ function setActiveTab() {
413
452
  */
414
453
  function scrollIntoView() {
415
454
  if (!state.inited) return
416
- Promise.all([getRect($item, true, proxy), getRect($container, false, proxy)]).then(
417
- ([navItemsRects, navRect]) => {
455
+ getNavLayoutWithRetry()
456
+ .then(([navItemsRects, navRect]) => {
418
457
  // 选中元素
419
458
  const selectItem = navItemsRects[state.activeIndex]
420
459
  // 选中元素之前的节点的宽度总和
@@ -428,8 +467,10 @@ function scrollIntoView() {
428
467
  } else {
429
468
  state.scrollLeft = left
430
469
  }
431
- },
432
- )
470
+ })
471
+ .catch(() => {
472
+ // ignore measure failure
473
+ })
433
474
  }
434
475
  /**
435
476
  * @description 单击tab的处理
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "@tplc/wot",
3
3
  "name": "@tplc/wot",
4
- "version": "1.0.26",
4
+ "version": "1.0.27",
5
5
  "keywords": [
6
6
  "wot-design-uni",
7
7
  "国际化",