@fe-free/core 2.8.8 → 2.8.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @fe-free/core
2
2
 
3
+ ## 2.8.10
4
+
5
+ ### Patch Changes
6
+
7
+ - fix: update
8
+ - @fe-free/tool@2.8.10
9
+
10
+ ## 2.8.9
11
+
12
+ ### Patch Changes
13
+
14
+ - fix: update
15
+ - @fe-free/tool@2.8.9
16
+
3
17
  ## 2.8.8
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fe-free/core",
3
- "version": "2.8.8",
3
+ "version": "2.8.10",
4
4
  "description": "",
5
5
  "main": "./src/index.ts",
6
6
  "author": "",
@@ -42,7 +42,7 @@
42
42
  "safe-stable-stringify": "^2.5.0",
43
43
  "vanilla-jsoneditor": "^0.23.1",
44
44
  "zustand": "^4.5.4",
45
- "@fe-free/tool": "2.8.8"
45
+ "@fe-free/tool": "2.8.10"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@ant-design/pro-components": "2.8.9",
@@ -7,6 +7,13 @@ import { BrowserRouter as Router, useNavigate } from 'react-router-dom';
7
7
  import { routeTool } from '../route';
8
8
  import { customValueTypeMap } from '../value_type_map';
9
9
 
10
+ function getPathname(src?: string) {
11
+ if (!src) {
12
+ return null;
13
+ }
14
+ return src.startsWith('/') ? src : new URL(src).pathname;
15
+ }
16
+
10
17
  function CheckUpdate({ basename }: { basename: string }) {
11
18
  const { modal } = App.useApp();
12
19
 
@@ -17,13 +24,14 @@ function CheckUpdate({ basename }: { basename: string }) {
17
24
  return;
18
25
  }
19
26
 
20
- async function getMainScriptSrc() {
27
+ async function getMainScriptPathname() {
21
28
  const res = await fetch(`${basename}?r=${Date.now()}`);
22
29
  const html = await res.text();
23
30
  const parser = new DOMParser();
24
31
  const doc = parser.parseFromString(html, 'text/html');
25
32
  const nextMainScript = doc.querySelector('[data-name="mainScript"]');
26
- return nextMainScript?.getAttribute('src');
33
+ const src = nextMainScript?.getAttribute('src');
34
+ return getPathname(src || undefined);
27
35
  }
28
36
 
29
37
  let ing = false;
@@ -49,13 +57,19 @@ function CheckUpdate({ basename }: { basename: string }) {
49
57
  }
50
58
 
51
59
  const src = mainScript.getAttribute('src');
60
+ const pathname = getPathname(src || undefined);
61
+
62
+ const checkUpdateInterval = parseInt(
63
+ localStorage.getItem('__free-checkUpdateInterval') || '60000',
64
+ 10,
65
+ );
52
66
  const timer = setInterval(async () => {
53
- const nextSrc = await getMainScriptSrc();
54
- if (nextSrc !== src) {
67
+ const nextPathname = await getMainScriptPathname();
68
+ if (nextPathname !== pathname) {
55
69
  confirm();
56
70
  return;
57
71
  }
58
- }, 1000 * 60);
72
+ }, checkUpdateInterval);
59
73
 
60
74
  return () => {
61
75
  clearInterval(timer);