升级Ant Design Vue到3最新版,日期工具类换成dayjs
parent
b94028de4d
commit
f94b99c169
|
@ -12,6 +12,8 @@
|
|||
import { useTitle } from '/@/hooks/web/useTitle';
|
||||
import { useLocale } from '/@/locales/useLocale';
|
||||
|
||||
// 解决日期时间国际化问题
|
||||
import 'dayjs/locale/zh-cn';
|
||||
// support Multi-language
|
||||
const { getAntdLocale } = useLocale();
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { isArray, isFunction, isObject, isString, isNullOrUnDef } from '/@/utils/is';
|
||||
import { dateUtil } from '/@/utils/dateUtil';
|
||||
import { unref } from 'vue';
|
||||
import type { Ref, ComputedRef } from 'vue';
|
||||
import type { FormProps, FormSchema } from '../types/form';
|
||||
import dayjs from "dayjs";
|
||||
import { set } from 'lodash-es';
|
||||
import { handleRangeValue } from '/@/components/Form/src/utils/formUtils';
|
||||
|
||||
|
@ -29,7 +29,8 @@ export function useFormValues({ defaultValueRef, getSchema, formModel, getProps
|
|||
if (isObject(value)) {
|
||||
value = transformDateFunc?.(value);
|
||||
}
|
||||
if (isArray(value) && value[0]?._isAMomentObject && value[1]?._isAMomentObject) {
|
||||
// 判断是否是dayjs实例
|
||||
if (isArray(value) && dayjs.isDayjs(value[0]) && dayjs.isDayjs(value[1])) {
|
||||
value = value.map((item) => transformDateFunc?.(item));
|
||||
}
|
||||
// Remove spaces
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/**
|
||||
* Independent time operation tool to facilitate subsequent switch to dayjs
|
||||
*/
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
|
||||
const DATE_FORMAT = 'YYYY-MM-DD ';
|
||||
|
||||
export function formatToDateTime(date: moment.MomentInput = undefined, format = DATE_TIME_FORMAT): string {
|
||||
return moment(date).format(format);
|
||||
//TODO dayjs.ConfigType不知是否用对
|
||||
export function formatToDateTime(date: dayjs.ConfigType = undefined, format = DATE_TIME_FORMAT): string {
|
||||
return dayjs(date).format(format);
|
||||
}
|
||||
|
||||
export function formatToDate(date: moment.MomentInput = undefined, format = DATE_FORMAT): string {
|
||||
return moment(date).format(format);
|
||||
export function formatToDate(date: dayjs.ConfigType = undefined, format = DATE_FORMAT): string {
|
||||
return dayjs(date).format(format);
|
||||
}
|
||||
|
||||
export const dateUtil = moment;
|
||||
export const dateUtil = dayjs;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { isObject, isString } from '/@/utils/is';
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm';
|
||||
|
||||
|
@ -24,7 +25,8 @@ export function formatRequestDate(params: Recordable) {
|
|||
}
|
||||
|
||||
for (const key in params) {
|
||||
if (params[key] && params[key]._isAMomentObject) {
|
||||
// 判断是否是dayjs实例
|
||||
if (dayjs.isDayjs(params[key])) {
|
||||
params[key] = params[key].format(DATE_TIME_FORMAT);
|
||||
}
|
||||
if (isString(key)) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { UserConfig, ConfigEnv } from 'vite';
|
||||
import pkg from './package.json';
|
||||
import moment from 'moment';
|
||||
import dayjs from 'dayjs';
|
||||
import { loadEnv } from 'vite';
|
||||
import { resolve } from 'path';
|
||||
//require('vue-jeecg-plugs/packages/utils')
|
||||
|
@ -17,7 +17,7 @@ function pathResolve(dir: string) {
|
|||
const { dependencies, devDependencies, name, version } = pkg;
|
||||
const __APP_INFO__ = {
|
||||
pkg: { dependencies, devDependencies, name, version },
|
||||
lastBuildTime: moment().format('YYYY-MM-DD HH:mm:ss'),
|
||||
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
};
|
||||
|
||||
export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||
|
@ -56,6 +56,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||
server: {
|
||||
// Listening on all local IPs
|
||||
host: true,
|
||||
https: false,
|
||||
port: VITE_PORT,
|
||||
// Load proxy configuration from .env
|
||||
proxy: createProxy(VITE_PROXY),
|
||||
|
@ -100,11 +101,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||
},
|
||||
// @iconify/iconify: The dependency is dynamically and virtually loaded by @purge-icons/generated, so it needs to be specified explicitly
|
||||
include: [
|
||||
'@vue/runtime-core',
|
||||
'@vue/shared',
|
||||
'@iconify/iconify',
|
||||
'ant-design-vue/es/locale/zh_CN',
|
||||
'moment/dist/locale/zh-cn',
|
||||
'ant-design-vue/es/locale/en_US',
|
||||
'moment/dist/locale/eu',
|
||||
],
|
||||
exclude: ['vue-demi'],
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue