Skip to content

Commit

Permalink
feat: 代码调整
Browse files Browse the repository at this point in the history
  • Loading branch information
liweijie0812 committed Dec 3, 2023
1 parent c834a2f commit 6291998
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/time-picker/panel/single-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default defineComponent({
const colsRef = reactive({ 0: null, 1: null, 2: null, 3: null, 4: null, 5: null });

const dayjsValue = computed(() => {
const isStepsSet = !!steps.value.filter((v) => v > 1).length;
const isStepsSet = !!steps.value.filter((step) => Number(step) > 1).length;

if (value.value) return dayjs(value.value, format.value);

Expand Down Expand Up @@ -271,17 +271,17 @@ export default defineComponent({
} else {
const currentHour = dayjsValue.value.hour();
if (el === AM && currentHour >= 12) {
props.onChange(dayjsValue.value.hour(currentHour - 12).format(format.value), e);
props.onChange?.(dayjsValue.value.hour(currentHour - 12).format(format.value), e);
} else if (el === PM && currentHour < 12) {
props.onChange(dayjsValue.value.hour(currentHour + 12).format(format.value), e);
props.onChange?.(dayjsValue.value.hour(currentHour + 12).format(format.value), e);
}
}
};

// update each columns scroll distance
const updateTimeScrollPos = (isAutoScroll = false) => {
const behavior = value.value && !isAutoScroll ? 'smooth' : 'auto';
const isStepsSet = !!steps.value.filter((v) => v > 1).length;
const isStepsSet = !!steps.value.filter((step) => Number(step) > 1).length;
nextTick(() => {
cols.value.forEach((col: EPickerCols, idx: number) => {
if (!isStepsSet || (isStepsSet && value.value)) {
Expand Down
4 changes: 2 additions & 2 deletions src/time-picker/panel/time-picker-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default defineComponent({
theme="primary"
variant="base"
disabled={!props.value}
onClick={() => props.handleConfirmClick(defaultValue.value)}
onClick={() => props.handleConfirmClick?.(defaultValue.value)}
size="small"
>
{globalConfig.value.confirm}
Expand All @@ -110,7 +110,7 @@ export default defineComponent({
theme="primary"
variant="text"
size="small"
onClick={() => props.onChange(dayjs().format(props.format))}
onClick={() => props.onChange?.(dayjs().format(props.format))}
>
{globalConfig.value.now}
</TButton>
Expand Down

0 comments on commit 6291998

Please sign in to comment.