@epxing/utils 0.0.0-stage → 5.3.0-beta.1
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/API.md +602 -0
- package/README.md +22 -2
- package/dist/_vendor/.pnpm/jsencrypt@3.5.4/_vendor/jsencrypt/bin/jsencrypt.min.js +1691 -0
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/jsencrypt.min.js +31 -0
- package/dist/_virtual/jsencrypt.min2.js +4 -0
- package/dist/_virtual/preload-helper.js +88 -0
- package/dist/assets/ai-BBFn3QRy.png +0 -0
- package/dist/assets/ai_import-BxQ7Ohn6.png +0 -0
- package/dist/assets/app-DBNIokDP.png +0 -0
- package/dist/assets/approval-DGcBv-re.png +0 -0
- package/dist/assets/create_market_system-BH__UVbt.png +0 -0
- package/dist/assets/create_system-irg--ePh.png +0 -0
- package/dist/assets/custom-C-ujlHz1.png +0 -0
- package/dist/assets/default-icon-2193FMjv.png +0 -0
- package/dist/assets/ex_link-4fYPd9nh.png +0 -0
- package/dist/assets/excel-BYqRm2Y8.png +0 -0
- package/dist/assets/folder-CFVsNbjj.png +0 -0
- package/dist/assets/form-DD9HV-jN.png +0 -0
- package/dist/assets/import-tfKWbWVS.png +0 -0
- package/dist/assets/meta-Qorpi70B.png +0 -0
- package/dist/assets/module-DQrs7VAS.png +0 -0
- package/dist/assets/null-B2An29h4.png +0 -0
- package/dist/assets/option-CG02tIgh.svg +1 -0
- package/dist/assets/photo-uscRzRXF.png +0 -0
- package/dist/assets/process-Dcndu9m2.png +0 -0
- package/dist/assets/rule-DcYhYse0.png +0 -0
- package/dist/assets/service-CLYLpPl3.png +0 -0
- package/dist/assets/single_file-B3TJtJli.png +0 -0
- package/dist/assets/snapshot-history-BsVY9cVj.png +0 -0
- package/dist/assets/snapshot-manual-DBRfFHYI.png +0 -0
- package/dist/assets/snapshot-realtime-DjHnJI6C.png +0 -0
- package/dist/assets/staff-Bn_-_00l.png +0 -0
- package/dist/assets/sync_append-Bm8mtvZs.png +0 -0
- package/dist/assets/sync_append_update-DzjxqJ_U.png +0 -0
- package/dist/assets/sync_loading-D7LoNPFP.png +0 -0
- package/dist/assets/sync_replace-Cbbzz327.png +0 -0
- package/dist/assets/sync_update-Birao6Cr.png +0 -0
- package/dist/assets/userRole-D1LAdM6N.png +0 -0
- package/dist/assets/user_bg-BFHtaZjz.png +0 -0
- package/dist/src/Config.js +25 -0
- package/dist/src/asset-images.js +125 -0
- package/dist/src/assets/images/add.png.js +4 -0
- package/dist/src/assets/images/ai-button.png.js +4 -0
- package/dist/src/assets/images/ai.png.js +4 -0
- package/dist/src/assets/images/ai_import.png.js +4 -0
- package/dist/src/assets/images/app.png.js +4 -0
- package/dist/src/assets/images/approval.png.js +4 -0
- package/dist/src/assets/images/book.png.js +4 -0
- package/dist/src/assets/images/canvas-editor/alignment.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/arrow-left.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/arrow-right.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/block.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/bold.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/catalog.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/center.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/checkbox.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/close.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/codeblock.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/color.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/control.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/date.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/exit-fullscreen.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/format.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/highlight.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/hyperlink.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/image.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/italic.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/justify.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/latex.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/left.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/line-dash-dot-dot.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/line-dash-dot.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/line-dash-large-gap.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/line-dash-small-gap.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/line-dot.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/line-double.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/line-single.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/line-wavy.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/list.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/option.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/page-break.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/page-mode.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/page-scale-add.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/page-scale-minus.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/painter.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/paper-direction.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/paper-margin.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/paper-size.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/print.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/radio.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/redo.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/request-fullscreen.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/right.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/row-margin.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/search.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/separator.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/signature-undo.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/signature.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/size-add.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/size-minus.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/strikeout.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/subscript.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/superscript.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/table.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/title.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/trash.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/underline.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/undo.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/watermark.svg.js +4 -0
- package/dist/src/assets/images/canvas-editor/word-tool.svg.js +4 -0
- package/dist/src/assets/images/clear.png.js +4 -0
- package/dist/src/assets/images/create_market_system.png.js +4 -0
- package/dist/src/assets/images/create_system.png.js +4 -0
- package/dist/src/assets/images/custom.png.js +4 -0
- package/dist/src/assets/images/default-icon.png.js +4 -0
- package/dist/src/assets/images/ex_link.png.js +4 -0
- package/dist/src/assets/images/excel.png.js +4 -0
- package/dist/src/assets/images/file.png.js +4 -0
- package/dist/src/assets/images/folder.png.js +4 -0
- package/dist/src/assets/images/hall/form.png.js +4 -0
- package/dist/src/assets/images/hall/meta.png.js +4 -0
- package/dist/src/assets/images/hall/process.png.js +4 -0
- package/dist/src/assets/images/hall/rule.png.js +4 -0
- package/dist/src/assets/images/hall/service.png.js +4 -0
- package/dist/src/assets/images/hall/userRole.png.js +4 -0
- package/dist/src/assets/images/hr.png.js +4 -0
- package/dist/src/assets/images/import.png.js +4 -0
- package/dist/src/assets/images/jian.png.js +4 -0
- package/dist/src/assets/images/module.png.js +4 -0
- package/dist/src/assets/images/null.png.js +4 -0
- package/dist/src/assets/images/photo.png.js +4 -0
- package/dist/src/assets/images/qq.png.js +4 -0
- package/dist/src/assets/images/robot.png.js +4 -0
- package/dist/src/assets/images/single_file.png.js +4 -0
- package/dist/src/assets/images/snapshot-history.png.js +4 -0
- package/dist/src/assets/images/snapshot-manual.png.js +4 -0
- package/dist/src/assets/images/snapshot-realtime.png.js +4 -0
- package/dist/src/assets/images/staff.png.js +4 -0
- package/dist/src/assets/images/switch_app.png.js +4 -0
- package/dist/src/assets/images/sync_append.png.js +4 -0
- package/dist/src/assets/images/sync_append_update.png.js +4 -0
- package/dist/src/assets/images/sync_loading.png.js +4 -0
- package/dist/src/assets/images/sync_replace.png.js +4 -0
- package/dist/src/assets/images/sync_update.png.js +4 -0
- package/dist/src/assets/images/user_bg.png.js +4 -0
- package/dist/src/assets/images/weixin.png.js +4 -0
- package/dist/src/chart-config-update.js +17 -0
- package/dist/src/chart-data-adapters.js +112 -0
- package/dist/src/chart-option-override.js +128 -0
- package/dist/src/chart-option-paths.js +64 -0
- package/dist/src/chart-registry.js +46 -0
- package/dist/src/chart-render-host.js +57 -0
- package/dist/src/chart-request-broker.js +176 -0
- package/dist/src/chartTheme.js +683 -0
- package/dist/src/collection.js +25 -0
- package/dist/src/date-helper.js +60 -0
- package/dist/src/dom-helper.js +22 -0
- package/dist/src/eval-with.js +14 -0
- package/dist/src/fieldFactory.js +5 -0
- package/dist/src/formula.js +365 -0
- package/dist/src/hljs-lite.js +29 -0
- package/dist/src/index.js +24 -0
- package/dist/src/lazy-jsencrypt.js +13 -0
- package/dist/src/legacy.js +25 -0
- package/dist/src/locale.js +88 -0
- package/dist/src/menu-open.js +43 -0
- package/dist/src/mermaid.js +79 -0
- package/dist/src/meta.js +4 -0
- package/dist/src/mobile-chart-appearance.js +148 -0
- package/dist/src/moment-compat.js +558 -0
- package/dist/src/nav-history.js +184 -0
- package/dist/src/page.js +116 -0
- package/dist/src/pdf.viewer.js +4 -0
- package/dist/src/placeholder.js +64 -0
- package/dist/src/public.js +49 -0
- package/dist/src/security.js +26 -0
- package/dist/src/storage.js +107 -0
- package/dist/src/token-storage.js +108 -0
- package/dist/src/util.js +4 -0
- package/package.json +109 -3
- package/src/Config.js +25 -0
- package/src/asset-images.js +16 -0
- package/src/chart-config-update.js +16 -0
- package/src/chart-data-adapters.js +106 -0
- package/src/chart-option-override.js +126 -0
- package/src/chart-option-paths.js +63 -0
- package/src/chart-registry.js +41 -0
- package/src/chart-render-host.js +56 -0
- package/src/chart-request-broker.js +171 -0
- package/src/chartTheme.js +711 -0
- package/src/collection.js +28 -0
- package/src/date-helper.js +72 -0
- package/src/dom-helper.js +26 -0
- package/src/eval-with.js +21 -0
- package/src/fieldFactory.js +3 -0
- package/src/formula.js +362 -0
- package/src/hljs-lite.js +41 -0
- package/src/index.js +2 -0
- package/src/lazy-jsencrypt.js +36 -0
- package/src/legacy.js +29 -0
- package/src/locale.js +104 -0
- package/src/menu-open.js +72 -0
- package/src/mermaid.js +115 -0
- package/src/meta.js +2 -0
- package/src/mobile-chart-appearance.js +147 -0
- package/src/moment-compat.d.ts +91 -0
- package/src/moment-compat.js +744 -0
- package/src/nav-history.js +274 -0
- package/src/page.js +129 -0
- package/src/pdf.viewer.js +2 -0
- package/src/placeholder.js +107 -0
- package/src/public.js +11 -0
- package/src/security.js +29 -0
- package/src/storage.js +135 -0
- package/src/token-storage.js +120 -0
- package/src/util.js +2 -0
- package/types/Config.d.ts +4 -0
- package/types/collection.d.ts +40 -0
- package/types/date-helper.d.ts +11 -0
- package/types/date-time.d.ts +2 -0
- package/types/date.d.ts +1 -0
- package/types/dom-helper.d.ts +3 -0
- package/types/dom.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/moment-compat.d.ts +91 -0
- package/types/page.d.ts +56 -0
- package/types/placeholder.d.ts +42 -0
- package/types/public.d.ts +10 -0
- package/types/storage.d.ts +31 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import storage from './storage'
|
|
2
|
+
|
|
3
|
+
const memoryTokens = Object.create(null)
|
|
4
|
+
const memoryOnlyTokens = Object.create(null)
|
|
5
|
+
let urlTokenConsumed = false
|
|
6
|
+
|
|
7
|
+
const tokenTimes = token => {
|
|
8
|
+
try {
|
|
9
|
+
const encodedPayload = token.split('.')[1]
|
|
10
|
+
if (!encodedPayload) return null
|
|
11
|
+
const base64 = encodedPayload.replace(/-/g, '+').replace(/_/g, '/')
|
|
12
|
+
const padding = '='.repeat((4 - base64.length % 4) % 4)
|
|
13
|
+
const claims = JSON.parse(window.atob(base64 + padding))
|
|
14
|
+
return {
|
|
15
|
+
issuedAt: Number(claims.iat) || 0,
|
|
16
|
+
expiresAt: Number(claims.exp) || 0
|
|
17
|
+
}
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const preferCandidateToken = (candidate, current) => {
|
|
24
|
+
if (!candidate || candidate === current) return false
|
|
25
|
+
if (!current) return true
|
|
26
|
+
const candidateTimes = tokenTimes(candidate)
|
|
27
|
+
const currentTimes = tokenTimes(current)
|
|
28
|
+
if (!candidateTimes || !currentTimes) return false
|
|
29
|
+
const now = Math.floor(Date.now() / 1000)
|
|
30
|
+
const candidateValid = !candidateTimes.expiresAt || candidateTimes.expiresAt > now
|
|
31
|
+
const currentValid = !currentTimes.expiresAt || currentTimes.expiresAt > now
|
|
32
|
+
if (candidateValid !== currentValid) return candidateValid
|
|
33
|
+
if (candidateTimes.issuedAt !== currentTimes.issuedAt) {
|
|
34
|
+
return candidateTimes.issuedAt > currentTimes.issuedAt
|
|
35
|
+
}
|
|
36
|
+
return candidateTimes.expiresAt > currentTimes.expiresAt
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const getUrlParam = (name, path) => {
|
|
40
|
+
const query = (path || '').split('?').slice(1).join('?')
|
|
41
|
+
if (!query) return ''
|
|
42
|
+
const item = query.split('&').find(part => part.split('=')[0] === name)
|
|
43
|
+
if (!item) return ''
|
|
44
|
+
const value = item.split('=').slice(1).join('=')
|
|
45
|
+
try {
|
|
46
|
+
return decodeURIComponent(value)
|
|
47
|
+
} catch (error) {
|
|
48
|
+
return value
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const removeTokenParams = path => {
|
|
53
|
+
const parts = path.split('?')
|
|
54
|
+
if (parts.length < 2) return path
|
|
55
|
+
const query = parts.slice(1).join('?').split('&').filter(item => {
|
|
56
|
+
const name = item.split('=')[0]
|
|
57
|
+
return name !== 'token' && name !== '_token'
|
|
58
|
+
})
|
|
59
|
+
return parts[0] + (query.length ? '?' + query.join('&') : '')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const clearUrlTokenParams = () => {
|
|
63
|
+
const search = removeTokenParams(window.location.search)
|
|
64
|
+
const hash = removeTokenParams(window.location.hash)
|
|
65
|
+
const url = window.location.pathname + search + hash
|
|
66
|
+
try {
|
|
67
|
+
window.history.replaceState(window.history.state, document.title, url)
|
|
68
|
+
} catch (error) {
|
|
69
|
+
// 受限 iframe 可能禁止改写历史记录;模块级标记仍能保证 URL Token 只消费一次。
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const getStoredToken = storageKey => {
|
|
74
|
+
const token = storage.get(storageKey) || ''
|
|
75
|
+
if (token) {
|
|
76
|
+
memoryTokens[storageKey] = token
|
|
77
|
+
delete memoryOnlyTokens[storageKey]
|
|
78
|
+
return token
|
|
79
|
+
}
|
|
80
|
+
if (memoryOnlyTokens[storageKey]) return memoryTokens[storageKey] || ''
|
|
81
|
+
delete memoryTokens[storageKey]
|
|
82
|
+
return ''
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const setStoredToken = (storageKey, token) => {
|
|
86
|
+
if (!token) return
|
|
87
|
+
memoryTokens[storageKey] = token
|
|
88
|
+
let persisted = storage.set(storageKey, token)
|
|
89
|
+
if (persisted === undefined) {
|
|
90
|
+
persisted = storage.set(storageKey, token, { session: true })
|
|
91
|
+
}
|
|
92
|
+
if (persisted === undefined) memoryOnlyTokens[storageKey] = true
|
|
93
|
+
else delete memoryOnlyTokens[storageKey]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export const removeStoredToken = storageKey => {
|
|
97
|
+
delete memoryTokens[storageKey]
|
|
98
|
+
delete memoryOnlyTokens[storageKey]
|
|
99
|
+
storage.remove(storageKey)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const consumeUrlToken = storageKey => {
|
|
103
|
+
const storedToken = getStoredToken(storageKey)
|
|
104
|
+
if (urlTokenConsumed || !storageKey) return storedToken
|
|
105
|
+
const urlToken = (
|
|
106
|
+
getUrlParam('_token', window.location.hash) ||
|
|
107
|
+
getUrlParam('token', window.location.hash) ||
|
|
108
|
+
getUrlParam('_token', window.location.search) ||
|
|
109
|
+
getUrlParam('token', window.location.search)
|
|
110
|
+
).replace(/^Bearer\s+/i, '').trim()
|
|
111
|
+
if (!urlToken) return storedToken
|
|
112
|
+
|
|
113
|
+
urlTokenConsumed = true
|
|
114
|
+
if (preferCandidateToken(urlToken, storedToken)) {
|
|
115
|
+
setStoredToken(storageKey, urlToken)
|
|
116
|
+
}
|
|
117
|
+
clearUrlTokenParams()
|
|
118
|
+
|
|
119
|
+
return getStoredToken(storageKey)
|
|
120
|
+
}
|
package/src/util.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** @type {<T>(value: T) => T} */
|
|
2
|
+
export const cloneDeep: <T>(value: T) => T;
|
|
3
|
+
/** @type {(value: unknown) => value is null | undefined} */
|
|
4
|
+
export const isNil: (value: unknown) => value is null | undefined;
|
|
5
|
+
/** @type {(value: unknown) => boolean} */
|
|
6
|
+
export const isEmpty: (value: unknown) => boolean;
|
|
7
|
+
/** @type {(value: unknown) => value is object} */
|
|
8
|
+
export const isObject: (value: unknown) => value is object;
|
|
9
|
+
/** @type {(value: unknown, other: unknown) => boolean} */
|
|
10
|
+
export const isEqual: (value: unknown, other: unknown) => boolean;
|
|
11
|
+
/** @type {<T extends object>(object: T, ...sources: any[]) => T} */
|
|
12
|
+
export const assignWith: <T extends object>(object: T, ...sources: any[]) => T;
|
|
13
|
+
/** @type {<T extends (...args: any[]) => any>(func: T, wait?: number, options?: { leading?: boolean, trailing?: boolean, maxWait?: number }) => T & { cancel(): void, flush(): ReturnType<T> | undefined }} */
|
|
14
|
+
export const debounce: <T extends (...args: any[]) => any>(func: T, wait?: number, options?: {
|
|
15
|
+
leading?: boolean;
|
|
16
|
+
trailing?: boolean;
|
|
17
|
+
maxWait?: number;
|
|
18
|
+
}) => T & {
|
|
19
|
+
cancel(): void;
|
|
20
|
+
flush(): ReturnType<T> | undefined;
|
|
21
|
+
};
|
|
22
|
+
/** @type {typeof debounce} */
|
|
23
|
+
export const throttle: typeof debounce;
|
|
24
|
+
/** @type {(object: unknown, path: string | (string | number)[], defaultValue?: any) => any} */
|
|
25
|
+
export const get: (object: unknown, path: string | (string | number)[], defaultValue?: any) => any;
|
|
26
|
+
/** @type {<T extends object>(object: T, path: string | (string | number)[], value: any) => T} */
|
|
27
|
+
export const set: <T extends object>(object: T, path: string | (string | number)[], value: any) => T;
|
|
28
|
+
declare namespace _default {
|
|
29
|
+
export { cloneDeep };
|
|
30
|
+
export { isNil };
|
|
31
|
+
export { isEmpty };
|
|
32
|
+
export { isObject };
|
|
33
|
+
export { isEqual };
|
|
34
|
+
export { assignWith };
|
|
35
|
+
export { debounce };
|
|
36
|
+
export { throttle };
|
|
37
|
+
export { get };
|
|
38
|
+
export { set };
|
|
39
|
+
}
|
|
40
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function isDate(date: any): boolean;
|
|
2
|
+
export function getDayCountOfMonth(year: any, month: any): number;
|
|
3
|
+
export function getDayCountOfYear(year: any): 366 | 365;
|
|
4
|
+
export function nextDate(date: any, amount?: number): Date;
|
|
5
|
+
export function nextMonth(date: any): Date;
|
|
6
|
+
export function prevYear(date: any, amount?: number): Date;
|
|
7
|
+
export function nextYear(date: any, amount?: number): Date;
|
|
8
|
+
export function range(n: any): any;
|
|
9
|
+
export function modifyDate(date: any, y: any, m: any, d: any): Date;
|
|
10
|
+
export function modifyTime(date: any, h: any, m: any, s: any): Date;
|
|
11
|
+
export function modifyWithTimeString(date: any, time: any): any;
|
package/types/date.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './date-helper'
|
package/types/dom.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dom-helper'
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public'
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Dayjs } from 'dayjs'
|
|
2
|
+
import type { Duration } from 'dayjs/plugin/duration'
|
|
3
|
+
|
|
4
|
+
/** 对应 moment-compat.js 的 READ_METHODS / WRITE_METHODS,保留可变链式语义。 */
|
|
5
|
+
export interface MomentLike {
|
|
6
|
+
format(format?: string): string
|
|
7
|
+
valueOf(): number
|
|
8
|
+
unix(): number
|
|
9
|
+
toDate(): Date
|
|
10
|
+
toISOString(): string | null
|
|
11
|
+
toJSON(): string | null
|
|
12
|
+
toString(): string
|
|
13
|
+
toArray(): number[]
|
|
14
|
+
toObject(): Record<string, number>
|
|
15
|
+
isValid(): boolean
|
|
16
|
+
clone(): MomentLike
|
|
17
|
+
diff(input?: unknown, unit?: string, precise?: boolean): number
|
|
18
|
+
isBefore(input?: unknown, unit?: string): boolean
|
|
19
|
+
isAfter(input?: unknown, unit?: string): boolean
|
|
20
|
+
isSame(input?: unknown, unit?: string): boolean
|
|
21
|
+
isSameOrBefore(input?: unknown, unit?: string): boolean
|
|
22
|
+
isSameOrAfter(input?: unknown, unit?: string): boolean
|
|
23
|
+
isBetween(start: unknown, end: unknown, unit?: string | null, inclusivity?: string): boolean
|
|
24
|
+
isLeapYear(): boolean
|
|
25
|
+
daysInMonth(): number
|
|
26
|
+
get(unit: string): number
|
|
27
|
+
from(input: unknown, withoutSuffix?: boolean): string
|
|
28
|
+
to(input: unknown, withoutSuffix?: boolean): string
|
|
29
|
+
fromNow(withoutSuffix?: boolean): string
|
|
30
|
+
toNow(withoutSuffix?: boolean): string
|
|
31
|
+
calendar(reference?: unknown, formats?: Record<string, string | ((...args: any[]) => string)>): string
|
|
32
|
+
utcOffset(): number
|
|
33
|
+
utcOffset(offset: number | string, keepLocalTime?: boolean): MomentLike
|
|
34
|
+
weekday(): number
|
|
35
|
+
weekday(value: number): MomentLike
|
|
36
|
+
isoWeekday(): number
|
|
37
|
+
isoWeekday(value: number): MomentLike
|
|
38
|
+
add(amount: number | Duration, unit?: string): this
|
|
39
|
+
subtract(amount: number | Duration, unit?: string): this
|
|
40
|
+
startOf(unit: string): this
|
|
41
|
+
endOf(unit: string): this
|
|
42
|
+
set(unit: string, value: number): this
|
|
43
|
+
set(values: Record<string, number>): this
|
|
44
|
+
local(): this
|
|
45
|
+
utc(keepLocalTime?: boolean): this
|
|
46
|
+
locale(): string
|
|
47
|
+
locale(name: string): this
|
|
48
|
+
year(): number
|
|
49
|
+
year(value: number): this
|
|
50
|
+
month(): number
|
|
51
|
+
month(value: number): this
|
|
52
|
+
date(): number
|
|
53
|
+
date(value: number): this
|
|
54
|
+
day(): number
|
|
55
|
+
day(value: number): this
|
|
56
|
+
hour(): number
|
|
57
|
+
hour(value: number): this
|
|
58
|
+
minute(): number
|
|
59
|
+
minute(value: number): this
|
|
60
|
+
second(): number
|
|
61
|
+
second(value: number): this
|
|
62
|
+
millisecond(): number
|
|
63
|
+
millisecond(value: number): this
|
|
64
|
+
quarter(): number
|
|
65
|
+
quarter(value: number): this
|
|
66
|
+
week(): number
|
|
67
|
+
week(value: number): this
|
|
68
|
+
isoWeek(): number
|
|
69
|
+
isoWeek(value: number): this
|
|
70
|
+
dayOfYear(): number
|
|
71
|
+
dayOfYear(value: number): this
|
|
72
|
+
}
|
|
73
|
+
export interface MomentFactory {
|
|
74
|
+
(input?: unknown, ...formatAndOptions: any[]): MomentLike
|
|
75
|
+
duration(input?: unknown, ...unit: any[]): Duration
|
|
76
|
+
locale(name?: string): string
|
|
77
|
+
isMoment(value: unknown): value is MomentLike
|
|
78
|
+
unix(seconds: number): MomentLike
|
|
79
|
+
utc(input?: unknown, ...formatAndOptions: any[]): MomentLike
|
|
80
|
+
max(...dates: (MomentLike | Dayjs | (MomentLike | Dayjs)[])[]): MomentLike
|
|
81
|
+
min(...dates: (MomentLike | Dayjs | (MomentLike | Dayjs)[])[]): MomentLike
|
|
82
|
+
}
|
|
83
|
+
declare const moment: MomentFactory
|
|
84
|
+
export { moment as createMoment }
|
|
85
|
+
export default moment
|
|
86
|
+
export declare function preprocessFormat(format: string, milliseconds?: number, year?: number): string
|
|
87
|
+
export declare const READ_METHODS: string[]
|
|
88
|
+
export declare const WRITE_METHODS: string[]
|
|
89
|
+
export declare const DUAL_METHODS: Set<string>
|
|
90
|
+
export declare const PASSTHROUGH: Set<string>
|
|
91
|
+
export declare const UNSUPPORTED_FORMAT_TOKENS: string[]
|
package/types/page.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export default Page;
|
|
2
|
+
declare class Page {
|
|
3
|
+
constructor(props: any);
|
|
4
|
+
label: any;
|
|
5
|
+
title: any;
|
|
6
|
+
linkEntitys: any;
|
|
7
|
+
relatedEntitys: any;
|
|
8
|
+
sysId: any;
|
|
9
|
+
config: any;
|
|
10
|
+
flag: any;
|
|
11
|
+
pageId: any;
|
|
12
|
+
templateId: any;
|
|
13
|
+
metaId: any;
|
|
14
|
+
metaCode: any;
|
|
15
|
+
pagePath: any;
|
|
16
|
+
pageCode: any;
|
|
17
|
+
system: any;
|
|
18
|
+
systemCode: any;
|
|
19
|
+
help: any;
|
|
20
|
+
rightControlMode: any;
|
|
21
|
+
visualConfigPath: any;
|
|
22
|
+
getPageId(): any;
|
|
23
|
+
getLabel(): any;
|
|
24
|
+
getMetaId(): any;
|
|
25
|
+
getFlag(): any;
|
|
26
|
+
getPagePath(): any;
|
|
27
|
+
getConfig(): any;
|
|
28
|
+
/**
|
|
29
|
+
* 主键字段
|
|
30
|
+
* @return {}
|
|
31
|
+
*/
|
|
32
|
+
getKey(): any;
|
|
33
|
+
/**
|
|
34
|
+
* 获取所有属性
|
|
35
|
+
* @return {}
|
|
36
|
+
*/
|
|
37
|
+
getAttris(): any;
|
|
38
|
+
/**
|
|
39
|
+
* ID对应LAVEL
|
|
40
|
+
*/
|
|
41
|
+
getIdLabelAttris(): any[];
|
|
42
|
+
/**
|
|
43
|
+
* NAME对应LAVEL
|
|
44
|
+
*/
|
|
45
|
+
getNameLabelAttris(): any[];
|
|
46
|
+
/**
|
|
47
|
+
* 根据字段ID获取字段Name
|
|
48
|
+
* @param {} attriId
|
|
49
|
+
* @return {}
|
|
50
|
+
*/
|
|
51
|
+
getAttriNameById(attriId: any): any;
|
|
52
|
+
/**
|
|
53
|
+
* 根据字段key获取label
|
|
54
|
+
*/
|
|
55
|
+
getLabelByField(field: any): any;
|
|
56
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按属性路径在**一个**来源里取值。
|
|
3
|
+
* 只按 `.` 和 `[...]` 分段;`|` 当普通字符(字段名可能长这样:`busi|NAME`)。
|
|
4
|
+
* @returns {{ found: boolean, value: any }} found 区分「没有这个路径」与「值恰好是 undefined」
|
|
5
|
+
*/
|
|
6
|
+
export function lookup(path: any, source: any): {
|
|
7
|
+
found: boolean;
|
|
8
|
+
value: any;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* 按给定顺序在多个来源里找第一个**拥有**该路径的。
|
|
12
|
+
* @param {string} path
|
|
13
|
+
* @param {Array<object>} sources 有序来源,如 [this, this.$query, this.$tab]
|
|
14
|
+
* @returns {{ found: boolean, value: any, index: number }} index 为命中的来源下标,未命中为 -1
|
|
15
|
+
*/
|
|
16
|
+
export function resolveKey(path: string, sources?: Array<object>): {
|
|
17
|
+
found: boolean;
|
|
18
|
+
value: any;
|
|
19
|
+
index: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* 替换字符串里的全部 `#{path}`。
|
|
23
|
+
* @param {string} text
|
|
24
|
+
* @param {Array<object>} sources 有序来源
|
|
25
|
+
* @param {object} [options]
|
|
26
|
+
* @param {'empty'|'keep'} [options.onMissing='empty']
|
|
27
|
+
* 'empty' —— 取不到就换成空串(与存量 `… || ''` 的收尾一致,是默认)
|
|
28
|
+
* 'keep' —— 原样保留 `#{path}`。⚠️ 保留下来的是**非空字符串**,
|
|
29
|
+
* 也就是真值,`a || b` 形式的兜底会失效——选它之前先确认调用方判得了。
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
export function resolvePlaceholders(text: string, sources?: Array<object>, options?: {
|
|
33
|
+
onMissing?: "empty" | "keep";
|
|
34
|
+
}): string;
|
|
35
|
+
export const PLACEHOLDER_RE: RegExp;
|
|
36
|
+
declare namespace _default {
|
|
37
|
+
export { PLACEHOLDER_RE };
|
|
38
|
+
export { lookup };
|
|
39
|
+
export { resolveKey };
|
|
40
|
+
export { resolvePlaceholders };
|
|
41
|
+
}
|
|
42
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as Config } from "./Config";
|
|
2
|
+
export { default as Page } from "./page";
|
|
3
|
+
export { default as placeholder } from "./placeholder";
|
|
4
|
+
export * from "./placeholder";
|
|
5
|
+
export * from "./date-helper";
|
|
6
|
+
export * from "./dom-helper";
|
|
7
|
+
export * from "./collection";
|
|
8
|
+
export { default as lodash } from "./collection";
|
|
9
|
+
export { default as storage, getXsrfToken, setXsrfToken, default as cookie } from "./storage";
|
|
10
|
+
export { default as moment, default as dateTime, createMoment } from "./moment-compat";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 防 CSRF 令牌:由后端通过响应头 `xsrf_token`(或 `X-XSRF-TOKEN`)下发,
|
|
3
|
+
* axios 响应拦截器写入 sessionStorage(随标签页关闭失效),请求拦截器再回填到
|
|
4
|
+
* `xsrf_token` 请求头 / 下载类 URL 的 `xsrf_token` 查询参数。
|
|
5
|
+
*/
|
|
6
|
+
export const XSRF_TOKEN_KEY: "xsrf_token";
|
|
7
|
+
export function getXsrfToken(): string;
|
|
8
|
+
export function setXsrfToken(token: any): void;
|
|
9
|
+
export function clearXsrfToken(): void;
|
|
10
|
+
export default storage;
|
|
11
|
+
declare namespace storage {
|
|
12
|
+
/**
|
|
13
|
+
* @param {string} key
|
|
14
|
+
* @returns {string | undefined} 不存在或已过期返回 undefined(与 js-cookie 一致)
|
|
15
|
+
*/
|
|
16
|
+
function get(key: string): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} key
|
|
19
|
+
* @param {*} value 非字符串会被转成字符串(对象走 JSON.stringify)
|
|
20
|
+
* @param {{ expires?: number | Date, session?: boolean }} [options]
|
|
21
|
+
* @returns {string | undefined} 实际写入的字符串
|
|
22
|
+
*/
|
|
23
|
+
function set(key: string, value: any, options?: {
|
|
24
|
+
expires?: number | Date;
|
|
25
|
+
session?: boolean;
|
|
26
|
+
}): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* @param {string} key
|
|
29
|
+
*/
|
|
30
|
+
function remove(key: string): void;
|
|
31
|
+
}
|