refactor:修复 antd typecheck 提供的报错

This commit is contained in:
YunaiV
2025-04-23 12:56:35 +08:00
parent a6f25d477b
commit b4efb7c468
19 changed files with 210 additions and 147 deletions

View File

@@ -1,6 +1,12 @@
import dayjs from 'dayjs';
export function formatDate(time: number | string | Date, format = 'YYYY-MM-DD') {
export function formatDate(
time: Date | number | string | undefined,
format = 'YYYY-MM-DD',
) {
if (!time) {
return time;
}
try {
const date = dayjs(time);
if (!date.isValid()) {
@@ -13,7 +19,10 @@ export function formatDate(time: number | string | Date, format = 'YYYY-MM-DD')
}
}
export function formatDateTime(time: number | string | Date) {
export function formatDateTime(time: Date | number | string | undefined) {
if (!time) {
return time;
}
return formatDate(time, 'YYYY-MM-DD HH:mm:ss');
}

View File

@@ -1,8 +1,9 @@
<script lang="ts" setup>
import type { ComponentInternalInstance } from 'vue';
import type { VerificationProps } from '../types';
import {
type ComponentInternalInstance,
getCurrentInstance,
nextTick,
onMounted,
@@ -127,7 +128,7 @@ onMounted(() => {
const canvas = ref(null);
// 获取坐标
const getMousePos = function (obj: any, e: any) {
const getMousePos = function (_obj: any, e: any) {
const x = e.offsetX;
const y = e.offsetY;
return { x, y };

View File

@@ -69,13 +69,13 @@ function extendProxyOption(
export function extendsDefaultFormatter(vxeUI: VxeUIExport) {
vxeUI.formats.add('formatDate', {
tableCellFormatMethod({ cellValue }) {
return formatDate(cellValue);
return formatDate(cellValue) as string;
},
});
vxeUI.formats.add('formatDateTime', {
tableCellFormatMethod({ cellValue }) {
return formatDateTime(cellValue);
return formatDateTime(cellValue) as string;
},
});
}