build(deps): 删除 moment 依赖

This commit is contained in:
dj
2025-06-12 12:08:41 +08:00
parent 7f0f74c844
commit 1ed6156117
2 changed files with 28 additions and 30 deletions

View File

@@ -19,7 +19,6 @@
"highlight.js": "9.18.5", "highlight.js": "9.18.5",
"jquery": "^3.6.0", "jquery": "^3.6.0",
"js-cookie": "^3.0.5", "js-cookie": "^3.0.5",
"moment": "^2.30.1",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"pinia": "^2.0.35", "pinia": "^2.0.35",
"sass": "^1.62.1", "sass": "^1.62.1",

View File

@@ -1,5 +1,4 @@
//时间转换为String类型 //时间转换为String类型
const moment = require("moment");
function simpleDateFormat(pattern) { function simpleDateFormat(pattern) {
var fmt = new Object(); var fmt = new Object();
@@ -83,36 +82,36 @@ function consumingTime(dateBegin, dateEnd) {
return dayDiff + "天 " + hours + "小时 " + minutes + " 分钟" + seconds + " 秒"; return dayDiff + "天 " + hours + "小时 " + minutes + " 分钟" + seconds + " 秒";
} }
export function timeLength(start, dateEnd) { // export function timeLength(start, dateEnd) {
// //如果时间格式是正确的,那下面这一步转化时间格式就可以不用了 // // //如果时间格式是正确的,那下面这一步转化时间格式就可以不用了
let mstart = moment(start); // let mstart = moment(start);
let mend = moment(dateEnd); // let mend = moment(dateEnd);
let years = mend.diff(start, "years"); // let years = mend.diff(start, "years");
let months = mend.diff(start, "months"); // let months = mend.diff(start, "months");
let days = mend.diff(start, "days"); // let days = mend.diff(start, "days");
let hours = mend.diff(start, "hours"); // let hours = mend.diff(start, "hours");
let minutes = mend.diff(start, "minutes"); // let minutes = mend.diff(start, "minutes");
minutes = minutes % 60; // minutes = minutes % 60;
hours = hours % 24; // hours = hours % 24;
months = months % 12; // months = months % 12;
//因为每月天不固定,所以天要特殊动态处理 // //因为每月天不固定,所以天要特殊动态处理
if (mstart.date() < mend.date()) { // if (mstart.date() < mend.date()) {
days = mend.date() - mstart.date(); // days = mend.date() - mstart.date();
if (minutes > 0 || hours > 0) { // if (minutes > 0 || hours > 0) {
days--; // days--;
} // }
} // }
//处理超过俩月且天超过31 // //处理超过俩月且天超过31
if (days > 31 && mend.month() - mstart.month() >= 2) { // if (days > 31 && mend.month() - mstart.month() >= 2) {
//将日期推至上月求差 // //将日期推至上月求差
days = mend.diff(mstart.add(mend.month() - mstart.month() - 1, "month"), "days"); // days = mend.diff(mstart.add(mend.month() - mstart.month() - 1, "month"), "days");
} // }
return `${years > 0 ? years + "年 " : " "}` + `${months > 0 ? months + "个月 " : " "}` + `${days > 0 ? days + "天 " : " "}` // return `${years > 0 ? years + "年 " : " "}` + `${months > 0 ? months + "个月 " : " "}` + `${days > 0 ? days + "天 " : " "}`
+ `${hours > 0 ? hours + "小时 " : " "}` + `${minutes > 0 ? minutes + "分钟 " : " "}`; // + `${hours > 0 ? hours + "小时 " : " "}` + `${minutes > 0 ? minutes + "分钟 " : " "}`;
} // }
module.exports = { module.exports = {
formatToYYYYMMDD: simpleDateFormatByMoreLine, formatToYYYYMMDD: simpleDateFormatByMoreLine,
consumingTime: consumingTime, consumingTime: consumingTime,
timeLength: timeLength // timeLength: timeLength
} }