From 7bcfc0507043dc878c801a259aa7d058f4982551 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 09 一月 2025 00:42:21 +0800 Subject: [PATCH] 工单管理优化 --- src/components/Scrollbar/src/util.ts | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/Scrollbar/src/util.ts b/src/components/Scrollbar/src/util.ts index 77694a9..6dfee84 100644 --- a/src/components/Scrollbar/src/util.ts +++ b/src/components/Scrollbar/src/util.ts @@ -1,4 +1,5 @@ import type { BarMap } from './types'; +import type { MergeAll } from '@/utils/types'; export const BAR_MAP: BarMap = { vertical: { @@ -23,7 +24,6 @@ }, }; -// @ts-ignore export function renderThumbStyle({ move, size, bar }) { const style = {} as any; const translate = `translate${bar.axis}(${move}%)`; @@ -36,12 +36,20 @@ return style; } -function extend<T, K>(to: T, _from: K): T & K { +function extend<T extends object, K extends object>(to: T, _from: K): T & K { return Object.assign(to, _from); } -export function toObject<T>(arr: Array<T>): Recordable<T> { - const res = {}; +/** + * [ + * { name: 'zhangsan', age: 18 }, + * { sex: 'male', age: 20 } + * ] + * => + * { name: 'zhangsan', sex: 'male', age: 20 } + */ +export function toObject<T extends object[]>(arr: T): MergeAll<T> { + const res = {} as MergeAll<T>; for (let i = 0; i < arr.length; i++) { if (arr[i]) { extend(res, arr[i]); -- Gitblit v1.9.3