@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,118 @@
|
|
|
1
|
+
import { ref, onMounted } from 'vue';
|
|
2
|
+
import { defineStore } from 'pinia';
|
|
3
|
+
import { Storage } from '@deot/helper-cache';
|
|
4
|
+
import { MODE_DEV } from '@/src/constants';
|
|
5
|
+
import * as Route from '@deot/helper-route';
|
|
6
|
+
|
|
7
|
+
const getkey = () => window.location.pathname;
|
|
8
|
+
const SCROLL_HISTORY_KEY = '@yaya/scroll-history';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 注意
|
|
12
|
+
* 1. popstate下才会触发记忆滚动(go / back / forward)
|
|
13
|
+
* 2. 点击触发的跳转页面(push/replace) 不会产生记忆滚动
|
|
14
|
+
* ,
|
|
15
|
+
* scrollBehavior: crossBack 跨系统回退标记
|
|
16
|
+
* history: [key]: [Object]
|
|
17
|
+
* {
|
|
18
|
+
* x,
|
|
19
|
+
* y,
|
|
20
|
+
* snapshot: 预留设计(crossBack下使用,popstate时,把x/y放到该处)
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
export const useLayoutDefaultScrollerStore = defineStore('layout-default-scroller', () => {
|
|
24
|
+
const isCrossBack = Route.get('scrollBehavior') === 'crossBack';
|
|
25
|
+
const history = ref<Record<string, any>>((isCrossBack && Storage.get(SCROLL_HISTORY_KEY, { session: true })) || {});
|
|
26
|
+
const currentPathname = ref('');
|
|
27
|
+
const scroller = ref<any>();
|
|
28
|
+
const setScroller = (v: any) => {
|
|
29
|
+
scroller.value = v;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const scrollTo = async (v: any) => {
|
|
33
|
+
if (typeof v === 'number') {
|
|
34
|
+
v = { x: 0, y: v };
|
|
35
|
+
} else if (typeof v !== 'object' || !v) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
scroller.value.scrollTo(v);
|
|
40
|
+
} catch {
|
|
41
|
+
console.error('layout/scroller 未找到');
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const refresh = async () => {
|
|
46
|
+
if (!currentPathname.value) return;
|
|
47
|
+
scrollTo(history.value[currentPathname.value]);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 进入 (onActivated/router.beforeEach)【当前为前者方案】
|
|
52
|
+
* 此时:浏览器显式地址=当前页
|
|
53
|
+
*/
|
|
54
|
+
const enter = () => {
|
|
55
|
+
currentPathname.value = getkey();
|
|
56
|
+
|
|
57
|
+
if (isCrossBack && history.value[currentPathname.value]?.snapshot) {
|
|
58
|
+
scrollTo(history.value[currentPathname.value]?.snapshot);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 离开 (onDeactivated/router.afterEach)【当前为前者方案】
|
|
64
|
+
* 此时:浏览器显式地址=下一页地址,取onActivated时记录的currentPathname.value
|
|
65
|
+
*/
|
|
66
|
+
const leave = () => {
|
|
67
|
+
if (!currentPathname.value || !scroller.value) return;
|
|
68
|
+
history.value[currentPathname.value] = {
|
|
69
|
+
x: scroller.value.scrollLeft,
|
|
70
|
+
y: scroller.value.scrollTop,
|
|
71
|
+
snapshot: null
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
Storage.set(SCROLL_HISTORY_KEY, history.value, { session: true });
|
|
75
|
+
currentPathname.value = '';
|
|
76
|
+
|
|
77
|
+
// 默认恢复置顶
|
|
78
|
+
scrollTo(0);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* go / back / forward
|
|
83
|
+
* 执行时机:leave -> enter -> handlePopStateChange
|
|
84
|
+
* 此时:浏览器显式地址=下一页地址, currentPathname.value=下一页地址
|
|
85
|
+
*/
|
|
86
|
+
const handlePopStateChange = () => {
|
|
87
|
+
const v = history.value[currentPathname.value];
|
|
88
|
+
if (!v || currentPathname.value !== getkey()) return;
|
|
89
|
+
const snapshot = {
|
|
90
|
+
x: v.x || 0,
|
|
91
|
+
y: v.y || 0
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
history.value[currentPathname.value].snapshot = snapshot;
|
|
95
|
+
scrollTo(snapshot);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const clear = () => {
|
|
99
|
+
history.value = {};
|
|
100
|
+
Storage.remove(SCROLL_HISTORY_KEY);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// 单页应用只执行有一次,除非重载, 不需要处理销毁逻辑
|
|
104
|
+
onMounted(() => window.addEventListener('popstate', handlePopStateChange));
|
|
105
|
+
|
|
106
|
+
MODE_DEV && ((window as any).__LAYOUT_SCROLLER_STORE__ = { currentPathname, history, scroller });
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
history,
|
|
110
|
+
scroller,
|
|
111
|
+
setScroller,
|
|
112
|
+
scrollTo,
|
|
113
|
+
enter,
|
|
114
|
+
leave,
|
|
115
|
+
refresh,
|
|
116
|
+
clear
|
|
117
|
+
};
|
|
118
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ref, computed, reactive, onMounted } from 'vue';
|
|
2
|
+
import { defineStore } from 'pinia';
|
|
3
|
+
import { Resize } from '@deot/helper-resize';
|
|
4
|
+
import { useLayoutDefaultStore } from './use-layout-default';
|
|
5
|
+
import { useLayoutDefaultTabsStore } from './use-layout-default-tabs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* layout下仅default可用
|
|
9
|
+
* 1366作为当前Layout的最小值
|
|
10
|
+
*/
|
|
11
|
+
export const useLayoutDefaultSizeStore = defineStore('layout-default-size', () => {
|
|
12
|
+
const layoutStore = useLayoutDefaultStore();
|
|
13
|
+
const layoutTabsStore = useLayoutDefaultTabsStore();
|
|
14
|
+
|
|
15
|
+
const gap = 4;
|
|
16
|
+
|
|
17
|
+
const scroller = ref<any>();
|
|
18
|
+
const width = ref(window.innerWidth);
|
|
19
|
+
const height = ref(window.innerHeight);
|
|
20
|
+
// 初始即按视口宽度决定,避免仅在 resize「宽度变化」时才更新导致窄屏仍按 220 占位
|
|
21
|
+
const forceHideNavbar = ref(width.value < 1366);
|
|
22
|
+
|
|
23
|
+
const baseHeight = computed(() => {
|
|
24
|
+
return height.value - gap * 2;
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const sidebar = reactive({
|
|
28
|
+
paddingRight: gap,
|
|
29
|
+
width: 108,
|
|
30
|
+
height: baseHeight
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const navbar = reactive({
|
|
34
|
+
width: computed(() => !forceHideNavbar.value ? 220 : 0),
|
|
35
|
+
height: baseHeight
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const header = reactive({
|
|
39
|
+
width: computed(() => content.width),
|
|
40
|
+
height: computed(() => !layoutTabsStore.innerDisabled && !layoutTabsStore.disabled && layoutStore.isInnerPage ? 88 : 52),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const content = reactive({
|
|
44
|
+
height: 0,
|
|
45
|
+
width: 0
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const container = reactive({
|
|
49
|
+
minWidth: 1024,
|
|
50
|
+
height: baseHeight,
|
|
51
|
+
width: computed(() => content.width),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const syncForceHideNavbar = () => {
|
|
55
|
+
if (width.value < 1366 && !forceHideNavbar.value) {
|
|
56
|
+
forceHideNavbar.value = true;
|
|
57
|
+
} else if (width.value >= 1366 && forceHideNavbar.value) {
|
|
58
|
+
forceHideNavbar.value = false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const handleResize = () => {
|
|
63
|
+
const widthChanged = width.value !== window.innerWidth;
|
|
64
|
+
|
|
65
|
+
height.value = window.innerHeight;
|
|
66
|
+
width.value = window.innerWidth;
|
|
67
|
+
|
|
68
|
+
if (!widthChanged) return;
|
|
69
|
+
syncForceHideNavbar();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const setContent = (e: any) => {
|
|
73
|
+
if (typeof e.height === 'undefined') return;
|
|
74
|
+
content.height = e.height;
|
|
75
|
+
content.width = e.width;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const setScroller = (v: any) => {
|
|
79
|
+
scroller.value = v;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const scrollTo = async (v: any) => {
|
|
83
|
+
if (typeof v === 'number') {
|
|
84
|
+
v = { x: 0, y: v };
|
|
85
|
+
} else if (typeof v !== 'object' || !v) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
scroller.value.scrollTo(v);
|
|
90
|
+
} catch {
|
|
91
|
+
console.error('layout/scroller 未找到');
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// 单页应用只执行有一次,除非重载, 不需要处理销毁逻辑
|
|
96
|
+
onMounted(() => Resize.on(document.body, handleResize));
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
scroller,
|
|
100
|
+
// size
|
|
101
|
+
width,
|
|
102
|
+
height,
|
|
103
|
+
gap,
|
|
104
|
+
sidebar,
|
|
105
|
+
navbar,
|
|
106
|
+
container,
|
|
107
|
+
header,
|
|
108
|
+
content,
|
|
109
|
+
|
|
110
|
+
// 外部控制
|
|
111
|
+
forceHideNavbar,
|
|
112
|
+
toggleNavBar: (v?: any) => {
|
|
113
|
+
v = typeof v === 'boolean' ? v : !forceHideNavbar.value;
|
|
114
|
+
forceHideNavbar.value = v;
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// methods
|
|
118
|
+
setContent,
|
|
119
|
+
setScroller,
|
|
120
|
+
scrollTo
|
|
121
|
+
};
|
|
122
|
+
});
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { ref, reactive, onBeforeMount, watch, computed } from 'vue';
|
|
2
|
+
import { useRoute } from 'vue-router';
|
|
3
|
+
import { Storage } from '@deot/helper-cache';
|
|
4
|
+
import { getUid } from '@deot/helper-utils';
|
|
5
|
+
import { defineStore } from 'pinia';
|
|
6
|
+
import { isEqualWith, cloneDeep } from 'lodash-es';
|
|
7
|
+
import { Context } from '@/src/modules/context';
|
|
8
|
+
import { MAX_KEEP_ALIVE } from '@/src/constants';
|
|
9
|
+
import { useLayoutDefaultStore } from './use-layout-default';
|
|
10
|
+
|
|
11
|
+
const TABS_DISABLED = false;
|
|
12
|
+
const TABS_INNER_DISABLED = false;
|
|
13
|
+
const TABS_MAX = Math.max(MAX_KEEP_ALIVE, 20);
|
|
14
|
+
const TABS_KEY = '@yaya/tabs';
|
|
15
|
+
const TABS_SKIP_KEY = ['session', 'token'];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 统一tag模型
|
|
19
|
+
* @param route { value, label }
|
|
20
|
+
* @param options { state, query }
|
|
21
|
+
* @returns Tag { id, value, label, deletable, draggable, lockless, visible, query }
|
|
22
|
+
*/
|
|
23
|
+
const createTag = (route: any, options: any = {}) => {
|
|
24
|
+
const { deletable = true, draggable = true, lockless = true, visible = true, query, id } = options;
|
|
25
|
+
const v: any = { value: route.value, label: route.label };
|
|
26
|
+
|
|
27
|
+
!deletable && (v.deletable = false);
|
|
28
|
+
!draggable && (v.draggable = false);
|
|
29
|
+
!lockless && (v.lockless = false);
|
|
30
|
+
!visible && (v.visible = false);
|
|
31
|
+
|
|
32
|
+
query && (v.query = query);
|
|
33
|
+
|
|
34
|
+
// 仅用于sort-list
|
|
35
|
+
v.id = id || getUid();
|
|
36
|
+
return v;
|
|
37
|
+
};
|
|
38
|
+
const getDefaultTags = () => ([
|
|
39
|
+
createTag(
|
|
40
|
+
{ value: '/home/main', label: '首页' },
|
|
41
|
+
{
|
|
42
|
+
deletable: false,
|
|
43
|
+
draggable: false,
|
|
44
|
+
lockless: false,
|
|
45
|
+
id: 'home'
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
const isEqual = (v1: any, v2: any) => {
|
|
51
|
+
return isEqualWith(v1 || {}, v2 || {});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* layout下仅default可用
|
|
56
|
+
*/
|
|
57
|
+
export const useLayoutDefaultTabsStore = defineStore('layout-default-tabs', () => {
|
|
58
|
+
const { Global } = Context;
|
|
59
|
+
const layoutStore = useLayoutDefaultStore();
|
|
60
|
+
const vRoute = useRoute();
|
|
61
|
+
const tags: any[] = reactive(getDefaultTags());
|
|
62
|
+
const disabled = ref(TABS_DISABLED);
|
|
63
|
+
const innerDisabled = ref(TABS_INNER_DISABLED);
|
|
64
|
+
const isReady = ref(false);
|
|
65
|
+
|
|
66
|
+
const isSimilarQuery = (v1: any, v2: any) => {
|
|
67
|
+
v1 = { ...v1 };
|
|
68
|
+
v2 = { ...v2 };
|
|
69
|
+
TABS_SKIP_KEY.forEach(k => (delete v1[k], delete v2[k]));
|
|
70
|
+
return isEqual(v1, v2);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// 非内页 + 相同参数的内页
|
|
74
|
+
const isSimilar = (v1: any, v2: any) => {
|
|
75
|
+
v1 = { ...v1 };
|
|
76
|
+
v2 = { ...v2 };
|
|
77
|
+
v1 = { value: v1.path || v1.value, query: { ...v1.query } };
|
|
78
|
+
v2 = { value: v2.path || v2.value, query: { ...v2.query } };
|
|
79
|
+
return v1.value === v2.value && (layoutStore.routesMap[v2.value] || isSimilarQuery(v1.query, v2.query));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const similarTagsMap = computed(() => {
|
|
83
|
+
return tags.reduce((pre: any, cur: any) => {
|
|
84
|
+
pre[cur.value] = pre[cur.value] || [];
|
|
85
|
+
pre[cur.value].push(cur);
|
|
86
|
+
return pre;
|
|
87
|
+
}, {});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// 当前标签active的位置;path 未变(replace)时 watch 不会触发,需要调用方主动 updateCurrent
|
|
91
|
+
const current = ref(-1);
|
|
92
|
+
|
|
93
|
+
// 返回为false时不执行同步
|
|
94
|
+
const sync = (next: any) => async (...args: any[]) => {
|
|
95
|
+
const status = await next(...args);
|
|
96
|
+
if (status === false) return;
|
|
97
|
+
|
|
98
|
+
Storage.set(`${TABS_KEY}/${Global.env.appCode}`, tags, { session: true });
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* add
|
|
103
|
+
* for循环
|
|
104
|
+
* 1. 内页:先找到相似query, query值不同则更新,否则终止
|
|
105
|
+
* 2. 非内页: 有且仅一个,query值不同则更新,否则终止
|
|
106
|
+
* @param route ~
|
|
107
|
+
* @param options ~
|
|
108
|
+
* @returns ~
|
|
109
|
+
*/
|
|
110
|
+
const add = sync((route: any, options: any = {}) => {
|
|
111
|
+
for (let index = 0; index < tags.length; index++) {
|
|
112
|
+
const item = tags[index];
|
|
113
|
+
if (
|
|
114
|
+
route.value === item.value
|
|
115
|
+
&& (
|
|
116
|
+
layoutStore.routesMap[item.value]
|
|
117
|
+
|| isSimilarQuery(options.query, item.query)
|
|
118
|
+
)
|
|
119
|
+
) {
|
|
120
|
+
if (isEqual(options.query, item.query)) return false;
|
|
121
|
+
tags[index].query = options.query;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (tags.length === TABS_MAX) {
|
|
127
|
+
const j = tags.findIndex((i: any) => i.deletable !== false);
|
|
128
|
+
j >= 0 && tags.splice(j, 1);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
tags.push(createTag(route, options));
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const remove = sync((route: any) => {
|
|
135
|
+
const index = tags.findIndex((i: any) => isSimilar(route, i));
|
|
136
|
+
if (index < 0) return false;
|
|
137
|
+
tags.splice(index, 1);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const clear = sync((routes?: any) => {
|
|
141
|
+
tags.splice(0, tags.length, ...(Array.isArray(routes) ? routes : getDefaultTags()));
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const update = sync((route: any, options?: any) => {
|
|
145
|
+
const index = tags.findIndex((i: any) => isSimilar(route, i));
|
|
146
|
+
if (index < 0) return false;
|
|
147
|
+
|
|
148
|
+
tags.splice(index, 1, createTag(route, {
|
|
149
|
+
...options,
|
|
150
|
+
id: tags[index].id
|
|
151
|
+
}));
|
|
152
|
+
// TODO: 去重,AB相同路径标签,当query在筛选过程中一致时要去除其他相同的
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const isActive = (route: any) => {
|
|
156
|
+
return isSimilar(route, vRoute);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const updateCurrent = (route: any) => {
|
|
160
|
+
const index = tags.findIndex((i: any) => isSimilar(route, i));
|
|
161
|
+
if (index !== current.value) {
|
|
162
|
+
current.value = index;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const enter = () => {
|
|
167
|
+
const routes = Storage.get(`${TABS_KEY}/${Global.env.appCode}`, { session: true });
|
|
168
|
+
|
|
169
|
+
routes && clear(routes);
|
|
170
|
+
|
|
171
|
+
isReady.value = true;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// 单页应用只执行有一次,除非重载, 不需要处理销毁逻辑
|
|
175
|
+
onBeforeMount(() => {
|
|
176
|
+
enter();
|
|
177
|
+
Global.on(Global.events.logout, clear);
|
|
178
|
+
Global.on(Global.events.login, enter);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// path的变化
|
|
182
|
+
watch(
|
|
183
|
+
() => [layoutStore.loaded, vRoute.path, layoutStore.currentPage, isReady.value],
|
|
184
|
+
(v1, v2) => {
|
|
185
|
+
const [loaded, path] = v1;
|
|
186
|
+
if (!loaded || isEqual(v1, v2)) return;
|
|
187
|
+
|
|
188
|
+
// 二级/三级菜单
|
|
189
|
+
let route: any = layoutStore.routesMap[path as any];
|
|
190
|
+
|
|
191
|
+
if (
|
|
192
|
+
innerDisabled.value
|
|
193
|
+
|| vRoute.meta.layout === 'none'
|
|
194
|
+
|| vRoute.meta.tabless
|
|
195
|
+
) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
// 内页,若开启,则可保留无限个内页, 还需要考虑(back时是否要清理上一个tab)
|
|
199
|
+
if (!route && layoutStore.isInnerPage && layoutStore.currentPageRoutes?.length) {
|
|
200
|
+
const item = layoutStore.currentPageRoutes.slice(-1)[0];
|
|
201
|
+
route = {
|
|
202
|
+
value: item.value || path,
|
|
203
|
+
label: item.label,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (!route) {
|
|
207
|
+
// 首页等非菜单、非内页路由不会进入 routesMap,但仍需同步已存在 tab 的高亮
|
|
208
|
+
updateCurrent(vRoute);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
add(route, { query: Object.keys(vRoute.query).length ? cloneDeep(vRoute.query) : (void 0) });
|
|
213
|
+
updateCurrent(vRoute);
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
// query的变化,如果使用history.replaceState是无法监听的
|
|
218
|
+
watch(
|
|
219
|
+
() => [vRoute.path, vRoute.query],
|
|
220
|
+
async () => {
|
|
221
|
+
if (
|
|
222
|
+
current.value < 0
|
|
223
|
+
|| !tags[current.value]
|
|
224
|
+
|| tags[current.value].value !== vRoute.path
|
|
225
|
+
|| isEqual(tags[current.value].query, vRoute.query)
|
|
226
|
+
) return;
|
|
227
|
+
update(tags[current.value], { query: vRoute.query });
|
|
228
|
+
},
|
|
229
|
+
{ deep: true }
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
disabled,
|
|
234
|
+
innerDisabled,
|
|
235
|
+
current,
|
|
236
|
+
similarTagsMap,
|
|
237
|
+
tags,
|
|
238
|
+
add,
|
|
239
|
+
remove,
|
|
240
|
+
update,
|
|
241
|
+
updateCurrent,
|
|
242
|
+
clear,
|
|
243
|
+
isActive
|
|
244
|
+
};
|
|
245
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { ref, computed } from 'vue';
|
|
2
|
+
import { useRoute } from 'vue-router';
|
|
3
|
+
import { defineStore } from 'pinia';
|
|
4
|
+
import { Utils } from '@/src/utils';
|
|
5
|
+
import { sleep } from '@deot/helper-utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* layout下仅default可用
|
|
9
|
+
* 符合格式才能启用
|
|
10
|
+
* routes: Array<{ icon, fullLabel, parent, value, label, children }>
|
|
11
|
+
* navbarVisibleMap: 存放navbar下的展开收齐
|
|
12
|
+
* loaded: 是否初始化完成
|
|
13
|
+
* currentPage: { title, routes } 当前组件setTitle传递当前的页面信息
|
|
14
|
+
* currentNavbarRoutes:(computed)当前navbar选中的路由,内页根据currentPage内的某个信息强制设置navbar(比如某个详情页)
|
|
15
|
+
* hasSidebar:(computed)是否存在sidebar
|
|
16
|
+
* hasNavbar:(computed)是否存在navbar
|
|
17
|
+
* hasLayout: 是否渲染壳层(sidebar/navbar/header);首次 query.hideLayout=1|true 时为 false,之后不变
|
|
18
|
+
*/
|
|
19
|
+
export const useLayoutDefaultStore = defineStore('layout-default', () => {
|
|
20
|
+
const routes = ref<any[]>([]); // Tree格式路由
|
|
21
|
+
const routesMap = ref<Record<string, any>>({});
|
|
22
|
+
|
|
23
|
+
const currentPage = ref<any>({ title: '', routes: [] });
|
|
24
|
+
const navbarVisibleMap = ref<Record<string, any>>({});
|
|
25
|
+
|
|
26
|
+
const loaded = ref(false);
|
|
27
|
+
const render = ref(true);
|
|
28
|
+
|
|
29
|
+
const route = useRoute();
|
|
30
|
+
|
|
31
|
+
const hideLayout = route.query.hideLayout;
|
|
32
|
+
const hasLayout = ref(!(hideLayout === '1' || hideLayout === 'true'));
|
|
33
|
+
|
|
34
|
+
const isInnerPage = computed(() => {
|
|
35
|
+
return !routesMap.value[route.path] && currentPageRoute.value?.value;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const theme = computed(() => (route.meta?.theme as any) || 'default');
|
|
39
|
+
|
|
40
|
+
const currentPageRoutes = computed(() => {
|
|
41
|
+
const { routes: currentRoutes } = currentPage.value;
|
|
42
|
+
const result: any[] = [];
|
|
43
|
+
for (let i = currentRoutes.length - 1; i >= 0; i--) {
|
|
44
|
+
const item = currentRoutes[i];
|
|
45
|
+
if (routesMap.value[item.value]) {
|
|
46
|
+
result.unshift(routesMap.value[item.value]);
|
|
47
|
+
} else {
|
|
48
|
+
result.unshift(item);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const currentPageRoute = computed(() => {
|
|
55
|
+
const v = currentPageRoutes.value[0];
|
|
56
|
+
return v && v.value ? v : null;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const currentNavbarRoutes = computed(() => {
|
|
60
|
+
let path = ((isInnerPage.value ? currentPageRoute.value?.value : route.path) || '').split('?')[0];
|
|
61
|
+
const v: any[] = [];
|
|
62
|
+
while (routesMap.value[path]) {
|
|
63
|
+
v.unshift(routesMap.value[path]);
|
|
64
|
+
path = routesMap.value[path].parent;
|
|
65
|
+
}
|
|
66
|
+
return v;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const currentNavbarRoute = computed(() => {
|
|
70
|
+
return currentNavbarRoutes.value[currentNavbarRoutes.value.length - 1];
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const hasSidebar = computed(() => {
|
|
74
|
+
return routes.value.length > 1;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const hasNavbar = computed(() => {
|
|
78
|
+
return currentNavbarRoutes.value.length > 1 || routes.value.length === 1;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// 注意这里最终的格式参考最上面的routes
|
|
82
|
+
const setData = (treeData: any, treeMap?: any) => {
|
|
83
|
+
if (!treeMap) {
|
|
84
|
+
[treeMap, treeData] = Utils.tree2map(treeData, { injectParent: true, labelAsValue: false, clean: false });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
routes.value = treeData;
|
|
88
|
+
routesMap.value = treeMap;
|
|
89
|
+
loaded.value = true;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* TODO: 后续用于不在navbar上的一些控制
|
|
94
|
+
* @param v ~
|
|
95
|
+
*/
|
|
96
|
+
const setCurrentPage = (v: any) => {
|
|
97
|
+
currentPage.value = v;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// 刷新整个组件
|
|
101
|
+
const reRender = async () => {
|
|
102
|
+
render.value = false;
|
|
103
|
+
await sleep(0);
|
|
104
|
+
render.value = true;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
theme,
|
|
109
|
+
render,
|
|
110
|
+
isInnerPage,
|
|
111
|
+
currentPage,
|
|
112
|
+
currentPageRoute,
|
|
113
|
+
currentPageRoutes,
|
|
114
|
+
|
|
115
|
+
loaded,
|
|
116
|
+
routes,
|
|
117
|
+
routesMap,
|
|
118
|
+
navbarVisibleMap,
|
|
119
|
+
|
|
120
|
+
// computed
|
|
121
|
+
currentNavbarRoutes,
|
|
122
|
+
currentNavbarRoute,
|
|
123
|
+
hasNavbar,
|
|
124
|
+
hasSidebar,
|
|
125
|
+
hasLayout,
|
|
126
|
+
|
|
127
|
+
// methods
|
|
128
|
+
setData,
|
|
129
|
+
setCurrentPage,
|
|
130
|
+
reRender
|
|
131
|
+
};
|
|
132
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Resizer class="c-ldnt g-flex-ac" @resize="handleResize">
|
|
3
|
+
<template #default="{ width }">
|
|
4
|
+
<Scroller
|
|
5
|
+
v-if="tabsStore.tags?.length"
|
|
6
|
+
ref="scroller"
|
|
7
|
+
:style="`width: ${width}px`"
|
|
8
|
+
:native="false"
|
|
9
|
+
content-class="g-flex-ac"
|
|
10
|
+
style="white-space: nowrap;"
|
|
11
|
+
>
|
|
12
|
+
<div ref="content" class="g-flex-ac">
|
|
13
|
+
<template v-for="(item, index) in tabsStore.tags" :key="index">
|
|
14
|
+
<Tag
|
|
15
|
+
v-if="displayable(index)"
|
|
16
|
+
:style="itemStyle"
|
|
17
|
+
:index="index"
|
|
18
|
+
v-bind="item"
|
|
19
|
+
:deletable="deletable(index)"
|
|
20
|
+
/>
|
|
21
|
+
</template>
|
|
22
|
+
</div>
|
|
23
|
+
</Scroller>
|
|
24
|
+
</template>
|
|
25
|
+
</Resizer>
|
|
26
|
+
</template>
|
|
27
|
+
<script setup lang="ts">
|
|
28
|
+
import { computed, ref, watch } from 'vue';
|
|
29
|
+
import { Resizer, Scroller } from '@deot/vc';
|
|
30
|
+
import { sleep } from '@deot/helper-utils';
|
|
31
|
+
import { Context } from '@/src/modules/context';
|
|
32
|
+
import { useLayoutDefaultTabsStore } from '../stores/use-layout-default-tabs';
|
|
33
|
+
import Tag from './item.vue';
|
|
34
|
+
|
|
35
|
+
const tabsStore = useLayoutDefaultTabsStore();
|
|
36
|
+
|
|
37
|
+
const scrollable = ref(false);
|
|
38
|
+
const content = ref<any>();
|
|
39
|
+
const scroller = ref<any>();
|
|
40
|
+
const clientWidth = ref(0);
|
|
41
|
+
const itemStyle = computed(() => {
|
|
42
|
+
const length = tabsStore.tags.length;
|
|
43
|
+
return {
|
|
44
|
+
width: Math.min(150, Math.max(clientWidth.value / length, 64)) + 'px'
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const displayable = (index: number) => {
|
|
49
|
+
const showHome = Context.platform.constant('LAYOUT_HOME_VISIBLE');
|
|
50
|
+
const min = showHome ? 0 : 1;
|
|
51
|
+
return (showHome || index !== 0) && tabsStore.tags.length > min;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const deletable = (index: number) => {
|
|
55
|
+
const item = tabsStore.tags[index];
|
|
56
|
+
const min = Context.platform.constant('LAYOUT_HOME_VISIBLE') ? 1 : 2;
|
|
57
|
+
return tabsStore.tags.length !== min && item.deletable;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const refresh = async () => {
|
|
61
|
+
await sleep(100);
|
|
62
|
+
if (!content.value) return;
|
|
63
|
+
const width = content.value.getBoundingClientRect().width;
|
|
64
|
+
|
|
65
|
+
clientWidth.value && (scrollable.value = width > clientWidth.value);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const handleResize = async (e: any) => {
|
|
69
|
+
clientWidth.value = e.width;
|
|
70
|
+
refresh();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
watch(() => tabsStore.tags, refresh);
|
|
74
|
+
</script>
|
|
75
|
+
<style lang="scss">
|
|
76
|
+
$block: c-ldnt; // c-layout-default-tabs;
|
|
77
|
+
|
|
78
|
+
@include block($block) {
|
|
79
|
+
|
|
80
|
+
};
|
|
81
|
+
</style>
|