浏览代码

增加 hash mode

gemercheung 3 年之前
父节点
当前提交
68965c9146
共有 7 个文件被更改,包括 76 次插入72 次删除
  1. 2 2
      package.json
  2. 1 1
      packages/core/package.json
  3. 4 0
      packages/core/src/history.ts
  4. 1 2
      play/index.html
  5. 15 14
      play/src/App.vue
  6. 1 1
      play/src/router.ts
  7. 52 52
      pnpm-lock.yaml

+ 2 - 2
package.json

@@ -18,8 +18,8 @@
     },
     "devDependencies": {
         "@changesets/cli": "^2.24.3",
-        "@typescript-eslint/eslint-plugin": "^5.33.0",
-        "@typescript-eslint/parser": "^5.33.0",
+        "@typescript-eslint/eslint-plugin": "^5.34.0",
+        "@typescript-eslint/parser": "^5.34.0",
         "doctoc": "~2.2.0",
         "eslint": "~8.19.0",
         "eslint-config-prettier": "^8.5.0",

+ 1 - 1
packages/core/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@medici/core",
-  "version": "0.0.4",
+  "version": "0.0.5",
   "main": "dist/index",
   "types": "dist/index",
   "files": [

+ 4 - 0
packages/core/src/history.ts

@@ -81,6 +81,7 @@ export class IHistory {
     handlePushState(data: any, unused: string, url?: string | URL): void {
         try {
             if (!url) return;
+            const { hash } = global.location;
             this._currentRef = this._currentUrl;
             const newUrl = url.toString();
             if (newUrl.substring(0, 4) === 'http') {
@@ -88,6 +89,9 @@ export class IHistory {
             } else {
                 this._currentUrl = newUrl;
             }
+            if (hash) {
+                this._currentUrl = '/' + newUrl.replace(hash, '');
+            }
             console.log('diff', this._currentUrl !== this._currentRef);
             console.log('this._currentUrl', this._currentUrl);
             console.log('this._currentRef', this._currentRef);

+ 1 - 2
play/index.html

@@ -5,8 +5,7 @@
         <link rel="icon" type="image/svg+xml" href="/vite.svg" />
         <meta name="viewport" content="width=device-width, initial-scale=1.0" />
         <title>Medici SDK</title>
-      
-        <script async defer data-website-id="7b5958d5-1ae6-4ad5-8a87-5fc8a4b92999" src="https://allreally.oss-cn-shenzhen.aliyuncs.com/wasm/test_legacy/medici.js"></script>
+        <!-- <script async defer src="https://allreally.oss-cn-shenzhen.aliyuncs.com/wasm/test_legacy/medici.js"></script> -->
     </head>
     <body>
         <div id="app"></div>

+ 15 - 14
play/src/App.vue

@@ -2,21 +2,22 @@
 // This starter template is using Vue 3 <script setup> SFCs
 // Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
 import HelloWorld from './components/HelloWorld.vue';
-// import * as Medici from '@medici/web';
-if ((window as any).Medici) {
-    const medici = (window as any).Medici.init({
-        platform: 'web',
-        appId: '7b5958d5-1ae6-4ad5-8a87-5fc8a4b92999',
-        endPoint: 'http://192.168.0.186:3000/api/collect', //服务器
-        trackEndPoint: 'http://192.168.0.186:3000/api/track',
-        config: {
-            user: 'testUser',
-            version: '1',
-        },
-    });
+import * as Medici from '@medici/web';
+
+const medici = Medici.init({
+    platform: 'web',
+    appId: '7b5958d5-1ae6-4ad5-8a87-5fc8a4b92999',
+    endPoint: 'http://192.168.0.186:3000/api/collect', //服务器
+    trackEndPoint: 'http://192.168.0.186:3000/api/track',
+    config: {
+        user: 'testUser',
+        version: '1',
+    },
+});
+console.log('medici', medici);
+(window as any).medici = medici;
+
 
-    (window as any).medici = medici;
-}
 
 // medici.track("BuyProduct", {
 //   eventType:"click",

+ 1 - 1
play/src/router.ts

@@ -8,7 +8,7 @@ const Page3 = () => import('./components/page3.vue');
 const Custom = () => import('./components/custom.vue');
 
 export const router = createRouter({
-    history: routerHistory,
+    history: webHashHistory,
     strict: true,
     routes: [
         {

+ 52 - 52
pnpm-lock.yaml

@@ -5,8 +5,8 @@ importers:
   .:
     specifiers:
       '@changesets/cli': ^2.24.3
-      '@typescript-eslint/eslint-plugin': ^5.33.0
-      '@typescript-eslint/parser': ^5.33.0
+      '@typescript-eslint/eslint-plugin': ^5.34.0
+      '@typescript-eslint/parser': ^5.34.0
       doctoc: ~2.2.0
       eslint: ~8.19.0
       eslint-config-prettier: ^8.5.0
@@ -16,12 +16,12 @@ importers:
       typescript: ~4.7.4
     devDependencies:
       '@changesets/cli': 2.24.3
-      '@typescript-eslint/eslint-plugin': 5.33.0_zxpjpjn7ttxndsux4u6tqpnusi
-      '@typescript-eslint/parser': 5.33.0_4x5o4skxv6sl53vpwefgt23khm
+      '@typescript-eslint/eslint-plugin': 5.34.0_w2hqzjfaeagrl2vartllf6jizi
+      '@typescript-eslint/parser': 5.34.0_4x5o4skxv6sl53vpwefgt23khm
       doctoc: 2.2.0
       eslint: 8.19.0
       eslint-config-prettier: 8.5.0_eslint@8.19.0
-      eslint-plugin-import: 2.26.0_w3v63qjy4nybka3xfk2a2gfigq
+      eslint-plugin-import: 2.26.0_6go5y6lenqclsnxfpqt7lvefdy
       eslint-plugin-prettier: 4.2.1_7uxdfn2xinezdgvmbammh6ev5i
       prettier: 2.7.1
       typescript: 4.7.4
@@ -632,8 +632,8 @@ packages:
     resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==}
     dev: false
 
-  /@typescript-eslint/eslint-plugin/5.33.0_zxpjpjn7ttxndsux4u6tqpnusi:
-    resolution: {integrity: sha512-jHvZNSW2WZ31OPJ3enhLrEKvAZNyAFWZ6rx9tUwaessTc4sx9KmgMNhVcqVAl1ETnT5rU5fpXTLmY9YvC1DCNg==}
+  /@typescript-eslint/eslint-plugin/5.34.0_w2hqzjfaeagrl2vartllf6jizi:
+    resolution: {integrity: sha512-eRfPPcasO39iwjlUAMtjeueRGuIrW3TQ9WseIDl7i5UWuFbf83yYaU7YPs4j8+4CxUMIsj1k+4kV+E+G+6ypDQ==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
       '@typescript-eslint/parser': ^5.0.0
@@ -643,10 +643,10 @@ packages:
       typescript:
         optional: true
     dependencies:
-      '@typescript-eslint/parser': 5.33.0_4x5o4skxv6sl53vpwefgt23khm
-      '@typescript-eslint/scope-manager': 5.33.0
-      '@typescript-eslint/type-utils': 5.33.0_4x5o4skxv6sl53vpwefgt23khm
-      '@typescript-eslint/utils': 5.33.0_4x5o4skxv6sl53vpwefgt23khm
+      '@typescript-eslint/parser': 5.34.0_4x5o4skxv6sl53vpwefgt23khm
+      '@typescript-eslint/scope-manager': 5.34.0
+      '@typescript-eslint/type-utils': 5.34.0_4x5o4skxv6sl53vpwefgt23khm
+      '@typescript-eslint/utils': 5.34.0_4x5o4skxv6sl53vpwefgt23khm
       debug: 4.3.4
       eslint: 8.19.0
       functional-red-black-tree: 1.0.1
@@ -659,8 +659,8 @@ packages:
       - supports-color
     dev: true
 
-  /@typescript-eslint/parser/5.33.0_4x5o4skxv6sl53vpwefgt23khm:
-    resolution: {integrity: sha512-cgM5cJrWmrDV2KpvlcSkelTBASAs1mgqq+IUGKJvFxWrapHpaRy5EXPQz9YaKF3nZ8KY18ILTiVpUtbIac86/w==}
+  /@typescript-eslint/parser/5.34.0_4x5o4skxv6sl53vpwefgt23khm:
+    resolution: {integrity: sha512-SZ3NEnK4usd2CXkoV3jPa/vo1mWX1fqRyIVUQZR4As1vyp4fneknBNJj+OFtV8WAVgGf+rOHMSqQbs2Qn3nFZQ==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
       eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
@@ -669,9 +669,9 @@ packages:
       typescript:
         optional: true
     dependencies:
-      '@typescript-eslint/scope-manager': 5.33.0
-      '@typescript-eslint/types': 5.33.0
-      '@typescript-eslint/typescript-estree': 5.33.0_typescript@4.7.4
+      '@typescript-eslint/scope-manager': 5.34.0
+      '@typescript-eslint/types': 5.34.0
+      '@typescript-eslint/typescript-estree': 5.34.0_typescript@4.7.4
       debug: 4.3.4
       eslint: 8.19.0
       typescript: 4.7.4
@@ -679,16 +679,16 @@ packages:
       - supports-color
     dev: true
 
-  /@typescript-eslint/scope-manager/5.33.0:
-    resolution: {integrity: sha512-/Jta8yMNpXYpRDl8EwF/M8It2A9sFJTubDo0ATZefGXmOqlaBffEw0ZbkbQ7TNDK6q55NPHFshGBPAZvZkE8Pw==}
+  /@typescript-eslint/scope-manager/5.34.0:
+    resolution: {integrity: sha512-HNvASMQlah5RsBW6L6c7IJ0vsm+8Sope/wu5sEAf7joJYWNb1LDbJipzmdhdUOnfrDFE6LR1j57x1EYVxrY4ow==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     dependencies:
-      '@typescript-eslint/types': 5.33.0
-      '@typescript-eslint/visitor-keys': 5.33.0
+      '@typescript-eslint/types': 5.34.0
+      '@typescript-eslint/visitor-keys': 5.34.0
     dev: true
 
-  /@typescript-eslint/type-utils/5.33.0_4x5o4skxv6sl53vpwefgt23khm:
-    resolution: {integrity: sha512-2zB8uEn7hEH2pBeyk3NpzX1p3lF9dKrEbnXq1F7YkpZ6hlyqb2yZujqgRGqXgRBTHWIUG3NGx/WeZk224UKlIA==}
+  /@typescript-eslint/type-utils/5.34.0_4x5o4skxv6sl53vpwefgt23khm:
+    resolution: {integrity: sha512-Pxlno9bjsQ7hs1pdWRUv9aJijGYPYsHpwMeCQ/Inavhym3/XaKt1ZKAA8FIw4odTBfowBdZJDMxf2aavyMDkLg==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
       eslint: '*'
@@ -697,7 +697,7 @@ packages:
       typescript:
         optional: true
     dependencies:
-      '@typescript-eslint/utils': 5.33.0_4x5o4skxv6sl53vpwefgt23khm
+      '@typescript-eslint/utils': 5.34.0_4x5o4skxv6sl53vpwefgt23khm
       debug: 4.3.4
       eslint: 8.19.0
       tsutils: 3.21.0_typescript@4.7.4
@@ -706,13 +706,13 @@ packages:
       - supports-color
     dev: true
 
-  /@typescript-eslint/types/5.33.0:
-    resolution: {integrity: sha512-nIMt96JngB4MYFYXpZ/3ZNU4GWPNdBbcB5w2rDOCpXOVUkhtNlG2mmm8uXhubhidRZdwMaMBap7Uk8SZMU/ppw==}
+  /@typescript-eslint/types/5.34.0:
+    resolution: {integrity: sha512-49fm3xbbUPuzBIOcy2CDpYWqy/X7VBkxVN+DC21e0zIm3+61Z0NZi6J9mqPmSW1BDVk9FIOvuCFyUPjXz93sjA==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     dev: true
 
-  /@typescript-eslint/typescript-estree/5.33.0_typescript@4.7.4:
-    resolution: {integrity: sha512-tqq3MRLlggkJKJUrzM6wltk8NckKyyorCSGMq4eVkyL5sDYzJJcMgZATqmF8fLdsWrW7OjjIZ1m9v81vKcaqwQ==}
+  /@typescript-eslint/typescript-estree/5.34.0_typescript@4.7.4:
+    resolution: {integrity: sha512-mXHAqapJJDVzxauEkfJI96j3D10sd567LlqroyCeJaHnu42sDbjxotGb3XFtGPYKPD9IyLjhsoULML1oI3M86A==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
       typescript: '*'
@@ -720,8 +720,8 @@ packages:
       typescript:
         optional: true
     dependencies:
-      '@typescript-eslint/types': 5.33.0
-      '@typescript-eslint/visitor-keys': 5.33.0
+      '@typescript-eslint/types': 5.34.0
+      '@typescript-eslint/visitor-keys': 5.34.0
       debug: 4.3.4
       globby: 11.1.0
       is-glob: 4.0.3
@@ -732,16 +732,16 @@ packages:
       - supports-color
     dev: true
 
-  /@typescript-eslint/utils/5.33.0_4x5o4skxv6sl53vpwefgt23khm:
-    resolution: {integrity: sha512-JxOAnXt9oZjXLIiXb5ZIcZXiwVHCkqZgof0O8KPgz7C7y0HS42gi75PdPlqh1Tf109M0fyUw45Ao6JLo7S5AHw==}
+  /@typescript-eslint/utils/5.34.0_4x5o4skxv6sl53vpwefgt23khm:
+    resolution: {integrity: sha512-kWRYybU4Rn++7lm9yu8pbuydRyQsHRoBDIo11k7eqBWTldN4xUdVUMCsHBiE7aoEkFzrUEaZy3iH477vr4xHAQ==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     peerDependencies:
       eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
     dependencies:
       '@types/json-schema': 7.0.11
-      '@typescript-eslint/scope-manager': 5.33.0
-      '@typescript-eslint/types': 5.33.0
-      '@typescript-eslint/typescript-estree': 5.33.0_typescript@4.7.4
+      '@typescript-eslint/scope-manager': 5.34.0
+      '@typescript-eslint/types': 5.34.0
+      '@typescript-eslint/typescript-estree': 5.34.0_typescript@4.7.4
       eslint: 8.19.0
       eslint-scope: 5.1.1
       eslint-utils: 3.0.0_eslint@8.19.0
@@ -750,11 +750,11 @@ packages:
       - typescript
     dev: true
 
-  /@typescript-eslint/visitor-keys/5.33.0:
-    resolution: {integrity: sha512-/XsqCzD4t+Y9p5wd9HZiptuGKBlaZO5showwqODii5C0nZawxWLF+Q6k5wYHBrQv96h6GYKyqqMHCSTqta8Kiw==}
+  /@typescript-eslint/visitor-keys/5.34.0:
+    resolution: {integrity: sha512-O1moYjOSrab0a2fUvFpsJe0QHtvTC+cR+ovYpgKrAVXzqQyc74mv76TgY6z+aEtjQE2vgZux3CQVtGryqdcOAw==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
     dependencies:
-      '@typescript-eslint/types': 5.33.0
+      '@typescript-eslint/types': 5.34.0
       eslint-visitor-keys: 3.3.0
     dev: true
 
@@ -1366,7 +1366,7 @@ packages:
       is-weakref: 1.0.2
       object-inspect: 1.12.2
       object-keys: 1.1.1
-      object.assign: 4.1.3
+      object.assign: 4.1.4
       regexp.prototype.flags: 1.4.3
       string.prototype.trimend: 1.0.5
       string.prototype.trimstart: 1.0.5
@@ -1630,7 +1630,7 @@ packages:
       - supports-color
     dev: true
 
-  /eslint-module-utils/2.7.4_niocblew5zxuxg7sxqt6e5ovlm:
+  /eslint-module-utils/2.7.4_jta27pxmheaimoao73exahy2ma:
     resolution: {integrity: sha512-j4GT+rqzCoRKHwURX7pddtIPGySnX9Si/cgMI5ztrcqOPtk5dDEeZ34CQVPphnqkJytlc97Vuk05Um2mJ3gEQA==}
     engines: {node: '>=4'}
     peerDependencies:
@@ -1651,7 +1651,7 @@ packages:
       eslint-import-resolver-webpack:
         optional: true
     dependencies:
-      '@typescript-eslint/parser': 5.33.0_4x5o4skxv6sl53vpwefgt23khm
+      '@typescript-eslint/parser': 5.34.0_4x5o4skxv6sl53vpwefgt23khm
       debug: 3.2.7
       eslint: 8.19.0
       eslint-import-resolver-node: 0.3.6
@@ -1659,7 +1659,7 @@ packages:
       - supports-color
     dev: true
 
-  /eslint-plugin-import/2.26.0_w3v63qjy4nybka3xfk2a2gfigq:
+  /eslint-plugin-import/2.26.0_6go5y6lenqclsnxfpqt7lvefdy:
     resolution: {integrity: sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==}
     engines: {node: '>=4'}
     peerDependencies:
@@ -1669,14 +1669,14 @@ packages:
       '@typescript-eslint/parser':
         optional: true
     dependencies:
-      '@typescript-eslint/parser': 5.33.0_4x5o4skxv6sl53vpwefgt23khm
+      '@typescript-eslint/parser': 5.34.0_4x5o4skxv6sl53vpwefgt23khm
       array-includes: 3.1.5
       array.prototype.flat: 1.3.0
       debug: 2.6.9
       doctrine: 2.1.0
       eslint: 8.19.0
       eslint-import-resolver-node: 0.3.6
-      eslint-module-utils: 2.7.4_niocblew5zxuxg7sxqt6e5ovlm
+      eslint-module-utils: 2.7.4_jta27pxmheaimoao73exahy2ma
       has: 1.0.3
       is-core-module: 2.10.0
       is-glob: 4.0.3
@@ -1935,12 +1935,12 @@ packages:
     resolution: {integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==}
     engines: {node: ^10.12.0 || >=12.0.0}
     dependencies:
-      flatted: 3.2.6
+      flatted: 3.2.7
       rimraf: 3.0.2
     dev: true
 
-  /flatted/3.2.6:
-    resolution: {integrity: sha512-0sQoMh9s0BYsm+12Huy/rkKxVu4R1+r96YX5cG44rHV0pQ6iC3Q+mkoMFaGWObMFYQxCVT+ssG1ksneA2MI9KQ==}
+  /flatted/3.2.7:
+    resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==}
     dev: true
 
   /format/0.2.2:
@@ -2778,8 +2778,8 @@ packages:
     engines: {node: '>= 0.4'}
     dev: true
 
-  /object.assign/4.1.3:
-    resolution: {integrity: sha512-ZFJnX3zltyjcYJL0RoCJuzb+11zWGyaDbjgxZbdV7rFEcHQuYxrZqhow67aA7xpes6LhojyFDaBKAFfogQrikA==}
+  /object.assign/4.1.4:
+    resolution: {integrity: sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==}
     engines: {node: '>= 0.4'}
     dependencies:
       call-bind: 1.0.2
@@ -3286,7 +3286,7 @@ packages:
     resolution: {integrity: sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==}
     dependencies:
       spdx-expression-parse: 3.0.1
-      spdx-license-ids: 3.0.11
+      spdx-license-ids: 3.0.12
     dev: true
 
   /spdx-exceptions/2.3.0:
@@ -3297,11 +3297,11 @@ packages:
     resolution: {integrity: sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==}
     dependencies:
       spdx-exceptions: 2.3.0
-      spdx-license-ids: 3.0.11
+      spdx-license-ids: 3.0.12
     dev: true
 
-  /spdx-license-ids/3.0.11:
-    resolution: {integrity: sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==}
+  /spdx-license-ids/3.0.12:
+    resolution: {integrity: sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==}
     dev: true
 
   /sprintf-js/1.0.3: