@tplc/wot 1.0.26 → 1.0.28
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 +14 -0
- package/components/wd-img/wd-img.vue +1 -1
- package/components/wd-tabs/wd-tabs.vue +64 -23
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
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.28](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.7.67...v1.0.28) (2026-01-13)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ♻️ Code Refactoring | 代码重构
|
|
9
|
+
|
|
10
|
+
* **types:** standardize type definitions and improve consistency across components ([227a8d9](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/227a8d9ee1c458f87916d28949513d68d808768c))
|
|
11
|
+
|
|
12
|
+
### [1.0.27](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v1.0.26...v1.0.27) (2026-01-11)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### ♻️ Code Refactoring | 代码重构
|
|
16
|
+
|
|
17
|
+
* **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))
|
|
18
|
+
|
|
5
19
|
### [1.0.26](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.7.63...v1.0.26) (2026-01-11)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -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
|
-
|
|
378
|
-
|
|
408
|
+
getNavLayoutWithRetry()
|
|
409
|
+
.then(([rects]) => {
|
|
410
|
+
const lineStyle: CSSProperties = {}
|
|
379
411
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
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
|
-
|
|
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的处理
|