@maketribe/ms-app 3.0.29 → 3.0.31
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/package.json +39 -42
- package/src/components/button/button-options.ts +22 -0
- package/src/components/button/button.tsx +37 -0
- package/src/components/button/index.ts +7 -0
- package/src/components/column-components/column-action/column-action-options.ts +11 -0
- package/src/components/column-components/column-action/column-action.tsx +36 -0
- package/src/components/column-components/column-action/index.ts +4 -0
- package/src/components/column-components/column-date/column-date-options.ts +12 -0
- package/src/components/column-components/column-date/column-date.tsx +47 -0
- package/src/components/column-components/column-date/index.ts +6 -0
- package/src/components/column-components/column-image/column-image-options.ts +9 -0
- package/src/components/column-components/column-image/column-image.tsx +20 -0
- package/src/components/column-components/column-image/index.ts +4 -0
- package/src/components/column-components/column-json/column-json-options.ts +13 -0
- package/src/components/column-components/column-json/column-json.tsx +41 -0
- package/src/components/column-components/column-json/index.ts +8 -0
- package/src/components/column-components/column-link/column-link-options.ts +34 -0
- package/src/components/column-components/column-link/column-link.tsx +27 -0
- package/src/components/column-components/column-link/index.ts +7 -0
- package/src/components/column-components/column-object-mapping-text/column-object-mapping-text-options.ts +12 -0
- package/src/components/column-components/column-object-mapping-text/column-object-mapping-text.tsx +22 -0
- package/src/components/column-components/column-object-mapping-text/index.ts +6 -0
- package/src/components/column-components/column-select/column-select-header-options.ts +8 -0
- package/src/components/column-components/column-select/column-select-header.tsx +57 -0
- package/src/components/column-components/column-select/column-select-options.ts +9 -0
- package/src/components/column-components/column-select/column-select.tsx +74 -0
- package/src/components/column-components/column-select/index.ts +5 -0
- package/src/components/column-components/column-switch/column-switch-options.ts +16 -0
- package/src/components/column-components/column-switch/column-switch.tsx +37 -0
- package/src/components/column-components/column-switch/index.ts +6 -0
- package/src/components/column-components/column-tag/column-tag-options.ts +42 -0
- package/src/components/column-components/column-tag/column-tag.tsx +59 -0
- package/src/components/column-components/column-tag/index.ts +6 -0
- package/src/components/column-components/column-text/column-text-options.ts +10 -0
- package/src/components/column-components/column-text/column-text.tsx +18 -0
- package/src/components/column-components/column-text/index.ts +6 -0
- package/src/components/column-components/index.ts +10 -0
- package/src/components/condition-components/condition-date/condition-date-options.ts +21 -0
- package/src/components/condition-components/condition-date/condition-date.tsx +68 -0
- package/src/components/condition-components/condition-date/index.ts +7 -0
- package/src/components/condition-components/condition-input/condition-input-options.ts +10 -0
- package/src/components/condition-components/condition-input/condition-input.tsx +41 -0
- package/src/components/condition-components/condition-input/index.ts +7 -0
- package/src/components/condition-components/condition-number/condition-number-options.ts +22 -0
- package/src/components/condition-components/condition-number/condition-number.tsx +74 -0
- package/src/components/condition-components/condition-number/index.ts +7 -0
- package/src/components/condition-components/condition-select/condition-select-options.ts +31 -0
- package/src/components/condition-components/condition-select/condition-select.tsx +56 -0
- package/src/components/condition-components/condition-select/index.ts +7 -0
- package/src/components/condition-components/index.ts +4 -0
- package/src/components/config-provider/config-provider-options.ts +24 -0
- package/src/components/config-provider/config-provider.tsx +21 -0
- package/src/components/config-provider/constants.ts +8 -0
- package/src/components/config-provider/index.ts +9 -0
- package/src/components/config-provider/use-global-config.ts +70 -0
- package/src/components/data-model/data-filter-form/composables/index.ts +1 -0
- package/src/components/data-model/data-filter-form/composables/use-condition.ts +68 -0
- package/src/components/data-model/data-filter-form/data-filter-form-item/data-filter-form-item-options.ts +11 -0
- package/src/components/data-model/data-filter-form/data-filter-form-item/data-filter-form-item.tsx +183 -0
- package/src/components/data-model/data-filter-form/data-filter-form-item/index.ts +7 -0
- package/src/components/data-model/data-filter-form/data-filter-form-options.ts +15 -0
- package/src/components/data-model/data-filter-form/data-filter-form.tsx +103 -0
- package/src/components/data-model/data-filter-form/index.ts +13 -0
- package/src/components/data-model/data-filter-form/operator-options.ts +48 -0
- package/src/components/data-model/data-filter-form/token.ts +30 -0
- package/src/components/data-model/data-filter-popover/data-filter-popover-options.ts +6 -0
- package/src/components/data-model/data-filter-popover/data-filter-popover.tsx +52 -0
- package/src/components/data-model/data-filter-popover/index.ts +8 -0
- package/src/components/data-model/data-form/composables/index.ts +1 -0
- package/src/components/data-model/data-form/composables/use-form-item.ts +40 -0
- package/src/components/data-model/data-form/data-form-item/data-form-item-options.ts +11 -0
- package/src/components/data-model/data-form/data-form-item/data-form-item.tsx +140 -0
- package/src/components/data-model/data-form/data-form-item/index.ts +6 -0
- package/src/components/data-model/data-form/data-form-options.ts +43 -0
- package/src/components/data-model/data-form/data-form.tsx +113 -0
- package/src/components/data-model/data-form/index.ts +13 -0
- package/src/components/data-model/data-form/token.ts +16 -0
- package/src/components/data-model/data-form/views/form/form-options.ts +16 -0
- package/src/components/data-model/data-form/views/form/form.tsx +206 -0
- package/src/components/data-model/data-form/views/form/index.ts +6 -0
- package/src/components/data-model/data-form/views/form-view/form-view-options.ts +17 -0
- package/src/components/data-model/data-form/views/form-view/form-view.tsx +68 -0
- package/src/components/data-model/data-form/views/form-view/index.ts +6 -0
- package/src/components/data-model/data-form/views/index.ts +2 -0
- package/src/components/data-model/data-form-page/data-form-page-options.ts +20 -0
- package/src/components/data-model/data-form-page/data-form-page.tsx +57 -0
- package/src/components/data-model/data-form-page/index.ts +7 -0
- package/src/components/data-model/data-table/composables/index.ts +1 -0
- package/src/components/data-model/data-table/composables/use-column.ts +23 -0
- package/src/components/data-model/data-table/data-table-column/data-table-column-options.ts +11 -0
- package/src/components/data-model/data-table/data-table-column/data-table-column.tsx +18 -0
- package/src/components/data-model/data-table/data-table-column/index.ts +7 -0
- package/src/components/data-model/data-table/data-table-column-component/data-table-column-component-options.ts +13 -0
- package/src/components/data-model/data-table/data-table-column-component/data-table-column-component.tsx +38 -0
- package/src/components/data-model/data-table/data-table-column-component/index.ts +7 -0
- package/src/components/data-model/data-table/data-table-options.ts +24 -0
- package/src/components/data-model/data-table/data-table.tsx +102 -0
- package/src/components/data-model/data-table/index.ts +17 -0
- package/src/components/data-model/data-table/token.ts +10 -0
- package/src/components/data-model/data-table/views/index.ts +5 -0
- package/src/components/data-model/data-table/views/table/index.ts +8 -0
- package/src/components/data-model/data-table/views/table/table-options.ts +12 -0
- package/src/components/data-model/data-table/views/table/table.tsx +98 -0
- package/src/components/data-model/data-table/views/table-tree/index.ts +8 -0
- package/src/components/data-model/data-table/views/table-tree/table-tree-options.ts +12 -0
- package/src/components/data-model/data-table/views/table-tree/table-tree.tsx +104 -0
- package/src/components/data-model/data-table/views/table-view/classify-search/classify-search-item/classify-search-item-options.ts +34 -0
- package/src/components/data-model/data-table/views/table-view/classify-search/classify-search-item/classify-search-item.tsx +97 -0
- package/src/components/data-model/data-table/views/table-view/classify-search/classify-search-item/index.ts +5 -0
- package/src/components/data-model/data-table/views/table-view/classify-search/classify-search.tsx +40 -0
- package/src/components/data-model/data-table/views/table-view/classify-search/index.ts +7 -0
- package/src/components/data-model/data-table/views/table-view/index.ts +8 -0
- package/src/components/data-model/data-table/views/table-view/table-view-options.ts +13 -0
- package/src/components/data-model/data-table/views/table-view/table-view.tsx +126 -0
- package/src/components/data-model/data-table/views/tree/index.ts +8 -0
- package/src/components/data-model/data-table/views/tree/tree-options.ts +14 -0
- package/src/components/data-model/data-table/views/tree/tree.tsx +131 -0
- package/src/components/data-model/data-table/views/tree-view/index.ts +8 -0
- package/src/components/data-model/data-table/views/tree-view/tree-view-options.ts +16 -0
- package/src/components/data-model/data-table/views/tree-view/tree-view.tsx +81 -0
- package/src/components/data-model/data-table-page/data-table-page-options.ts +11 -0
- package/src/components/data-model/data-table-page/data-table-page.tsx +26 -0
- package/src/components/data-model/data-table-page/index.ts +6 -0
- package/src/components/data-model/data-table-pagination/data-table-pagination-options.ts +14 -0
- package/src/components/data-model/data-table-pagination/data-table-pagination.tsx +22 -0
- package/src/components/data-model/data-table-pagination/index.ts +7 -0
- package/src/components/data-model/filter-panel/composables/index.ts +1 -0
- package/src/components/data-model/filter-panel/composables/use-condition.ts +66 -0
- package/src/components/data-model/filter-panel/filter-panel-item/filter-panel-item-options.ts +11 -0
- package/src/components/data-model/filter-panel/filter-panel-item/filter-panel-item.tsx +187 -0
- package/src/components/data-model/filter-panel/filter-panel-item/index.ts +7 -0
- package/src/components/data-model/filter-panel/filter-panel-options.ts +15 -0
- package/src/components/data-model/filter-panel/filter-panel.tsx +102 -0
- package/src/components/data-model/filter-panel/index.ts +11 -0
- package/src/components/data-model/filter-panel/operator-options.ts +48 -0
- package/src/components/data-model/filter-panel/token.ts +17 -0
- package/src/components/data-model/index.ts +5 -0
- package/src/components/data-select/data-select-options.ts +43 -0
- package/src/components/data-select/data-select.tsx +87 -0
- package/src/components/data-select/index.ts +7 -0
- package/src/components/data-table-select/data-table-select-options.ts +43 -0
- package/src/components/data-table-select/data-table-select.tsx +190 -0
- package/src/components/data-table-select/index.ts +6 -0
- package/src/components/data-table-select-dialog/data-table-select-dialog-options.ts +33 -0
- package/src/components/data-table-select-dialog/data-table-select-dialog.tsx +154 -0
- package/src/components/data-table-select-dialog/index.ts +7 -0
- package/src/components/file-view/file-view-options.ts +8 -0
- package/src/components/file-view/file-view.tsx +40 -0
- package/src/components/file-view/index.ts +7 -0
- package/src/components/form-components/form-data-select/form-data-select-options.ts +23 -0
- package/src/components/form-components/form-data-select/form-data-select.tsx +28 -0
- package/src/components/form-components/form-data-select/index.ts +7 -0
- package/src/components/form-components/form-data-table-select/form-data-table-select-options.ts +19 -0
- package/src/components/form-components/form-data-table-select/form-data-table-select.tsx +32 -0
- package/src/components/form-components/form-data-table-select/index.ts +7 -0
- package/src/components/form-components/form-date-picker/form-date-picker-options.ts +18 -0
- package/src/components/form-components/form-date-picker/form-date-picker.tsx +49 -0
- package/src/components/form-components/form-date-picker/index.ts +8 -0
- package/src/components/form-components/form-detail/form-detail-options.ts +15 -0
- package/src/components/form-components/form-detail/form-detail.tsx +112 -0
- package/src/components/form-components/form-detail/index.ts +7 -0
- package/src/components/form-components/form-detail-select/form-detail-select-options.ts +39 -0
- package/src/components/form-components/form-detail-select/form-detail-select.tsx +68 -0
- package/src/components/form-components/form-detail-select/index.ts +5 -0
- package/src/components/form-components/form-icon-select/form-icon-select-options.ts +9 -0
- package/src/components/form-components/form-icon-select/form-icon-select.tsx +71 -0
- package/src/components/form-components/form-icon-select/index.ts +5 -0
- package/src/components/form-components/form-image-upload/form-image-upload-options.ts +11 -0
- package/src/components/form-components/form-image-upload/form-image-upload.tsx +22 -0
- package/src/components/form-components/form-image-upload/index.ts +5 -0
- package/src/components/form-components/form-radio-box/form-radio-box-options.ts +32 -0
- package/src/components/form-components/form-radio-box/form-radio-box.tsx +83 -0
- package/src/components/form-components/form-radio-box/index.ts +7 -0
- package/src/components/form-components/form-rich-text-editor/form-rich-text-editor-options.ts +6 -0
- package/src/components/form-components/form-rich-text-editor/form-rich-text-editor.tsx +22 -0
- package/src/components/form-components/form-rich-text-editor/index.ts +7 -0
- package/src/components/form-components/index.ts +9 -0
- package/src/components/image-select/image-select-option.ts +11 -0
- package/src/components/image-select/image-select.tsx +44 -0
- package/src/components/image-select/index.ts +6 -0
- package/src/components/image-view/image-view-options.ts +14 -0
- package/src/components/image-view/image-view.tsx +30 -0
- package/src/components/image-view/index.ts +7 -0
- package/src/components/index.ts +23 -0
- package/src/components/json-editor/index.ts +8 -0
- package/src/components/json-editor/json-editor-options.ts +21 -0
- package/src/components/json-editor/json-editor.tsx +28 -0
- package/src/components/markdown-editor/index.ts +10 -0
- package/src/components/markdown-editor/markdown-editor-options.ts +17 -0
- package/src/components/markdown-editor/markdown-editor.tsx +136 -0
- package/src/components/material-list/index.ts +7 -0
- package/src/components/material-list/material-group-form-popover.vue +78 -0
- package/src/components/material-list/material-group.vue +145 -0
- package/src/components/material-list/material-item.vue +26 -0
- package/src/components/material-list/material-list-options.ts +24 -0
- package/src/components/material-list/material-list.vue +153 -0
- package/src/components/material-select/index.ts +17 -0
- package/src/components/material-select/material-select-api.ts +55 -0
- package/src/components/material-select/material-select-options.ts +22 -0
- package/src/components/material-select/material-select-type.ts +21 -0
- package/src/components/material-select/material-select.tsx +106 -0
- package/src/components/pagination/index.ts +7 -0
- package/src/components/pagination/pagination-options.tsx +30 -0
- package/src/components/pagination/pagination.tsx +41 -0
- package/src/components/rich-text-editor/index.ts +10 -0
- package/src/components/rich-text-editor/langs/zh-Hans.js +1 -0
- package/src/components/rich-text-editor/rich-text-editor-options.ts +21 -0
- package/src/components/rich-text-editor/rich-text-editor.tsx +111 -0
- package/src/components/role-permission-config/index.ts +7 -0
- package/src/components/role-permission-config/role-permission-config-options.ts +20 -0
- package/src/components/role-permission-config/role-permission-config.tsx +269 -0
- package/src/components/svg-icon/index.ts +5 -0
- package/src/components/svg-icon/svg-icon-options.ts +21 -0
- package/src/components/svg-icon/svg-icon.tsx +48 -0
- package/src/components/system-provider/index.ts +5 -0
- package/src/components/system-provider/system-provider.tsx +95 -0
- package/src/components/upload-file/context/MaterialUploadContext.ts +33 -0
- package/src/components/upload-file/context/UploadContext.ts +21 -0
- package/src/components/upload-file/context/WebFileUploadContext.ts +77 -0
- package/src/components/upload-file/context/index.ts +7 -0
- package/src/components/upload-file/context/material-upload-context-options.ts +13 -0
- package/src/components/upload-file/context/material-upload-context.tsx +34 -0
- package/src/components/upload-file/context/web-file-upload-context-options.ts +16 -0
- package/src/components/upload-file/context/web-file-upload-context.tsx +37 -0
- package/src/components/upload-file/index.ts +11 -0
- package/src/components/upload-file/ui/index.ts +1 -0
- package/src/components/upload-file/ui/upload-image/index.ts +7 -0
- package/src/components/upload-file/ui/upload-image/upload-image-options.ts +25 -0
- package/src/components/upload-file/ui/upload-image/upload-image.tsx +337 -0
- package/src/components/upload-file/upload-file-options.ts +22 -0
- package/src/components/upload-file/upload-file.tsx +69 -0
- package/src/components/verify-dialog/index.ts +5 -0
- package/src/components/verify-dialog/verify-dialog-option.ts +24 -0
- package/src/components/verify-dialog/verify-dialog.tsx +179 -0
- package/src/components/video-view/index.ts +7 -0
- package/src/components/video-view/video-view-options.ts +10 -0
- package/src/components/video-view/video-view.tsx +115 -0
- package/src/composables/create-data-form.ts +6 -0
- package/src/composables/create-data-table.ts +8 -0
- package/src/composables/index.ts +17 -0
- package/src/composables/on-tab-before-close.ts +8 -0
- package/src/composables/on-tab-before-switch.ts +8 -0
- package/src/composables/on-tab-refresh.ts +8 -0
- package/src/composables/use-column-component.ts +184 -0
- package/src/composables/use-current-tab.ts +4 -0
- package/src/composables/use-http-request.ts +5 -0
- package/src/composables/use-i18n.ts +7 -0
- package/src/composables/use-ms-app-client.ts +10 -0
- package/src/composables/use-user-info.ts +4 -0
- package/src/constants/index.ts +6 -0
- package/src/constants/log.ts +5 -0
- package/src/constants/menu.ts +5 -0
- package/src/constants/pattern.ts +4 -0
- package/src/constants/region.ts +6 -0
- package/src/constants/route.ts +4 -0
- package/src/constants/token.ts +5 -0
- package/src/core/DataModelDefines.ts +72 -0
- package/src/core/MSAppClient.ts +260 -0
- package/src/core/PageManager.ts +169 -0
- package/src/core/PermissionPointManager.ts +26 -0
- package/src/core/Router.ts +150 -0
- package/src/core/UserInfo.ts +66 -0
- package/src/core/UserSession.ts +215 -0
- package/src/core/component/ConfigComponents.ts +32 -0
- package/src/core/component/DataFilterComponents.ts +40 -0
- package/src/core/component/DataFormComponents.ts +93 -0
- package/src/core/component/DataTableComponents.ts +91 -0
- package/src/core/component/MaterialComponents.ts +32 -0
- package/src/core/component/index.ts +5 -0
- package/src/core/index.ts +11 -0
- package/src/core/menu/Menu.ts +143 -0
- package/src/core/menu/MenuNode.ts +53 -0
- package/src/core/menu/index.ts +2 -0
- package/src/core/resolver/ITypeResolver.ts +5 -0
- package/src/core/tabs/Tab.ts +59 -0
- package/src/core/tabs/Tabs.ts +187 -0
- package/src/core/tabs/index.ts +2 -0
- package/src/dataview/config/ConfigForm.ts +142 -0
- package/src/dataview/config/ConfigTable.ts +72 -0
- package/src/dataview/config/index.ts +2 -0
- package/src/dataview/deny-ip-access-list/DenyIPAccessListForm.ts +33 -0
- package/src/dataview/deny-ip-access-list/DenyIPAccessListTable.ts +84 -0
- package/src/dataview/deny-ip-access-list/index.ts +2 -0
- package/src/dataview/department/DepartmentForm.ts +41 -0
- package/src/dataview/department/DepartmentTable.ts +64 -0
- package/src/dataview/department/DepartmentTree.ts +47 -0
- package/src/dataview/department/index.ts +3 -0
- package/src/dataview/index.ts +11 -0
- package/src/dataview/ip-white-list/IPWhitelistForm.ts +38 -0
- package/src/dataview/ip-white-list/IPWhitelistTable.ts +81 -0
- package/src/dataview/ip-white-list/index.ts +2 -0
- package/src/dataview/log/index.ts +4 -0
- package/src/dataview/log/local-log/LocalLogTree.ts +77 -0
- package/src/dataview/log/local-log/index.ts +1 -0
- package/src/dataview/log/login-log/LoginLogTable.ts +55 -0
- package/src/dataview/log/login-log/index.ts +1 -0
- package/src/dataview/log/operate-log/OperateLogTable.ts +20 -0
- package/src/dataview/log/operate-log/index.ts +1 -0
- package/src/dataview/log/request-log/RequestLogTable.ts +82 -0
- package/src/dataview/log/request-log/index.ts +1 -0
- package/src/dataview/material/MaterialForm.ts +49 -0
- package/src/dataview/material/MaterialMan.ts +203 -0
- package/src/dataview/material/MaterialTable.ts +125 -0
- package/src/dataview/material/index.ts +4 -0
- package/src/dataview/material/material-group/MaterialGroupForm.ts +27 -0
- package/src/dataview/material/material-group/MaterialGroupTable.ts +57 -0
- package/src/dataview/material/material-group/MaterialGroupTree.ts +71 -0
- package/src/dataview/material/material-group/index.ts +3 -0
- package/src/dataview/member/MemberForm.ts +124 -0
- package/src/dataview/member/MemberTable.tsx +257 -0
- package/src/dataview/member/index.ts +2 -0
- package/src/dataview/member/member-role/MemberRoleTable.ts +23 -0
- package/src/dataview/menu/MenuForm.ts +192 -0
- package/src/dataview/menu/MenuTable.ts +40 -0
- package/src/dataview/menu/MenuTree.ts +112 -0
- package/src/dataview/menu/index.ts +4 -0
- package/src/dataview/menu/permission-point/PermissionPointDefineForm.ts +30 -0
- package/src/dataview/menu/permission-point/PermissionPointDefineTable.ts +32 -0
- package/src/dataview/menu/permission-point/index.ts +2 -0
- package/src/dataview/region/RegionForm.ts +52 -0
- package/src/dataview/region/RegionTable.ts +64 -0
- package/src/dataview/region/index.ts +2 -0
- package/src/dataview/role/RoleForm.ts +34 -0
- package/src/dataview/role/RolePermissionConfigTable.ts +476 -0
- package/src/dataview/role/RoleTable.ts +70 -0
- package/src/dataview/role/index.ts +5 -0
- package/src/dataview/role/role-permission-point/RolePermissionPointTable.ts +29 -0
- package/src/dataview/role/role-permission-point/index.ts +1 -0
- package/src/dataview/role/role-route/RoleRouteTable.ts +30 -0
- package/src/dataview/role/role-route/index.ts +1 -0
- package/src/dataview/route/RouteForm.ts +94 -0
- package/src/dataview/route/RouteTable.ts +73 -0
- package/src/dataview/route/index.ts +2 -0
- package/src/define-data-form.ts +12 -0
- package/src/define-data-table.ts +12 -0
- package/src/define-data-tree.ts +12 -0
- package/src/index.ts +19 -0
- package/src/init-application.ts +83 -0
- package/src/installer.ts +73 -0
- package/src/layouts/components/bar/index.tsx +102 -0
- package/src/layouts/components/dialogs/dialogs.tsx +100 -0
- package/src/layouts/components/dialogs/index.ts +5 -0
- package/src/layouts/components/header/index.tsx +18 -0
- package/src/layouts/components/header/tools.tsx +55 -0
- package/src/layouts/components/index.ts +3 -0
- package/src/layouts/components/lock/index.ts +5 -0
- package/src/layouts/components/lock/lock.tsx +92 -0
- package/src/layouts/components/menu/index.tsx +61 -0
- package/src/layouts/components/menu/menu-item.tsx +63 -0
- package/src/layouts/container/default.tsx +85 -0
- package/src/layouts/index.ts +6 -0
- package/src/layouts/layout.tsx +11 -0
- package/src/message-impl/DialogerImpl.ts +84 -0
- package/src/message-impl/MessagerImpl.ts +17 -0
- package/src/message-impl/NotificationerImpl.ts +17 -0
- package/src/message-impl/index.ts +3 -0
- package/src/page/index/404.vue +3 -0
- package/src/page/index/dv/default/add.vue +50 -0
- package/src/page/index/dv/default/edit.vue +56 -0
- package/src/page/index/dv/default/single/list/dialog.vue +155 -0
- package/src/page/index/dv/default/single/list/normal.vue +128 -0
- package/src/page/index/dv/default/single/table-tree/dialog.vue +60 -0
- package/src/page/index/dv/default/single/tree/dialog.vue +174 -0
- package/src/page/index/dv/default/table.vue +52 -0
- package/src/page/index/dv/local-log/index.vue +98 -0
- package/src/page/index/dv/ms-member/index.vue +33 -0
- package/src/page/index/dv/ms-role/index.vue +32 -0
- package/src/page/index/material/index.vue +16 -0
- package/src/page/index.vue +9 -0
- package/src/page/login/index.vue +196 -0
- package/src/page/signup/index.vue +157 -0
- package/src/router-middleware/auth.ts +31 -0
- package/src/router-middleware/index.ts +1 -0
- package/src/tokens/index.ts +1 -0
- package/src/tokens/ms-app-client.ts +10 -0
- package/src/utils.ts +233 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DefaultSingleListDialogPage :data-table="roleTable" />
|
|
3
|
+
|
|
4
|
+
<ElDialog v-model="isShowDialog" appendToBody width="80%">
|
|
5
|
+
<MKRolePermissionConfig
|
|
6
|
+
:rolePermissionConfigTable="rolePermissionConfigTable"
|
|
7
|
+
/>
|
|
8
|
+
</ElDialog>
|
|
9
|
+
</template>
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { reactive, ref } from "vue";
|
|
12
|
+
import { ElDialog } from "element-plus";
|
|
13
|
+
import DefaultSingleListDialogPage from "../default/single/list/dialog.vue";
|
|
14
|
+
import { RoleTable, RolePermissionConfigTable } from "../../../../dataview";
|
|
15
|
+
import { MKRolePermissionConfig } from "../../../../components";
|
|
16
|
+
import { DataModelDefines } from "../../../../core";
|
|
17
|
+
|
|
18
|
+
const roleTable = reactive(
|
|
19
|
+
DataModelDefines.instance.getDataTable("ms-role")!
|
|
20
|
+
) as RoleTable;
|
|
21
|
+
const rolePermissionConfigTable = reactive(
|
|
22
|
+
new RolePermissionConfigTable()
|
|
23
|
+
) as RolePermissionConfigTable;
|
|
24
|
+
|
|
25
|
+
const isShowDialog = ref(false);
|
|
26
|
+
|
|
27
|
+
roleTable.configRolePermissionEvent.on(({ item }) => {
|
|
28
|
+
rolePermissionConfigTable.selectRolePermission(item);
|
|
29
|
+
|
|
30
|
+
isShowDialog.value = true;
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<MKMaterialList :material-man="materialMan" />
|
|
3
|
+
</template>
|
|
4
|
+
<script setup lang="ts">
|
|
5
|
+
import { reactive } from "vue";
|
|
6
|
+
import { MaterialMan } from "../../../dataview";
|
|
7
|
+
import { MKMaterialList } from "../../../components";
|
|
8
|
+
import { MSAppClient, MaterialComponents } from "../../../core";
|
|
9
|
+
|
|
10
|
+
const materialMan = reactive(
|
|
11
|
+
new MaterialMan({
|
|
12
|
+
components: new MaterialComponents(),
|
|
13
|
+
httpRequest: MSAppClient.instance!.httpRequest,
|
|
14
|
+
})
|
|
15
|
+
) as MaterialMan;
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="login-wrap">
|
|
3
|
+
<div class="login-bg">
|
|
4
|
+
<div class="login-bg-block"></div>
|
|
5
|
+
<div class="login-bg-block"></div>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="login-root">
|
|
8
|
+
<div class="login-main">
|
|
9
|
+
<div class="form-container">
|
|
10
|
+
<div class="form-wrap">
|
|
11
|
+
<div class="form-title" v-if="!forgotPassword">
|
|
12
|
+
账号登录
|
|
13
|
+
<span class="notify">
|
|
14
|
+
没有账号?<ElButton
|
|
15
|
+
link
|
|
16
|
+
class="operaBtn"
|
|
17
|
+
@click="router.push('/signup')"
|
|
18
|
+
>
|
|
19
|
+
申请使用
|
|
20
|
+
</ElButton>
|
|
21
|
+
</span>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="form-title" v-else>账号重置</div>
|
|
24
|
+
<ElForm
|
|
25
|
+
:model="loginFormData"
|
|
26
|
+
:rules="rules"
|
|
27
|
+
size="large"
|
|
28
|
+
ref="formEl"
|
|
29
|
+
@submit.native.prevent
|
|
30
|
+
>
|
|
31
|
+
<ElFormItem prop="account">
|
|
32
|
+
<ElInput
|
|
33
|
+
v-model="loginFormData.account"
|
|
34
|
+
placeholder="帐号"
|
|
35
|
+
@keyup.enter.native.prevent="verifyHandle"
|
|
36
|
+
/>
|
|
37
|
+
</ElFormItem>
|
|
38
|
+
<ElFormItem prop="password" v-if="!forgotPassword">
|
|
39
|
+
<ElInput
|
|
40
|
+
v-model="loginFormData.password"
|
|
41
|
+
type="password"
|
|
42
|
+
placeholder="密码"
|
|
43
|
+
@keyup.enter.native.prevent="verifyHandle"
|
|
44
|
+
/>
|
|
45
|
+
</ElFormItem>
|
|
46
|
+
<ElFormItem>
|
|
47
|
+
<ElRow style="width: 100%">
|
|
48
|
+
<ElCol :span="12">
|
|
49
|
+
<ElButton
|
|
50
|
+
link
|
|
51
|
+
class="operaBtn"
|
|
52
|
+
@click="forgotPassword = !forgotPassword"
|
|
53
|
+
>{{
|
|
54
|
+
forgotPassword ? "返回登陆" : "忘记密码?"
|
|
55
|
+
}}</ElButton
|
|
56
|
+
>
|
|
57
|
+
</ElCol>
|
|
58
|
+
</ElRow>
|
|
59
|
+
</ElFormItem>
|
|
60
|
+
<ElFormItem>
|
|
61
|
+
<ElButton
|
|
62
|
+
type="primary"
|
|
63
|
+
style="width: 100%"
|
|
64
|
+
:loading="loading"
|
|
65
|
+
@click="verifyHandle"
|
|
66
|
+
:disabled="loginDisabled"
|
|
67
|
+
v-if="!forgotPassword"
|
|
68
|
+
>
|
|
69
|
+
登陆
|
|
70
|
+
</ElButton>
|
|
71
|
+
<ElButton
|
|
72
|
+
type="primary"
|
|
73
|
+
style="width: 100%"
|
|
74
|
+
:loading="loading"
|
|
75
|
+
@click="verifyHandle"
|
|
76
|
+
:disabled="resetDisabled"
|
|
77
|
+
v-else
|
|
78
|
+
>
|
|
79
|
+
重置
|
|
80
|
+
</ElButton>
|
|
81
|
+
</ElFormItem>
|
|
82
|
+
</ElForm>
|
|
83
|
+
<ElDivider></ElDivider>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<MKVerifyDialog
|
|
91
|
+
ref="verifyDialog"
|
|
92
|
+
:scene="scene"
|
|
93
|
+
v-model:visible="verifyVisible"
|
|
94
|
+
v-if="verifyVisible"
|
|
95
|
+
@confirm="handleLogin"
|
|
96
|
+
/>
|
|
97
|
+
</template>
|
|
98
|
+
|
|
99
|
+
<script setup lang="ts">
|
|
100
|
+
import { ElMessage, ElForm, ElFormItem } from "element-plus";
|
|
101
|
+
import { useMSAppClient } from "../../composables";
|
|
102
|
+
import { MKVerifyDialog } from "../../components";
|
|
103
|
+
import { Ref, computed, reactive, ref } from "vue";
|
|
104
|
+
import { useRouter } from "vue-router";
|
|
105
|
+
|
|
106
|
+
defineOptions({
|
|
107
|
+
mkRoute: {
|
|
108
|
+
name: "login",
|
|
109
|
+
path: "/login",
|
|
110
|
+
meta: {
|
|
111
|
+
isAuthorization: false,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const verifyDialog: Ref<{ fail: () => void } | null> = ref(null);
|
|
117
|
+
|
|
118
|
+
// 记住登陆状态
|
|
119
|
+
const rememberLoginState = ref(false);
|
|
120
|
+
|
|
121
|
+
const formEl: Ref<any> = ref(null);
|
|
122
|
+
|
|
123
|
+
const system = useMSAppClient()!;
|
|
124
|
+
|
|
125
|
+
const router = useRouter();
|
|
126
|
+
|
|
127
|
+
const loading = ref(false);
|
|
128
|
+
|
|
129
|
+
const loginDisabled = computed(
|
|
130
|
+
() => !loginFormData.account || !loginFormData.password
|
|
131
|
+
);
|
|
132
|
+
const resetDisabled = computed(() => !loginFormData.account);
|
|
133
|
+
|
|
134
|
+
const forgotPassword = ref(false);
|
|
135
|
+
const scene = computed(() =>
|
|
136
|
+
forgotPassword.value ? "ModifyPassword" : "Login"
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const rules = {
|
|
140
|
+
account: [{ required: true, message: "账号必填" }],
|
|
141
|
+
password: [{ required: true, message: "密码必填" }],
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const loginFormData = reactive({
|
|
145
|
+
account: "",
|
|
146
|
+
password: "",
|
|
147
|
+
vCode: "code",
|
|
148
|
+
});
|
|
149
|
+
const verifyVisible = ref(false);
|
|
150
|
+
|
|
151
|
+
const verifyHandle = async () => {
|
|
152
|
+
const result = await formEl.value?.validate();
|
|
153
|
+
if (!result) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
verifyVisible.value = true;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const handleLogin = async (v: string) => {
|
|
160
|
+
loginFormData.vCode = v;
|
|
161
|
+
try {
|
|
162
|
+
loading.value = true;
|
|
163
|
+
if (forgotPassword.value) {
|
|
164
|
+
const { data } = await system.modifyPassword(
|
|
165
|
+
loginFormData.account,
|
|
166
|
+
loginFormData.vCode
|
|
167
|
+
);
|
|
168
|
+
if (data.code !== 200) {
|
|
169
|
+
ElMessage.error(data.msg || "重置邮箱失败!");
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
ElMessage.success("重置密码邮件已发送到邮箱");
|
|
173
|
+
forgotPassword.value = false;
|
|
174
|
+
} else {
|
|
175
|
+
const { data } = await system.login(
|
|
176
|
+
loginFormData.account,
|
|
177
|
+
loginFormData.password,
|
|
178
|
+
loginFormData.vCode
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
if (data.code !== 200) {
|
|
182
|
+
ElMessage.error(data.msg || "登录失败!");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
verifyVisible.value = false;
|
|
186
|
+
|
|
187
|
+
router.push({ path: "/" });
|
|
188
|
+
}
|
|
189
|
+
} catch (e) {
|
|
190
|
+
ElMessage.error("登录失败");
|
|
191
|
+
} finally {
|
|
192
|
+
verifyVisible.value = false;
|
|
193
|
+
loading.value = false;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
</script>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="login-wrap">
|
|
3
|
+
<div class="login-bg">
|
|
4
|
+
<div class="login-bg-block"></div>
|
|
5
|
+
<div class="login-bg-block"></div>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="login-root">
|
|
8
|
+
<div class="login-main">
|
|
9
|
+
<div class="form-container">
|
|
10
|
+
<div class="form-wrap">
|
|
11
|
+
<div class="form-title" v-if="!forgotPassword">
|
|
12
|
+
账号注册
|
|
13
|
+
<span class="notify">
|
|
14
|
+
已有账号?<ElButton
|
|
15
|
+
link
|
|
16
|
+
class="operaBtn"
|
|
17
|
+
@click="router.push('/login')"
|
|
18
|
+
>
|
|
19
|
+
返回登录
|
|
20
|
+
</ElButton>
|
|
21
|
+
</span>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="form-title" v-else>账号重置</div>
|
|
24
|
+
<ElForm
|
|
25
|
+
:model="signFormData"
|
|
26
|
+
:rules="rules"
|
|
27
|
+
size="large"
|
|
28
|
+
ref="formEl"
|
|
29
|
+
>
|
|
30
|
+
<ElFormItem prop="account">
|
|
31
|
+
<ElInput v-model="signFormData.account" placeholder="帐号" />
|
|
32
|
+
</ElFormItem>
|
|
33
|
+
<ElFormItem prop="email">
|
|
34
|
+
<ElInput v-model="signFormData.email" placeholder="邮箱" />
|
|
35
|
+
</ElFormItem>
|
|
36
|
+
<ElFormItem prop="name">
|
|
37
|
+
<ElInput v-model="signFormData.name" placeholder="姓名" />
|
|
38
|
+
</ElFormItem>
|
|
39
|
+
<ElFormItem prop="nickName">
|
|
40
|
+
<ElInput v-model="signFormData.nickName" placeholder="昵称" />
|
|
41
|
+
</ElFormItem>
|
|
42
|
+
<ElFormItem prop="phone">
|
|
43
|
+
<ElInput v-model="signFormData.phone" placeholder="手机号" />
|
|
44
|
+
</ElFormItem>
|
|
45
|
+
|
|
46
|
+
<ElFormItem>
|
|
47
|
+
<ElButton
|
|
48
|
+
type="primary"
|
|
49
|
+
style="width: 100%"
|
|
50
|
+
:loading="loading"
|
|
51
|
+
@click="verifyHandle"
|
|
52
|
+
>
|
|
53
|
+
提交申请
|
|
54
|
+
</ElButton>
|
|
55
|
+
</ElFormItem>
|
|
56
|
+
</ElForm>
|
|
57
|
+
<ElDivider></ElDivider>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<MKVerifyDialog
|
|
65
|
+
:scene="scene"
|
|
66
|
+
v-model:visible="verifyVisible"
|
|
67
|
+
v-if="verifyVisible"
|
|
68
|
+
@verifySuccessful="handleSign"
|
|
69
|
+
/>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script setup lang="ts">
|
|
73
|
+
import { Ref, computed, reactive, ref } from "vue";
|
|
74
|
+
import { useRouter } from "vue-router";
|
|
75
|
+
import { FormRules } from "element-plus";
|
|
76
|
+
import { Messager } from "@maketribe/dm";
|
|
77
|
+
import { useHttpRequest } from "../../composables";
|
|
78
|
+
import { MKVerifyDialog } from "../../components";
|
|
79
|
+
|
|
80
|
+
defineOptions({
|
|
81
|
+
mkRoute: {
|
|
82
|
+
name: "signup",
|
|
83
|
+
path: "/signup",
|
|
84
|
+
meta: {
|
|
85
|
+
isAuthorization: false,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const formEl: Ref<any> = ref(null);
|
|
91
|
+
|
|
92
|
+
const router = useRouter();
|
|
93
|
+
|
|
94
|
+
const httpRequest = useHttpRequest()!;
|
|
95
|
+
|
|
96
|
+
const loading = ref(false);
|
|
97
|
+
|
|
98
|
+
const verifyVisible = ref(false);
|
|
99
|
+
|
|
100
|
+
const forgotPassword = ref(false);
|
|
101
|
+
const scene = computed(() =>
|
|
102
|
+
forgotPassword.value ? "ModifyPassword" : "Login"
|
|
103
|
+
);
|
|
104
|
+
const rules: FormRules = {
|
|
105
|
+
account: [{ required: true, message: "账号必填" }],
|
|
106
|
+
email: [
|
|
107
|
+
{
|
|
108
|
+
required: true,
|
|
109
|
+
trigger: "change",
|
|
110
|
+
validator: (rule, value, callback) => {
|
|
111
|
+
if (!value) {
|
|
112
|
+
callback(new Error("邮箱必填"));
|
|
113
|
+
} else if (
|
|
114
|
+
!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value)
|
|
115
|
+
) {
|
|
116
|
+
callback(new Error("邮箱规则不符"));
|
|
117
|
+
} else {
|
|
118
|
+
callback();
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
name: [{ required: true, message: "姓名必填" }],
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const verifyHandle = async () => {
|
|
127
|
+
const result = await formEl.value.validate();
|
|
128
|
+
if (!result) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
verifyVisible.value = true;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const signFormData = reactive({
|
|
135
|
+
account: "",
|
|
136
|
+
email: "",
|
|
137
|
+
name: "",
|
|
138
|
+
nickName: "",
|
|
139
|
+
phone: "",
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const handleSign = async (v: string) => {
|
|
143
|
+
const result = await httpRequest.post(
|
|
144
|
+
"/api/dv/ms-member/apply/account",
|
|
145
|
+
signFormData
|
|
146
|
+
);
|
|
147
|
+
if (result.data.code != 200) {
|
|
148
|
+
Messager.instance.error(result.data.msg || "注册失败");
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
verifyVisible.value = false;
|
|
152
|
+
Messager.instance.success({ message: "注册成功,请联系管理员通过验证" });
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// 记住登陆状态
|
|
156
|
+
const rememberLoginState = ref(false);
|
|
157
|
+
</script>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RouteLocationNormalized, RouteLocationRaw } from "vue-router";
|
|
2
|
+
import type { MSAppClient } from "../core";
|
|
3
|
+
|
|
4
|
+
export const authBeforeEach = async (
|
|
5
|
+
msAppClient: MSAppClient,
|
|
6
|
+
to: RouteLocationNormalized,
|
|
7
|
+
from: RouteLocationNormalized
|
|
8
|
+
): Promise<RouteLocationRaw | void> => {
|
|
9
|
+
if (to.meta.isAuthorization === false) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let userSession = msAppClient.userSession;
|
|
14
|
+
|
|
15
|
+
if (!userSession) {
|
|
16
|
+
try {
|
|
17
|
+
await msAppClient.loadCurrentUserSession();
|
|
18
|
+
|
|
19
|
+
userSession = msAppClient.userSession;
|
|
20
|
+
|
|
21
|
+
if (!userSession) {
|
|
22
|
+
return { name: "login" };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 因为登陆成功会添加用户可以访问的路由,这里给到vue-router去重新resolve
|
|
26
|
+
return { path: to.fullPath };
|
|
27
|
+
} catch (e) {
|
|
28
|
+
return { name: "login" };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./auth";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./ms-app-client";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InjectionKey } from "vue";
|
|
2
|
+
import { MSAppClient } from "../core";
|
|
3
|
+
|
|
4
|
+
export interface MSAppClientContext {
|
|
5
|
+
msAppClient: MSAppClient;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const MSAPPCLIENT_CONTEXT_KEY: InjectionKey<MSAppClientContext> = Symbol(
|
|
9
|
+
"msAppClientContextKey"
|
|
10
|
+
);
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { encodePath } from "ufo";
|
|
2
|
+
|
|
3
|
+
enum SegmentParserState {
|
|
4
|
+
initial,
|
|
5
|
+
static,
|
|
6
|
+
dynamic,
|
|
7
|
+
optional,
|
|
8
|
+
catchall,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ScannedFile {
|
|
12
|
+
path: string;
|
|
13
|
+
module: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
enum SegmentTokenType {
|
|
17
|
+
static,
|
|
18
|
+
dynamic,
|
|
19
|
+
optional,
|
|
20
|
+
catchall,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface SegmentToken {
|
|
24
|
+
type: SegmentTokenType;
|
|
25
|
+
value: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function generateRoutesFromFiles(files: ScannedFile[]) {
|
|
29
|
+
const routes: any[] = [];
|
|
30
|
+
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
const segments = file.path.split("/");
|
|
33
|
+
|
|
34
|
+
const route: Record<string, any> = {
|
|
35
|
+
meta: {},
|
|
36
|
+
...file.module.mkRoute,
|
|
37
|
+
key: "",
|
|
38
|
+
path: "",
|
|
39
|
+
component: async () => file.module,
|
|
40
|
+
children: [],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
let parent = routes;
|
|
44
|
+
|
|
45
|
+
for (const segment of segments) {
|
|
46
|
+
const tokens = parseSegment(segment);
|
|
47
|
+
const segmentName = tokens.map(({ value }) => value).join("");
|
|
48
|
+
|
|
49
|
+
route.key += (route.key && "/") + segmentName;
|
|
50
|
+
|
|
51
|
+
const path = route.path + getRoutePath(tokens).replace(/\/index$/, "/");
|
|
52
|
+
const child = parent.find(
|
|
53
|
+
(parentRoute) =>
|
|
54
|
+
parentRoute.key === route.key && parentRoute.path === path
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (child && child.children) {
|
|
58
|
+
parent = child.children;
|
|
59
|
+
route.path = "";
|
|
60
|
+
} else if (segmentName === "index" && !route.path) {
|
|
61
|
+
route.path += "/";
|
|
62
|
+
} else if (segmentName !== "index") {
|
|
63
|
+
route.path += getRoutePath(tokens);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
route.path = file.module.mkRoute?.path || route.path;
|
|
68
|
+
|
|
69
|
+
parent.push(route);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return prepareRoutes(routes);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getRoutePath(tokens: SegmentToken[]) {
|
|
76
|
+
return tokens.reduce((path, token) => {
|
|
77
|
+
return (
|
|
78
|
+
path +
|
|
79
|
+
(token.type === SegmentTokenType.optional
|
|
80
|
+
? `:${token.value}?`
|
|
81
|
+
: token.type === SegmentTokenType.dynamic
|
|
82
|
+
? `:${token.value}()`
|
|
83
|
+
: token.type === SegmentTokenType.catchall
|
|
84
|
+
? `:${token.value}(.*)*`
|
|
85
|
+
: encodePath(token.value).replace(/:/g, "\\:"))
|
|
86
|
+
);
|
|
87
|
+
}, "/");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const PARAM_CHAR_RE = /[\w\d_.]/;
|
|
91
|
+
|
|
92
|
+
function parseSegment(segment: string) {
|
|
93
|
+
let state: SegmentParserState = SegmentParserState.initial;
|
|
94
|
+
|
|
95
|
+
let i = 0;
|
|
96
|
+
|
|
97
|
+
let buffer = "";
|
|
98
|
+
const tokens: SegmentToken[] = [];
|
|
99
|
+
|
|
100
|
+
function consumeBuffer() {
|
|
101
|
+
if (!buffer) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (state === SegmentParserState.initial) {
|
|
106
|
+
throw new Error("错误的状态");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
tokens.push({
|
|
110
|
+
type:
|
|
111
|
+
state === SegmentParserState.static
|
|
112
|
+
? SegmentTokenType.static
|
|
113
|
+
: state === SegmentParserState.dynamic
|
|
114
|
+
? SegmentTokenType.dynamic
|
|
115
|
+
: state === SegmentParserState.optional
|
|
116
|
+
? SegmentTokenType.optional
|
|
117
|
+
: SegmentTokenType.catchall,
|
|
118
|
+
value: buffer,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
buffer = "";
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
while (i < segment.length) {
|
|
125
|
+
const c = segment[i];
|
|
126
|
+
|
|
127
|
+
switch (state) {
|
|
128
|
+
case SegmentParserState.initial:
|
|
129
|
+
buffer = "";
|
|
130
|
+
|
|
131
|
+
if (c === "[") {
|
|
132
|
+
state = SegmentParserState.dynamic;
|
|
133
|
+
} else {
|
|
134
|
+
i--;
|
|
135
|
+
state = SegmentParserState.static;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
break;
|
|
139
|
+
case SegmentParserState.static:
|
|
140
|
+
if (c === "[") {
|
|
141
|
+
consumeBuffer();
|
|
142
|
+
state = SegmentParserState.dynamic;
|
|
143
|
+
} else {
|
|
144
|
+
buffer += c;
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case SegmentParserState.catchall:
|
|
148
|
+
case SegmentParserState.dynamic:
|
|
149
|
+
case SegmentParserState.optional:
|
|
150
|
+
if (buffer === "...") {
|
|
151
|
+
buffer = "";
|
|
152
|
+
state = SegmentParserState.catchall;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (c === "[" && state === SegmentParserState.dynamic) {
|
|
156
|
+
state = SegmentParserState.optional;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (
|
|
160
|
+
c === "]" &&
|
|
161
|
+
(state !== SegmentParserState.optional || segment[i - 1] === "]")
|
|
162
|
+
) {
|
|
163
|
+
if (!buffer) {
|
|
164
|
+
throw new Error("空参数");
|
|
165
|
+
}
|
|
166
|
+
consumeBuffer();
|
|
167
|
+
state = SegmentParserState.initial;
|
|
168
|
+
} else if (PARAM_CHAR_RE.test(c)) {
|
|
169
|
+
buffer += c;
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
i++;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (state === SegmentParserState.dynamic) {
|
|
178
|
+
throw new Error(`Unfinished param "${buffer}"`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
consumeBuffer();
|
|
182
|
+
|
|
183
|
+
return tokens;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function findRouteByKey(key: string, routes: any[]): any | undefined {
|
|
187
|
+
for (const route of routes) {
|
|
188
|
+
if (route.key === key) {
|
|
189
|
+
return route;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return findRouteByKey(key, routes);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function prepareRoutes(routes: any[], parent?: any, keys = new Set<string>()) {
|
|
196
|
+
for (const route of routes) {
|
|
197
|
+
// Remove -index
|
|
198
|
+
if (route.key) {
|
|
199
|
+
route.key = route.key.replace(/\/index$/, "").replace(/\//g, "-");
|
|
200
|
+
|
|
201
|
+
if (keys.has(route.key)) {
|
|
202
|
+
const existingRoute = findRouteByKey(route.key, routes);
|
|
203
|
+
const extra = existingRoute?.name
|
|
204
|
+
? `is the same as \`${existingRoute.file}\``
|
|
205
|
+
: "is a duplicate";
|
|
206
|
+
console.warn(
|
|
207
|
+
`Route name generated for \`${route.file}\` ${extra}. You may wish to set a custom name using \`definePageMeta\` within the page file.`
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
route.path = route.path.replace(/\/\//g, "/");
|
|
213
|
+
|
|
214
|
+
// Remove leading / if children route
|
|
215
|
+
if (parent && route.path.startsWith("/")) {
|
|
216
|
+
route.path = route.path.slice(1);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (route.children?.length) {
|
|
220
|
+
route.children = prepareRoutes(route.children, route, keys);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// if (route.children?.find((childRoute: any) => childRoute.path === "")) {
|
|
224
|
+
// delete route.key;
|
|
225
|
+
// }
|
|
226
|
+
|
|
227
|
+
if (route.key) {
|
|
228
|
+
keys.add(route.key);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return routes;
|
|
233
|
+
}
|