Skip to content

Commit

Permalink
perf: use getPickerCols (#3283)
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 authored Aug 28, 2024
1 parent 5bb3deb commit d73444e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/_common
Submodule _common updated 47 files
+41 −0 docs/mobile/api/action-sheet.en-US.md
+8 −0 docs/mobile/api/action-sheet.md
+19 −0 docs/mobile/api/badge.en-US.md
+5 −5 docs/mobile/api/badge.md
+66 −0 docs/mobile/api/button.en-US.md
+34 −5 docs/mobile/api/button.md
+36 −0 docs/mobile/api/collapse.en-US.md
+18 −3 docs/mobile/api/collapse.md
+21 −0 docs/mobile/api/count-down.en-US.md
+8 −3 docs/mobile/api/count-down.md
+35 −0 docs/mobile/api/grid.en-US.md
+18 −2 docs/mobile/api/grid.md
+29 −0 docs/mobile/api/image.en-US.md
+11 −17 docs/mobile/api/image.md
+64 −0 docs/mobile/api/input.en-US.md
+40 −12 docs/mobile/api/input.md
+17 −0 docs/mobile/api/link.en-US.md
+15 −0 docs/mobile/api/link.md
+45 −0 docs/mobile/api/loading.en-US.md
+14 −12 docs/mobile/api/loading.md
+31 −0 docs/mobile/api/search.en-US.md
+19 −5 docs/mobile/api/search.md
+25 −0 docs/mobile/api/side-bar.en-US.md
+25 −0 docs/mobile/api/side-bar.md
+41 −0 docs/mobile/api/tab-bar.en-US.md
+22 −10 docs/mobile/api/tab-bar.md
+21 −0 docs/mobile/api/table.en-US.md
+21 −0 docs/mobile/api/table.md
+25 −0 docs/mobile/api/toast.en-US.md
+7 −17 docs/mobile/api/toast.md
+4 −0 docs/web/api/empty.en-US.md
+4 −0 docs/web/api/empty.md
+1 −1 js/time-picker/const.ts
+37 −0 js/time-picker/utils.ts
+10 −10 style/mobile/components/_index.less
+11 −11 style/mobile/components/badge/v2/_index.less
+40 −2 style/mobile/components/button/v2/_index.less
+8 −0 style/mobile/components/button/v2/_var.less
+44 −0 style/mobile/components/image/v2/_index.less
+10 −5 style/mobile/components/link/_index.less
+61 −15 style/mobile/components/link/_var.less
+8 −0 style/mobile/components/loading/_index.less
+1 −1 style/mobile/components/overlay/v2/_index.less
+14 −0 style/mobile/utilities/_animation.less
+29 −0 style/web/components/empty/_index.less
+10 −5 style/web/components/empty/_var.less
+78 −0 test/unit/time-picker/utils.test.js
40 changes: 2 additions & 38 deletions src/time-picker/panel/single-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { panelColProps } from './props';
import {
EPickerCols, TWELVE_HOUR_FORMAT, AM, PM, MERIDIEM_LIST,
} from '../../_common/js/time-picker/const';
import { closestLookup } from '../../_common/js/time-picker/utils';
import { closestLookup, getPickerCols } from '../../_common/js/time-picker/utils';
import { useConfig } from '../../hooks/useConfig';

dayjs.extend(customParseFormat);
Expand All @@ -23,8 +23,6 @@ const panelOffset = {
bottom: 21,
};

export const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;

export default defineComponent({
name: 'TTimePickerPanelCol',
props: {
Expand Down Expand Up @@ -79,41 +77,7 @@ export default defineComponent({
);

onMounted(() => {
const match = format.value.match(REGEX_FORMAT);
const {
meridiem, hour, minute, second, milliSecond,
} = EPickerCols;

const renderCol: EPickerCols[] = [];

match.forEach((m) => {
switch (m) {
case 'H':
case 'HH':
case 'h':
case 'hh':
renderCol.push(hour);
break;
case 'a':
case 'A':
renderCol.push(meridiem);
break;
case 'm':
case 'mm':
renderCol.push(minute);
break;
case 's':
case 'ss':
renderCol.push(second);
break;
case 'SSS':
renderCol.push(milliSecond);
break;
default:
break;
}
});
cols.value = renderCol;
cols.value = getPickerCols(format.value);
});

// 获取每个时间的高度
Expand Down

0 comments on commit d73444e

Please sign in to comment.