@sybz-components/utils 0.0.12 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.cjs +1 -1
- package/dist/base.d.cts +1 -1
- package/dist/base.d.mts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/base.mjs +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.mjs +1 -1
- package/dist/index.cjs +1 -11
- package/dist/index.d.cts +0 -3
- package/dist/index.d.mts +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.mjs +1 -5
- package/dist/shared/{utils.CTnx12Vx.mjs → utils.BEyMaMZg.mjs} +13 -3
- package/dist/shared/{utils.DUIw9c4e.cjs → utils.aC91nrkh.cjs} +14 -4
- package/package.json +3 -4
- package/dist/day.cjs +0 -41
- package/dist/day.d.cts +0 -81
- package/dist/day.d.mts +0 -81
- package/dist/day.d.ts +0 -81
- package/dist/day.mjs +0 -31
- package/dist/ws.cjs +0 -175
- package/dist/ws.d.cts +0 -165
- package/dist/ws.d.mts +0 -165
- package/dist/ws.d.ts +0 -165
- package/dist/ws.mjs +0 -169
package/dist/base.cjs
CHANGED
package/dist/base.d.cts
CHANGED
package/dist/base.d.mts
CHANGED
package/dist/base.d.ts
CHANGED
package/dist/base.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'vue';
|
|
2
2
|
import 'consola';
|
|
3
3
|
import 'es-toolkit';
|
|
4
|
-
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.
|
|
4
|
+
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.BEyMaMZg.mjs';
|
|
5
5
|
import 'element-plus';
|
|
6
6
|
import './is.mjs';
|
package/dist/format.cjs
CHANGED
package/dist/format.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.
|
|
1
|
+
export { y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.BEyMaMZg.mjs';
|
|
2
2
|
import './is.mjs';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'vue';
|
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const format = require('./shared/utils.
|
|
4
|
-
const day = require('./day.cjs');
|
|
3
|
+
const format = require('./shared/utils.aC91nrkh.cjs');
|
|
5
4
|
const is = require('./is.cjs');
|
|
6
|
-
const ws = require('./ws.cjs');
|
|
7
5
|
require('vue');
|
|
8
6
|
require('consola');
|
|
9
7
|
require('es-toolkit');
|
|
10
8
|
require('element-plus');
|
|
11
|
-
require('dayjs');
|
|
12
|
-
require('qs');
|
|
13
9
|
|
|
14
10
|
|
|
15
11
|
|
|
@@ -46,11 +42,6 @@ exports.tryCatch = format.tryCatch;
|
|
|
46
42
|
exports.validate = format.validate;
|
|
47
43
|
exports.validateForm = format.validateForm;
|
|
48
44
|
exports.validateOnSubmit = format.validateOnSubmit;
|
|
49
|
-
exports.diffDate = day.diffDate;
|
|
50
|
-
exports.diffDateFromCurrent = day.diffDateFromCurrent;
|
|
51
|
-
exports.formatDate = day.formatDate;
|
|
52
|
-
exports.formatDateToDay = day.formatDateToDay;
|
|
53
|
-
exports.formatDateToMinute = day.formatDateToMinute;
|
|
54
45
|
exports.isArray = is.isArray;
|
|
55
46
|
exports.isBoolean = is.isBoolean;
|
|
56
47
|
exports.isComponent = is.isComponent;
|
|
@@ -73,4 +64,3 @@ exports.isUrl = is.isUrl;
|
|
|
73
64
|
exports.objectToString = is.objectToString;
|
|
74
65
|
exports.toRawType = is.toRawType;
|
|
75
66
|
exports.toTypeString = is.toTypeString;
|
|
76
|
-
exports.WS = ws.WS;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.cjs';
|
|
2
|
-
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.cjs';
|
|
3
2
|
export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.cjs';
|
|
4
|
-
export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.cjs';
|
|
5
3
|
export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.cjs';
|
|
6
4
|
import 'element-plus';
|
|
7
5
|
import 'vue';
|
|
8
|
-
import 'dayjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.mjs';
|
|
2
|
-
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.mjs';
|
|
3
2
|
export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
|
|
4
|
-
export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.mjs';
|
|
5
3
|
export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.mjs';
|
|
6
4
|
import 'element-plus';
|
|
7
5
|
import 'vue';
|
|
8
|
-
import 'dayjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.js';
|
|
2
|
-
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.js';
|
|
3
2
|
export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.js';
|
|
4
|
-
export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.js';
|
|
5
3
|
export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.js';
|
|
6
4
|
import 'element-plus';
|
|
7
5
|
import 'vue';
|
|
8
|
-
import 'dayjs';
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.
|
|
2
|
-
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.mjs';
|
|
1
|
+
export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.BEyMaMZg.mjs';
|
|
3
2
|
export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
|
|
4
|
-
export { WS } from './ws.mjs';
|
|
5
3
|
import 'vue';
|
|
6
4
|
import 'consola';
|
|
7
5
|
import 'es-toolkit';
|
|
8
6
|
import 'element-plus';
|
|
9
|
-
import 'dayjs';
|
|
10
|
-
import 'qs';
|
|
@@ -234,6 +234,9 @@ const DEFAULT_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn";
|
|
|
234
234
|
const CHENGHUA_CONFIRM_BOX_CLASS = "s-message-box--chenghua";
|
|
235
235
|
const CHENGHUA_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--chenghua";
|
|
236
236
|
const CHENGHUA_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--chenghua";
|
|
237
|
+
const SHIJINGSHAN_CONFIRM_BOX_CLASS = "s-message-box--shijingshan";
|
|
238
|
+
const SHIJINGSHAN_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--shijingshan";
|
|
239
|
+
const SHIJINGSHAN_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--shijingshan";
|
|
237
240
|
function _getBrowserStorage(isSession = false) {
|
|
238
241
|
if (typeof window === "undefined") {
|
|
239
242
|
return null;
|
|
@@ -800,7 +803,7 @@ function toLine(text, connect = "-") {
|
|
|
800
803
|
const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
|
|
801
804
|
function processWidth(initValue, isBase = false) {
|
|
802
805
|
const raw = unref(initValue);
|
|
803
|
-
if (
|
|
806
|
+
if (raw === void 0 || raw === null || raw === "") {
|
|
804
807
|
return isBase ? "" : {};
|
|
805
808
|
}
|
|
806
809
|
const str = typeof raw === "number" ? `${raw}` : raw;
|
|
@@ -957,6 +960,7 @@ function confirm(message, options = {}, appContext = null) {
|
|
|
957
960
|
const resolvedAppendTo = _resolveAppendTarget(appendTo);
|
|
958
961
|
const resolvedAppContext = _resolveAppContext(optionAppContext || appContext);
|
|
959
962
|
const isChenghuaTheme = theme === "chenghua";
|
|
963
|
+
const isShijingshanTheme = theme === "shijingshan";
|
|
960
964
|
const mergeOptions = {
|
|
961
965
|
title: "\u63D0\u793A",
|
|
962
966
|
draggable: true,
|
|
@@ -967,15 +971,21 @@ function confirm(message, options = {}, appContext = null) {
|
|
|
967
971
|
...messageBoxOptions,
|
|
968
972
|
appendTo: resolvedAppendTo,
|
|
969
973
|
appContext: resolvedAppContext,
|
|
970
|
-
customClass: _mergeClassNames(
|
|
974
|
+
customClass: _mergeClassNames(
|
|
975
|
+
isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS,
|
|
976
|
+
isShijingshanTheme && SHIJINGSHAN_CONFIRM_BOX_CLASS,
|
|
977
|
+
customClass
|
|
978
|
+
),
|
|
971
979
|
confirmButtonClass: _mergeClassNames(
|
|
972
980
|
DEFAULT_CONFIRM_BUTTON_CLASS,
|
|
973
981
|
isChenghuaTheme && CHENGHUA_CONFIRM_BUTTON_CLASS,
|
|
982
|
+
isShijingshanTheme && SHIJINGSHAN_CONFIRM_BUTTON_CLASS,
|
|
974
983
|
confirmButtonClass
|
|
975
984
|
),
|
|
976
985
|
cancelButtonClass: _mergeClassNames(
|
|
977
986
|
DEFAULT_CANCEL_BUTTON_CLASS,
|
|
978
987
|
isChenghuaTheme && CHENGHUA_CANCEL_BUTTON_CLASS,
|
|
988
|
+
isShijingshanTheme && SHIJINGSHAN_CANCEL_BUTTON_CLASS,
|
|
979
989
|
cancelButtonClass
|
|
980
990
|
)
|
|
981
991
|
};
|
|
@@ -1034,7 +1044,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
1034
1044
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
1035
1045
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
1036
1046
|
{
|
|
1037
|
-
return "2026-07-
|
|
1047
|
+
return "2026-07-08 15:30:00";
|
|
1038
1048
|
}
|
|
1039
1049
|
}
|
|
1040
1050
|
function test() {
|
|
@@ -190,7 +190,7 @@ function formatImg(photoName, addPath = "", { basePath = "assets/images" } = {})
|
|
|
190
190
|
const addLastSlash = addPath.endsWith("/") || !addPath ? addPath : `${addPath}/`;
|
|
191
191
|
const addLastBasePathSlash = basePath.endsWith("/") || !basePath ? basePath : `${basePath}/`;
|
|
192
192
|
const mergeSrc = `${addLastSlash}${photoName}`;
|
|
193
|
-
return new URL(`../${addLastBasePathSlash}${mergeSrc}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/utils.
|
|
193
|
+
return new URL(`../${addLastBasePathSlash}${mergeSrc}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/utils.aC91nrkh.cjs', document.baseURI).href))).href;
|
|
194
194
|
}
|
|
195
195
|
function formatToFixed(value, options) {
|
|
196
196
|
if (typeof options === "number") {
|
|
@@ -237,6 +237,9 @@ const DEFAULT_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn";
|
|
|
237
237
|
const CHENGHUA_CONFIRM_BOX_CLASS = "s-message-box--chenghua";
|
|
238
238
|
const CHENGHUA_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--chenghua";
|
|
239
239
|
const CHENGHUA_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--chenghua";
|
|
240
|
+
const SHIJINGSHAN_CONFIRM_BOX_CLASS = "s-message-box--shijingshan";
|
|
241
|
+
const SHIJINGSHAN_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--shijingshan";
|
|
242
|
+
const SHIJINGSHAN_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--shijingshan";
|
|
240
243
|
function _getBrowserStorage(isSession = false) {
|
|
241
244
|
if (typeof window === "undefined") {
|
|
242
245
|
return null;
|
|
@@ -803,7 +806,7 @@ function toLine(text, connect = "-") {
|
|
|
803
806
|
const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
|
|
804
807
|
function processWidth(initValue, isBase = false) {
|
|
805
808
|
const raw = vue.unref(initValue);
|
|
806
|
-
if (
|
|
809
|
+
if (raw === void 0 || raw === null || raw === "") {
|
|
807
810
|
return isBase ? "" : {};
|
|
808
811
|
}
|
|
809
812
|
const str = typeof raw === "number" ? `${raw}` : raw;
|
|
@@ -960,6 +963,7 @@ function confirm(message, options = {}, appContext = null) {
|
|
|
960
963
|
const resolvedAppendTo = _resolveAppendTarget(appendTo);
|
|
961
964
|
const resolvedAppContext = _resolveAppContext(optionAppContext || appContext);
|
|
962
965
|
const isChenghuaTheme = theme === "chenghua";
|
|
966
|
+
const isShijingshanTheme = theme === "shijingshan";
|
|
963
967
|
const mergeOptions = {
|
|
964
968
|
title: "\u63D0\u793A",
|
|
965
969
|
draggable: true,
|
|
@@ -970,15 +974,21 @@ function confirm(message, options = {}, appContext = null) {
|
|
|
970
974
|
...messageBoxOptions,
|
|
971
975
|
appendTo: resolvedAppendTo,
|
|
972
976
|
appContext: resolvedAppContext,
|
|
973
|
-
customClass: _mergeClassNames(
|
|
977
|
+
customClass: _mergeClassNames(
|
|
978
|
+
isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS,
|
|
979
|
+
isShijingshanTheme && SHIJINGSHAN_CONFIRM_BOX_CLASS,
|
|
980
|
+
customClass
|
|
981
|
+
),
|
|
974
982
|
confirmButtonClass: _mergeClassNames(
|
|
975
983
|
DEFAULT_CONFIRM_BUTTON_CLASS,
|
|
976
984
|
isChenghuaTheme && CHENGHUA_CONFIRM_BUTTON_CLASS,
|
|
985
|
+
isShijingshanTheme && SHIJINGSHAN_CONFIRM_BUTTON_CLASS,
|
|
977
986
|
confirmButtonClass
|
|
978
987
|
),
|
|
979
988
|
cancelButtonClass: _mergeClassNames(
|
|
980
989
|
DEFAULT_CANCEL_BUTTON_CLASS,
|
|
981
990
|
isChenghuaTheme && CHENGHUA_CANCEL_BUTTON_CLASS,
|
|
991
|
+
isShijingshanTheme && SHIJINGSHAN_CANCEL_BUTTON_CLASS,
|
|
982
992
|
cancelButtonClass
|
|
983
993
|
)
|
|
984
994
|
};
|
|
@@ -1037,7 +1047,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
1037
1047
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
1038
1048
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
1039
1049
|
{
|
|
1040
|
-
return "2026-07-
|
|
1050
|
+
return "2026-07-08 15:30:00";
|
|
1041
1051
|
}
|
|
1042
1052
|
}
|
|
1043
1053
|
function test() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sybz-components/utils",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "utils of sybz-components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -18,18 +18,17 @@
|
|
|
18
18
|
"build": "npx unbuild",
|
|
19
19
|
"stub": "npx unbuild --stub",
|
|
20
20
|
"releaseOld": "npx unbuild && npm version patch && git add . && git commit -m \"chore: release @sybz-components/utils v$(npm pkg get version | sed 's/\"//g')\" && git push origin && npm publish",
|
|
21
|
-
"release": "node ./scripts/release.mjs"
|
|
21
|
+
"release": "node ./scripts/release.mjs",
|
|
22
|
+
"release:skip": "node ./scripts/release.mjs --skip-version-bump"
|
|
22
23
|
},
|
|
23
24
|
"author": "",
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@vue/reactivity": "^3.5.18",
|
|
26
27
|
"@vue/shared": "^3.5.18",
|
|
27
28
|
"consola": "^3.4.2",
|
|
28
|
-
"dayjs": "^1.11.19",
|
|
29
29
|
"element-plus": "^2.11.5",
|
|
30
30
|
"es-toolkit": "^1.39.10",
|
|
31
31
|
"lodash-es": "^4.17.21",
|
|
32
|
-
"qs": "^6.15.0",
|
|
33
32
|
"vue": "3.4.15"
|
|
34
33
|
}
|
|
35
34
|
}
|
package/dist/day.cjs
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const dayjs = require('dayjs');
|
|
4
|
-
|
|
5
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
6
|
-
|
|
7
|
-
const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
|
|
8
|
-
|
|
9
|
-
function formatDate(date, format = "YYYY-MM-DD HH:mm:ss") {
|
|
10
|
-
return dayjs__default(date || /* @__PURE__ */ new Date()).format(format);
|
|
11
|
-
}
|
|
12
|
-
const formatDateToDay = (date) => formatDate(date, "YYYY-MM-DD");
|
|
13
|
-
const formatDateToMinute = (date) => formatDate(date, "YYYY-MM-DD HH:mm");
|
|
14
|
-
function diffDate(date1, date2 = dayjs__default(), format = "second") {
|
|
15
|
-
if (!date1) return;
|
|
16
|
-
return dayjs__default(date1).diff(dayjs__default(date2), format);
|
|
17
|
-
}
|
|
18
|
-
function diffDateFromCurrent(second) {
|
|
19
|
-
if (second >= 60 * 60 * 24 * 365) {
|
|
20
|
-
return `${parseInt(String(second / (60 * 60 * 24 * 365)))}\u5E74\u524D`;
|
|
21
|
-
}
|
|
22
|
-
if (second >= 60 * 60 * 24 * 30) {
|
|
23
|
-
return `${parseInt(String(second / (60 * 60 * 24 * 30)))}\u6708\u524D`;
|
|
24
|
-
}
|
|
25
|
-
if (second >= 60 * 60 * 24) {
|
|
26
|
-
return `${parseInt(String(second / (60 * 60 * 24)))}\u5929\u524D`;
|
|
27
|
-
}
|
|
28
|
-
if (second >= 60 * 60) {
|
|
29
|
-
return `${parseInt(String(second / (60 * 60)))}\u5C0F\u65F6\u524D`;
|
|
30
|
-
}
|
|
31
|
-
if (second >= 60) {
|
|
32
|
-
return `${parseInt(String(second / 60))}\u5206\u949F\u524D`;
|
|
33
|
-
}
|
|
34
|
-
return `${parseInt(String(second))}\u79D2\u524D`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.diffDate = diffDate;
|
|
38
|
-
exports.diffDateFromCurrent = diffDateFromCurrent;
|
|
39
|
-
exports.formatDate = formatDate;
|
|
40
|
-
exports.formatDateToDay = formatDateToDay;
|
|
41
|
-
exports.formatDateToMinute = formatDateToMinute;
|
package/dist/day.d.cts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { ConfigType, QUnitType, OpUnitType } from 'dayjs';
|
|
2
|
-
|
|
3
|
-
type DayUnit = QUnitType | OpUnitType;
|
|
4
|
-
/**
|
|
5
|
-
* 使用 `dayjs` 格式化日期。
|
|
6
|
-
*
|
|
7
|
-
* @param date 要格式化的日期值。为空时默认使用当前时间。
|
|
8
|
-
* @param format 输出格式,默认 `YYYY-MM-DD HH:mm:ss`。
|
|
9
|
-
* @returns 格式化后的日期字符串。
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* formatDate('2026-04-24 12:30:45')
|
|
13
|
-
* // => '2026-04-24 12:30:45'
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* formatDate('2026-04-24 12:30:45', 'YYYY/MM/DD')
|
|
17
|
-
* // => '2026/04/24'
|
|
18
|
-
*/
|
|
19
|
-
declare function formatDate(date?: ConfigType, format?: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* 将日期格式化为 `YYYY-MM-DD`。
|
|
22
|
-
*
|
|
23
|
-
* @param date 要格式化的日期值。
|
|
24
|
-
* @returns 形如 `2026-04-24` 的字符串。
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* formatDateToDay(new Date())
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* formatDateToDay('2026-04-24 12:30:45')
|
|
31
|
-
* // => '2026-04-24'
|
|
32
|
-
*/
|
|
33
|
-
declare const formatDateToDay: (date: ConfigType) => string;
|
|
34
|
-
/**
|
|
35
|
-
* 将日期格式化为 `YYYY-MM-DD HH:mm`。
|
|
36
|
-
*
|
|
37
|
-
* @param date 要格式化的日期值。
|
|
38
|
-
* @returns 形如 `2026-04-24 12:30` 的字符串。
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* formatDateToMinute(new Date())
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* formatDateToMinute('2026-04-24 12:30:45')
|
|
45
|
-
* // => '2026-04-24 12:30'
|
|
46
|
-
*/
|
|
47
|
-
declare const formatDateToMinute: (date: ConfigType) => string;
|
|
48
|
-
/**
|
|
49
|
-
* 计算两个日期之间的差值。
|
|
50
|
-
*
|
|
51
|
-
* @param date1 起始时间。未传时返回 `undefined`。
|
|
52
|
-
* @param date2 对比时间,默认取当前时间。
|
|
53
|
-
* @param format 差值单位,默认 `second`。
|
|
54
|
-
* @returns 两个时间的差值。
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* diffDate('2026-04-24 12:00:00', '2026-04-24 11:59:00')
|
|
58
|
-
* // => 60
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* diffDate('2026-04-24 12:00:00', '2026-04-24 11:30:00', 'minute')
|
|
62
|
-
* // => 30
|
|
63
|
-
*/
|
|
64
|
-
declare function diffDate(date1: ConfigType, date2?: ConfigType, format?: DayUnit): number | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* 将秒数转换成“几秒前 / 几分钟前 / 几小时前 / 几天前”这类相对时间文案。
|
|
67
|
-
*
|
|
68
|
-
* @param second 距离当前时间的秒数。
|
|
69
|
-
* @returns 中文相对时间描述。
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* diffDateFromCurrent(45)
|
|
73
|
-
* // => '45秒前'
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* diffDateFromCurrent(3600)
|
|
77
|
-
* // => '1小时前'
|
|
78
|
-
*/
|
|
79
|
-
declare function diffDateFromCurrent(second: number): string;
|
|
80
|
-
|
|
81
|
-
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute };
|
package/dist/day.d.mts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { ConfigType, QUnitType, OpUnitType } from 'dayjs';
|
|
2
|
-
|
|
3
|
-
type DayUnit = QUnitType | OpUnitType;
|
|
4
|
-
/**
|
|
5
|
-
* 使用 `dayjs` 格式化日期。
|
|
6
|
-
*
|
|
7
|
-
* @param date 要格式化的日期值。为空时默认使用当前时间。
|
|
8
|
-
* @param format 输出格式,默认 `YYYY-MM-DD HH:mm:ss`。
|
|
9
|
-
* @returns 格式化后的日期字符串。
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* formatDate('2026-04-24 12:30:45')
|
|
13
|
-
* // => '2026-04-24 12:30:45'
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* formatDate('2026-04-24 12:30:45', 'YYYY/MM/DD')
|
|
17
|
-
* // => '2026/04/24'
|
|
18
|
-
*/
|
|
19
|
-
declare function formatDate(date?: ConfigType, format?: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* 将日期格式化为 `YYYY-MM-DD`。
|
|
22
|
-
*
|
|
23
|
-
* @param date 要格式化的日期值。
|
|
24
|
-
* @returns 形如 `2026-04-24` 的字符串。
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* formatDateToDay(new Date())
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* formatDateToDay('2026-04-24 12:30:45')
|
|
31
|
-
* // => '2026-04-24'
|
|
32
|
-
*/
|
|
33
|
-
declare const formatDateToDay: (date: ConfigType) => string;
|
|
34
|
-
/**
|
|
35
|
-
* 将日期格式化为 `YYYY-MM-DD HH:mm`。
|
|
36
|
-
*
|
|
37
|
-
* @param date 要格式化的日期值。
|
|
38
|
-
* @returns 形如 `2026-04-24 12:30` 的字符串。
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* formatDateToMinute(new Date())
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* formatDateToMinute('2026-04-24 12:30:45')
|
|
45
|
-
* // => '2026-04-24 12:30'
|
|
46
|
-
*/
|
|
47
|
-
declare const formatDateToMinute: (date: ConfigType) => string;
|
|
48
|
-
/**
|
|
49
|
-
* 计算两个日期之间的差值。
|
|
50
|
-
*
|
|
51
|
-
* @param date1 起始时间。未传时返回 `undefined`。
|
|
52
|
-
* @param date2 对比时间,默认取当前时间。
|
|
53
|
-
* @param format 差值单位,默认 `second`。
|
|
54
|
-
* @returns 两个时间的差值。
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* diffDate('2026-04-24 12:00:00', '2026-04-24 11:59:00')
|
|
58
|
-
* // => 60
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* diffDate('2026-04-24 12:00:00', '2026-04-24 11:30:00', 'minute')
|
|
62
|
-
* // => 30
|
|
63
|
-
*/
|
|
64
|
-
declare function diffDate(date1: ConfigType, date2?: ConfigType, format?: DayUnit): number | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* 将秒数转换成“几秒前 / 几分钟前 / 几小时前 / 几天前”这类相对时间文案。
|
|
67
|
-
*
|
|
68
|
-
* @param second 距离当前时间的秒数。
|
|
69
|
-
* @returns 中文相对时间描述。
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* diffDateFromCurrent(45)
|
|
73
|
-
* // => '45秒前'
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* diffDateFromCurrent(3600)
|
|
77
|
-
* // => '1小时前'
|
|
78
|
-
*/
|
|
79
|
-
declare function diffDateFromCurrent(second: number): string;
|
|
80
|
-
|
|
81
|
-
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute };
|
package/dist/day.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { ConfigType, QUnitType, OpUnitType } from 'dayjs';
|
|
2
|
-
|
|
3
|
-
type DayUnit = QUnitType | OpUnitType;
|
|
4
|
-
/**
|
|
5
|
-
* 使用 `dayjs` 格式化日期。
|
|
6
|
-
*
|
|
7
|
-
* @param date 要格式化的日期值。为空时默认使用当前时间。
|
|
8
|
-
* @param format 输出格式,默认 `YYYY-MM-DD HH:mm:ss`。
|
|
9
|
-
* @returns 格式化后的日期字符串。
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* formatDate('2026-04-24 12:30:45')
|
|
13
|
-
* // => '2026-04-24 12:30:45'
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* formatDate('2026-04-24 12:30:45', 'YYYY/MM/DD')
|
|
17
|
-
* // => '2026/04/24'
|
|
18
|
-
*/
|
|
19
|
-
declare function formatDate(date?: ConfigType, format?: string): string;
|
|
20
|
-
/**
|
|
21
|
-
* 将日期格式化为 `YYYY-MM-DD`。
|
|
22
|
-
*
|
|
23
|
-
* @param date 要格式化的日期值。
|
|
24
|
-
* @returns 形如 `2026-04-24` 的字符串。
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* formatDateToDay(new Date())
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* formatDateToDay('2026-04-24 12:30:45')
|
|
31
|
-
* // => '2026-04-24'
|
|
32
|
-
*/
|
|
33
|
-
declare const formatDateToDay: (date: ConfigType) => string;
|
|
34
|
-
/**
|
|
35
|
-
* 将日期格式化为 `YYYY-MM-DD HH:mm`。
|
|
36
|
-
*
|
|
37
|
-
* @param date 要格式化的日期值。
|
|
38
|
-
* @returns 形如 `2026-04-24 12:30` 的字符串。
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* formatDateToMinute(new Date())
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* formatDateToMinute('2026-04-24 12:30:45')
|
|
45
|
-
* // => '2026-04-24 12:30'
|
|
46
|
-
*/
|
|
47
|
-
declare const formatDateToMinute: (date: ConfigType) => string;
|
|
48
|
-
/**
|
|
49
|
-
* 计算两个日期之间的差值。
|
|
50
|
-
*
|
|
51
|
-
* @param date1 起始时间。未传时返回 `undefined`。
|
|
52
|
-
* @param date2 对比时间,默认取当前时间。
|
|
53
|
-
* @param format 差值单位,默认 `second`。
|
|
54
|
-
* @returns 两个时间的差值。
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* diffDate('2026-04-24 12:00:00', '2026-04-24 11:59:00')
|
|
58
|
-
* // => 60
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* diffDate('2026-04-24 12:00:00', '2026-04-24 11:30:00', 'minute')
|
|
62
|
-
* // => 30
|
|
63
|
-
*/
|
|
64
|
-
declare function diffDate(date1: ConfigType, date2?: ConfigType, format?: DayUnit): number | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* 将秒数转换成“几秒前 / 几分钟前 / 几小时前 / 几天前”这类相对时间文案。
|
|
67
|
-
*
|
|
68
|
-
* @param second 距离当前时间的秒数。
|
|
69
|
-
* @returns 中文相对时间描述。
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* diffDateFromCurrent(45)
|
|
73
|
-
* // => '45秒前'
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* diffDateFromCurrent(3600)
|
|
77
|
-
* // => '1小时前'
|
|
78
|
-
*/
|
|
79
|
-
declare function diffDateFromCurrent(second: number): string;
|
|
80
|
-
|
|
81
|
-
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute };
|
package/dist/day.mjs
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
|
|
3
|
-
function formatDate(date, format = "YYYY-MM-DD HH:mm:ss") {
|
|
4
|
-
return dayjs(date || /* @__PURE__ */ new Date()).format(format);
|
|
5
|
-
}
|
|
6
|
-
const formatDateToDay = (date) => formatDate(date, "YYYY-MM-DD");
|
|
7
|
-
const formatDateToMinute = (date) => formatDate(date, "YYYY-MM-DD HH:mm");
|
|
8
|
-
function diffDate(date1, date2 = dayjs(), format = "second") {
|
|
9
|
-
if (!date1) return;
|
|
10
|
-
return dayjs(date1).diff(dayjs(date2), format);
|
|
11
|
-
}
|
|
12
|
-
function diffDateFromCurrent(second) {
|
|
13
|
-
if (second >= 60 * 60 * 24 * 365) {
|
|
14
|
-
return `${parseInt(String(second / (60 * 60 * 24 * 365)))}\u5E74\u524D`;
|
|
15
|
-
}
|
|
16
|
-
if (second >= 60 * 60 * 24 * 30) {
|
|
17
|
-
return `${parseInt(String(second / (60 * 60 * 24 * 30)))}\u6708\u524D`;
|
|
18
|
-
}
|
|
19
|
-
if (second >= 60 * 60 * 24) {
|
|
20
|
-
return `${parseInt(String(second / (60 * 60 * 24)))}\u5929\u524D`;
|
|
21
|
-
}
|
|
22
|
-
if (second >= 60 * 60) {
|
|
23
|
-
return `${parseInt(String(second / (60 * 60)))}\u5C0F\u65F6\u524D`;
|
|
24
|
-
}
|
|
25
|
-
if (second >= 60) {
|
|
26
|
-
return `${parseInt(String(second / 60))}\u5206\u949F\u524D`;
|
|
27
|
-
}
|
|
28
|
-
return `${parseInt(String(second))}\u79D2\u524D`;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute };
|