bzkf3 преди 2 години
родител
ревизия
6e6cc5486b
променени са 4 файла, в които са добавени 130 реда и са изтрити 2 реда
  1. 1 0
      package.json
  2. 119 0
      pnpm-lock.yaml
  3. 3 2
      src/router/index.ts
  4. 7 0
      vite.config.ts

+ 1 - 0
package.json

@@ -35,6 +35,7 @@
     "unplugin-icons": "^0.14.13",
     "unplugin-vue-components": "^0.19.9",
     "vite": "^2.9.15",
+    "vite-plugin-top-level-await": "^1.2.1",
     "vite-plugin-windicss": "^1.8.8",
     "vue-tsc": "0.38.2",
     "windicss": "^3.5.6"

+ 119 - 0
pnpm-lock.yaml

@@ -21,6 +21,7 @@ specifiers:
   unplugin-icons: ^0.14.13
   unplugin-vue-components: ^0.19.9
   vite: ^2.9.15
+  vite-plugin-top-level-await: ^1.2.1
   vite-plugin-windicss: ^1.8.8
   vue: ^3.2.41
   vue-router: ^4.1.6
@@ -52,6 +53,7 @@ devDependencies:
   unplugin-icons: 0.14.13
   unplugin-vue-components: 0.19.9_vite@2.9.15+vue@3.2.41
   vite: 2.9.15_sass@1.56.0
+  vite-plugin-top-level-await: 1.2.1_vite@2.9.15
   vite-plugin-windicss: 1.8.8_vite@2.9.15
   vue-tsc: 0.38.2_typescript@4.8.4
   windicss: 3.5.6
@@ -178,6 +180,114 @@ packages:
       picomatch: 2.3.1
     dev: true
 
+  /@swc/core-darwin-arm64/1.3.14:
+    resolution: {integrity: sha512-QFuUq3341uOCrJMIWGuo+CmRC5qZoM2lUo7o2lmv1FO1Dh9njTG85pLD83vz6y4j/F034DBGzvRgSti/Bsoccw==}
+    engines: {node: '>=10'}
+    cpu: [arm64]
+    os: [darwin]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-darwin-x64/1.3.14:
+    resolution: {integrity: sha512-fpAjbjXimJBmxCumRB8zjEtPc0lGUi9Uvu92XH6ww6AyXvg7KQmua5P2R9tnzAm6NwTCXKkgS86cgKysAbbObw==}
+    engines: {node: '>=10'}
+    cpu: [x64]
+    os: [darwin]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-linux-arm-gnueabihf/1.3.14:
+    resolution: {integrity: sha512-3XSFlgIyDPS+x2c0IFr0AGj4NUbrWGKbkkUCpmAURII0n3YoDsYw8Ux73I8MkWxTTwDGkou8qQOXyA28kAUM4w==}
+    engines: {node: '>=10'}
+    cpu: [arm]
+    os: [linux]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-linux-arm64-gnu/1.3.14:
+    resolution: {integrity: sha512-r3fToDRYX76NEptAjvDg5aGrbitOgqooV37RpSTIGYd/CSNuin4cpCNFdca/Vh5lnNfal7mqdGDbG7gMruARtw==}
+    engines: {node: '>=10'}
+    cpu: [arm64]
+    os: [linux]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-linux-arm64-musl/1.3.14:
+    resolution: {integrity: sha512-IivEUC+3HNSsQNCfaCDzev2CpsvWpgFReitCmj0PKIdXFRsTi78jtJiraLWnYy956j4wwZbKN0OFGkS2ekKAVg==}
+    engines: {node: '>=10'}
+    cpu: [arm64]
+    os: [linux]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-linux-x64-gnu/1.3.14:
+    resolution: {integrity: sha512-HtwwA1Z0tE2z9fgaR5ehgY5ULbnVLHj3tayyWhIElF4EWsi6aQfCyn/oCZAcjoPKfEnJiSNBYt5gMmfK8l4mJA==}
+    engines: {node: '>=10'}
+    cpu: [x64]
+    os: [linux]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-linux-x64-musl/1.3.14:
+    resolution: {integrity: sha512-RPXilkTD8IVgpou4TNuqZJOB7kMrVJ7sm7GgHF4v1eV3xdIyvy4w5FWjXZRdwMW6iunLgQEckuOmVx0I4mrdNg==}
+    engines: {node: '>=10'}
+    cpu: [x64]
+    os: [linux]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-win32-arm64-msvc/1.3.14:
+    resolution: {integrity: sha512-H8Ka/ahJRs84hQCHC5ndORujbLBmi1mv+Z/m4CXpOaEX7TmeAo8nA17rrRckNvVkud9fghsKQGjkBQvJ0v7mRw==}
+    engines: {node: '>=10'}
+    cpu: [arm64]
+    os: [win32]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-win32-ia32-msvc/1.3.14:
+    resolution: {integrity: sha512-H3ZmDXrVxrqBzzCFodwYfcXfTHE0xGNLJlLGzJ4haV6RBM3ZYIvRzDtPivDzic/VQncmPj1WpLoEDfx/7KNC8Q==}
+    engines: {node: '>=10'}
+    cpu: [ia32]
+    os: [win32]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core-win32-x64-msvc/1.3.14:
+    resolution: {integrity: sha512-/D1lhWF/DQi2M7b6jWL35NmTY0mRJ5mwTXdmjqNNWOZ8h8TXQo1A3/FDFnfIIcRUeSNdF7IeB3xInT3BI34E1w==}
+    engines: {node: '>=10'}
+    cpu: [x64]
+    os: [win32]
+    requiresBuild: true
+    dev: true
+    optional: true
+
+  /@swc/core/1.3.14:
+    resolution: {integrity: sha512-LpTTrXOGS7vnbR/rHrAux7GykUWbyVmI5NbICl9iF9yeqFdGm6JjaGBhbanmG8zrQL5aFx2kMxxb92V9D1KUiw==}
+    engines: {node: '>=10'}
+    hasBin: true
+    requiresBuild: true
+    optionalDependencies:
+      '@swc/core-darwin-arm64': 1.3.14
+      '@swc/core-darwin-x64': 1.3.14
+      '@swc/core-linux-arm-gnueabihf': 1.3.14
+      '@swc/core-linux-arm64-gnu': 1.3.14
+      '@swc/core-linux-arm64-musl': 1.3.14
+      '@swc/core-linux-x64-gnu': 1.3.14
+      '@swc/core-linux-x64-musl': 1.3.14
+      '@swc/core-win32-arm64-msvc': 1.3.14
+      '@swc/core-win32-ia32-msvc': 1.3.14
+      '@swc/core-win32-x64-msvc': 1.3.14
+    dev: true
+
   /@sxzz/popperjs-es/2.11.7:
     resolution: {integrity: sha512-Ccy0NlLkzr0Ex2FKvh2X+OyERHXJ88XJ1MXtsI9y9fGexlaXaVTPzBCRBwIxFkORuOb+uBqeu+RqnpgYTEZRUQ==}
     dev: false
@@ -2311,6 +2421,15 @@ packages:
     engines: {node: '>= 10.13.0'}
     dev: false
 
+  /vite-plugin-top-level-await/1.2.1_vite@2.9.15:
+    resolution: {integrity: sha512-zcWT63N+N9lLIKuBIjmRd4Iufx62AGorLu/RDmMwm40ZsGNllP1Q0jObF3Mjqe6OByj+0vjy1LH/pupr5yWGgw==}
+    peerDependencies:
+      vite: '>=2.8'
+    dependencies:
+      '@swc/core': 1.3.14
+      vite: 2.9.15_sass@1.56.0
+    dev: true
+
   /vite-plugin-windicss/1.8.8_vite@2.9.15:
     resolution: {integrity: sha512-iyu+ZX0NmhNEUaLPv7xtC+EFRBpWMmw0nhd9a9upayfuNG/thwslKiQKmRB7U/dG0k/2oWLvPDvN/B9i7oRgSA==}
     peerDependencies:

+ 3 - 2
src/router/index.ts

@@ -25,7 +25,6 @@ const router = createRouter({
     // }
   ]
 })
-export default router
 
 // function hasPermission(route: RouteRecordDetailRaw, role: string) {
 //   if (Array.isArray(route?.meta?.roles)) {
@@ -54,7 +53,7 @@ export default router
 const modules = import.meta.globEager('./routes/*.ts')
 const importRoutes: RouteRecordDetailRaw[] = Object.values(modules).reduce((previous, module) => { return previous.concat(module.default) }, []) as RouteRecordDetailRaw[]
 
-request({
+await request({
   url: '/user/org_menu/setting',
   data: {
     cpm_id: '90000',
@@ -127,6 +126,8 @@ request({
   app_routes.value = (routes as RouteRecordDetailRaw[])
 })
 
+export default router
+
 
 router.beforeEach((to, from) => {
   if (to?.name) {

+ 7 - 0
vite.config.ts

@@ -7,6 +7,7 @@ import Components from 'unplugin-vue-components/vite'
 import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
 import Icons from 'unplugin-icons/vite'
 import IconsResolver from 'unplugin-icons/resolver'
+import topLevelAwait from "vite-plugin-top-level-await";
 
 // https://vitejs.dev/config/
 export default defineConfig(({ command }) => {
@@ -31,6 +32,12 @@ export default defineConfig(({ command }) => {
       },
     },
     plugins: [
+      topLevelAwait({
+        // The export name of top-level await promise for each chunk module
+        promiseExportName: "__tla",
+        // The function to generate import names of top-level await promise in each chunk module
+        promiseImportName: i => `__tla_${i}`
+      }),
       vue({
         reactivityTransform: true
       }),