chore(admin): 使用dayjs替换moment

This commit is contained in:
roymondchen 2022-12-30 15:46:52 +08:00
parent 8fa1d4a5c3
commit a41a5b3ad4
3 changed files with 19 additions and 6 deletions

View File

@ -8,6 +8,7 @@
"name": "magic-admin", "name": "magic-admin",
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"dayjs": "^1.11.7",
"koa": "^2.7.0", "koa": "^2.7.0",
"koa-bodyparser": "^4.2.1", "koa-bodyparser": "^4.2.1",
"koa-router": "^8.0.6", "koa-router": "^8.0.6",
@ -45,8 +46,6 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"minimatch": "^5.1.0", "minimatch": "^5.1.0",
"module-alias": "^2.2.2", "module-alias": "^2.2.2",
"moment": "^2.29.4",
"moment-timezone": "^0.5.34",
"nodemon": "^1.19.0", "nodemon": "^1.19.0",
"prettier": "^2.3.2", "prettier": "^2.3.2",
"serialize-javascript": "^6.0.0", "serialize-javascript": "^6.0.0",
@ -4530,6 +4529,11 @@
"node": ">=4.0" "node": ">=4.0"
} }
}, },
"node_modules/dayjs": {
"version": "1.11.7",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz",
"integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
},
"node_modules/debug": { "node_modules/debug": {
"version": "4.3.3", "version": "4.3.3",
"resolved": "https://mirrors.tencent.com/npm/debug/-/debug-4.3.3.tgz", "resolved": "https://mirrors.tencent.com/npm/debug/-/debug-4.3.3.tgz",
@ -16501,6 +16505,11 @@
"resolved": "https://mirrors.tencent.com/npm/date-format/-/date-format-3.0.0.tgz", "resolved": "https://mirrors.tencent.com/npm/date-format/-/date-format-3.0.0.tgz",
"integrity": "sha512-eyTcpKOcamdhWJXj56DpQMo1ylSQpcGtGKXcU0Tb97+K56/CF5amAqqqNj0+KvA0iw2ynxtHWFsPDSClCxe48w==" "integrity": "sha512-eyTcpKOcamdhWJXj56DpQMo1ylSQpcGtGKXcU0Tb97+K56/CF5amAqqqNj0+KvA0iw2ynxtHWFsPDSClCxe48w=="
}, },
"dayjs": {
"version": "1.11.7",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.7.tgz",
"integrity": "sha512-+Yw9U6YO5TQohxLcIkrXBeY73WP3ejHWVvx8XCk3gxvQDCTEmS48ZrSZCKciI7Bhl/uCMyxYtE9UqRILmFphkQ=="
},
"debug": { "debug": {
"version": "4.3.3", "version": "4.3.3",
"resolved": "https://mirrors.tencent.com/npm/debug/-/debug-4.3.3.tgz", "resolved": "https://mirrors.tencent.com/npm/debug/-/debug-4.3.3.tgz",

View File

@ -27,6 +27,7 @@
"exec": "ts-node -r tsconfig-paths/register src/index.ts --files" "exec": "ts-node -r tsconfig-paths/register src/index.ts --files"
}, },
"dependencies": { "dependencies": {
"dayjs": "^1.11.7",
"koa": "^2.7.0", "koa": "^2.7.0",
"koa-bodyparser": "^4.2.1", "koa-bodyparser": "^4.2.1",
"koa-router": "^8.0.6", "koa-router": "^8.0.6",
@ -64,8 +65,6 @@
"lodash": "^4.17.21", "lodash": "^4.17.21",
"minimatch": "^5.1.0", "minimatch": "^5.1.0",
"module-alias": "^2.2.2", "module-alias": "^2.2.2",
"moment": "^2.29.4",
"moment-timezone": "^0.5.34",
"nodemon": "^1.19.0", "nodemon": "^1.19.0",
"prettier": "^2.3.2", "prettier": "^2.3.2",
"serialize-javascript": "^6.0.0", "serialize-javascript": "^6.0.0",

View File

@ -19,14 +19,19 @@
import path from 'path'; import path from 'path';
import axios from 'axios'; import axios from 'axios';
import dayjs from 'dayjs';
import timezone from 'dayjs/plugin/timezone';
import utc from 'dayjs/plugin/utc';
import { createWriteStream, emptyDir } from 'fs-extra'; import { createWriteStream, emptyDir } from 'fs-extra';
import momentTimezone from 'moment-timezone';
import serialize from 'serialize-javascript'; import serialize from 'serialize-javascript';
import uglifyJS from 'uglify-js'; import uglifyJS from 'uglify-js';
import type { UiConfig } from '@src/typings'; import type { UiConfig } from '@src/typings';
import { babelTransform } from '@src/utils/transform'; import { babelTransform } from '@src/utils/transform';
dayjs.extend(utc);
dayjs.extend(timezone);
/** /**
* *
* @param {string} value * @param {string} value
@ -91,6 +96,6 @@ const getFileFromUrl = async ({ url, filePath, fileName }) => {
* @returns {string} * @returns {string}
*/ */
const getFormatTime = (time: string | number = Date.now(), formatTmp = 'YYYY-MM-DD HH:mm:ss') => const getFormatTime = (time: string | number = Date.now(), formatTmp = 'YYYY-MM-DD HH:mm:ss') =>
momentTimezone.tz(time, 'Asia/Shanghai').format(formatTmp); dayjs.tz(time, 'Asia/Shanghai').format(formatTmp);
export { serializeConfig, configTransformDist, processTransConfig, getFileFromUrl, getFormatTime }; export { serializeConfig, configTransformDist, processTransConfig, getFileFromUrl, getFormatTime };