message-verify 1.0.1-beta.69 → 1.0.1-beta.71
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 +3 -2
- package/dist/index.js +27 -22
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/src/index.tsx +28 -24
- package/src/main.tsx +1 -1
package/dist/index.d.ts
CHANGED
@@ -2,6 +2,7 @@ import { VerifyModalConfig, LoginModalConfig } from './utils/type.js';
|
|
2
2
|
export declare const initFingerprint: () => Promise<string>;
|
3
3
|
export declare const createReLoginModal: (modalProps: LoginModalConfig) => void;
|
4
4
|
export declare const VerifyHandler: {
|
5
|
-
|
6
|
-
|
5
|
+
_currentUrl: string;
|
6
|
+
createModal: ({ data, config, http, verifyPromise, sendApi }: VerifyModalConfig) => Promise<any>;
|
7
|
+
getResponse: (response: any) => any;
|
7
8
|
};
|
package/dist/index.js
CHANGED
@@ -55,27 +55,32 @@ export const createReLoginModal = (modalProps) => {
|
|
55
55
|
const reLoginModalId = 'relogin-modal-container';
|
56
56
|
creatModal(modalProps, reLoginModalId, ReLoginModal);
|
57
57
|
};
|
58
|
-
export const VerifyHandler =
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
58
|
+
export const VerifyHandler = {
|
59
|
+
_currentUrl: '',
|
60
|
+
createModal: ({ data, config, http, verifyPromise, sendApi }) => {
|
61
|
+
VerifyHandler._currentUrl = config?.url || '';
|
62
|
+
const toEmpty = () => {
|
63
|
+
verifyPromise.current = null;
|
64
|
+
};
|
65
|
+
if (!verifyPromise.current) {
|
66
|
+
verifyPromise.current = new Promise((resolve, reject) => {
|
67
|
+
createMessageVerifyModal({
|
68
|
+
data,
|
69
|
+
config,
|
70
|
+
http,
|
71
|
+
apiResolve: resolve,
|
72
|
+
apiReject: reject,
|
73
|
+
apiPromiseToEmpty: toEmpty,
|
74
|
+
sendApi
|
75
|
+
});
|
76
|
+
}).finally(toEmpty);
|
77
|
+
}
|
78
|
+
return verifyPromise.current;
|
79
|
+
},
|
80
|
+
getResponse: (response) => {
|
81
|
+
if (VerifyHandler._currentUrl === response?.config?.url) {
|
82
|
+
eventEmitter.emit('response', response?.data?.status?.code ?? -1);
|
83
|
+
}
|
84
|
+
return response;
|
74
85
|
}
|
75
|
-
return verifyPromise.current;
|
76
|
-
};
|
77
|
-
// 获取当前触发接口response
|
78
|
-
VerifyHandler.getResponse = (response) => {
|
79
|
-
eventEmitter.emit('response', response?.data?.status?.code ?? -1);
|
80
|
-
return response;
|
81
86
|
};
|
package/dist/main.js
CHANGED
@@ -38,7 +38,7 @@ const config = {
|
|
38
38
|
};
|
39
39
|
const promise = { current: null };
|
40
40
|
createRoot(document.getElementById('root')).render(_jsxs(_Fragment, { children: [_jsx("button", { onClick: () => {
|
41
|
-
return VerifyHandler({ data, config, http: axios, verifyPromise: promise });
|
41
|
+
return VerifyHandler.createModal({ data, config, http: axios, verifyPromise: promise });
|
42
42
|
}, children: "Show verify Modal" }), _jsx("button", { onClick: () => createReLoginModal({
|
43
43
|
goLogin: () => {
|
44
44
|
console.log('goLogin');
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
@@ -36,7 +36,7 @@ const destroyModal = (modalId: string) => {
|
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
39
|
-
const creatModal = (modalProps: VerifyModalConfig | LoginModalConfig, modalId: string, ModalDom:any) => {
|
39
|
+
const creatModal = (modalProps: VerifyModalConfig | LoginModalConfig, modalId: string, ModalDom: any) => {
|
40
40
|
destroyModal(modalId);
|
41
41
|
const container = document.createElement('div')
|
42
42
|
container.id = modalId
|
@@ -65,28 +65,32 @@ export const createReLoginModal = (modalProps: LoginModalConfig) => {
|
|
65
65
|
creatModal(modalProps, reLoginModalId, ReLoginModal);
|
66
66
|
}
|
67
67
|
|
68
|
-
export const VerifyHandler =
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
68
|
+
export const VerifyHandler = {
|
69
|
+
_currentUrl: '',
|
70
|
+
createModal: ({ data, config, http, verifyPromise, sendApi }: VerifyModalConfig) => {
|
71
|
+
VerifyHandler._currentUrl = config?.url as string || '';
|
72
|
+
const toEmpty = () => {
|
73
|
+
verifyPromise.current = null;
|
74
|
+
};
|
75
|
+
if (!verifyPromise.current) {
|
76
|
+
verifyPromise.current = new Promise((resolve, reject) => {
|
77
|
+
createMessageVerifyModal({
|
78
|
+
data,
|
79
|
+
config,
|
80
|
+
http,
|
81
|
+
apiResolve: resolve,
|
82
|
+
apiReject: reject,
|
83
|
+
apiPromiseToEmpty: toEmpty,
|
84
|
+
sendApi
|
85
|
+
} as VerifyModalConfig);
|
86
|
+
}).finally(toEmpty);
|
87
|
+
}
|
88
|
+
return verifyPromise.current;
|
89
|
+
},
|
90
|
+
getResponse: (response: any) => {
|
91
|
+
if (VerifyHandler._currentUrl === response?.config?.url) {
|
92
|
+
eventEmitter.emit('response', response?.data?.status?.code ?? -1);
|
93
|
+
}
|
94
|
+
return response;
|
84
95
|
}
|
85
|
-
return verifyPromise.current;
|
86
|
-
};
|
87
|
-
|
88
|
-
// 获取当前触发接口response
|
89
|
-
VerifyHandler.getResponse = (response: any) => {
|
90
|
-
eventEmitter.emit('response', response?.data?.status?.code ?? -1);
|
91
|
-
return response;
|
92
96
|
};
|
package/src/main.tsx
CHANGED
@@ -43,7 +43,7 @@ const promise = {current: null};
|
|
43
43
|
createRoot(document.getElementById('root')!).render(
|
44
44
|
<>
|
45
45
|
<button onClick={() => {
|
46
|
-
return VerifyHandler({data, config, http: axios, verifyPromise: promise});
|
46
|
+
return VerifyHandler.createModal({data, config, http: axios, verifyPromise: promise});
|
47
47
|
}}>
|
48
48
|
Show verify Modal
|
49
49
|
</button>
|