@deot/env-scaffold 0.0.0-stage → 1.1.0
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/README.md +73 -2
- package/dist/index.d.ts +30 -0
- package/dist/index.js +172 -0
- package/package.json +23 -3
- package/templates/monorepo-js/.browserslistrc +4 -0
- package/templates/monorepo-js/.editorconfig +12 -0
- package/templates/monorepo-js/.husky/commit-msg +3 -0
- package/templates/monorepo-js/.husky/pre-commit +3 -0
- package/templates/monorepo-js/.lintstagedrc.json +5 -0
- package/templates/monorepo-js/README.md +62 -0
- package/templates/monorepo-js/_gitignore +73 -0
- package/templates/monorepo-js/_npmrc +0 -0
- package/templates/monorepo-js/eslint.config.js +7 -0
- package/templates/monorepo-js/jsconfig.json +7 -0
- package/templates/monorepo-js/package.json +40 -0
- package/templates/monorepo-js/pnpm-lock.yaml +11215 -0
- package/templates/monorepo-js/pnpm-workspace.yaml +15 -0
- package/templates/monorepo-js/src/index.ejs +14 -0
- package/templates/monorepo-js/src/manage/components/index.js +1 -0
- package/templates/monorepo-js/src/manage/components/layouts/README.md +3 -0
- package/templates/monorepo-js/src/manage/components/send-code/api.js +18 -0
- package/templates/monorepo-js/src/manage/components/send-code/index.js +5 -0
- package/templates/monorepo-js/src/manage/components/send-code/send-code.vue +133 -0
- package/templates/monorepo-js/src/manage/constants/index.js +1 -0
- package/templates/monorepo-js/src/manage/env.js +76 -0
- package/templates/monorepo-js/src/manage/index.js +15 -0
- package/templates/monorepo-js/src/manage/modules/shared.js +40 -0
- package/templates/monorepo-js/src/manage/package.json +6 -0
- package/templates/monorepo-js/src/manage/pages/escape/main/index.vue +57 -0
- package/templates/monorepo-js/src/manage/pages/home/main/index.vue +31 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/account/api.js +59 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/account/check-code.vue +54 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/account/dingtalk-qrocde.vue +94 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/account/index.vue +246 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/account/password.vue +119 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/account/sms-code.vue +73 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/index.js +5 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/login-view.vue +165 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/password/api.js +15 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/password/index.vue +84 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/password/mobile.vue +149 -0
- package/templates/monorepo-js/src/manage/pages/login/main/components/login/website-records/index.vue +31 -0
- package/templates/monorepo-js/src/manage/pages/login/main/index.vue +13 -0
- package/templates/monorepo-js/src/manage/pages/state/manage/scroll/index.vue +73 -0
- package/templates/monorepo-js/src/manage/pages/workspace/features/env/index.vue +58 -0
- package/templates/monorepo-js/src/manage/pages/workspace/features/feedback/index.vue +40 -0
- package/templates/monorepo-js/src/manage/router/index.js +8 -0
- package/templates/monorepo-js/src/manage/stores/apis/index.js +4 -0
- package/templates/monorepo-js/src/manage/stores/apis/layout.js +35 -0
- package/templates/monorepo-js/src/manage/stores/apis/notice.js +23 -0
- package/templates/monorepo-js/src/manage/stores/apis/upload.js +1 -0
- package/templates/monorepo-js/src/manage/stores/apis/user.js +47 -0
- package/templates/monorepo-js/src/manage/stores/index.js +1 -0
- package/templates/monorepo-js/src/manage/styles/font.scss +0 -0
- package/templates/monorepo-js/src/manage/styles/global.scss +6 -0
- package/templates/monorepo-js/src/manage/styles/index.scss +15 -0
- package/templates/monorepo-js/src/manage/styles/reset.scss +3 -0
- package/templates/monorepo-js/src/manage/styles/theme.scss +40 -0
- package/templates/monorepo-js/src/manage/utils/index.js +1 -0
- package/templates/monorepo-js/src/mobile/components/index.js +1 -0
- package/templates/monorepo-js/src/mobile/constants/index.js +1 -0
- package/templates/monorepo-js/src/mobile/env.js +61 -0
- package/templates/monorepo-js/src/mobile/hooks/index.js +1 -0
- package/templates/monorepo-js/src/mobile/index.js +32 -0
- package/templates/monorepo-js/src/mobile/modules/shared.js +40 -0
- package/templates/monorepo-js/src/mobile/package.json +6 -0
- package/templates/monorepo-js/src/mobile/pages/escape/main/index.vue +57 -0
- package/templates/monorepo-js/src/mobile/pages/home/main/index.vue +56 -0
- package/templates/monorepo-js/src/mobile/pages/login/main/api.js +13 -0
- package/templates/monorepo-js/src/mobile/pages/login/main/index.vue +85 -0
- package/templates/monorepo-js/src/mobile/router/index.js +8 -0
- package/templates/monorepo-js/src/mobile/stores/apis/index.js +2 -0
- package/templates/monorepo-js/src/mobile/stores/apis/upload.js +1 -0
- package/templates/monorepo-js/src/mobile/stores/apis/user.js +47 -0
- package/templates/monorepo-js/src/mobile/stores/index.js +1 -0
- package/templates/monorepo-js/src/mobile/styles/font.scss +0 -0
- package/templates/monorepo-js/src/mobile/styles/global.scss +6 -0
- package/templates/monorepo-js/src/mobile/styles/index.scss +16 -0
- package/templates/monorepo-js/src/mobile/styles/reset.scss +3 -0
- package/templates/monorepo-js/src/mobile/styles/theme.scss +45 -0
- package/templates/monorepo-js/src/mobile/utils/index.js +1 -0
- package/templates/monorepo-js/src/preload.js +2 -0
- package/templates/monorepo-js/src/shared/components/authority/authority.vue +106 -0
- package/templates/monorepo-js/src/shared/components/authority/hooks.js +27 -0
- package/templates/monorepo-js/src/shared/components/authority/index.js +7 -0
- package/templates/monorepo-js/src/shared/components/index.js +2 -0
- package/templates/monorepo-js/src/shared/components/layouts/README.md +33 -0
- package/templates/monorepo-js/src/shared/components/layouts/avatar/index.vue +114 -0
- package/templates/monorepo-js/src/shared/components/layouts/avatar/password-editor/index.js +4 -0
- package/templates/monorepo-js/src/shared/components/layouts/avatar/password-editor/wrapper.vue +164 -0
- package/templates/monorepo-js/src/shared/components/layouts/default-mobile.vue +31 -0
- package/templates/monorepo-js/src/shared/components/layouts/default.vue +244 -0
- package/templates/monorepo-js/src/shared/components/layouts/download/api.js +5 -0
- package/templates/monorepo-js/src/shared/components/layouts/download/floating.vue +45 -0
- package/templates/monorepo-js/src/shared/components/layouts/download/index.js +2 -0
- package/templates/monorepo-js/src/shared/components/layouts/download/index.vue +24 -0
- package/templates/monorepo-js/src/shared/components/layouts/header/index.vue +101 -0
- package/templates/monorepo-js/src/shared/components/layouts/header/navbar-toggle.vue +57 -0
- package/templates/monorepo-js/src/shared/components/layouts/header/title-inner.vue +63 -0
- package/templates/monorepo-js/src/shared/components/layouts/header/title.vue +69 -0
- package/templates/monorepo-js/src/shared/components/layouts/navbar/index.vue +127 -0
- package/templates/monorepo-js/src/shared/components/layouts/navbar/item.vue +88 -0
- package/templates/monorepo-js/src/shared/components/layouts/none.vue +3 -0
- package/templates/monorepo-js/src/shared/components/layouts/notice/index.vue +51 -0
- package/templates/monorepo-js/src/shared/components/layouts/right-menu/index.js +4 -0
- package/templates/monorepo-js/src/shared/components/layouts/right-menu/wrapper.vue +149 -0
- package/templates/monorepo-js/src/shared/components/layouts/sidebar/index.vue +52 -0
- package/templates/monorepo-js/src/shared/components/layouts/sidebar/item.vue +116 -0
- package/templates/monorepo-js/src/shared/components/layouts/stores/index.js +4 -0
- package/templates/monorepo-js/src/shared/components/layouts/stores/use-layout-default-scroller.js +118 -0
- package/templates/monorepo-js/src/shared/components/layouts/stores/use-layout-default-size.js +122 -0
- package/templates/monorepo-js/src/shared/components/layouts/stores/use-layout-default-tabs.js +246 -0
- package/templates/monorepo-js/src/shared/components/layouts/stores/use-layout-default.js +132 -0
- package/templates/monorepo-js/src/shared/components/layouts/tabs/index.vue +81 -0
- package/templates/monorepo-js/src/shared/components/layouts/tabs/item.vue +211 -0
- package/templates/monorepo-js/src/shared/components/set-title/index.js +1 -0
- package/templates/monorepo-js/src/shared/components/set-title/set-title.vue +96 -0
- package/templates/monorepo-js/src/shared/constants/caches.js +10 -0
- package/templates/monorepo-js/src/shared/constants/index.js +7 -0
- package/templates/monorepo-js/src/shared/constants/modes.js +10 -0
- package/templates/monorepo-js/src/shared/constants/normal.js +1 -0
- package/templates/monorepo-js/src/shared/constants/pages.js +2 -0
- package/templates/monorepo-js/src/shared/constants/radios.js +50 -0
- package/templates/monorepo-js/src/shared/constants/routes.js +7 -0
- package/templates/monorepo-js/src/shared/examples/index.js +10 -0
- package/templates/monorepo-js/src/shared/examples/layout.js +22 -0
- package/templates/monorepo-js/src/shared/examples/pages/home/main/index.vue +30 -0
- package/templates/monorepo-js/src/shared/examples/pages/login/main/index.vue +13 -0
- package/templates/monorepo-js/src/shared/examples/pages/style/unocss/on-demand/index.vue +45 -0
- package/templates/monorepo-js/src/shared/examples/router/index.js +8 -0
- package/templates/monorepo-js/src/shared/hooks/index.js +5 -0
- package/templates/monorepo-js/src/shared/hooks/use-first-route.js +50 -0
- package/templates/monorepo-js/src/shared/hooks/use-keep-alive.js +16 -0
- package/templates/monorepo-js/src/shared/hooks/use-safe-router.js +32 -0
- package/templates/monorepo-js/src/shared/hooks/use-session-data.js +68 -0
- package/templates/monorepo-js/src/shared/hooks/use-sync-data.js +34 -0
- package/templates/monorepo-js/src/shared/index.html +13 -0
- package/templates/monorepo-js/src/shared/index.js +38 -0
- package/templates/monorepo-js/src/shared/modules/context.js +35 -0
- package/templates/monorepo-js/src/shared/modules/global.js +97 -0
- package/templates/monorepo-js/src/shared/modules/network.js +189 -0
- package/templates/monorepo-js/src/shared/modules/pinia.js +30 -0
- package/templates/monorepo-js/src/shared/modules/router.js +75 -0
- package/templates/monorepo-js/src/shared/modules/shared.js +42 -0
- package/templates/monorepo-js/src/shared/modules/vc.js +135 -0
- package/templates/monorepo-js/src/shared/package.json +7 -0
- package/templates/monorepo-js/src/shared/stores/apis/download.js +99 -0
- package/templates/monorepo-js/src/shared/stores/apis/index.js +4 -0
- package/templates/monorepo-js/src/shared/stores/apis/upload.js +68 -0
- package/templates/monorepo-js/src/shared/stores/index.js +5 -0
- package/templates/monorepo-js/src/shared/stores/modules/app.js +58 -0
- package/templates/monorepo-js/src/shared/stores/modules/env.js +47 -0
- package/templates/monorepo-js/src/shared/stores/modules/index.js +4 -0
- package/templates/monorepo-js/src/shared/stores/modules/notice.js +54 -0
- package/templates/monorepo-js/src/shared/stores/modules/user.js +84 -0
- package/templates/monorepo-js/src/shared/styles/font.scss +0 -0
- package/templates/monorepo-js/src/shared/styles/global.scss +25 -0
- package/templates/monorepo-js/src/shared/styles/index.scss +4 -0
- package/templates/monorepo-js/src/shared/styles/reset.scss +3 -0
- package/templates/monorepo-js/src/shared/utils/fullscreen.js +72 -0
- package/templates/monorepo-js/src/shared/utils/index.js +3 -0
- package/templates/monorepo-js/src/shared/utils/rules.js +56 -0
- package/templates/monorepo-js/src/shared/utils/utils.js +294 -0
- package/templates/monorepo-js/stylelint.config.js +3 -0
- package/templates/monorepo-js/vite.config.js +10 -0
- package/templates/monorepo-ts/.browserslistrc +4 -0
- package/templates/monorepo-ts/.editorconfig +12 -0
- package/templates/monorepo-ts/.husky/commit-msg +3 -0
- package/templates/monorepo-ts/.husky/pre-commit +3 -0
- package/templates/monorepo-ts/.lintstagedrc.json +5 -0
- package/templates/monorepo-ts/README.md +62 -0
- package/templates/monorepo-ts/_gitignore +73 -0
- package/templates/monorepo-ts/_npmrc +0 -0
- package/templates/monorepo-ts/eslint.config.js +13 -0
- package/templates/monorepo-ts/package.json +43 -0
- package/templates/monorepo-ts/pnpm-lock.yaml +11271 -0
- package/templates/monorepo-ts/pnpm-workspace.yaml +15 -0
- package/templates/monorepo-ts/src/index.ejs +14 -0
- package/templates/monorepo-ts/src/manage/components/index.ts +1 -0
- package/templates/monorepo-ts/src/manage/components/layouts/README.md +3 -0
- package/templates/monorepo-ts/src/manage/components/send-code/api.ts +19 -0
- package/templates/monorepo-ts/src/manage/components/send-code/index.ts +5 -0
- package/templates/monorepo-ts/src/manage/components/send-code/send-code.vue +133 -0
- package/templates/monorepo-ts/src/manage/constants/index.ts +1 -0
- package/templates/monorepo-ts/src/manage/env.ts +76 -0
- package/templates/monorepo-ts/src/manage/index.ts +15 -0
- package/templates/monorepo-ts/src/manage/modules/shared.ts +41 -0
- package/templates/monorepo-ts/src/manage/package.json +6 -0
- package/templates/monorepo-ts/src/manage/pages/escape/main/index.vue +57 -0
- package/templates/monorepo-ts/src/manage/pages/home/main/index.vue +31 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/account/api.ts +59 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/account/check-code.vue +54 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/account/dingtalk-qrocde.vue +94 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/account/index.vue +246 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/account/password.vue +119 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/account/sms-code.vue +73 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/index.ts +5 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/login-view.vue +164 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/password/api.ts +15 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/password/index.vue +84 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/password/mobile.vue +149 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/components/login/website-records/index.vue +31 -0
- package/templates/monorepo-ts/src/manage/pages/login/main/index.vue +13 -0
- package/templates/monorepo-ts/src/manage/pages/state/manage/scroll/index.vue +73 -0
- package/templates/monorepo-ts/src/manage/pages/workspace/features/env/index.vue +58 -0
- package/templates/monorepo-ts/src/manage/pages/workspace/features/feedback/index.vue +40 -0
- package/templates/monorepo-ts/src/manage/router/index.ts +8 -0
- package/templates/monorepo-ts/src/manage/stores/apis/index.ts +4 -0
- package/templates/monorepo-ts/src/manage/stores/apis/layout.ts +35 -0
- package/templates/monorepo-ts/src/manage/stores/apis/notice.ts +23 -0
- package/templates/monorepo-ts/src/manage/stores/apis/upload.ts +1 -0
- package/templates/monorepo-ts/src/manage/stores/apis/user.ts +47 -0
- package/templates/monorepo-ts/src/manage/stores/index.ts +1 -0
- package/templates/monorepo-ts/src/manage/styles/font.scss +0 -0
- package/templates/monorepo-ts/src/manage/styles/global.scss +6 -0
- package/templates/monorepo-ts/src/manage/styles/index.scss +15 -0
- package/templates/monorepo-ts/src/manage/styles/reset.scss +3 -0
- package/templates/monorepo-ts/src/manage/styles/theme.scss +40 -0
- package/templates/monorepo-ts/src/manage/utils/index.ts +1 -0
- package/templates/monorepo-ts/src/mobile/components/index.ts +1 -0
- package/templates/monorepo-ts/src/mobile/constants/index.ts +1 -0
- package/templates/monorepo-ts/src/mobile/env.ts +64 -0
- package/templates/monorepo-ts/src/mobile/hooks/index.ts +1 -0
- package/templates/monorepo-ts/src/mobile/index.ts +32 -0
- package/templates/monorepo-ts/src/mobile/modules/shared.ts +41 -0
- package/templates/monorepo-ts/src/mobile/package.json +6 -0
- package/templates/monorepo-ts/src/mobile/pages/escape/main/index.vue +57 -0
- package/templates/monorepo-ts/src/mobile/pages/home/main/index.vue +56 -0
- package/templates/monorepo-ts/src/mobile/pages/login/main/api.ts +13 -0
- package/templates/monorepo-ts/src/mobile/pages/login/main/index.vue +85 -0
- package/templates/monorepo-ts/src/mobile/router/index.ts +8 -0
- package/templates/monorepo-ts/src/mobile/stores/apis/index.ts +2 -0
- package/templates/monorepo-ts/src/mobile/stores/apis/upload.ts +1 -0
- package/templates/monorepo-ts/src/mobile/stores/apis/user.ts +47 -0
- package/templates/monorepo-ts/src/mobile/stores/index.ts +1 -0
- package/templates/monorepo-ts/src/mobile/styles/font.scss +0 -0
- package/templates/monorepo-ts/src/mobile/styles/global.scss +6 -0
- package/templates/monorepo-ts/src/mobile/styles/index.scss +16 -0
- package/templates/monorepo-ts/src/mobile/styles/reset.scss +3 -0
- package/templates/monorepo-ts/src/mobile/styles/theme.scss +45 -0
- package/templates/monorepo-ts/src/mobile/utils/index.ts +1 -0
- package/templates/monorepo-ts/src/preload.ts +2 -0
- package/templates/monorepo-ts/src/shared/components/authority/authority.vue +107 -0
- package/templates/monorepo-ts/src/shared/components/authority/hooks.ts +27 -0
- package/templates/monorepo-ts/src/shared/components/authority/index.ts +7 -0
- package/templates/monorepo-ts/src/shared/components/index.ts +2 -0
- package/templates/monorepo-ts/src/shared/components/layouts/README.md +33 -0
- package/templates/monorepo-ts/src/shared/components/layouts/avatar/index.vue +114 -0
- package/templates/monorepo-ts/src/shared/components/layouts/avatar/password-editor/index.ts +4 -0
- package/templates/monorepo-ts/src/shared/components/layouts/avatar/password-editor/wrapper.vue +164 -0
- package/templates/monorepo-ts/src/shared/components/layouts/default-mobile.vue +31 -0
- package/templates/monorepo-ts/src/shared/components/layouts/default.vue +244 -0
- package/templates/monorepo-ts/src/shared/components/layouts/download/api.ts +5 -0
- package/templates/monorepo-ts/src/shared/components/layouts/download/floating.vue +45 -0
- package/templates/monorepo-ts/src/shared/components/layouts/download/index.ts +2 -0
- package/templates/monorepo-ts/src/shared/components/layouts/download/index.vue +24 -0
- package/templates/monorepo-ts/src/shared/components/layouts/header/index.vue +101 -0
- package/templates/monorepo-ts/src/shared/components/layouts/header/navbar-toggle.vue +57 -0
- package/templates/monorepo-ts/src/shared/components/layouts/header/title-inner.vue +63 -0
- package/templates/monorepo-ts/src/shared/components/layouts/header/title.vue +69 -0
- package/templates/monorepo-ts/src/shared/components/layouts/navbar/index.vue +128 -0
- package/templates/monorepo-ts/src/shared/components/layouts/navbar/item.vue +89 -0
- package/templates/monorepo-ts/src/shared/components/layouts/none.vue +3 -0
- package/templates/monorepo-ts/src/shared/components/layouts/notice/index.vue +51 -0
- package/templates/monorepo-ts/src/shared/components/layouts/right-menu/index.ts +4 -0
- package/templates/monorepo-ts/src/shared/components/layouts/right-menu/wrapper.vue +150 -0
- package/templates/monorepo-ts/src/shared/components/layouts/sidebar/index.vue +52 -0
- package/templates/monorepo-ts/src/shared/components/layouts/sidebar/item.vue +117 -0
- package/templates/monorepo-ts/src/shared/components/layouts/stores/index.ts +4 -0
- package/templates/monorepo-ts/src/shared/components/layouts/stores/use-layout-default-scroller.ts +118 -0
- package/templates/monorepo-ts/src/shared/components/layouts/stores/use-layout-default-size.ts +122 -0
- package/templates/monorepo-ts/src/shared/components/layouts/stores/use-layout-default-tabs.ts +245 -0
- package/templates/monorepo-ts/src/shared/components/layouts/stores/use-layout-default.ts +132 -0
- package/templates/monorepo-ts/src/shared/components/layouts/tabs/index.vue +81 -0
- package/templates/monorepo-ts/src/shared/components/layouts/tabs/item.vue +212 -0
- package/templates/monorepo-ts/src/shared/components/set-title/index.ts +1 -0
- package/templates/monorepo-ts/src/shared/components/set-title/set-title.vue +97 -0
- package/templates/monorepo-ts/src/shared/constants/caches.ts +10 -0
- package/templates/monorepo-ts/src/shared/constants/index.ts +7 -0
- package/templates/monorepo-ts/src/shared/constants/modes.ts +10 -0
- package/templates/monorepo-ts/src/shared/constants/normal.ts +1 -0
- package/templates/monorepo-ts/src/shared/constants/pages.ts +2 -0
- package/templates/monorepo-ts/src/shared/constants/radios.ts +50 -0
- package/templates/monorepo-ts/src/shared/constants/routes.ts +7 -0
- package/templates/monorepo-ts/src/shared/examples/index.ts +10 -0
- package/templates/monorepo-ts/src/shared/examples/layout.ts +22 -0
- package/templates/monorepo-ts/src/shared/examples/pages/home/main/index.vue +30 -0
- package/templates/monorepo-ts/src/shared/examples/pages/login/main/index.vue +13 -0
- package/templates/monorepo-ts/src/shared/examples/pages/style/unocss/on-demand/index.vue +45 -0
- package/templates/monorepo-ts/src/shared/examples/router/index.ts +8 -0
- package/templates/monorepo-ts/src/shared/hooks/index.ts +5 -0
- package/templates/monorepo-ts/src/shared/hooks/use-first-route.ts +50 -0
- package/templates/monorepo-ts/src/shared/hooks/use-keep-alive.ts +16 -0
- package/templates/monorepo-ts/src/shared/hooks/use-safe-router.ts +32 -0
- package/templates/monorepo-ts/src/shared/hooks/use-session-data.ts +68 -0
- package/templates/monorepo-ts/src/shared/hooks/use-sync-data.ts +34 -0
- package/templates/monorepo-ts/src/shared/index.html +13 -0
- package/templates/monorepo-ts/src/shared/index.ts +48 -0
- package/templates/monorepo-ts/src/shared/modules/context.ts +41 -0
- package/templates/monorepo-ts/src/shared/modules/global.ts +97 -0
- package/templates/monorepo-ts/src/shared/modules/network.ts +189 -0
- package/templates/monorepo-ts/src/shared/modules/pinia.ts +30 -0
- package/templates/monorepo-ts/src/shared/modules/router.ts +75 -0
- package/templates/monorepo-ts/src/shared/modules/shared.ts +43 -0
- package/templates/monorepo-ts/src/shared/modules/vc.ts +135 -0
- package/templates/monorepo-ts/src/shared/package.json +7 -0
- package/templates/monorepo-ts/src/shared/stores/apis/download.ts +99 -0
- package/templates/monorepo-ts/src/shared/stores/apis/index.ts +4 -0
- package/templates/monorepo-ts/src/shared/stores/apis/upload.ts +68 -0
- package/templates/monorepo-ts/src/shared/stores/index.ts +5 -0
- package/templates/monorepo-ts/src/shared/stores/modules/app.ts +58 -0
- package/templates/monorepo-ts/src/shared/stores/modules/env.ts +47 -0
- package/templates/monorepo-ts/src/shared/stores/modules/index.ts +4 -0
- package/templates/monorepo-ts/src/shared/stores/modules/notice.ts +54 -0
- package/templates/monorepo-ts/src/shared/stores/modules/user.ts +84 -0
- package/templates/monorepo-ts/src/shared/styles/font.scss +0 -0
- package/templates/monorepo-ts/src/shared/styles/global.scss +25 -0
- package/templates/monorepo-ts/src/shared/styles/index.scss +4 -0
- package/templates/monorepo-ts/src/shared/styles/reset.scss +3 -0
- package/templates/monorepo-ts/src/shared/utils/fullscreen.ts +72 -0
- package/templates/monorepo-ts/src/shared/utils/index.ts +3 -0
- package/templates/monorepo-ts/src/shared/utils/rules.ts +56 -0
- package/templates/monorepo-ts/src/shared/utils/utils.ts +294 -0
- package/templates/monorepo-ts/src/shims.d.ts +25 -0
- package/templates/monorepo-ts/stylelint.config.js +3 -0
- package/templates/monorepo-ts/tsconfig.json +11 -0
- package/templates/monorepo-ts/vite.config.ts +10 -0
- package/templates/single-js/.browserslistrc +4 -0
- package/templates/single-js/.editorconfig +12 -0
- package/templates/single-js/.husky/commit-msg +3 -0
- package/templates/single-js/.husky/pre-commit +3 -0
- package/templates/single-js/.lintstagedrc.json +5 -0
- package/templates/single-js/README.md +72 -0
- package/templates/single-js/_gitignore +73 -0
- package/templates/single-js/_npmrc +0 -0
- package/templates/single-js/eslint.config.js +7 -0
- package/templates/single-js/index.html +14 -0
- package/templates/single-js/jsconfig.json +7 -0
- package/templates/single-js/package.json +40 -0
- package/templates/single-js/pnpm-lock.yaml +11215 -0
- package/templates/single-js/src/app.js +41 -0
- package/templates/single-js/src/components/authority/authority.vue +106 -0
- package/templates/single-js/src/components/authority/hooks.js +27 -0
- package/templates/single-js/src/components/authority/index.js +7 -0
- package/templates/single-js/src/components/index.js +3 -0
- package/templates/single-js/src/components/layouts/README.md +33 -0
- package/templates/single-js/src/components/layouts/avatar/index.vue +114 -0
- package/templates/single-js/src/components/layouts/avatar/password-editor/index.js +4 -0
- package/templates/single-js/src/components/layouts/avatar/password-editor/wrapper.vue +164 -0
- package/templates/single-js/src/components/layouts/default-mobile.vue +31 -0
- package/templates/single-js/src/components/layouts/default.vue +244 -0
- package/templates/single-js/src/components/layouts/download/api.js +5 -0
- package/templates/single-js/src/components/layouts/download/floating.vue +45 -0
- package/templates/single-js/src/components/layouts/download/index.js +2 -0
- package/templates/single-js/src/components/layouts/download/index.vue +24 -0
- package/templates/single-js/src/components/layouts/header/index.vue +101 -0
- package/templates/single-js/src/components/layouts/header/navbar-toggle.vue +57 -0
- package/templates/single-js/src/components/layouts/header/title-inner.vue +63 -0
- package/templates/single-js/src/components/layouts/header/title.vue +69 -0
- package/templates/single-js/src/components/layouts/navbar/index.vue +127 -0
- package/templates/single-js/src/components/layouts/navbar/item.vue +88 -0
- package/templates/single-js/src/components/layouts/none.vue +3 -0
- package/templates/single-js/src/components/layouts/notice/index.vue +51 -0
- package/templates/single-js/src/components/layouts/right-menu/index.js +4 -0
- package/templates/single-js/src/components/layouts/right-menu/wrapper.vue +149 -0
- package/templates/single-js/src/components/layouts/sidebar/index.vue +52 -0
- package/templates/single-js/src/components/layouts/sidebar/item.vue +116 -0
- package/templates/single-js/src/components/layouts/stores/index.js +4 -0
- package/templates/single-js/src/components/layouts/stores/use-layout-default-scroller.js +118 -0
- package/templates/single-js/src/components/layouts/stores/use-layout-default-size.js +122 -0
- package/templates/single-js/src/components/layouts/stores/use-layout-default-tabs.js +245 -0
- package/templates/single-js/src/components/layouts/stores/use-layout-default.js +132 -0
- package/templates/single-js/src/components/layouts/tabs/index.vue +81 -0
- package/templates/single-js/src/components/layouts/tabs/item.vue +211 -0
- package/templates/single-js/src/components/send-code/api.js +19 -0
- package/templates/single-js/src/components/send-code/index.js +5 -0
- package/templates/single-js/src/components/send-code/send-code.vue +133 -0
- package/templates/single-js/src/components/set-title/index.js +1 -0
- package/templates/single-js/src/components/set-title/set-title.vue +96 -0
- package/templates/single-js/src/constants/caches.js +10 -0
- package/templates/single-js/src/constants/index.js +8 -0
- package/templates/single-js/src/constants/layout.js +7 -0
- package/templates/single-js/src/constants/modes.js +10 -0
- package/templates/single-js/src/constants/normal.js +1 -0
- package/templates/single-js/src/constants/pages.js +2 -0
- package/templates/single-js/src/constants/radios.js +50 -0
- package/templates/single-js/src/constants/routes.js +7 -0
- package/templates/single-js/src/env.js +75 -0
- package/templates/single-js/src/hooks/index.js +5 -0
- package/templates/single-js/src/hooks/use-first-route.js +50 -0
- package/templates/single-js/src/hooks/use-keep-alive.js +16 -0
- package/templates/single-js/src/hooks/use-safe-router.js +32 -0
- package/templates/single-js/src/hooks/use-session-data.js +68 -0
- package/templates/single-js/src/hooks/use-sync-data.js +34 -0
- package/templates/single-js/src/layout.js +38 -0
- package/templates/single-js/src/modules/context.js +39 -0
- package/templates/single-js/src/modules/global.js +93 -0
- package/templates/single-js/src/modules/network.js +189 -0
- package/templates/single-js/src/modules/pinia.js +30 -0
- package/templates/single-js/src/modules/router.js +66 -0
- package/templates/single-js/src/modules/shared.js +42 -0
- package/templates/single-js/src/modules/vc.js +135 -0
- package/templates/single-js/src/pages/escape/main/index.vue +57 -0
- package/templates/single-js/src/pages/home/main/index.vue +32 -0
- package/templates/single-js/src/pages/login/main/components/login/account/api.js +59 -0
- package/templates/single-js/src/pages/login/main/components/login/account/check-code.vue +54 -0
- package/templates/single-js/src/pages/login/main/components/login/account/dingtalk-qrocde.vue +94 -0
- package/templates/single-js/src/pages/login/main/components/login/account/index.vue +246 -0
- package/templates/single-js/src/pages/login/main/components/login/account/password.vue +114 -0
- package/templates/single-js/src/pages/login/main/components/login/account/sms-code.vue +73 -0
- package/templates/single-js/src/pages/login/main/components/login/index.js +5 -0
- package/templates/single-js/src/pages/login/main/components/login/login-view.vue +164 -0
- package/templates/single-js/src/pages/login/main/components/login/password/api.js +15 -0
- package/templates/single-js/src/pages/login/main/components/login/password/index.vue +84 -0
- package/templates/single-js/src/pages/login/main/components/login/password/mobile.vue +149 -0
- package/templates/single-js/src/pages/login/main/components/login/website-records/index.vue +31 -0
- package/templates/single-js/src/pages/login/main/index.vue +13 -0
- package/templates/single-js/src/pages/state/manage/scroll/index.vue +73 -0
- package/templates/single-js/src/pages/workspace/features/env/index.vue +59 -0
- package/templates/single-js/src/pages/workspace/features/feedback/index.vue +40 -0
- package/templates/single-js/src/preload.js +2 -0
- package/templates/single-js/src/router/index.js +5 -0
- package/templates/single-js/src/stores/apis/download.js +99 -0
- package/templates/single-js/src/stores/apis/index.js +5 -0
- package/templates/single-js/src/stores/apis/notice.js +23 -0
- package/templates/single-js/src/stores/apis/upload.js +68 -0
- package/templates/single-js/src/stores/apis/user.js +47 -0
- package/templates/single-js/src/stores/index.js +5 -0
- package/templates/single-js/src/stores/modules/app.js +58 -0
- package/templates/single-js/src/stores/modules/env.js +47 -0
- package/templates/single-js/src/stores/modules/index.js +4 -0
- package/templates/single-js/src/stores/modules/notice.js +54 -0
- package/templates/single-js/src/stores/modules/user.js +84 -0
- package/templates/single-js/src/styles/font.scss +0 -0
- package/templates/single-js/src/styles/global.scss +31 -0
- package/templates/single-js/src/styles/index.scss +14 -0
- package/templates/single-js/src/styles/reset.scss +3 -0
- package/templates/single-js/src/styles/theme.scss +40 -0
- package/templates/single-js/src/utils/fullscreen.js +72 -0
- package/templates/single-js/src/utils/index.js +3 -0
- package/templates/single-js/src/utils/rules.js +56 -0
- package/templates/single-js/src/utils/utils.js +294 -0
- package/templates/single-js/stylelint.config.js +3 -0
- package/templates/single-js/vite.config.js +10 -0
- package/templates/single-ts/.browserslistrc +4 -0
- package/templates/single-ts/.editorconfig +12 -0
- package/templates/single-ts/.husky/commit-msg +3 -0
- package/templates/single-ts/.husky/pre-commit +3 -0
- package/templates/single-ts/.lintstagedrc.json +5 -0
- package/templates/single-ts/README.md +72 -0
- package/templates/single-ts/_gitignore +73 -0
- package/templates/single-ts/_npmrc +0 -0
- package/templates/single-ts/eslint.config.js +13 -0
- package/templates/single-ts/index.html +14 -0
- package/templates/single-ts/package.json +43 -0
- package/templates/single-ts/pnpm-lock.yaml +11271 -0
- package/templates/single-ts/src/app.ts +41 -0
- package/templates/single-ts/src/components/authority/authority.vue +107 -0
- package/templates/single-ts/src/components/authority/hooks.ts +27 -0
- package/templates/single-ts/src/components/authority/index.ts +7 -0
- package/templates/single-ts/src/components/index.ts +3 -0
- package/templates/single-ts/src/components/layouts/README.md +33 -0
- package/templates/single-ts/src/components/layouts/avatar/index.vue +114 -0
- package/templates/single-ts/src/components/layouts/avatar/password-editor/index.ts +4 -0
- package/templates/single-ts/src/components/layouts/avatar/password-editor/wrapper.vue +164 -0
- package/templates/single-ts/src/components/layouts/default-mobile.vue +31 -0
- package/templates/single-ts/src/components/layouts/default.vue +244 -0
- package/templates/single-ts/src/components/layouts/download/api.ts +5 -0
- package/templates/single-ts/src/components/layouts/download/floating.vue +45 -0
- package/templates/single-ts/src/components/layouts/download/index.ts +2 -0
- package/templates/single-ts/src/components/layouts/download/index.vue +24 -0
- package/templates/single-ts/src/components/layouts/header/index.vue +101 -0
- package/templates/single-ts/src/components/layouts/header/navbar-toggle.vue +57 -0
- package/templates/single-ts/src/components/layouts/header/title-inner.vue +63 -0
- package/templates/single-ts/src/components/layouts/header/title.vue +69 -0
- package/templates/single-ts/src/components/layouts/navbar/index.vue +128 -0
- package/templates/single-ts/src/components/layouts/navbar/item.vue +89 -0
- package/templates/single-ts/src/components/layouts/none.vue +3 -0
- package/templates/single-ts/src/components/layouts/notice/index.vue +51 -0
- package/templates/single-ts/src/components/layouts/right-menu/index.ts +4 -0
- package/templates/single-ts/src/components/layouts/right-menu/wrapper.vue +150 -0
- package/templates/single-ts/src/components/layouts/sidebar/index.vue +52 -0
- package/templates/single-ts/src/components/layouts/sidebar/item.vue +117 -0
- package/templates/single-ts/src/components/layouts/stores/index.ts +4 -0
- package/templates/single-ts/src/components/layouts/stores/use-layout-default-scroller.ts +118 -0
- package/templates/single-ts/src/components/layouts/stores/use-layout-default-size.ts +122 -0
- package/templates/single-ts/src/components/layouts/stores/use-layout-default-tabs.ts +245 -0
- package/templates/single-ts/src/components/layouts/stores/use-layout-default.ts +132 -0
- package/templates/single-ts/src/components/layouts/tabs/index.vue +81 -0
- package/templates/single-ts/src/components/layouts/tabs/item.vue +212 -0
- package/templates/single-ts/src/components/send-code/api.ts +19 -0
- package/templates/single-ts/src/components/send-code/index.ts +5 -0
- package/templates/single-ts/src/components/send-code/send-code.vue +133 -0
- package/templates/single-ts/src/components/set-title/index.ts +1 -0
- package/templates/single-ts/src/components/set-title/set-title.vue +97 -0
- package/templates/single-ts/src/constants/caches.ts +10 -0
- package/templates/single-ts/src/constants/index.ts +8 -0
- package/templates/single-ts/src/constants/layout.ts +7 -0
- package/templates/single-ts/src/constants/modes.ts +10 -0
- package/templates/single-ts/src/constants/normal.ts +1 -0
- package/templates/single-ts/src/constants/pages.ts +2 -0
- package/templates/single-ts/src/constants/radios.ts +50 -0
- package/templates/single-ts/src/constants/routes.ts +7 -0
- package/templates/single-ts/src/env.ts +75 -0
- package/templates/single-ts/src/hooks/index.ts +5 -0
- package/templates/single-ts/src/hooks/use-first-route.ts +50 -0
- package/templates/single-ts/src/hooks/use-keep-alive.ts +16 -0
- package/templates/single-ts/src/hooks/use-safe-router.ts +32 -0
- package/templates/single-ts/src/hooks/use-session-data.ts +68 -0
- package/templates/single-ts/src/hooks/use-sync-data.ts +34 -0
- package/templates/single-ts/src/layout.ts +38 -0
- package/templates/single-ts/src/modules/context.ts +41 -0
- package/templates/single-ts/src/modules/global.ts +94 -0
- package/templates/single-ts/src/modules/network.ts +189 -0
- package/templates/single-ts/src/modules/pinia.ts +30 -0
- package/templates/single-ts/src/modules/router.ts +66 -0
- package/templates/single-ts/src/modules/shared.ts +43 -0
- package/templates/single-ts/src/modules/vc.ts +135 -0
- package/templates/single-ts/src/pages/escape/main/index.vue +57 -0
- package/templates/single-ts/src/pages/home/main/index.vue +32 -0
- package/templates/single-ts/src/pages/login/main/components/login/account/api.ts +59 -0
- package/templates/single-ts/src/pages/login/main/components/login/account/check-code.vue +54 -0
- package/templates/single-ts/src/pages/login/main/components/login/account/dingtalk-qrocde.vue +94 -0
- package/templates/single-ts/src/pages/login/main/components/login/account/index.vue +246 -0
- package/templates/single-ts/src/pages/login/main/components/login/account/password.vue +114 -0
- package/templates/single-ts/src/pages/login/main/components/login/account/sms-code.vue +73 -0
- package/templates/single-ts/src/pages/login/main/components/login/index.ts +5 -0
- package/templates/single-ts/src/pages/login/main/components/login/login-view.vue +164 -0
- package/templates/single-ts/src/pages/login/main/components/login/password/api.ts +15 -0
- package/templates/single-ts/src/pages/login/main/components/login/password/index.vue +84 -0
- package/templates/single-ts/src/pages/login/main/components/login/password/mobile.vue +149 -0
- package/templates/single-ts/src/pages/login/main/components/login/website-records/index.vue +31 -0
- package/templates/single-ts/src/pages/login/main/index.vue +13 -0
- package/templates/single-ts/src/pages/state/manage/scroll/index.vue +73 -0
- package/templates/single-ts/src/pages/workspace/features/env/index.vue +59 -0
- package/templates/single-ts/src/pages/workspace/features/feedback/index.vue +40 -0
- package/templates/single-ts/src/preload.ts +2 -0
- package/templates/single-ts/src/router/index.ts +5 -0
- package/templates/single-ts/src/shims.d.ts +25 -0
- package/templates/single-ts/src/stores/apis/download.ts +99 -0
- package/templates/single-ts/src/stores/apis/index.ts +5 -0
- package/templates/single-ts/src/stores/apis/notice.ts +23 -0
- package/templates/single-ts/src/stores/apis/upload.ts +68 -0
- package/templates/single-ts/src/stores/apis/user.ts +47 -0
- package/templates/single-ts/src/stores/index.ts +5 -0
- package/templates/single-ts/src/stores/modules/app.ts +58 -0
- package/templates/single-ts/src/stores/modules/env.ts +47 -0
- package/templates/single-ts/src/stores/modules/index.ts +4 -0
- package/templates/single-ts/src/stores/modules/notice.ts +54 -0
- package/templates/single-ts/src/stores/modules/user.ts +84 -0
- package/templates/single-ts/src/styles/font.scss +0 -0
- package/templates/single-ts/src/styles/global.scss +31 -0
- package/templates/single-ts/src/styles/index.scss +14 -0
- package/templates/single-ts/src/styles/reset.scss +3 -0
- package/templates/single-ts/src/styles/theme.scss +40 -0
- package/templates/single-ts/src/utils/fullscreen.ts +72 -0
- package/templates/single-ts/src/utils/index.ts +3 -0
- package/templates/single-ts/src/utils/rules.ts +56 -0
- package/templates/single-ts/src/utils/utils.ts +294 -0
- package/templates/single-ts/stylelint.config.js +3 -0
- package/templates/single-ts/tsconfig.json +11 -0
- package/templates/single-ts/vite.config.ts +10 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Emitter } from '@deot/helper-emitter';
|
|
2
|
+
import { Utils } from '@/shared/utils';
|
|
3
|
+
import { useUserStore, useEnvStore, useAppStore } from '@/shared/stores/modules';
|
|
4
|
+
import { MODE_DEV } from '@/shared/constants';
|
|
5
|
+
import * as LINKS from '@/shared/constants/pages';
|
|
6
|
+
import { Context } from './context';
|
|
7
|
+
|
|
8
|
+
class GlobalManager extends Emitter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
// 重定向地址,可以是函数
|
|
12
|
+
this.redirect = '';
|
|
13
|
+
|
|
14
|
+
this.user = null;
|
|
15
|
+
this.env = null;
|
|
16
|
+
this.app = null;
|
|
17
|
+
|
|
18
|
+
this.events = {
|
|
19
|
+
logout: '@/logout',
|
|
20
|
+
login: '@/login',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 清理登录
|
|
26
|
+
* reLogin为true时
|
|
27
|
+
* 1. 主动退出,下次登录回到首页
|
|
28
|
+
* 2. token失效退出,下次登录回到原地址;
|
|
29
|
+
* isReady用于避免路由系统未完成注册的情况
|
|
30
|
+
* @param options ~
|
|
31
|
+
*/
|
|
32
|
+
clearLoginAuth = Utils.locked(async (options = {}) => {
|
|
33
|
+
const { reLogin = true, redirect } = options;
|
|
34
|
+
await Context.Network.clear(); // 取消所有请求和shared缓存
|
|
35
|
+
await this.user.clear();
|
|
36
|
+
this.emit(this.events.logout);
|
|
37
|
+
if (reLogin) {
|
|
38
|
+
await Context.router.isReady();
|
|
39
|
+
Global.setRedirect(redirect);
|
|
40
|
+
await Context.router.replace(LINKS.PAGE_lOGIN);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
async createLoginAuth(config) {
|
|
45
|
+
this.user.clear();
|
|
46
|
+
this.user.update(config);
|
|
47
|
+
this.emit(this.events.login);
|
|
48
|
+
if (this.redirect) {
|
|
49
|
+
try {
|
|
50
|
+
if (typeof this.redirect === 'function') {
|
|
51
|
+
await this.redirect();
|
|
52
|
+
} else {
|
|
53
|
+
const current = this.redirect.split('?')[0];
|
|
54
|
+
if (['/', LINKS.PAGE_HOME, LINKS.PAGE_lOGIN].includes(current)) {
|
|
55
|
+
await Context.router.replace('/');
|
|
56
|
+
} else {
|
|
57
|
+
await Context.router.push(this.redirect);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} catch {
|
|
61
|
+
this.reLaunchHome();
|
|
62
|
+
} finally {
|
|
63
|
+
this.redirect = '';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setRedirect(v) {
|
|
69
|
+
this.redirect = v || '/';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 关闭了所有的页面, 慎用!
|
|
74
|
+
* @param code ~
|
|
75
|
+
*/
|
|
76
|
+
reLaunchHome(code) {
|
|
77
|
+
code = code || Context.options.name;
|
|
78
|
+
window.location.replace(MODE_DEV ? `/${code}/` : `/`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
install(app) {
|
|
82
|
+
app.config.globalProperties.$global = Global;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const Global = new GlobalManager();
|
|
87
|
+
|
|
88
|
+
export const sort = -9999; // 插件排序,越小优先注入
|
|
89
|
+
export const install = (context) => {
|
|
90
|
+
Global.user = useUserStore();
|
|
91
|
+
Global.env = useEnvStore();
|
|
92
|
+
Global.app = useAppStore();
|
|
93
|
+
|
|
94
|
+
context.app.use(Global);
|
|
95
|
+
// 其他使用module使用
|
|
96
|
+
context.add('Global', Global);
|
|
97
|
+
};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { createInstance } from '@deot/http';
|
|
2
|
+
import { Context } from './context';
|
|
3
|
+
|
|
4
|
+
const getConfig = () => ({
|
|
5
|
+
token: Context.Global.user.token,
|
|
6
|
+
baseUrl: Context.Global.env.baseUrl,
|
|
7
|
+
headerSourceCode: Context.Global.env.headerSourceCode
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const loadingStore = {
|
|
11
|
+
target: null,
|
|
12
|
+
messages: [],
|
|
13
|
+
refresh() {
|
|
14
|
+
const { target, messages } = loadingStore;
|
|
15
|
+
if (messages.length) {
|
|
16
|
+
const message = `${messages.length >= 2 ? `(${messages.length})` : ''}${messages.at(-1)[1]}`;
|
|
17
|
+
if (target) {
|
|
18
|
+
if (target.wrapper?.setContent) {
|
|
19
|
+
target.wrapper.setContent(message);
|
|
20
|
+
} else {
|
|
21
|
+
target.destroy();
|
|
22
|
+
loadingStore.target = Context.platform.loading(message);
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
loadingStore.target = Context.platform.loading(message);
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
if (!loadingStore.messages.length && loadingStore.target) {
|
|
31
|
+
loadingStore.target.destroy();
|
|
32
|
+
loadingStore.target = null;
|
|
33
|
+
}
|
|
34
|
+
}, 30);
|
|
35
|
+
},
|
|
36
|
+
add(leaf) {
|
|
37
|
+
loadingStore.messages.push([
|
|
38
|
+
leaf.id,
|
|
39
|
+
typeof leaf.request.loading === 'string' ? leaf.request.loading : '加载中...'
|
|
40
|
+
]);
|
|
41
|
+
loadingStore.refresh();
|
|
42
|
+
},
|
|
43
|
+
remove(leaf) {
|
|
44
|
+
const index = loadingStore.messages.findIndex(item => item[0] === leaf.id);
|
|
45
|
+
index >= 0 && loadingStore.messages.splice(index, 1);
|
|
46
|
+
loadingStore.refresh();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const errorMap = {
|
|
51
|
+
HTTP_REQUEST_TIMEOUT: '网络超时,请稍后再试',
|
|
52
|
+
HTTP_STATUS_ERROR: '网络异常,请稍后再试'
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const errorStore = {
|
|
56
|
+
messages: [],
|
|
57
|
+
async add(leaf) {
|
|
58
|
+
const { id } = leaf;
|
|
59
|
+
const message = errorMap[leaf.response.statusText] || leaf.response.statusText;
|
|
60
|
+
if (errorStore.messages.some(item => item[1] === message)) return;
|
|
61
|
+
|
|
62
|
+
if (typeof leaf.request.errorTip === 'function' || leaf.request.errorTip === 'modal') {
|
|
63
|
+
const data = leaf.response.body?.data;
|
|
64
|
+
const defaultContent = (Array.isArray(data) && data.length ? data.join('<br><br>') : data)
|
|
65
|
+
|| leaf.response.body?.msg;
|
|
66
|
+
const content = typeof leaf.request.errorTip === 'function'
|
|
67
|
+
? leaf.request.errorTip(leaf)
|
|
68
|
+
: defaultContent;
|
|
69
|
+
content && Context.platform.modal({ title: '异常提示', content, cancelText: false });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
errorStore.messages.push([id, message]);
|
|
74
|
+
Context.platform.error(message, 2000, () => {
|
|
75
|
+
const index = errorStore.messages.findIndex(item => item[0] === id);
|
|
76
|
+
index >= 0 && errorStore.messages.splice(index, 1);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const Network = createInstance({
|
|
82
|
+
token: true,
|
|
83
|
+
json: true,
|
|
84
|
+
loading: true,
|
|
85
|
+
errorTip: true,
|
|
86
|
+
successTip: false,
|
|
87
|
+
confirmTip: false,
|
|
88
|
+
onRequest: [
|
|
89
|
+
async (leaf) => {
|
|
90
|
+
if (typeof leaf.request.confirmTip === 'string') {
|
|
91
|
+
await new Promise((resolve, reject) => {
|
|
92
|
+
Context.platform.modal({
|
|
93
|
+
title: '提示',
|
|
94
|
+
content: leaf.request.confirmTip,
|
|
95
|
+
onOk: resolve,
|
|
96
|
+
onCancel: reject
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
leaf.request.loading && loadingStore.add(leaf);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const config = getConfig();
|
|
103
|
+
if (!/^https?:/.test(leaf.request.url)) {
|
|
104
|
+
leaf.request.url = config.baseUrl + leaf.request.url;
|
|
105
|
+
}
|
|
106
|
+
if (leaf.request.method === 'POST') {
|
|
107
|
+
leaf.request.headers.set(
|
|
108
|
+
'Content-Type',
|
|
109
|
+
leaf.request.json
|
|
110
|
+
? 'application/json'
|
|
111
|
+
: 'application/x-www-form-urlencoded; charset=UTF-8'
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
if (leaf.request.method === 'FORM') {
|
|
115
|
+
leaf.request.headers.set('Content-Type', 'multipart/form-data');
|
|
116
|
+
leaf.request.method = 'POST';
|
|
117
|
+
}
|
|
118
|
+
if (leaf.request.token !== false && config.token) {
|
|
119
|
+
const token = typeof leaf.request.token === 'string' ? leaf.request.token : config.token;
|
|
120
|
+
leaf.request.headers.set('Authorization', `Bearer ${token}`);
|
|
121
|
+
}
|
|
122
|
+
if (config.headerSourceCode) {
|
|
123
|
+
leaf.request.headers.set('source', config.headerSourceCode);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
onResponse: [
|
|
128
|
+
(leaf) => {
|
|
129
|
+
const { successTip, errorTip, responseType } = leaf.request;
|
|
130
|
+
const { body } = leaf.response;
|
|
131
|
+
if (body && body.code !== 200 && leaf.response.type !== 'error') {
|
|
132
|
+
leaf.response.statusText = typeof errorTip === 'string' && errorTip !== 'modal'
|
|
133
|
+
? errorTip
|
|
134
|
+
: body.msg;
|
|
135
|
+
leaf.response.type = 'error';
|
|
136
|
+
if (body.code === 401) {
|
|
137
|
+
errorStore.add(leaf);
|
|
138
|
+
Context.Global.clearLoginAuth({
|
|
139
|
+
redirect: window.location.pathname.replace(Context.router.options.history.base, '')
|
|
140
|
+
+ window.location.search
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (typeof body.data === 'string') {
|
|
145
|
+
try {
|
|
146
|
+
leaf.response.body.data = JSON.parse(body.data);
|
|
147
|
+
} catch { /* keep original data */ }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (responseType === 'blob' && body instanceof Blob) {
|
|
152
|
+
leaf.response.type = 'success';
|
|
153
|
+
leaf.response.body = { code: 200, data: body };
|
|
154
|
+
}
|
|
155
|
+
if (
|
|
156
|
+
errorTip
|
|
157
|
+
&& leaf.response.type === 'error'
|
|
158
|
+
&& leaf.response.statusText
|
|
159
|
+
&& leaf.response.statusText !== 'HTTP_CANCEL'
|
|
160
|
+
&& leaf.request.maxTries === 1
|
|
161
|
+
) {
|
|
162
|
+
errorStore.add(leaf);
|
|
163
|
+
} else if (successTip && leaf.request.method !== 'GET') {
|
|
164
|
+
const message = typeof successTip === 'string' ? successTip : leaf.response.body?.msg;
|
|
165
|
+
message && Context.platform.success(message);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (import.meta.env.DEV && leaf.response.type === 'error') {
|
|
169
|
+
console.error('[Network Error]', {
|
|
170
|
+
url: leaf.request.url,
|
|
171
|
+
request: leaf.request.body,
|
|
172
|
+
response: leaf.response.body,
|
|
173
|
+
error: leaf.response.statusText,
|
|
174
|
+
status: leaf.response.status
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
onStart: (leaf) => {
|
|
180
|
+
if (leaf.request.loading && !leaf.request.confirmTip) loadingStore.add(leaf);
|
|
181
|
+
},
|
|
182
|
+
onFinish: (leaf) => {
|
|
183
|
+
if (leaf.request.loading) loadingStore.remove(leaf);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
export const install = (context) => {
|
|
188
|
+
context.add('Network', Network);
|
|
189
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createPinia } from 'pinia';
|
|
2
|
+
import { Storage } from '@deot/helper-cache';
|
|
3
|
+
import { CACHE_ENV, MODE_DEV } from '@/shared/constants';
|
|
4
|
+
|
|
5
|
+
export const sort = -99999; // 插件排序,越小优先注入
|
|
6
|
+
export const install = (context) => {
|
|
7
|
+
const { app, options } = context;
|
|
8
|
+
const pinia = createPinia();
|
|
9
|
+
app.use(pinia);
|
|
10
|
+
|
|
11
|
+
// 本地开发的时候,强制清理
|
|
12
|
+
if (MODE_DEV && options.name === 'manage') {
|
|
13
|
+
Storage.remove(CACHE_ENV);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const envConfig = Storage.get(`${CACHE_ENV}`) || '';
|
|
17
|
+
|
|
18
|
+
// 设定初始的initialState, 这个值不会被改变
|
|
19
|
+
pinia.state.value = {
|
|
20
|
+
...(options.pinia || {}),
|
|
21
|
+
env: {
|
|
22
|
+
appCode: envConfig.appCode || options.name,
|
|
23
|
+
|
|
24
|
+
branch: envConfig.branch || __BRANCH__
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 其他使用module使用
|
|
29
|
+
context.add('pinia', pinia);
|
|
30
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as Route from '@deot/helper-route';
|
|
2
|
+
import * as LINKS from '@/shared/constants/pages';
|
|
3
|
+
import { MODE_DEV, ROUTE_UNAUTHORISED_REGEXP } from '@/shared/constants';
|
|
4
|
+
|
|
5
|
+
const MAX_REDIRECT = 1000;
|
|
6
|
+
export const install = (context) => {
|
|
7
|
+
let redirectCount = 0;
|
|
8
|
+
const router = context.router;
|
|
9
|
+
const Global = context.Global;
|
|
10
|
+
|
|
11
|
+
const userStore = Global.user;
|
|
12
|
+
const envStore = Global.env;
|
|
13
|
+
|
|
14
|
+
const PAGE_lOGIN_NAME = `/${envStore.appCode}${LINKS.PAGE_lOGIN}/`;
|
|
15
|
+
const PAGE_HOME_NAME = `/${envStore.appCode}${LINKS.PAGE_HOME}/`;
|
|
16
|
+
|
|
17
|
+
router.beforeEach((to, _from, next) => {
|
|
18
|
+
redirectCount++;
|
|
19
|
+
if (redirectCount > MAX_REDIRECT) {
|
|
20
|
+
console.error('路由异常', to);
|
|
21
|
+
to.path === LINKS.PAGE_lOGIN ? next() : next(LINKS.PAGE_lOGIN);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (
|
|
25
|
+
router.options.history.base === '/shared'
|
|
26
|
+
|| ROUTE_UNAUTHORISED_REGEXP.test(to.path)
|
|
27
|
+
) return next();
|
|
28
|
+
|
|
29
|
+
// 保持端的域名一致
|
|
30
|
+
if (envStore.appCode !== context.options.name) {
|
|
31
|
+
Global.reLaunchHome(envStore.appCode);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (
|
|
36
|
+
!userStore.logged
|
|
37
|
+
&& to.path !== LINKS.PAGE_lOGIN
|
|
38
|
+
&& router.hasRoute(PAGE_lOGIN_NAME)
|
|
39
|
+
) {
|
|
40
|
+
Global.setRedirect(to.fullPath);
|
|
41
|
+
return next(LINKS.PAGE_lOGIN);
|
|
42
|
+
}
|
|
43
|
+
if (
|
|
44
|
+
router.hasRoute(PAGE_HOME_NAME)
|
|
45
|
+
&& (to.path === '/' || (to.path === LINKS.PAGE_lOGIN && userStore.logged))
|
|
46
|
+
) {
|
|
47
|
+
return next(LINKS.PAGE_HOME);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
next();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
router.afterEach((to) => {
|
|
54
|
+
redirectCount = 0;
|
|
55
|
+
// 清理token
|
|
56
|
+
if (to.query.token) {
|
|
57
|
+
history.replaceState(null, null, Route.merge({
|
|
58
|
+
path: `${router.options.history.base}${to.path}`,
|
|
59
|
+
query: {
|
|
60
|
+
...to.query,
|
|
61
|
+
token: undefined,
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
router.onError((error) => {
|
|
68
|
+
if (
|
|
69
|
+
!MODE_DEV
|
|
70
|
+
&& error.message.match(/(Failed to load module script|Failed to fetch dynamically imported module)/g)
|
|
71
|
+
) {
|
|
72
|
+
location.reload(true);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { reactive } from 'vue';
|
|
2
|
+
import * as Components from '../components';
|
|
3
|
+
|
|
4
|
+
class SharedManager {
|
|
5
|
+
/**
|
|
6
|
+
* 配置项
|
|
7
|
+
*/
|
|
8
|
+
options = reactive({
|
|
9
|
+
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
configure(options) {
|
|
13
|
+
if (options) {
|
|
14
|
+
Object.keys(options).forEach((i) => {
|
|
15
|
+
if (typeof this.options[i] !== 'undefined') {
|
|
16
|
+
this.options[i] = options[i];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
install(app, options) {
|
|
25
|
+
app.config.globalProperties.$shared = this.configure(options);
|
|
26
|
+
Object.keys(Components).forEach((key) => {
|
|
27
|
+
const component = Components[key];
|
|
28
|
+
if (typeof component.setup === 'function') {
|
|
29
|
+
app.component(key, Components[key]);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const Shared = new SharedManager();
|
|
36
|
+
|
|
37
|
+
export const install = (context) => {
|
|
38
|
+
context.app.use(Shared, context.options?.shared);
|
|
39
|
+
|
|
40
|
+
// 其他使用module使用
|
|
41
|
+
context.add('Shared', Shared);
|
|
42
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { createVcPlugin } from '@deot/vc/full';
|
|
2
|
+
import { VcInstance } from '@deot/vc';
|
|
3
|
+
import { transfromOssMessage } from '@/shared/stores/apis/upload';
|
|
4
|
+
|
|
5
|
+
export const install = (context) => {
|
|
6
|
+
const vc = createVcPlugin(
|
|
7
|
+
{
|
|
8
|
+
Portal: {
|
|
9
|
+
aliveRules: { className: /(vc-portal-alive|vc-modal|vc-drawer)/ },
|
|
10
|
+
install: (app) => {
|
|
11
|
+
app.use(vc);
|
|
12
|
+
app.use(context.Global);
|
|
13
|
+
app.use(context.router);
|
|
14
|
+
app.use(context.pinia);
|
|
15
|
+
app.use(context.Shared);
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
Upload: {
|
|
19
|
+
onRequest: async ({ requestOptions: options }) => {
|
|
20
|
+
// 非oss地址
|
|
21
|
+
if (options.url) return {
|
|
22
|
+
...options,
|
|
23
|
+
url: /^http/.test(options.url) ? options.url : context.Global?.env?.baseUrl + options.url,
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${context.Global?.user?.token}`,
|
|
26
|
+
...options.headers
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
// OSS地址
|
|
30
|
+
const { url, body } = await context.platform.http('getOssUploadSignature', options.file.name);
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
...options,
|
|
34
|
+
url,
|
|
35
|
+
body: {
|
|
36
|
+
...body,
|
|
37
|
+
file: options.file
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
onResponse: ({ request, requestOptions: options }) => {
|
|
42
|
+
const response = request?.responseText || request?.response;
|
|
43
|
+
const e = {
|
|
44
|
+
file: options.file
|
|
45
|
+
};
|
|
46
|
+
// OSS地址
|
|
47
|
+
if (!response) {
|
|
48
|
+
e.source = `${options.url}/${options.body.key}`;
|
|
49
|
+
// ETag 形如 "MD5",引号是头字段格式,不是摘要的一部分
|
|
50
|
+
e.entityTag = request?.getResponseHeader?.('etag')?.replace(/^"|"$/g, '');
|
|
51
|
+
} else {
|
|
52
|
+
const v = JSON.parse(response);
|
|
53
|
+
e.data = v;
|
|
54
|
+
e.source = context.Global?.env?.ossUrl + v.data;
|
|
55
|
+
}
|
|
56
|
+
return e;
|
|
57
|
+
},
|
|
58
|
+
onMessage: ({ cause: e, message }) => {
|
|
59
|
+
// OSS报的错误
|
|
60
|
+
if (e && e.data) {
|
|
61
|
+
return transfromOssMessage(e.data) || message;
|
|
62
|
+
}
|
|
63
|
+
return message;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
TableColumn: {
|
|
67
|
+
line: 1
|
|
68
|
+
},
|
|
69
|
+
Snapshot: {
|
|
70
|
+
download: async ({ instance, options }) => {
|
|
71
|
+
if (options.format === 'pdf') {
|
|
72
|
+
await instance.exposed.refresh();
|
|
73
|
+
const canvas = await instance.exposed.snapshot.value.toCanvas();
|
|
74
|
+
const { jsPDF } = await import('jspdf');
|
|
75
|
+
const pdf = new jsPDF('p', 'mm', 'a4');
|
|
76
|
+
const ctx = canvas.getContext('2d');
|
|
77
|
+
const a4w = 170;
|
|
78
|
+
const a4h = 250;
|
|
79
|
+
const imageHeight = Math.floor(a4h * canvas.width / a4w);
|
|
80
|
+
let renderedHeight = 0;
|
|
81
|
+
|
|
82
|
+
while (renderedHeight < canvas.height) {
|
|
83
|
+
const el = document.createElement('canvas');
|
|
84
|
+
el.width = canvas.width;
|
|
85
|
+
el.height = Math.min(imageHeight, canvas.height - renderedHeight);
|
|
86
|
+
|
|
87
|
+
const imageData = ctx.getImageData(0,
|
|
88
|
+
renderedHeight,
|
|
89
|
+
canvas.width,
|
|
90
|
+
Math.min(imageHeight, canvas.height - renderedHeight)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
el.getContext('2d').putImageData(imageData, 0, 0);
|
|
94
|
+
pdf.addImage(el.toDataURL('image/png', 1.0), 'PNG', 20, 20, a4w, Math.min(a4h, a4w * el.height / el.width));
|
|
95
|
+
|
|
96
|
+
renderedHeight += imageHeight;
|
|
97
|
+
if (renderedHeight < canvas.height) {
|
|
98
|
+
pdf.addPage();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
await pdf.save(`${options.filename}.pdf`, { returnPromise: true });
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
Editor: {
|
|
110
|
+
options: {
|
|
111
|
+
toolbar: [
|
|
112
|
+
'bold',
|
|
113
|
+
'italic',
|
|
114
|
+
'underline',
|
|
115
|
+
'strike',
|
|
116
|
+
'color',
|
|
117
|
+
'line-height',
|
|
118
|
+
'font-size',
|
|
119
|
+
'letter-spacing',
|
|
120
|
+
'link',
|
|
121
|
+
'upload/image',
|
|
122
|
+
'undo',
|
|
123
|
+
'redo'
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
v => `V${v}`
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
context.app.use(vc);
|
|
132
|
+
|
|
133
|
+
// 其他使用module使用
|
|
134
|
+
context.add('vc', VcInstance);
|
|
135
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Network } from '@/shared/modules/network';
|
|
2
|
+
import JSZip from 'jszip';
|
|
3
|
+
|
|
4
|
+
const _download = (blob, filename) => {
|
|
5
|
+
const url = window.URL.createObjectURL(blob);
|
|
6
|
+
const el = document.createElement('a');
|
|
7
|
+
|
|
8
|
+
el.href = url;
|
|
9
|
+
el.download = filename;
|
|
10
|
+
el.click();
|
|
11
|
+
window.URL.revokeObjectURL(url);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const _getBlob = async (url, body, requestOptions) => {
|
|
15
|
+
if (/^http/.test(url)) {
|
|
16
|
+
const response = await fetch(url);
|
|
17
|
+
return response.blob();
|
|
18
|
+
} else {
|
|
19
|
+
const response = await Network.http(url, {
|
|
20
|
+
method: 'POST',
|
|
21
|
+
responseType: 'blob',
|
|
22
|
+
body,
|
|
23
|
+
...requestOptions
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return response.body.data;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 同步导出
|
|
32
|
+
* file -> { url: '', name: '', body: {} }
|
|
33
|
+
* @param v file/Files/Url
|
|
34
|
+
* @param body ~
|
|
35
|
+
* @param filename ~
|
|
36
|
+
* @param requestOptions ~
|
|
37
|
+
* @returns ~
|
|
38
|
+
*/
|
|
39
|
+
export const download = async (v, body, filename, requestOptions = {}) => {
|
|
40
|
+
const isFiles = Array.isArray(v);
|
|
41
|
+
if (!v || (isFiles && !v.length)) return Promise.reject();
|
|
42
|
+
|
|
43
|
+
const files = (isFiles ? v : [v]).map((i) => {
|
|
44
|
+
if (typeof i === 'string') {
|
|
45
|
+
return {
|
|
46
|
+
url: i,
|
|
47
|
+
name: filename || i.replace(/^.*\/([^/]+)$/, '$1'),
|
|
48
|
+
body
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
url: i.url || i.fileUrl,
|
|
53
|
+
name: i.name || i.fileName,
|
|
54
|
+
body: i.body || body
|
|
55
|
+
};
|
|
56
|
+
}).filter(i => i.url);
|
|
57
|
+
if (!files.length) return Promise.reject();
|
|
58
|
+
|
|
59
|
+
const isZip = files.length > 1;
|
|
60
|
+
let content;
|
|
61
|
+
if (isZip) {
|
|
62
|
+
const zip = new JSZip();
|
|
63
|
+
await Promise.all(files.map((file) => {
|
|
64
|
+
return new Promise((resolve) => {
|
|
65
|
+
_getBlob(file.url, file.body, requestOptions).then(res => res instanceof Blob ? res : res.blob()).then((blob) => {
|
|
66
|
+
zip.file(file.name, blob);
|
|
67
|
+
resolve();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
}));
|
|
71
|
+
content = await zip.generateAsync({ type: 'blob' });
|
|
72
|
+
} else {
|
|
73
|
+
content = await _getBlob(files[0].url, files[0].body, requestOptions);
|
|
74
|
+
}
|
|
75
|
+
_download(
|
|
76
|
+
content,
|
|
77
|
+
(() => {
|
|
78
|
+
try {
|
|
79
|
+
if (!filename) return isZip ? '下载文件.zip' : (files[0].name || '下载文件');
|
|
80
|
+
if (isZip && !/\.zip$/.test(filename)) {
|
|
81
|
+
return `${filename.replace(/(?:\.[^/.]+)?$/, '.zip')}`;
|
|
82
|
+
};
|
|
83
|
+
return filename;
|
|
84
|
+
} catch {
|
|
85
|
+
return filename;
|
|
86
|
+
}
|
|
87
|
+
})()
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// 异步导出
|
|
92
|
+
export const downloadAsync = async (url, body, options = {}) => {
|
|
93
|
+
return Network.http(url, {
|
|
94
|
+
successTip: '导出成功,请到下载中心下载',
|
|
95
|
+
method: 'POST',
|
|
96
|
+
body,
|
|
97
|
+
...options
|
|
98
|
+
});
|
|
99
|
+
};
|