@easyv/biz-components 1.0.16 → 1.0.18
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/components/ai-message-render/utils.es.js +1 -0
- package/dist/components/ai-message-render/utils.es.js.map +1 -1
- package/dist/index.es.js +2 -0
- package/dist/index.es.js.map +1 -1
- package/dist/stats.html +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/useDocumentUnmount/index.d.ts +1 -0
- package/dist/utils/useDocumentUnmount/index.es.js +18 -0
- package/dist/utils/useDocumentUnmount/index.es.js.map +1 -0
- package/package.json +1 -1
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDocumentUnmount(fn: () => void): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import useMemoizedFn from "../../node_modules/.pnpm/ahooks@3.8.5_react@18.2.0/node_modules/ahooks/es/useMemoizedFn/index.es.js";
|
|
3
|
+
function useDocumentUnmount(fn) {
|
|
4
|
+
const finalFn = useMemoizedFn(fn);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const handleBeforeUnload = () => {
|
|
7
|
+
finalFn();
|
|
8
|
+
};
|
|
9
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
10
|
+
return () => {
|
|
11
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
12
|
+
};
|
|
13
|
+
}, [finalFn]);
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
useDocumentUnmount
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../src/utils/useDocumentUnmount/index.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { useMemoizedFn } from 'ahooks';\n\nexport function useDocumentUnmount(fn: () => void) {\n const finalFn = useMemoizedFn(fn);\n // 监听页面卸载事件\n useEffect(() => {\n const handleBeforeUnload = () => {\n finalFn();\n };\n\n window.addEventListener('beforeunload', handleBeforeUnload);\n\n return () => {\n window.removeEventListener('beforeunload', handleBeforeUnload);\n };\n }, [finalFn]);\n}\n"],"names":[],"mappings":";;AAGO,SAAS,mBAAmB,IAAgB;AAC3C,QAAA,UAAU,cAAc,EAAE;AAEhC,YAAU,MAAM;AACd,UAAM,qBAAqB,MAAM;AACvB,cAAA;AAAA,IACV;AAEO,WAAA,iBAAiB,gBAAgB,kBAAkB;AAE1D,WAAO,MAAM;AACJ,aAAA,oBAAoB,gBAAgB,kBAAkB;AAAA,IAC/D;AAAA,EAAA,GACC,CAAC,OAAO,CAAC;AACd;"}
|