command-center-v3-common 0.0.13 → 0.0.14
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/assets/time-utils-8BaVMoat.js +11874 -0
- package/dist/img/login-bg.jpg +0 -0
- package/dist/index.js +62653 -0
- package/dist/style/common.css +50 -0
- package/dist/style/index.js +1 -0
- package/dist/style/style.css +6585 -0
- package/dist/{index.d.ts → types/common.d.ts} +5 -5
- package/dist/types/style.d.ts +1 -0
- package/dist/types/utils.d.ts +136 -0
- package/dist/utils/index.js +4710 -0
- package/package.json +1 -1
- package/dist/box-border-demo-Dh91nJs5.js +0 -28
- package/dist/button-demo-CA60mqsh.js +0 -176
- package/dist/command-center-v3-common-BbSatiTO.js +0 -49812
- package/dist/command-center-v3-common.js +0 -17
- package/dist/command-center-v3-common.umd.cjs +0 -134
- package/dist/data-time-shortcuts-demo-DtCNlph9.js +0 -31
- package/dist/hy-table-demo-C4u4TNma.js +0 -108
- package/dist/hy-test-BMk3QduK.js +0 -186
- package/dist/image-viewer-demo-OOwssb8m.js +0 -72
- package/dist/round-button-demo-QP1t72o5.js +0 -43
- package/dist/style.css +0 -1
- package/dist/svg-icon-demo-Cjqzl51P.js +0 -36
- package/dist/test-demo-DCJjf5Cm.js +0 -46
- package/dist/tips-modal-demo-0c71esGY.js +0 -98
- package/dist/user-head-demo-C1y4pQvP.js +0 -66
- package/dist/utils/utils/EventBus.ts +0 -71
- package/dist/utils/utils/cache.ts +0 -36
- package/dist/utils/utils/is.ts +0 -102
- package/dist/utils/utils/logger.ts +0 -37
- package/dist/utils/utils/time-utils.ts +0 -145
- package/dist/utils/utils/wujie.ts +0 -6
- package/dist/vue-cropper-demo-DNrZGJ4Y.js +0 -93
@@ -1,36 +0,0 @@
|
|
1
|
-
import { resolveComponent as s, openBlock as n, createElementBlock as c, createVNode as t } from "vue";
|
2
|
-
import { b as o } from "./command-center-v3-common-BbSatiTO.js";
|
3
|
-
const a = {}, i = { class: "flex items-center justify-center gap-x-3" };
|
4
|
-
function m(r, h) {
|
5
|
-
const e = s("SvgIcon");
|
6
|
-
return n(), c("div", i, [
|
7
|
-
t(e, {
|
8
|
-
name: "sys-button-add",
|
9
|
-
width: "26",
|
10
|
-
height: "26",
|
11
|
-
"class-name": "text-hy-main"
|
12
|
-
}),
|
13
|
-
t(e, {
|
14
|
-
name: "sys-button-delete",
|
15
|
-
width: "26",
|
16
|
-
height: "26",
|
17
|
-
"class-name": "text-hy-danger"
|
18
|
-
}),
|
19
|
-
t(e, {
|
20
|
-
name: "sys-button-success",
|
21
|
-
width: "26",
|
22
|
-
height: "26",
|
23
|
-
"class-name": "text-hy-success"
|
24
|
-
}),
|
25
|
-
t(e, {
|
26
|
-
name: "sys-button-tips",
|
27
|
-
width: "26",
|
28
|
-
height: "26",
|
29
|
-
"class-name": "text-hy-warning"
|
30
|
-
})
|
31
|
-
]);
|
32
|
-
}
|
33
|
-
const _ = /* @__PURE__ */ o(a, [["render", m]]);
|
34
|
-
export {
|
35
|
-
_ as default
|
36
|
-
};
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import { resolveComponent as c, openBlock as i, createElementBlock as s, Fragment as a, createVNode as t, withCtx as e, createTextVNode as r } from "vue";
|
2
|
-
import { b as l } from "./command-center-v3-common-BbSatiTO.js";
|
3
|
-
const _ = {};
|
4
|
-
function m(p, d) {
|
5
|
-
const o = c("el-button"), n = c("el-popover");
|
6
|
-
return i(), s(a, null, [
|
7
|
-
t(n, {
|
8
|
-
placement: "top-start",
|
9
|
-
title: "Title",
|
10
|
-
width: 200,
|
11
|
-
trigger: "hover",
|
12
|
-
content: "this is content, this is content, this is content"
|
13
|
-
}, {
|
14
|
-
reference: e(() => [
|
15
|
-
t(o, { class: "m-2" }, {
|
16
|
-
default: e(() => [
|
17
|
-
r(" Hover to activate ")
|
18
|
-
]),
|
19
|
-
_: 1
|
20
|
-
})
|
21
|
-
]),
|
22
|
-
_: 1
|
23
|
-
}),
|
24
|
-
t(n, {
|
25
|
-
placement: "bottom",
|
26
|
-
title: "Title",
|
27
|
-
width: 200,
|
28
|
-
trigger: "click",
|
29
|
-
content: "this is content, this is content, this is content"
|
30
|
-
}, {
|
31
|
-
reference: e(() => [
|
32
|
-
t(o, { class: "m-2" }, {
|
33
|
-
default: e(() => [
|
34
|
-
r(" Click to activate ")
|
35
|
-
]),
|
36
|
-
_: 1
|
37
|
-
})
|
38
|
-
]),
|
39
|
-
_: 1
|
40
|
-
})
|
41
|
-
], 64);
|
42
|
-
}
|
43
|
-
const u = /* @__PURE__ */ l(_, [["render", m], ["__scopeId", "data-v-89d47af3"]]);
|
44
|
-
export {
|
45
|
-
u as default
|
46
|
-
};
|
@@ -1,98 +0,0 @@
|
|
1
|
-
import { defineComponent as p, ref as r, resolveComponent as a, openBlock as u, createElementBlock as m, Fragment as d, createElementVNode as T, createVNode as t, withCtx as s, createTextVNode as n } from "vue";
|
2
|
-
import { c as y, H as f } from "./command-center-v3-common-BbSatiTO.js";
|
3
|
-
const _ = { class: "flex items-center justify-center gap-x-3" }, w = /* @__PURE__ */ p({
|
4
|
-
__name: "tips-modal-demo",
|
5
|
-
setup(h) {
|
6
|
-
const e = r();
|
7
|
-
function i() {
|
8
|
-
f({
|
9
|
-
width: 440,
|
10
|
-
tipsTitleIcon: "sys-button-delete",
|
11
|
-
tipsTitleIconClass: "text-hy-danger",
|
12
|
-
tipsTitle: "删除",
|
13
|
-
tipsContent: "是否确认删除?",
|
14
|
-
isShowClose: !0,
|
15
|
-
isShowSubmit: !0,
|
16
|
-
closeBtnText: "取消",
|
17
|
-
submitBtnText: "删除",
|
18
|
-
closeBtnType: "primary",
|
19
|
-
submitBtnType: "danger"
|
20
|
-
}, () => {
|
21
|
-
console.log("2");
|
22
|
-
}, () => {
|
23
|
-
console.log("1");
|
24
|
-
});
|
25
|
-
}
|
26
|
-
function l() {
|
27
|
-
e.value.onShowModal({
|
28
|
-
width: 440,
|
29
|
-
tipsTitleIcon: "sys-button-delete",
|
30
|
-
tipsTitleIconClass: "text-hy-danger",
|
31
|
-
tipsTitle: "删除",
|
32
|
-
tipsContent: "是否确认删除?",
|
33
|
-
isShowClose: !0,
|
34
|
-
isShowSubmit: !0,
|
35
|
-
closeBtnText: "取消",
|
36
|
-
submitBtnText: "删除",
|
37
|
-
closeBtnType: "primary",
|
38
|
-
submitBtnType: "danger"
|
39
|
-
});
|
40
|
-
}
|
41
|
-
function c() {
|
42
|
-
e.value.onShowModal({
|
43
|
-
width: 440,
|
44
|
-
tipsTitleIcon: "sys-button-jump",
|
45
|
-
tipsTitleIconClass: "text-hy-success",
|
46
|
-
tipsTitle: "跳转",
|
47
|
-
tipsContent: "是否确认跳转?",
|
48
|
-
isShowClose: !0,
|
49
|
-
isShowSubmit: !0,
|
50
|
-
closeBtnText: "取消",
|
51
|
-
submitBtnText: "跳转",
|
52
|
-
closeBtnType: "primary",
|
53
|
-
submitBtnType: "success"
|
54
|
-
});
|
55
|
-
}
|
56
|
-
return (x, C) => {
|
57
|
-
const o = a("el-button");
|
58
|
-
return u(), m(d, null, [
|
59
|
-
T("div", _, [
|
60
|
-
t(o, {
|
61
|
-
type: "danger",
|
62
|
-
onClick: i
|
63
|
-
}, {
|
64
|
-
default: s(() => [
|
65
|
-
n(" test ")
|
66
|
-
]),
|
67
|
-
_: 1
|
68
|
-
}),
|
69
|
-
t(o, {
|
70
|
-
type: "danger",
|
71
|
-
onClick: l
|
72
|
-
}, {
|
73
|
-
default: s(() => [
|
74
|
-
n(" 删除 ")
|
75
|
-
]),
|
76
|
-
_: 1
|
77
|
-
}),
|
78
|
-
t(o, {
|
79
|
-
type: "primary",
|
80
|
-
onClick: c
|
81
|
-
}, {
|
82
|
-
default: s(() => [
|
83
|
-
n(" 跳转 ")
|
84
|
-
]),
|
85
|
-
_: 1
|
86
|
-
})
|
87
|
-
]),
|
88
|
-
t(y, {
|
89
|
-
ref_key: "tipsModalRef",
|
90
|
-
ref: e
|
91
|
-
}, null, 512)
|
92
|
-
], 64);
|
93
|
-
};
|
94
|
-
}
|
95
|
-
});
|
96
|
-
export {
|
97
|
-
w as default
|
98
|
-
};
|
@@ -1,66 +0,0 @@
|
|
1
|
-
import { defineComponent as o, ref as l, openBlock as r, createElementBlock as d, createVNode as t, normalizeStyle as n, unref as a, normalizeClass as c, withCtx as x, createElementVNode as p } from "vue";
|
2
|
-
import { e as s } from "./command-center-v3-common-BbSatiTO.js";
|
3
|
-
const h = { class: "flex items-center justify-center gap-x-3" }, y = /* @__PURE__ */ o({
|
4
|
-
__name: "user-head-demo",
|
5
|
-
setup(i) {
|
6
|
-
const e = l({
|
7
|
-
headImg: "",
|
8
|
-
audioContextType: !1,
|
9
|
-
onlineState: 1,
|
10
|
-
gbDevice: 1
|
11
|
-
});
|
12
|
-
return (m, u) => (r(), d("div", h, [
|
13
|
-
t(s, {
|
14
|
-
url: "",
|
15
|
-
"head-box-class-name": "w-[28px] h-[28px]"
|
16
|
-
}),
|
17
|
-
t(s, {
|
18
|
-
url: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
|
19
|
-
"head-box-class-name": "w-[28px] h-[28px]",
|
20
|
-
"class-name": "w-[18px] h-[18px]",
|
21
|
-
name: "user-head-demo-user"
|
22
|
-
}),
|
23
|
-
t(s, {
|
24
|
-
url: "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg",
|
25
|
-
"head-box-class-name": "w-[36px] h-[36px]",
|
26
|
-
"class-name": "w-[18px] h-[18px]"
|
27
|
-
}),
|
28
|
-
t(s, {
|
29
|
-
style: n({
|
30
|
-
background: "linear-gradient(180deg, #5A2120 0%, #C81F12 100%)",
|
31
|
-
color: "#FDE777"
|
32
|
-
}),
|
33
|
-
"gb-device": !0,
|
34
|
-
"head-box-class-name": "w-[28px] h-[28px] text-xs",
|
35
|
-
"class-name": "w-[18px] h-[18px]",
|
36
|
-
name: "user-head-demo-user"
|
37
|
-
}, null, 8, ["style"]),
|
38
|
-
t(s, {
|
39
|
-
url: a(e).headImg,
|
40
|
-
class: c({
|
41
|
-
"!border-hy-main": a(e).audioContextType,
|
42
|
-
"text-hy-text-primary": a(e).onlineState === 1 && a(e).gbDevice !== 1,
|
43
|
-
"text-hy-gb-device-text": a(e).onlineState === 1 && a(e).gbDevice === 1
|
44
|
-
}),
|
45
|
-
style: n(a(e).onlineState === 1 && a(e).gbDevice === 1 ? "background:var(--hy-gb-device-background)" : ""),
|
46
|
-
"gb-device": !0,
|
47
|
-
"head-box-class-name": "w-[60px] h-[60px] z-[1] bg-hy-page-bg-2 text-base relative",
|
48
|
-
"class-name": "w-[56%] h-[56%]",
|
49
|
-
name: "sys-icon-user-head"
|
50
|
-
}, {
|
51
|
-
content: x(() => [
|
52
|
-
p("span", {
|
53
|
-
class: c([{
|
54
|
-
"bg-hy-success shadow-hy-success": a(e).onlineState === 1,
|
55
|
-
"bg-hy-text-secondary shadow-hy-text-secondary": a(e).onlineState !== 1
|
56
|
-
}, "absolute bottom-[2px] right-[2px] w-[14px] h-[14px] rounded-full shadow-[0_0_10px_0]"])
|
57
|
-
}, null, 2)
|
58
|
-
]),
|
59
|
-
_: 1
|
60
|
-
}, 8, ["url", "class", "style"])
|
61
|
-
]));
|
62
|
-
}
|
63
|
-
});
|
64
|
-
export {
|
65
|
-
y as default
|
66
|
-
};
|
@@ -1,71 +0,0 @@
|
|
1
|
-
import WujieVue from 'wujie-vue3'
|
2
|
-
import { logger } from '@/utils/logger'
|
3
|
-
|
4
|
-
const { bus } = WujieVue
|
5
|
-
|
6
|
-
export type EventCallback = (...args: Array<any>) => any
|
7
|
-
|
8
|
-
export class EventBus {
|
9
|
-
private bus: any
|
10
|
-
private framework: string
|
11
|
-
|
12
|
-
constructor(framework?: string) {
|
13
|
-
this.framework = framework || 'wujie'
|
14
|
-
this.bus = this.initializeBus()
|
15
|
-
}
|
16
|
-
|
17
|
-
private initializeBus(): any {
|
18
|
-
switch (this.framework) {
|
19
|
-
case 'wujie':
|
20
|
-
return window.$wujie ? window.$wujie.bus : bus
|
21
|
-
// 如果未来切换到其他微前端框架,可以在这里初始化相应的 bus
|
22
|
-
case 'otherFramework':
|
23
|
-
// return window.$otherFramework?.bus;
|
24
|
-
break
|
25
|
-
default:
|
26
|
-
logger.warning('EventBus', 'init', '未检测到已识别的微前端框架')
|
27
|
-
return null
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
public on(event: string, callback: EventCallback): void {
|
32
|
-
if (!this.bus)
|
33
|
-
return logger.warning('EventBus', 'on', '没有可用于当前框架的总线')
|
34
|
-
|
35
|
-
if (typeof callback !== 'function')
|
36
|
-
return logger.error('EventBus', 'on', '回调必须是一个函数')
|
37
|
-
|
38
|
-
this.bus.$on(event, callback)
|
39
|
-
}
|
40
|
-
|
41
|
-
public once(event: string, callback: EventCallback): void {
|
42
|
-
if (!this.bus)
|
43
|
-
return logger.warning('EventBus', 'once', '没有可用于当前框架的总线')
|
44
|
-
|
45
|
-
if (typeof callback !== 'function')
|
46
|
-
return logger.error('EventBus', 'once', '回调必须是一个函数')
|
47
|
-
|
48
|
-
this.bus.$once(event, callback)
|
49
|
-
}
|
50
|
-
|
51
|
-
public emit(event: string, ...args: any[]): void {
|
52
|
-
if (!this.bus)
|
53
|
-
return logger.warning('EventBus', 'emit', '没有可用于当前框架的总线')
|
54
|
-
|
55
|
-
this.bus.$emit(event, ...args)
|
56
|
-
}
|
57
|
-
|
58
|
-
public off(event: string, callback: EventCallback): void {
|
59
|
-
if (!this.bus)
|
60
|
-
return logger.warning('EventBus', 'off', '没有可用于当前框架的总线')
|
61
|
-
|
62
|
-
this.bus.$off(event, callback)
|
63
|
-
}
|
64
|
-
|
65
|
-
public clear(): void {
|
66
|
-
if (!this.bus)
|
67
|
-
return logger.warning('EventBus', 'clear', '没有可用于当前框架的总线')
|
68
|
-
|
69
|
-
this.bus.$clear()
|
70
|
-
}
|
71
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
enum CacheType {
|
2
|
-
Local,
|
3
|
-
Session
|
4
|
-
}
|
5
|
-
|
6
|
-
class Cache {
|
7
|
-
storage: Storage
|
8
|
-
|
9
|
-
constructor(type: CacheType) {
|
10
|
-
this.storage = type === CacheType.Local ? localStorage : sessionStorage
|
11
|
-
}
|
12
|
-
|
13
|
-
setCache(key: string, value: any) {
|
14
|
-
if (value)
|
15
|
-
this.storage.setItem(key, JSON.stringify(value))
|
16
|
-
}
|
17
|
-
|
18
|
-
getCache(key: string) {
|
19
|
-
const value = this.storage.getItem(key)
|
20
|
-
if (value)
|
21
|
-
return JSON.parse(value)
|
22
|
-
}
|
23
|
-
|
24
|
-
removeCache(key: string) {
|
25
|
-
this.storage.removeItem(key)
|
26
|
-
}
|
27
|
-
|
28
|
-
clear() {
|
29
|
-
this.storage.clear()
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
const localCache = new Cache(CacheType.Local)
|
34
|
-
const sessionCache = new Cache(CacheType.Session)
|
35
|
-
|
36
|
-
export { localCache, sessionCache }
|
package/dist/utils/utils/is.ts
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
const toString = Object.prototype.toString
|
2
|
-
|
3
|
-
export function is(val: unknown, type: string) {
|
4
|
-
return toString.call(val) === `[object ${type}]`
|
5
|
-
}
|
6
|
-
|
7
|
-
export function isDef<T = unknown>(val?: T): val is T {
|
8
|
-
return typeof val !== 'undefined'
|
9
|
-
}
|
10
|
-
|
11
|
-
export function isUnDef<T = unknown>(val?: T): val is T {
|
12
|
-
return !isDef(val)
|
13
|
-
}
|
14
|
-
|
15
|
-
export function isObject(val: any): val is Record<any, any> {
|
16
|
-
return val !== null && is(val, 'Object')
|
17
|
-
}
|
18
|
-
|
19
|
-
export function isEmpty<T = unknown>(val: T): val is T {
|
20
|
-
if (isArray(val) || isString(val))
|
21
|
-
return val.length === 0
|
22
|
-
|
23
|
-
if (val instanceof Map || val instanceof Set)
|
24
|
-
return val.size === 0
|
25
|
-
|
26
|
-
if (isObject(val))
|
27
|
-
return Object.keys(val).length === 0
|
28
|
-
|
29
|
-
return false
|
30
|
-
}
|
31
|
-
|
32
|
-
export function isDate(val: unknown): val is Date {
|
33
|
-
return is(val, 'Date')
|
34
|
-
}
|
35
|
-
|
36
|
-
export function isNull(val: unknown): val is null {
|
37
|
-
return val === null
|
38
|
-
}
|
39
|
-
|
40
|
-
export function isNullAndUnDef(val: unknown): val is null | undefined {
|
41
|
-
return isUnDef(val) && isNull(val)
|
42
|
-
}
|
43
|
-
|
44
|
-
export function isNullOrUnDef(val: unknown): val is null | undefined {
|
45
|
-
return isUnDef(val) || isNull(val)
|
46
|
-
}
|
47
|
-
|
48
|
-
export function isNumber(val: unknown): val is number {
|
49
|
-
return is(val, 'Number')
|
50
|
-
}
|
51
|
-
|
52
|
-
export function isPromise<T = any>(val: unknown): val is Promise<T> {
|
53
|
-
return (
|
54
|
-
is(val, 'Promise')
|
55
|
-
&& isObject(val)
|
56
|
-
&& isFunction(val.then)
|
57
|
-
&& isFunction(val.catch)
|
58
|
-
)
|
59
|
-
}
|
60
|
-
|
61
|
-
export function isString(val: unknown): val is string {
|
62
|
-
return is(val, 'String')
|
63
|
-
}
|
64
|
-
|
65
|
-
export function isFunction(val: unknown): val is Function {
|
66
|
-
return typeof val === 'function'
|
67
|
-
}
|
68
|
-
|
69
|
-
export function isBoolean(val: unknown): val is boolean {
|
70
|
-
return is(val, 'Boolean')
|
71
|
-
}
|
72
|
-
|
73
|
-
export function isRegExp(val: unknown): val is RegExp {
|
74
|
-
return is(val, 'RegExp')
|
75
|
-
}
|
76
|
-
|
77
|
-
export function isArray(val: any): val is Array<any> {
|
78
|
-
return val && Array.isArray(val)
|
79
|
-
}
|
80
|
-
|
81
|
-
export function isWindow(val: any): val is Window {
|
82
|
-
return typeof window !== 'undefined' && is(val, 'Window')
|
83
|
-
}
|
84
|
-
|
85
|
-
export function isElement(val: unknown): val is Element {
|
86
|
-
return isObject(val) && !!val.tagName
|
87
|
-
}
|
88
|
-
|
89
|
-
export function isMap(val: unknown): val is Map<any, any> {
|
90
|
-
return is(val, 'Map')
|
91
|
-
}
|
92
|
-
|
93
|
-
export const isServer = typeof window === 'undefined'
|
94
|
-
|
95
|
-
export const isClient = !isServer
|
96
|
-
|
97
|
-
export function isValidKey(
|
98
|
-
key: string | number | symbol,
|
99
|
-
object: object
|
100
|
-
): key is keyof typeof object {
|
101
|
-
return key in object
|
102
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
import debug from 'debug'
|
2
|
-
|
3
|
-
type Color = 'primary' | 'success' | 'info' | 'warning' | 'danger' | 'error'
|
4
|
-
|
5
|
-
const colorList: Color[] = ['primary', 'success', 'info', 'warning', 'danger', 'error']
|
6
|
-
|
7
|
-
const colorMap: Record<Color, string> = {
|
8
|
-
primary: '#2d8cf0',
|
9
|
-
success: '#19be6b',
|
10
|
-
info: '#909399',
|
11
|
-
warning: '#ff9900',
|
12
|
-
danger: '#35495E',
|
13
|
-
error: '#FF0000'
|
14
|
-
}
|
15
|
-
|
16
|
-
const getColor = (type: Color) => colorMap[type]
|
17
|
-
|
18
|
-
function createLog<T extends any[]>(fn: (type: Color, ...args: T) => void): Record<Color, (...args: T) => void> {
|
19
|
-
return colorList.reduce((logs, type) => {
|
20
|
-
logs[type] = (...args: T) => fn(type, ...args)
|
21
|
-
return logs
|
22
|
-
}, {} as Record<Color, (...args: T) => void>)
|
23
|
-
}
|
24
|
-
|
25
|
-
function initLog(type: Color, model: string, ns: string, msg: string, ...args: any[]) {
|
26
|
-
const color = getColor(type)
|
27
|
-
const logger = debug(model)
|
28
|
-
const config = `%c ${ns} %c ${msg} %c ${args.length ? '%o' : ''}`
|
29
|
-
const title = `background:${color};border:1px solid ${color}; padding: 1px; border-radius: 4px 0 0 4px; color: #fff;`
|
30
|
-
const content = `border:1px solid ${color}; padding: 1px; border-radius: 0 4px 4px 0; color: ${color};`
|
31
|
-
const joinColor = 'background:transparent'
|
32
|
-
|
33
|
-
logger(config, title, content, joinColor, ...args)
|
34
|
-
localStorage.debug = `${model}*`
|
35
|
-
}
|
36
|
-
|
37
|
-
export const logger = createLog(initLog)
|
@@ -1,145 +0,0 @@
|
|
1
|
-
import { getI18n } from '@/lang'
|
2
|
-
|
3
|
-
const { t } = getI18n().global
|
4
|
-
|
5
|
-
/**
|
6
|
-
* 获取当天日期
|
7
|
-
* @param cutOff 分隔号
|
8
|
-
* @returns {string}
|
9
|
-
*/
|
10
|
-
export function getToday(cutOff: string = '-'): string {
|
11
|
-
const dateObj = new Date()
|
12
|
-
return formatDay(dateObj).join(cutOff)
|
13
|
-
}
|
14
|
-
|
15
|
-
/**
|
16
|
-
* 获取传入日期的过后几天日期数组
|
17
|
-
* @param today
|
18
|
-
* @param daysCount
|
19
|
-
* @param cutOff
|
20
|
-
* @returns {string[]}
|
21
|
-
*/
|
22
|
-
export function getNextDays({ today, daysCount, cutOff = '-' }: { today?: string, daysCount: number, cutOff?: string }): string[] {
|
23
|
-
if (!today)
|
24
|
-
today = getToday('/')
|
25
|
-
|
26
|
-
const dateObj = new Date(today)
|
27
|
-
const arr = [formatDay(dateObj).join(cutOff)]
|
28
|
-
for (let i = 0; i < daysCount; i++) {
|
29
|
-
const days = dateObj.setDate(dateObj.getDate() + 1)
|
30
|
-
arr.push(formatDay(new Date(days)).join(cutOff))
|
31
|
-
}
|
32
|
-
return arr
|
33
|
-
}
|
34
|
-
|
35
|
-
/**
|
36
|
-
* 获取传入日期的前几天日期数组
|
37
|
-
* @param today
|
38
|
-
* @param daysCount
|
39
|
-
* @param cutOff
|
40
|
-
* @returns {string[]}
|
41
|
-
*/
|
42
|
-
export function getBeforeDays({ today, daysCount, cutOff = '-' }: { today?: string, daysCount: number, cutOff?: string }): string[] {
|
43
|
-
if (!today)
|
44
|
-
today = getToday('/')
|
45
|
-
|
46
|
-
const dateObj = new Date(today)
|
47
|
-
const arr = [formatDay(dateObj).join(cutOff)]
|
48
|
-
for (let i = 0; i < daysCount; i++) {
|
49
|
-
const days = dateObj.setDate(dateObj.getDate() - 1)
|
50
|
-
arr.push(formatDay(new Date(days)).join(cutOff))
|
51
|
-
}
|
52
|
-
return arr
|
53
|
-
}
|
54
|
-
|
55
|
-
/**
|
56
|
-
* 传入date对象 返回格式化后的数组
|
57
|
-
* @param dateObj
|
58
|
-
* @returns {[number, number, number]}
|
59
|
-
*/
|
60
|
-
export function formatDay(dateObj: Date): [number, number, number] {
|
61
|
-
const year = dateObj.getFullYear()
|
62
|
-
const month = dateObj.getMonth() + 1
|
63
|
-
const date = dateObj.getDate()
|
64
|
-
return [year, month, date]
|
65
|
-
}
|
66
|
-
|
67
|
-
export function formatTime(dateObj: Date): string[] {
|
68
|
-
const h = dateObj.getHours()
|
69
|
-
let m: string | number = dateObj.getMinutes()
|
70
|
-
let s: string | number = dateObj.getSeconds()
|
71
|
-
if (m < 10)
|
72
|
-
m = `0${m}`
|
73
|
-
if (s < 10)
|
74
|
-
s = `0${s}`
|
75
|
-
|
76
|
-
return [h, m, s].map(String)
|
77
|
-
}
|
78
|
-
|
79
|
-
export function getCurDtm(cutOff: string = '-'): string {
|
80
|
-
return `${getToday(cutOff)} ${this.formatTime(new Date()).join(':')}`
|
81
|
-
}
|
82
|
-
|
83
|
-
/**
|
84
|
-
* 传入秒数 返回时分秒
|
85
|
-
* @param value
|
86
|
-
* @returns {string}
|
87
|
-
*/
|
88
|
-
export function formatSeconds(value: number): string {
|
89
|
-
let theTime = Math.floor(value) // 秒
|
90
|
-
let middle = 0 // 分
|
91
|
-
let hour = 0 // 小时
|
92
|
-
|
93
|
-
if (theTime > 60) {
|
94
|
-
middle = Math.floor(theTime / 60)
|
95
|
-
theTime = theTime % 60
|
96
|
-
if (middle > 60) {
|
97
|
-
hour = Math.floor(middle / 60)
|
98
|
-
middle = middle % 60
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
let result = theTime < 10 ? `00:0${theTime}` : `00:${theTime}`
|
103
|
-
if (middle > 0)
|
104
|
-
result = middle < 10 ? `0${middle}:${result}` : `${middle}:${result}`
|
105
|
-
|
106
|
-
if (hour > 0)
|
107
|
-
result = `${hour}:${result}`
|
108
|
-
|
109
|
-
return result
|
110
|
-
}
|
111
|
-
|
112
|
-
// 转化时间
|
113
|
-
export function formatTimeFn(number: number, format: string): string {
|
114
|
-
const time = new Date(number)
|
115
|
-
const newArr = []
|
116
|
-
const formatArr = ['Y', 'M', 'D', 'day', 'h', 'm', 's']
|
117
|
-
const arrWeek = [
|
118
|
-
t('sunday'),
|
119
|
-
t('monday'),
|
120
|
-
t('tuesday'),
|
121
|
-
t('wednesday'),
|
122
|
-
t('thursday'),
|
123
|
-
t('sundayFriday'),
|
124
|
-
t('saturday')
|
125
|
-
]
|
126
|
-
|
127
|
-
const formatNumber = (n) => {
|
128
|
-
n = n.toString()
|
129
|
-
return n[1] ? n : `0${n}`
|
130
|
-
}
|
131
|
-
|
132
|
-
newArr.push(time.getFullYear())
|
133
|
-
newArr.push(formatNumber(time.getMonth() + 1))
|
134
|
-
newArr.push(formatNumber(time.getHours()))
|
135
|
-
newArr.push(arrWeek[time.getDay()])
|
136
|
-
newArr.push(formatNumber(time.getDate()))
|
137
|
-
newArr.push(formatNumber(time.getMinutes()))
|
138
|
-
newArr.push(formatNumber(time.getSeconds()))
|
139
|
-
newArr.push(formatNumber(time.getDay()))
|
140
|
-
|
141
|
-
for (const i in newArr)
|
142
|
-
format = format.replace(formatArr[i], newArr[i])
|
143
|
-
|
144
|
-
return format
|
145
|
-
}
|