x-essential-lib 0.1.1 → 0.1.3
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/index.d.ts +19 -2
- package/dist/index.js +325 -274
- package/package.json +4 -1
- package/.editorconfig +0 -5
- package/.eslintignore +0 -1
- package/.eslintrc.cjs +0 -18
- package/.husky/pre-commit +0 -1
- package/.prettierignore +0 -7
- package/.prettierrc +0 -16
- package/index.html +0 -12
- package/public/index.d.ts +0 -89
- package/src/App.vue +0 -9
- package/src/components/confirmDlg/index.vue +0 -98
- package/src/components/loading/index.vue +0 -131
- package/src/components/message/index.vue +0 -70
- package/src/components/message/item.vue +0 -75
- package/src/components/promptDlg/index.vue +0 -119
- package/src/components/waitDlg/index.vue +0 -41
- package/src/index.ts +0 -38
- package/src/main.ts +0 -5
- package/src/plugins/vuetify.ts +0 -4
- package/src/utils/core.ts +0 -31
- package/src/utils/dialog.ts +0 -87
- package/src/utils/message.ts +0 -17
- package/src/utils/misc.ts +0 -23
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -25
- package/tsconfig.node.json +0 -9
- package/vite.config.ts +0 -37
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { eventBus } from '../../utils/core'
|
|
3
|
-
import { useLocale } from 'vuetify/lib/framework.mjs'
|
|
4
|
-
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
|
5
|
-
|
|
6
|
-
const locale = useLocale()
|
|
7
|
-
|
|
8
|
-
const open = ref(false)
|
|
9
|
-
|
|
10
|
-
const onOpen = () => {
|
|
11
|
-
open.value = true
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const onClose = () => {
|
|
15
|
-
open.value = false
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
onMounted(() => {
|
|
19
|
-
eventBus.on('openWaitDlg', onOpen)
|
|
20
|
-
eventBus.on('closeWaitDlg', onClose)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
onBeforeUnmount(() => {
|
|
24
|
-
eventBus.off('openWaitDlg', onOpen)
|
|
25
|
-
eventBus.off('closeWaitDlg', onClose)
|
|
26
|
-
})
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<template>
|
|
30
|
-
<v-dialog v-model:model-value="open" persistent no-click-animation fullscreen>
|
|
31
|
-
<div class="mx-auto my-auto">
|
|
32
|
-
<v-card width="300px" height="80px" loading>
|
|
33
|
-
<div class="d-flex align-center justify-center w-100 h-100">
|
|
34
|
-
<span>
|
|
35
|
-
{{ locale.t('waitingResponse') }}
|
|
36
|
-
</span>
|
|
37
|
-
</div>
|
|
38
|
-
</v-card>
|
|
39
|
-
</div>
|
|
40
|
-
</v-dialog>
|
|
41
|
-
</template>
|
package/src/index.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import XConfirmDlg from './components/confirmDlg/index.vue'
|
|
2
|
-
import XLoading from './components/loading/index.vue'
|
|
3
|
-
import XMessage from './components/message/index.vue'
|
|
4
|
-
import XPromptDlg from './components/promptDlg/index.vue'
|
|
5
|
-
import XWaitDlg from './components/waitDlg/index.vue'
|
|
6
|
-
import { waitMs, waitUtil } from './utils/core'
|
|
7
|
-
import {
|
|
8
|
-
openConfirmDlg,
|
|
9
|
-
openPromptDlg,
|
|
10
|
-
openWaitDlg,
|
|
11
|
-
closeWaitDlg
|
|
12
|
-
} from './utils/dialog'
|
|
13
|
-
import {
|
|
14
|
-
messageError,
|
|
15
|
-
messageInfo,
|
|
16
|
-
messageSuccess,
|
|
17
|
-
messageWarning
|
|
18
|
-
} from './utils/message'
|
|
19
|
-
import { appAppear } from './utils/misc'
|
|
20
|
-
|
|
21
|
-
export {
|
|
22
|
-
XConfirmDlg,
|
|
23
|
-
XLoading,
|
|
24
|
-
XMessage,
|
|
25
|
-
XPromptDlg,
|
|
26
|
-
XWaitDlg,
|
|
27
|
-
waitMs,
|
|
28
|
-
waitUtil,
|
|
29
|
-
openConfirmDlg,
|
|
30
|
-
openPromptDlg,
|
|
31
|
-
openWaitDlg,
|
|
32
|
-
closeWaitDlg,
|
|
33
|
-
messageError,
|
|
34
|
-
messageInfo,
|
|
35
|
-
messageSuccess,
|
|
36
|
-
messageWarning,
|
|
37
|
-
appAppear
|
|
38
|
-
}
|
package/src/main.ts
DELETED
package/src/plugins/vuetify.ts
DELETED
package/src/utils/core.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import mitt from 'mitt'
|
|
2
|
-
|
|
3
|
-
export const eventBus = mitt()
|
|
4
|
-
|
|
5
|
-
export async function waitMs(ms: number): Promise<void> {
|
|
6
|
-
return new Promise(resolve => {
|
|
7
|
-
setTimeout(resolve, ms)
|
|
8
|
-
})
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export async function waitUtil(
|
|
12
|
-
conditionFunc: () => boolean,
|
|
13
|
-
timeout?: number,
|
|
14
|
-
interval?: number
|
|
15
|
-
): Promise<boolean> {
|
|
16
|
-
const timestamp = Date.now()
|
|
17
|
-
return new Promise((resolve: any) => {
|
|
18
|
-
const check = async () => {
|
|
19
|
-
if (conditionFunc()) {
|
|
20
|
-
resolve(true)
|
|
21
|
-
} else {
|
|
22
|
-
if (timeout && Date.now() - timestamp > timeout) {
|
|
23
|
-
resolve(false)
|
|
24
|
-
} else {
|
|
25
|
-
setTimeout(check, interval ?? 30)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
check()
|
|
30
|
-
})
|
|
31
|
-
}
|
package/src/utils/dialog.ts
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { eventBus, waitUtil } from './core'
|
|
2
|
-
|
|
3
|
-
let lastTime: number = Date.now()
|
|
4
|
-
|
|
5
|
-
function tryCooldown(): boolean {
|
|
6
|
-
const now = Date.now()
|
|
7
|
-
if (now - lastTime > 500) {
|
|
8
|
-
lastTime = now
|
|
9
|
-
return true
|
|
10
|
-
}
|
|
11
|
-
return false
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let sequence: number = 0
|
|
15
|
-
|
|
16
|
-
function getSequence(): number {
|
|
17
|
-
return ++sequence
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface ButtonOptions {
|
|
21
|
-
color?: string
|
|
22
|
-
text?: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface ConfirmParams {
|
|
26
|
-
title: string
|
|
27
|
-
text: string
|
|
28
|
-
cancel?: ButtonOptions
|
|
29
|
-
confirm?: ButtonOptions
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export async function openConfirmDlg(
|
|
33
|
-
params: ConfirmParams
|
|
34
|
-
): Promise<boolean | undefined> {
|
|
35
|
-
if (!tryCooldown()) {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
let resp: boolean = false
|
|
39
|
-
let result: boolean | undefined
|
|
40
|
-
const onResult = (res: unknown) => {
|
|
41
|
-
result = res as boolean
|
|
42
|
-
resp = true
|
|
43
|
-
}
|
|
44
|
-
const seq = getSequence()
|
|
45
|
-
eventBus.on('confirmDlgResult' + seq, onResult)
|
|
46
|
-
eventBus.emit('confirmDlg', { ...params, seq })
|
|
47
|
-
await waitUtil(() => resp)
|
|
48
|
-
eventBus.off('confirmDlgResult' + seq, onResult)
|
|
49
|
-
return result
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface PromptParams {
|
|
53
|
-
title: string
|
|
54
|
-
text?: string
|
|
55
|
-
label?: string
|
|
56
|
-
placeholder?: string
|
|
57
|
-
rules?: ((val: string) => string | boolean)[]
|
|
58
|
-
value?: string
|
|
59
|
-
cancel?: ButtonOptions
|
|
60
|
-
confirm?: ButtonOptions
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export async function openPromptDlg(params: PromptParams): Promise<any> {
|
|
64
|
-
if (!tryCooldown()) {
|
|
65
|
-
return
|
|
66
|
-
}
|
|
67
|
-
let resp: boolean = false
|
|
68
|
-
let result: any
|
|
69
|
-
const onResult = (res: any) => {
|
|
70
|
-
result = res
|
|
71
|
-
resp = true
|
|
72
|
-
}
|
|
73
|
-
const seq = getSequence()
|
|
74
|
-
eventBus.on('promptDlgResult' + seq, onResult)
|
|
75
|
-
eventBus.emit('promptDlg', { ...params, seq })
|
|
76
|
-
await waitUtil(() => resp)
|
|
77
|
-
eventBus.off('promptDlgResult' + seq, onResult)
|
|
78
|
-
return result
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function openWaitDlg() {
|
|
82
|
-
eventBus.emit('openWaitDlg')
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function closeWaitDlg() {
|
|
86
|
-
eventBus.emit('closeWaitDlg')
|
|
87
|
-
}
|
package/src/utils/message.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { eventBus } from './core'
|
|
2
|
-
|
|
3
|
-
export function messageError(text: string, timeout?: number) {
|
|
4
|
-
eventBus.emit('message', { type: 'error', text, timeout })
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function messageInfo(text: string, timeout?: number) {
|
|
8
|
-
eventBus.emit('message', { type: 'info', text, timeout })
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function messageSuccess(text: string, timeout?: number) {
|
|
12
|
-
eventBus.emit('message', { type: 'success', text, timeout })
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function messageWarning(text: string, timeout?: number) {
|
|
16
|
-
eventBus.emit('message', { type: 'warning', text, timeout })
|
|
17
|
-
}
|
package/src/utils/misc.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
declare let window: any
|
|
2
|
-
|
|
3
|
-
export function appAppear(name: string) {
|
|
4
|
-
// 忽略第一次动画
|
|
5
|
-
if (!window.appAppear) {
|
|
6
|
-
window.appAppear = true
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
const fullname = 'single-spa-application:' + name
|
|
10
|
-
const classList = document.getElementById(fullname)?.classList
|
|
11
|
-
if (!classList) {
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
classList.remove('app-left', 'app-right', 'app-reset')
|
|
15
|
-
if (window.routeExtras?.forward) {
|
|
16
|
-
classList.add('app-left')
|
|
17
|
-
} else {
|
|
18
|
-
classList.add('app-right')
|
|
19
|
-
}
|
|
20
|
-
setTimeout(() => {
|
|
21
|
-
classList.add('app-reset')
|
|
22
|
-
}, 0)
|
|
23
|
-
}
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"useDefineForClassFields": true,
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
|
|
9
|
-
/* Bundler mode */
|
|
10
|
-
"moduleResolution": "Node",
|
|
11
|
-
"allowImportingTsExtensions": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"noEmit": true,
|
|
15
|
-
"jsx": "preserve",
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"noFallthroughCasesInSwitch": true
|
|
22
|
-
},
|
|
23
|
-
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
|
|
24
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
25
|
-
}
|
package/tsconfig.node.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import { fileURLToPath, URL } from 'node:url'
|
|
3
|
-
import vue from '@vitejs/plugin-vue'
|
|
4
|
-
import cssInjectedByJs from 'vite-plugin-css-injected-by-js'
|
|
5
|
-
|
|
6
|
-
// https://vitejs.dev/config/
|
|
7
|
-
export default () => {
|
|
8
|
-
return defineConfig({
|
|
9
|
-
plugins: [vue(), cssInjectedByJs()],
|
|
10
|
-
define: { 'process.env': {} },
|
|
11
|
-
resolve: {
|
|
12
|
-
alias: {
|
|
13
|
-
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
server: {
|
|
17
|
-
port: 3333
|
|
18
|
-
},
|
|
19
|
-
build: {
|
|
20
|
-
lib: {
|
|
21
|
-
entry: 'src/index.ts',
|
|
22
|
-
formats: ['es'],
|
|
23
|
-
fileName: 'index'
|
|
24
|
-
},
|
|
25
|
-
rollupOptions: {
|
|
26
|
-
external: ['vue', 'vuetify'],
|
|
27
|
-
output: {
|
|
28
|
-
globals: {
|
|
29
|
-
vue: 'Vue',
|
|
30
|
-
vuetify: 'Vuetify'
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
emptyOutDir: true
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
}
|