bfg-common 1.5.238 → 1.5.239
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.
|
@@ -105,9 +105,7 @@ watch(
|
|
|
105
105
|
const headItems = computed<UI_I_HeadItem[]>(() =>
|
|
106
106
|
table[props.type].headItems(localization.value)
|
|
107
107
|
)
|
|
108
|
-
const columnKeys = computed<UI_I_ColumnKey[]>(()
|
|
109
|
-
table[props.type].columnKeys(localization.value)
|
|
110
|
-
)
|
|
108
|
+
const columnKeys = computed<UI_I_ColumnKey[]>(table[props.type].columnKeys(localization.value))
|
|
111
109
|
watch(localization, () => {
|
|
112
110
|
columnKeys.value = table[props.type].columnKeys(localization.value)
|
|
113
111
|
})
|
package/package.json
CHANGED
package/plugins/cron.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from '#app'
|
|
2
|
+
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
3
|
+
|
|
4
|
+
export default defineNuxtPlugin(() => {
|
|
5
|
+
const cron = function (): any {
|
|
6
|
+
const self: any = {}
|
|
7
|
+
|
|
8
|
+
self.cronToHumanReadable = (
|
|
9
|
+
cronString: string,
|
|
10
|
+
localization: UI_I_Localization
|
|
11
|
+
): string => {
|
|
12
|
+
const [minutes, hours, , , daysString] = cronString.split(' ')
|
|
13
|
+
|
|
14
|
+
const daysMap = {
|
|
15
|
+
0: localization.sundays,
|
|
16
|
+
1: localization.mondays,
|
|
17
|
+
2: localization.tuesdays,
|
|
18
|
+
3: localization.wednesdays,
|
|
19
|
+
4: localization.thursdays,
|
|
20
|
+
5: localization.fridays,
|
|
21
|
+
6: localization.saturdays,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let days = localization.everyDay
|
|
25
|
+
if (daysString !== '*') {
|
|
26
|
+
const daysArray = daysString
|
|
27
|
+
.split(',')
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
.map((day: number) => daysMap[day])
|
|
30
|
+
days = `${localization.on2} ${daysArray.join(', ')}`
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Формирование строки времени
|
|
34
|
+
const time = `${String(hours).padStart(2, '0')}:${String(
|
|
35
|
+
minutes
|
|
36
|
+
).padStart(2, '0')}`
|
|
37
|
+
|
|
38
|
+
return `${days} ${localization.in} ${time}`
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
self.decodeCron = (cronString: string): any => {
|
|
42
|
+
const [minutes, hours, , , daysString] = cronString.split(' ')
|
|
43
|
+
|
|
44
|
+
const days =
|
|
45
|
+
daysString === '*'
|
|
46
|
+
? [0, 1, 2, 3, 4, 5, 6]
|
|
47
|
+
: daysString.split(',').map(Number)
|
|
48
|
+
|
|
49
|
+
const h = hours === '*' ? '00' : String(hours).padStart(2, '0')
|
|
50
|
+
const m = minutes === '*' ? '00' : String(minutes).padStart(2, '0')
|
|
51
|
+
const time = `${h}:${m}`
|
|
52
|
+
|
|
53
|
+
return [
|
|
54
|
+
days,
|
|
55
|
+
time,
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
self.encodeCron = (days: number[], time: string): string => {
|
|
60
|
+
const { 0: hours, 1: minutes } = time.split(':').map(Number)
|
|
61
|
+
|
|
62
|
+
const daysString = days.length === 7 ? '*' : days.join(',')
|
|
63
|
+
|
|
64
|
+
return `${minutes} ${hours} * * ${daysString}`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return self
|
|
68
|
+
}.call({})
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
provide: {
|
|
72
|
+
cron,
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
})
|