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