From 9667701b78526c2b464ef089afb1a256c445d548 Mon Sep 17 00:00:00 2001 From: lijiantao Date: Fri, 31 May 2019 17:57:30 +0800 Subject: [PATCH 1/4] add ant design pro --- antdsp-admin/pom.xml | 5 + .../com/antdsp/common/AntdspResponse.java | 41 + .../java/com/antdsp/common/ResponseCode.java | 25 + .../common/exception/AntdspException.java | 30 + .../antdsp/common/pagination/Pagination.java | 52 + .../common/pagination/PaginationData.java | 58 + .../com/antdsp/web/sys/SystemMenuApi.java | 10 + .../com/antdsp/web/sys/SystemRoleApi.java | 15 + .../com/antdsp/web/sys/SystemUserApi.java | 66 + antdsp-admin/src/main/web/.dockerignore | 35 + antdsp-admin/src/main/web/.editorconfig | 17 + antdsp-admin/src/main/web/.eslintignore | 3 + antdsp-admin/src/main/web/.eslintrc.js | 40 + antdsp-admin/src/main/web/.gitignore | 38 + antdsp-admin/src/main/web/.gitpod.yml | 6 + antdsp-admin/src/main/web/.prettierignore | 5 + antdsp-admin/src/main/web/.prettierrc | 13 + antdsp-admin/src/main/web/.stylelintrc.json | 13 + antdsp-admin/src/main/web/CODE_OF_CONDUCT.md | 46 + antdsp-admin/src/main/web/Dockerfile | 12 + antdsp-admin/src/main/web/Dockerfile.dev | 11 + antdsp-admin/src/main/web/Dockerfile.hub | 11 + antdsp-admin/src/main/web/LICENSE | 21 + antdsp-admin/src/main/web/README.md | 23 + antdsp-admin/src/main/web/azure-pipelines.yml | 78 + antdsp-admin/src/main/web/config/config.js | 130 ++ .../src/main/web/config/plugin.config.js | 83 + .../src/main/web/config/router.config.js | 30 + .../main/web/docker/docker-compose.dev.yml | 14 + .../src/main/web/docker/docker-compose.yml | 21 + antdsp-admin/src/main/web/docker/nginx.conf | 22 + .../src/main/web/jest-puppeteer.config.js | 12 + antdsp-admin/src/main/web/jest.config.js | 7 + antdsp-admin/src/main/web/jsconfig.json | 10 + antdsp-admin/src/main/web/lambda/api.js | 11 + .../src/main/web/lambda/mock/matchMock.js | 116 ++ antdsp-admin/src/main/web/mock/api.js | 336 ++++ antdsp-admin/src/main/web/mock/chart.js | 196 ++ antdsp-admin/src/main/web/mock/geographic.js | 15 + .../src/main/web/mock/geographic/city.json | 1784 +++++++++++++++++ .../main/web/mock/geographic/province.json | 138 ++ antdsp-admin/src/main/web/mock/notices.js | 102 + antdsp-admin/src/main/web/mock/profile.js | 177 ++ antdsp-admin/src/main/web/mock/rule.js | 131 ++ antdsp-admin/src/main/web/mock/user.js | 138 ++ antdsp-admin/src/main/web/netlify.toml | 16 + antdsp-admin/src/main/web/package.json | 142 ++ antdsp-admin/src/main/web/public/favicon.png | Bin 0 -> 2849 bytes .../web/public/ggeditor/flow/decision.svg | 29 + .../main/web/public/ggeditor/flow/model.svg | 29 + .../main/web/public/ggeditor/flow/normal.svg | 29 + .../main/web/public/ggeditor/flow/start.svg | 29 + .../main/web/public/ggeditor/koni/bank.svg | 29 + .../main/web/public/ggeditor/koni/country.svg | 29 + .../main/web/public/ggeditor/koni/icon.svg | 14 + .../main/web/public/ggeditor/koni/person.svg | 29 + .../main/web/public/icons/icon-128x128.png | Bin 0 -> 1329 bytes .../main/web/public/icons/icon-192x192.png | Bin 0 -> 1856 bytes .../main/web/public/icons/icon-512x512.png | Bin 0 -> 5082 bytes .../src/main/web/scripts/generateMock.js | 3 + .../src/main/web/scripts/getPrettierFiles.js | 21 + .../src/main/web/scripts/lint-prettier.js | 50 + antdsp-admin/src/main/web/scripts/prettier.js | 46 + antdsp-admin/src/main/web/src/app.js | 11 + antdsp-admin/src/main/web/src/assets/logo.svg | 43 + .../web/src/components/ActiveChart/index.js | 98 + .../web/src/components/ActiveChart/index.less | 51 + .../components/ArticleListContent/index.d.ts | 13 + .../components/ArticleListContent/index.js | 17 + .../components/ArticleListContent/index.less | 38 + .../src/components/Authorized/Authorized.js | 8 + .../Authorized/AuthorizedRoute.d.ts | 13 + .../components/Authorized/AuthorizedRoute.js | 15 + .../components/Authorized/CheckPermissions.js | 70 + .../Authorized/CheckPermissions.test.js | 55 + .../components/Authorized/PromiseRender.js | 76 + .../web/src/components/Authorized/Secured.js | 68 + .../Authorized/demo/AuthorizedArray.md | 23 + .../Authorized/demo/AuthorizedFunction.md | 31 + .../src/components/Authorized/demo/basic.md | 25 + .../src/components/Authorized/demo/secured.md | 30 + .../web/src/components/Authorized/index.d.ts | 32 + .../web/src/components/Authorized/index.js | 11 + .../web/src/components/Authorized/index.md | 56 + .../components/Authorized/renderAuthorize.js | 25 + .../src/components/AvatarList/AvatarItem.d.ts | 15 + .../components/AvatarList/demo/maxLength.md | 24 + .../src/components/AvatarList/demo/simple.md | 20 + .../web/src/components/AvatarList/index.d.ts | 14 + .../src/components/AvatarList/index.en-US.md | 24 + .../web/src/components/AvatarList/index.js | 61 + .../web/src/components/AvatarList/index.less | 50 + .../src/components/AvatarList/index.test.js | 29 + .../src/components/AvatarList/index.zh-CN.md | 25 + .../web/src/components/Charts/Bar/index.d.ts | 15 + .../web/src/components/Charts/Bar/index.js | 113 ++ .../components/Charts/ChartCard/index.d.ts | 14 + .../src/components/Charts/ChartCard/index.js | 82 + .../components/Charts/ChartCard/index.less | 75 + .../src/components/Charts/Field/index.d.ts | 8 + .../web/src/components/Charts/Field/index.js | 12 + .../src/components/Charts/Field/index.less | 17 + .../src/components/Charts/Gauge/index.d.ts | 11 + .../web/src/components/Charts/Gauge/index.js | 167 ++ .../src/components/Charts/MiniArea/index.d.ts | 29 + .../src/components/Charts/MiniArea/index.js | 108 + .../src/components/Charts/MiniBar/index.d.ts | 12 + .../src/components/Charts/MiniBar/index.js | 51 + .../components/Charts/MiniProgress/index.d.ts | 11 + .../components/Charts/MiniProgress/index.js | 34 + .../components/Charts/MiniProgress/index.less | 37 + .../web/src/components/Charts/Pie/index.d.ts | 21 + .../web/src/components/Charts/Pie/index.js | 271 +++ .../web/src/components/Charts/Pie/index.less | 94 + .../src/components/Charts/Radar/index.d.ts | 15 + .../web/src/components/Charts/Radar/index.js | 184 ++ .../src/components/Charts/Radar/index.less | 46 + .../src/components/Charts/TagCloud/index.d.ts | 11 + .../src/components/Charts/TagCloud/index.js | 178 ++ .../src/components/Charts/TagCloud/index.less | 6 + .../Charts/TimelineChart/index.d.ts | 14 + .../components/Charts/TimelineChart/index.js | 120 ++ .../Charts/TimelineChart/index.less | 3 + .../components/Charts/WaterWave/index.d.ts | 10 + .../src/components/Charts/WaterWave/index.js | 213 ++ .../components/Charts/WaterWave/index.less | 28 + .../web/src/components/Charts/autoHeight.js | 62 + .../web/src/components/Charts/bizcharts.d.ts | 3 + .../web/src/components/Charts/bizcharts.js | 3 + .../web/src/components/Charts/demo/bar.md | 26 + .../src/components/Charts/demo/chart-card.md | 95 + .../web/src/components/Charts/demo/gauge.md | 18 + .../src/components/Charts/demo/mini-area.md | 28 + .../src/components/Charts/demo/mini-bar.md | 28 + .../src/components/Charts/demo/mini-pie.md | 16 + .../components/Charts/demo/mini-progress.md | 12 + .../web/src/components/Charts/demo/mix.md | 84 + .../web/src/components/Charts/demo/pie.md | 54 + .../web/src/components/Charts/demo/radar.md | 64 + .../src/components/Charts/demo/tag-cloud.md | 25 + .../components/Charts/demo/timeline-chart.md | 27 + .../src/components/Charts/demo/waterwave.md | 20 + .../main/web/src/components/Charts/index.d.ts | 48 + .../main/web/src/components/Charts/index.js | 48 + .../main/web/src/components/Charts/index.less | 19 + .../main/web/src/components/Charts/index.md | 130 ++ .../src/components/CountDown/demo/simple.md | 24 + .../web/src/components/CountDown/index.d.ts | 9 + .../src/components/CountDown/index.en-US.md | 15 + .../web/src/components/CountDown/index.js | 121 ++ .../src/components/CountDown/index.zh-CN.md | 16 + .../DescriptionList/Description.d.ts | 11 + .../components/DescriptionList/Description.js | 22 + .../DescriptionList/DescriptionList.js | 33 + .../components/DescriptionList/demo/basic.md | 43 + .../DescriptionList/demo/vertical.md | 43 + .../src/components/DescriptionList/index.d.ts | 17 + .../components/DescriptionList/index.en-US.md | 33 + .../src/components/DescriptionList/index.js | 5 + .../src/components/DescriptionList/index.less | 92 + .../components/DescriptionList/index.zh-CN.md | 37 + .../components/DescriptionList/responsive.js | 6 + .../src/components/EditableItem/index.d.ts | 7 + .../web/src/components/EditableItem/index.js | 50 + .../src/components/EditableItem/index.less | 25 + .../components/EditableLinkGroup/index.d.ts | 9 + .../src/components/EditableLinkGroup/index.js | 46 + .../components/EditableLinkGroup/index.less | 16 + .../web/src/components/Ellipsis/demo/line.md | 31 + .../src/components/Ellipsis/demo/number.md | 28 + .../web/src/components/Ellipsis/index.d.ts | 21 + .../src/components/Ellipsis/index.en-US.md | 16 + .../main/web/src/components/Ellipsis/index.js | 270 +++ .../web/src/components/Ellipsis/index.less | 24 + .../web/src/components/Ellipsis/index.test.js | 13 + .../src/components/Ellipsis/index.zh-CN.md | 17 + .../web/src/components/Exception/demo/403.md | 29 + .../web/src/components/Exception/demo/404.md | 22 + .../web/src/components/Exception/demo/500.md | 22 + .../web/src/components/Exception/index.d.ts | 23 + .../src/components/Exception/index.en-US.md | 20 + .../web/src/components/Exception/index.js | 61 + .../web/src/components/Exception/index.less | 89 + .../src/components/Exception/index.zh-CN.md | 21 + .../src/components/Exception/typeConfig.js | 19 + .../components/FooterToolbar/demo/basic.md | 44 + .../src/components/FooterToolbar/index.d.ts | 8 + .../components/FooterToolbar/index.en-US.md | 18 + .../web/src/components/FooterToolbar/index.js | 47 + .../src/components/FooterToolbar/index.less | 33 + .../components/FooterToolbar/index.zh-CN.md | 19 + .../src/components/GlobalFooter/demo/basic.md | 37 + .../src/components/GlobalFooter/index.d.ts | 14 + .../web/src/components/GlobalFooter/index.js | 28 + .../src/components/GlobalFooter/index.less | 29 + .../web/src/components/GlobalFooter/index.md | 15 + .../components/GlobalHeader/RightContent.d.ts | 26 + .../components/GlobalHeader/RightContent.js | 194 ++ .../src/components/GlobalHeader/index.d.ts | 13 + .../web/src/components/GlobalHeader/index.js | 41 + .../src/components/GlobalHeader/index.less | 130 ++ .../src/components/HeaderDropdown/index.d.ts | 12 + .../src/components/HeaderDropdown/index.js | 13 + .../src/components/HeaderDropdown/index.less | 16 + .../src/components/HeaderSearch/demo/basic.md | 34 + .../src/components/HeaderSearch/index.d.ts | 15 + .../components/HeaderSearch/index.en-US.md | 22 + .../web/src/components/HeaderSearch/index.js | 145 ++ .../src/components/HeaderSearch/index.less | 32 + .../components/HeaderSearch/index.zh-CN.md | 22 + .../main/web/src/components/IconFont/index.js | 7 + .../web/src/components/Login/LoginItem.d.ts | 28 + .../web/src/components/Login/LoginItem.js | 147 ++ .../web/src/components/Login/LoginSubmit.js | 17 + .../web/src/components/Login/LoginTab.d.ts | 11 + .../main/web/src/components/Login/LoginTab.js | 41 + .../web/src/components/Login/demo/basic.md | 148 ++ .../main/web/src/components/Login/index.d.ts | 25 + .../web/src/components/Login/index.en-US.md | 49 + .../main/web/src/components/Login/index.js | 132 ++ .../main/web/src/components/Login/index.less | 53 + .../web/src/components/Login/index.zh-CN.md | 49 + .../web/src/components/Login/loginContext.js | 4 + .../src/main/web/src/components/Login/map.js | 65 + .../components/NoticeIcon/NoticeIconTab.d.ts | 30 + .../src/components/NoticeIcon/NoticeList.js | 76 + .../src/components/NoticeIcon/NoticeList.less | 105 + .../src/components/NoticeIcon/demo/basic.md | 12 + .../src/components/NoticeIcon/demo/popover.md | 175 ++ .../web/src/components/NoticeIcon/index.d.ts | 27 + .../src/components/NoticeIcon/index.en-US.md | 47 + .../web/src/components/NoticeIcon/index.js | 141 ++ .../web/src/components/NoticeIcon/index.less | 31 + .../src/components/NoticeIcon/index.zh-CN.md | 47 + .../src/components/NumberInfo/demo/basic.md | 30 + .../web/src/components/NumberInfo/index.d.ts | 14 + .../src/components/NumberInfo/index.en-US.md | 19 + .../web/src/components/NumberInfo/index.js | 41 + .../web/src/components/NumberInfo/index.less | 68 + .../src/components/NumberInfo/index.zh-CN.md | 20 + .../PageHeaderWrapper/GridContent.d.ts | 8 + .../PageHeaderWrapper/GridContent.js | 18 + .../PageHeaderWrapper/GridContent.less | 10 + .../PageHeaderWrapper/breadcrumb.js | 130 ++ .../components/PageHeaderWrapper/index.d.ts | 11 + .../src/components/PageHeaderWrapper/index.js | 106 + .../components/PageHeaderWrapper/index.less | 110 + .../web/src/components/PageLoading/index.js | 10 + .../web/src/components/Result/demo/classic.md | 80 + .../web/src/components/Result/demo/error.md | 39 + .../src/components/Result/demo/structure.md | 20 + .../main/web/src/components/Result/index.d.ts | 12 + .../main/web/src/components/Result/index.js | 29 + .../main/web/src/components/Result/index.less | 58 + .../main/web/src/components/Result/index.md | 18 + .../web/src/components/SelectLang/index.d.ts | 7 + .../web/src/components/SelectLang/index.js | 49 + .../web/src/components/SelectLang/index.less | 24 + .../SettingDrawer/BlockCheckbox.d.ts | 9 + .../components/SettingDrawer/BlockCheckbox.js | 25 + .../components/SettingDrawer/ThemeColor.d.ts | 10 + .../components/SettingDrawer/ThemeColor.js | 74 + .../components/SettingDrawer/ThemeColor.less | 21 + .../src/components/SettingDrawer/index.d.ts | 24 + .../web/src/components/SettingDrawer/index.js | 258 +++ .../src/components/SettingDrawer/index.less | 81 + .../src/components/SiderMenu/BaseMenu.d.ts | 23 + .../web/src/components/SiderMenu/BaseMenu.js | 166 ++ .../src/components/SiderMenu/SiderMenu.d.ts | 11 + .../web/src/components/SiderMenu/SiderMenu.js | 99 + .../components/SiderMenu/SiderMenu.test.js | 39 + .../components/SiderMenu/SiderMenuUtils.js | 40 + .../web/src/components/SiderMenu/index.d.ts | 13 + .../web/src/components/SiderMenu/index.js | 26 + .../web/src/components/SiderMenu/index.less | 105 + .../src/components/StandardFormRow/index.d.ts | 11 + .../src/components/StandardFormRow/index.js | 24 + .../src/components/StandardFormRow/index.less | 72 + .../src/components/StandardTable/index.d.ts | 19 + .../web/src/components/StandardTable/index.js | 121 ++ .../src/components/StandardTable/index.less | 13 + .../components/TagSelect/TagSelectOption.d.ts | 12 + .../components/TagSelect/demo/controlled.md | 50 + .../components/TagSelect/demo/expandable.md | 31 + .../src/components/TagSelect/demo/simple.md | 25 + .../web/src/components/TagSelect/index.d.ts | 25 + .../web/src/components/TagSelect/index.js | 143 ++ .../web/src/components/TagSelect/index.less | 33 + .../web/src/components/TagSelect/index.md | 27 + .../src/components/TopNavHeader/index.d.ts | 25 + .../web/src/components/TopNavHeader/index.js | 56 + .../src/components/TopNavHeader/index.less | 72 + .../web/src/components/Trend/demo/basic.md | 17 + .../web/src/components/Trend/demo/reverse.md | 17 + .../main/web/src/components/Trend/index.d.ts | 11 + .../main/web/src/components/Trend/index.js | 27 + .../main/web/src/components/Trend/index.less | 37 + .../main/web/src/components/Trend/index.md | 20 + .../web/src/components/_utils/pathTools.js | 6 + .../src/components/_utils/pathTools.test.js | 17 + .../src/main/web/src/defaultSettings.js | 19 + .../src/main/web/src/e2e/baseLayout.e2e.js | 38 + antdsp-admin/src/main/web/src/e2e/home.e2e.js | 15 + .../src/main/web/src/e2e/login.e2e.js | 34 + .../src/main/web/src/e2e/topMenu.e2e.js | 19 + .../src/main/web/src/e2e/userLayout.e2e.js | 32 + antdsp-admin/src/main/web/src/global.js | 61 + antdsp-admin/src/main/web/src/global.less | 52 + .../src/main/web/src/layouts/BasicLayout.js | 176 ++ .../src/main/web/src/layouts/BasicLayout.less | 6 + .../src/main/web/src/layouts/BlankLayout.js | 3 + .../src/main/web/src/layouts/Footer.js | 37 + .../src/main/web/src/layouts/Header.js | 163 ++ .../src/main/web/src/layouts/Header.less | 8 + .../src/main/web/src/layouts/MenuContext.js | 3 + .../src/main/web/src/layouts/UserLayout.js | 83 + .../src/main/web/src/layouts/UserLayout.less | 71 + .../src/main/web/src/locales/en-US.js | 37 + .../main/web/src/locales/en-US/analysis.js | 34 + .../main/web/src/locales/en-US/component.js | 6 + .../src/main/web/src/locales/en-US/editor.js | 11 + .../main/web/src/locales/en-US/exception.js | 6 + .../src/main/web/src/locales/en-US/form.js | 38 + .../web/src/locales/en-US/globalHeader.js | 17 + .../src/main/web/src/locales/en-US/login.js | 41 + .../src/main/web/src/locales/en-US/menu.js | 45 + .../src/main/web/src/locales/en-US/monitor.js | 18 + .../src/main/web/src/locales/en-US/pwa.js | 6 + .../src/main/web/src/locales/en-US/result.js | 28 + .../web/src/locales/en-US/settingDrawer.js | 31 + .../main/web/src/locales/en-US/settings.js | 60 + .../src/main/web/src/locales/pt-BR.js | 37 + .../main/web/src/locales/pt-BR/analysis.js | 34 + .../main/web/src/locales/pt-BR/component.js | 6 + .../src/main/web/src/locales/pt-BR/editor.js | 11 + .../main/web/src/locales/pt-BR/exception.js | 6 + .../src/main/web/src/locales/pt-BR/form.js | 39 + .../web/src/locales/pt-BR/globalHeader.js | 18 + .../src/main/web/src/locales/pt-BR/login.js | 38 + .../src/main/web/src/locales/pt-BR/menu.js | 45 + .../src/main/web/src/locales/pt-BR/monitor.js | 19 + .../src/main/web/src/locales/pt-BR/pwa.js | 7 + .../src/main/web/src/locales/pt-BR/result.js | 28 + .../web/src/locales/pt-BR/settingDrawer.js | 32 + .../main/web/src/locales/pt-BR/settings.js | 60 + .../src/main/web/src/locales/zh-CN.js | 37 + .../main/web/src/locales/zh-CN/analysis.js | 34 + .../main/web/src/locales/zh-CN/component.js | 6 + .../src/main/web/src/locales/zh-CN/editor.js | 9 + .../main/web/src/locales/zh-CN/exception.js | 6 + .../src/main/web/src/locales/zh-CN/form.js | 37 + .../web/src/locales/zh-CN/globalHeader.js | 17 + .../src/main/web/src/locales/zh-CN/login.js | 40 + .../src/main/web/src/locales/zh-CN/menu.js | 10 + .../src/main/web/src/locales/zh-CN/monitor.js | 18 + .../src/main/web/src/locales/zh-CN/pwa.js | 6 + .../src/main/web/src/locales/zh-CN/result.js | 27 + .../web/src/locales/zh-CN/settingDrawer.js | 31 + .../main/web/src/locales/zh-CN/settings.js | 55 + .../src/main/web/src/locales/zh-TW.js | 37 + .../main/web/src/locales/zh-TW/analysis.js | 34 + .../main/web/src/locales/zh-TW/component.js | 6 + .../src/main/web/src/locales/zh-TW/editor.js | 9 + .../main/web/src/locales/zh-TW/exception.js | 6 + .../src/main/web/src/locales/zh-TW/form.js | 37 + .../web/src/locales/zh-TW/globalHeader.js | 17 + .../src/main/web/src/locales/zh-TW/login.js | 40 + .../src/main/web/src/locales/zh-TW/menu.js | 45 + .../src/main/web/src/locales/zh-TW/monitor.js | 18 + .../src/main/web/src/locales/zh-TW/pwa.js | 6 + .../src/main/web/src/locales/zh-TW/result.js | 27 + .../web/src/locales/zh-TW/settingDrawer.js | 31 + .../main/web/src/locales/zh-TW/settings.js | 55 + antdsp-admin/src/main/web/src/manifest.json | 22 + .../src/main/web/src/models/global.js | 101 + antdsp-admin/src/main/web/src/models/list.js | 54 + antdsp-admin/src/main/web/src/models/login.js | 80 + antdsp-admin/src/main/web/src/models/menu.js | 131 ++ .../src/main/web/src/models/project.js | 28 + .../src/main/web/src/models/setting.js | 124 ++ antdsp-admin/src/main/web/src/models/user.js | 52 + antdsp-admin/src/main/web/src/pages/404.js | 13 + .../src/main/web/src/pages/Authorized.js | 38 + .../main/web/src/pages/Dashboard/Analysis.js | 184 ++ .../web/src/pages/Dashboard/Analysis.less | 198 ++ .../web/src/pages/Dashboard/IntroduceRow.js | 152 ++ .../main/web/src/pages/Dashboard/Monitor.js | 244 +++ .../main/web/src/pages/Dashboard/Monitor.less | 23 + .../web/src/pages/Dashboard/OfflineData.js | 65 + .../src/pages/Dashboard/ProportionSales.js | 58 + .../main/web/src/pages/Dashboard/SalesCard.js | 150 ++ .../main/web/src/pages/Dashboard/TopSearch.js | 111 + .../main/web/src/pages/Dashboard/Workplace.js | 255 +++ .../web/src/pages/Dashboard/Workplace.less | 228 +++ .../src/pages/Dashboard/models/activities.js | 28 + .../web/src/pages/Dashboard/models/chart.js | 61 + .../web/src/pages/Dashboard/models/monitor.js | 28 + .../src/main/web/src/pages/Exception/403.js | 15 + .../src/main/web/src/pages/Exception/404.js | 15 + .../src/main/web/src/pages/Exception/500.js | 15 + .../src/pages/Exception/TriggerException.js | 50 + .../web/src/pages/Exception/models/error.js | 28 + .../main/web/src/pages/Exception/style.less | 7 + .../src/main/web/src/pages/Result/Error.js | 66 + .../src/main/web/src/pages/Result/Success.js | 144 ++ .../main/web/src/pages/System/menu/Index.js | 15 + .../web/src/pages/System/models/system.js | 17 + .../main/web/src/pages/System/role/Index.js | 15 + .../main/web/src/pages/System/user/Index.js | 15 + .../src/main/web/src/pages/User/Login.js | 172 ++ .../src/main/web/src/pages/User/Login.less | 32 + .../src/main/web/src/pages/User/Register.js | 335 ++++ .../src/main/web/src/pages/User/Register.less | 57 + .../main/web/src/pages/User/RegisterResult.js | 41 + .../web/src/pages/User/RegisterResult.less | 18 + .../web/src/pages/User/models/register.js | 32 + .../src/main/web/src/pages/document.ejs | 17 + .../src/main/web/src/service-worker.js | 65 + antdsp-admin/src/main/web/src/services/api.js | 126 ++ .../src/main/web/src/services/error.js | 5 + .../src/main/web/src/services/geographic.js | 9 + .../src/main/web/src/services/user.js | 9 + .../src/main/web/src/utils/Authorized.js | 12 + antdsp-admin/src/main/web/src/utils/Yuan.js | 31 + .../src/main/web/src/utils/authority.js | 25 + .../src/main/web/src/utils/authority.test.js | 19 + .../src/main/web/src/utils/getPageTitle.js | 27 + .../src/main/web/src/utils/request.js | 72 + antdsp-admin/src/main/web/src/utils/utils.js | 194 ++ .../src/main/web/src/utils/utils.less | 50 + .../src/main/web/src/utils/utils.test.js | 62 + antdsp-admin/src/main/web/tests/run-tests.js | 47 + antdsp-admin/src/main/web/tsconfig.json | 35 + antdsp-admin/src/main/web/tslint.json | 11 + .../antdsp/dao/jpa/AntdspBaseRepository.java | 14 + .../dao/jpa/AntdspBaseRepositoryImpl.java | 29 + .../main/java/com/antdsp/dao/jpa/UserJpa.java | 5 +- 437 files changed, 21938 insertions(+), 1 deletion(-) create mode 100644 antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java create mode 100644 antdsp-admin/src/main/java/com/antdsp/common/ResponseCode.java create mode 100644 antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java create mode 100644 antdsp-admin/src/main/java/com/antdsp/common/pagination/Pagination.java create mode 100644 antdsp-admin/src/main/java/com/antdsp/common/pagination/PaginationData.java create mode 100644 antdsp-admin/src/main/java/com/antdsp/web/sys/SystemMenuApi.java create mode 100644 antdsp-admin/src/main/java/com/antdsp/web/sys/SystemRoleApi.java create mode 100644 antdsp-admin/src/main/java/com/antdsp/web/sys/SystemUserApi.java create mode 100644 antdsp-admin/src/main/web/.dockerignore create mode 100644 antdsp-admin/src/main/web/.editorconfig create mode 100644 antdsp-admin/src/main/web/.eslintignore create mode 100644 antdsp-admin/src/main/web/.eslintrc.js create mode 100644 antdsp-admin/src/main/web/.gitignore create mode 100644 antdsp-admin/src/main/web/.gitpod.yml create mode 100644 antdsp-admin/src/main/web/.prettierignore create mode 100644 antdsp-admin/src/main/web/.prettierrc create mode 100644 antdsp-admin/src/main/web/.stylelintrc.json create mode 100644 antdsp-admin/src/main/web/CODE_OF_CONDUCT.md create mode 100644 antdsp-admin/src/main/web/Dockerfile create mode 100644 antdsp-admin/src/main/web/Dockerfile.dev create mode 100644 antdsp-admin/src/main/web/Dockerfile.hub create mode 100644 antdsp-admin/src/main/web/LICENSE create mode 100644 antdsp-admin/src/main/web/README.md create mode 100644 antdsp-admin/src/main/web/azure-pipelines.yml create mode 100644 antdsp-admin/src/main/web/config/config.js create mode 100644 antdsp-admin/src/main/web/config/plugin.config.js create mode 100644 antdsp-admin/src/main/web/config/router.config.js create mode 100644 antdsp-admin/src/main/web/docker/docker-compose.dev.yml create mode 100644 antdsp-admin/src/main/web/docker/docker-compose.yml create mode 100644 antdsp-admin/src/main/web/docker/nginx.conf create mode 100644 antdsp-admin/src/main/web/jest-puppeteer.config.js create mode 100644 antdsp-admin/src/main/web/jest.config.js create mode 100644 antdsp-admin/src/main/web/jsconfig.json create mode 100644 antdsp-admin/src/main/web/lambda/api.js create mode 100644 antdsp-admin/src/main/web/lambda/mock/matchMock.js create mode 100644 antdsp-admin/src/main/web/mock/api.js create mode 100644 antdsp-admin/src/main/web/mock/chart.js create mode 100644 antdsp-admin/src/main/web/mock/geographic.js create mode 100644 antdsp-admin/src/main/web/mock/geographic/city.json create mode 100644 antdsp-admin/src/main/web/mock/geographic/province.json create mode 100644 antdsp-admin/src/main/web/mock/notices.js create mode 100644 antdsp-admin/src/main/web/mock/profile.js create mode 100644 antdsp-admin/src/main/web/mock/rule.js create mode 100644 antdsp-admin/src/main/web/mock/user.js create mode 100644 antdsp-admin/src/main/web/netlify.toml create mode 100644 antdsp-admin/src/main/web/package.json create mode 100644 antdsp-admin/src/main/web/public/favicon.png create mode 100644 antdsp-admin/src/main/web/public/ggeditor/flow/decision.svg create mode 100644 antdsp-admin/src/main/web/public/ggeditor/flow/model.svg create mode 100644 antdsp-admin/src/main/web/public/ggeditor/flow/normal.svg create mode 100644 antdsp-admin/src/main/web/public/ggeditor/flow/start.svg create mode 100644 antdsp-admin/src/main/web/public/ggeditor/koni/bank.svg create mode 100644 antdsp-admin/src/main/web/public/ggeditor/koni/country.svg create mode 100644 antdsp-admin/src/main/web/public/ggeditor/koni/icon.svg create mode 100644 antdsp-admin/src/main/web/public/ggeditor/koni/person.svg create mode 100644 antdsp-admin/src/main/web/public/icons/icon-128x128.png create mode 100644 antdsp-admin/src/main/web/public/icons/icon-192x192.png create mode 100644 antdsp-admin/src/main/web/public/icons/icon-512x512.png create mode 100644 antdsp-admin/src/main/web/scripts/generateMock.js create mode 100644 antdsp-admin/src/main/web/scripts/getPrettierFiles.js create mode 100644 antdsp-admin/src/main/web/scripts/lint-prettier.js create mode 100644 antdsp-admin/src/main/web/scripts/prettier.js create mode 100644 antdsp-admin/src/main/web/src/app.js create mode 100644 antdsp-admin/src/main/web/src/assets/logo.svg create mode 100644 antdsp-admin/src/main/web/src/components/ActiveChart/index.js create mode 100644 antdsp-admin/src/main/web/src/components/ActiveChart/index.less create mode 100644 antdsp-admin/src/main/web/src/components/ArticleListContent/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/ArticleListContent/index.js create mode 100644 antdsp-admin/src/main/web/src/components/ArticleListContent/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/Authorized.js create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/AuthorizedRoute.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/AuthorizedRoute.js create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/CheckPermissions.js create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/CheckPermissions.test.js create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/PromiseRender.js create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/Secured.js create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/demo/AuthorizedArray.md create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/demo/AuthorizedFunction.md create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/demo/secured.md create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/index.md create mode 100644 antdsp-admin/src/main/web/src/components/Authorized/renderAuthorize.js create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/AvatarItem.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/demo/maxLength.md create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/demo/simple.md create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/index.js create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/index.less create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/index.test.js create mode 100644 antdsp-admin/src/main/web/src/components/AvatarList/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Bar/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Bar/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Field/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Field/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Field/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Gauge/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Gauge/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/MiniArea/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/MiniArea/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/MiniBar/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/MiniBar/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Pie/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Pie/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Pie/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Radar/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Radar/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/Radar/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/autoHeight.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/bizcharts.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/bizcharts.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/bar.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/chart-card.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/gauge.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/mini-area.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/mini-bar.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/mini-pie.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/mini-progress.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/mix.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/pie.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/radar.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/tag-cloud.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/timeline-chart.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/demo/waterwave.md create mode 100644 antdsp-admin/src/main/web/src/components/Charts/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Charts/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Charts/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Charts/index.md create mode 100644 antdsp-admin/src/main/web/src/components/CountDown/demo/simple.md create mode 100644 antdsp-admin/src/main/web/src/components/CountDown/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/CountDown/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/CountDown/index.js create mode 100644 antdsp-admin/src/main/web/src/components/CountDown/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/Description.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/Description.js create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/DescriptionList.js create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/demo/vertical.md create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/index.js create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/index.less create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/DescriptionList/responsive.js create mode 100644 antdsp-admin/src/main/web/src/components/EditableItem/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/EditableItem/index.js create mode 100644 antdsp-admin/src/main/web/src/components/EditableItem/index.less create mode 100644 antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.js create mode 100644 antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Ellipsis/demo/line.md create mode 100644 antdsp-admin/src/main/web/src/components/Ellipsis/demo/number.md create mode 100644 antdsp-admin/src/main/web/src/components/Ellipsis/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Ellipsis/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/Ellipsis/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Ellipsis/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Ellipsis/index.test.js create mode 100644 antdsp-admin/src/main/web/src/components/Ellipsis/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/Exception/demo/403.md create mode 100644 antdsp-admin/src/main/web/src/components/Exception/demo/404.md create mode 100644 antdsp-admin/src/main/web/src/components/Exception/demo/500.md create mode 100644 antdsp-admin/src/main/web/src/components/Exception/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Exception/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/Exception/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Exception/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Exception/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/Exception/typeConfig.js create mode 100644 antdsp-admin/src/main/web/src/components/FooterToolbar/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/FooterToolbar/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/FooterToolbar/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/FooterToolbar/index.js create mode 100644 antdsp-admin/src/main/web/src/components/FooterToolbar/index.less create mode 100644 antdsp-admin/src/main/web/src/components/FooterToolbar/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/GlobalFooter/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/GlobalFooter/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/GlobalFooter/index.js create mode 100644 antdsp-admin/src/main/web/src/components/GlobalFooter/index.less create mode 100644 antdsp-admin/src/main/web/src/components/GlobalFooter/index.md create mode 100644 antdsp-admin/src/main/web/src/components/GlobalHeader/RightContent.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/GlobalHeader/RightContent.js create mode 100644 antdsp-admin/src/main/web/src/components/GlobalHeader/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/GlobalHeader/index.js create mode 100644 antdsp-admin/src/main/web/src/components/GlobalHeader/index.less create mode 100644 antdsp-admin/src/main/web/src/components/HeaderDropdown/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/HeaderDropdown/index.js create mode 100644 antdsp-admin/src/main/web/src/components/HeaderDropdown/index.less create mode 100644 antdsp-admin/src/main/web/src/components/HeaderSearch/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/HeaderSearch/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/HeaderSearch/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/HeaderSearch/index.js create mode 100644 antdsp-admin/src/main/web/src/components/HeaderSearch/index.less create mode 100644 antdsp-admin/src/main/web/src/components/HeaderSearch/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/IconFont/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Login/LoginItem.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Login/LoginItem.js create mode 100644 antdsp-admin/src/main/web/src/components/Login/LoginSubmit.js create mode 100644 antdsp-admin/src/main/web/src/components/Login/LoginTab.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Login/LoginTab.js create mode 100644 antdsp-admin/src/main/web/src/components/Login/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/Login/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Login/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/Login/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Login/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Login/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/Login/loginContext.js create mode 100644 antdsp-admin/src/main/web/src/components/Login/map.js create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/NoticeIconTab.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/NoticeList.js create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/NoticeList.less create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/demo/popover.md create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/index.js create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/index.less create mode 100644 antdsp-admin/src/main/web/src/components/NoticeIcon/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/NumberInfo/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/NumberInfo/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/NumberInfo/index.en-US.md create mode 100644 antdsp-admin/src/main/web/src/components/NumberInfo/index.js create mode 100644 antdsp-admin/src/main/web/src/components/NumberInfo/index.less create mode 100644 antdsp-admin/src/main/web/src/components/NumberInfo/index.zh-CN.md create mode 100644 antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.js create mode 100644 antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.less create mode 100644 antdsp-admin/src/main/web/src/components/PageHeaderWrapper/breadcrumb.js create mode 100644 antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.js create mode 100644 antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.less create mode 100644 antdsp-admin/src/main/web/src/components/PageLoading/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Result/demo/classic.md create mode 100644 antdsp-admin/src/main/web/src/components/Result/demo/error.md create mode 100644 antdsp-admin/src/main/web/src/components/Result/demo/structure.md create mode 100644 antdsp-admin/src/main/web/src/components/Result/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Result/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Result/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Result/index.md create mode 100644 antdsp-admin/src/main/web/src/components/SelectLang/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/SelectLang/index.js create mode 100644 antdsp-admin/src/main/web/src/components/SelectLang/index.less create mode 100644 antdsp-admin/src/main/web/src/components/SettingDrawer/BlockCheckbox.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/SettingDrawer/BlockCheckbox.js create mode 100644 antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.js create mode 100644 antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.less create mode 100644 antdsp-admin/src/main/web/src/components/SettingDrawer/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/SettingDrawer/index.js create mode 100644 antdsp-admin/src/main/web/src/components/SettingDrawer/index.less create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/BaseMenu.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/BaseMenu.js create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.js create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.test.js create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenuUtils.js create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/index.js create mode 100644 antdsp-admin/src/main/web/src/components/SiderMenu/index.less create mode 100644 antdsp-admin/src/main/web/src/components/StandardFormRow/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/StandardFormRow/index.js create mode 100644 antdsp-admin/src/main/web/src/components/StandardFormRow/index.less create mode 100644 antdsp-admin/src/main/web/src/components/StandardTable/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/StandardTable/index.js create mode 100644 antdsp-admin/src/main/web/src/components/StandardTable/index.less create mode 100644 antdsp-admin/src/main/web/src/components/TagSelect/TagSelectOption.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/TagSelect/demo/controlled.md create mode 100644 antdsp-admin/src/main/web/src/components/TagSelect/demo/expandable.md create mode 100644 antdsp-admin/src/main/web/src/components/TagSelect/demo/simple.md create mode 100644 antdsp-admin/src/main/web/src/components/TagSelect/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/TagSelect/index.js create mode 100644 antdsp-admin/src/main/web/src/components/TagSelect/index.less create mode 100644 antdsp-admin/src/main/web/src/components/TagSelect/index.md create mode 100644 antdsp-admin/src/main/web/src/components/TopNavHeader/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/TopNavHeader/index.js create mode 100644 antdsp-admin/src/main/web/src/components/TopNavHeader/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Trend/demo/basic.md create mode 100644 antdsp-admin/src/main/web/src/components/Trend/demo/reverse.md create mode 100644 antdsp-admin/src/main/web/src/components/Trend/index.d.ts create mode 100644 antdsp-admin/src/main/web/src/components/Trend/index.js create mode 100644 antdsp-admin/src/main/web/src/components/Trend/index.less create mode 100644 antdsp-admin/src/main/web/src/components/Trend/index.md create mode 100644 antdsp-admin/src/main/web/src/components/_utils/pathTools.js create mode 100644 antdsp-admin/src/main/web/src/components/_utils/pathTools.test.js create mode 100644 antdsp-admin/src/main/web/src/defaultSettings.js create mode 100644 antdsp-admin/src/main/web/src/e2e/baseLayout.e2e.js create mode 100644 antdsp-admin/src/main/web/src/e2e/home.e2e.js create mode 100644 antdsp-admin/src/main/web/src/e2e/login.e2e.js create mode 100644 antdsp-admin/src/main/web/src/e2e/topMenu.e2e.js create mode 100644 antdsp-admin/src/main/web/src/e2e/userLayout.e2e.js create mode 100644 antdsp-admin/src/main/web/src/global.js create mode 100644 antdsp-admin/src/main/web/src/global.less create mode 100644 antdsp-admin/src/main/web/src/layouts/BasicLayout.js create mode 100644 antdsp-admin/src/main/web/src/layouts/BasicLayout.less create mode 100644 antdsp-admin/src/main/web/src/layouts/BlankLayout.js create mode 100644 antdsp-admin/src/main/web/src/layouts/Footer.js create mode 100644 antdsp-admin/src/main/web/src/layouts/Header.js create mode 100644 antdsp-admin/src/main/web/src/layouts/Header.less create mode 100644 antdsp-admin/src/main/web/src/layouts/MenuContext.js create mode 100644 antdsp-admin/src/main/web/src/layouts/UserLayout.js create mode 100644 antdsp-admin/src/main/web/src/layouts/UserLayout.less create mode 100644 antdsp-admin/src/main/web/src/locales/en-US.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/analysis.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/component.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/editor.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/exception.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/form.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/globalHeader.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/login.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/menu.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/monitor.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/pwa.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/result.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/settingDrawer.js create mode 100644 antdsp-admin/src/main/web/src/locales/en-US/settings.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/analysis.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/component.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/editor.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/exception.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/form.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/globalHeader.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/login.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/menu.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/monitor.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/pwa.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/result.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/settingDrawer.js create mode 100644 antdsp-admin/src/main/web/src/locales/pt-BR/settings.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/analysis.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/component.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/editor.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/exception.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/form.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/globalHeader.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/login.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/menu.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/monitor.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/pwa.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/result.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/settingDrawer.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-CN/settings.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/analysis.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/component.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/editor.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/exception.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/form.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/globalHeader.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/login.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/menu.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/monitor.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/pwa.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/result.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/settingDrawer.js create mode 100644 antdsp-admin/src/main/web/src/locales/zh-TW/settings.js create mode 100644 antdsp-admin/src/main/web/src/manifest.json create mode 100644 antdsp-admin/src/main/web/src/models/global.js create mode 100644 antdsp-admin/src/main/web/src/models/list.js create mode 100644 antdsp-admin/src/main/web/src/models/login.js create mode 100644 antdsp-admin/src/main/web/src/models/menu.js create mode 100644 antdsp-admin/src/main/web/src/models/project.js create mode 100644 antdsp-admin/src/main/web/src/models/setting.js create mode 100644 antdsp-admin/src/main/web/src/models/user.js create mode 100644 antdsp-admin/src/main/web/src/pages/404.js create mode 100644 antdsp-admin/src/main/web/src/pages/Authorized.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.less create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/IntroduceRow.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.less create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/OfflineData.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/ProportionSales.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/SalesCard.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/TopSearch.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.less create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/models/activities.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/models/chart.js create mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/models/monitor.js create mode 100644 antdsp-admin/src/main/web/src/pages/Exception/403.js create mode 100644 antdsp-admin/src/main/web/src/pages/Exception/404.js create mode 100644 antdsp-admin/src/main/web/src/pages/Exception/500.js create mode 100644 antdsp-admin/src/main/web/src/pages/Exception/TriggerException.js create mode 100644 antdsp-admin/src/main/web/src/pages/Exception/models/error.js create mode 100644 antdsp-admin/src/main/web/src/pages/Exception/style.less create mode 100644 antdsp-admin/src/main/web/src/pages/Result/Error.js create mode 100644 antdsp-admin/src/main/web/src/pages/Result/Success.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/menu/Index.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/models/system.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/role/Index.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/user/Index.js create mode 100644 antdsp-admin/src/main/web/src/pages/User/Login.js create mode 100644 antdsp-admin/src/main/web/src/pages/User/Login.less create mode 100644 antdsp-admin/src/main/web/src/pages/User/Register.js create mode 100644 antdsp-admin/src/main/web/src/pages/User/Register.less create mode 100644 antdsp-admin/src/main/web/src/pages/User/RegisterResult.js create mode 100644 antdsp-admin/src/main/web/src/pages/User/RegisterResult.less create mode 100644 antdsp-admin/src/main/web/src/pages/User/models/register.js create mode 100644 antdsp-admin/src/main/web/src/pages/document.ejs create mode 100644 antdsp-admin/src/main/web/src/service-worker.js create mode 100644 antdsp-admin/src/main/web/src/services/api.js create mode 100644 antdsp-admin/src/main/web/src/services/error.js create mode 100644 antdsp-admin/src/main/web/src/services/geographic.js create mode 100644 antdsp-admin/src/main/web/src/services/user.js create mode 100644 antdsp-admin/src/main/web/src/utils/Authorized.js create mode 100644 antdsp-admin/src/main/web/src/utils/Yuan.js create mode 100644 antdsp-admin/src/main/web/src/utils/authority.js create mode 100644 antdsp-admin/src/main/web/src/utils/authority.test.js create mode 100644 antdsp-admin/src/main/web/src/utils/getPageTitle.js create mode 100644 antdsp-admin/src/main/web/src/utils/request.js create mode 100644 antdsp-admin/src/main/web/src/utils/utils.js create mode 100644 antdsp-admin/src/main/web/src/utils/utils.less create mode 100644 antdsp-admin/src/main/web/src/utils/utils.test.js create mode 100644 antdsp-admin/src/main/web/tests/run-tests.js create mode 100644 antdsp-admin/src/main/web/tsconfig.json create mode 100644 antdsp-admin/src/main/web/tslint.json create mode 100644 antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java create mode 100644 antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java diff --git a/antdsp-admin/pom.xml b/antdsp-admin/pom.xml index e6cd849..ccf175b 100644 --- a/antdsp-admin/pom.xml +++ b/antdsp-admin/pom.xml @@ -23,6 +23,11 @@ org.springframework.boot spring-boot-starter-web + + org.apache.shiro + shiro-spring + 1.3.2 + org.springframework.boot diff --git a/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java b/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java new file mode 100644 index 0000000..2b23c1c --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java @@ -0,0 +1,41 @@ +package com.antdsp.common; + +public class AntdspResponse { + + private int code; + + private String message; + + public AntdspResponse() { + } + + public AntdspResponse(ResponseCode code){ + this(code.getValue() , code.getMsg()); + } + + public AntdspResponse(ResponseCode code , String message) { + this(code.getValue() , message); + } + + public AntdspResponse(int code , String message) { + this.code = code; + this.message = message; + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + + public void setCode(int code) { + this.code = code; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/common/ResponseCode.java b/antdsp-admin/src/main/java/com/antdsp/common/ResponseCode.java new file mode 100644 index 0000000..decb222 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/common/ResponseCode.java @@ -0,0 +1,25 @@ +package com.antdsp.common; + +public enum ResponseCode { + + UNAUTHORIZED(1401 , "未登录"), + FORBIDDEN(1403 , "权限不足"); + + + private final int value; + private final String msg; + + ResponseCode(int value , String msg) { + this.value = value; + this.msg = msg; + } + + public int getValue() { + return value; + } + + public String getMsg() { + return msg; + } + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java b/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java new file mode 100644 index 0000000..d44a54e --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java @@ -0,0 +1,30 @@ +package com.antdsp.common.exception; + +import org.apache.shiro.authz.UnauthorizedException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import com.antdsp.common.AntdspResponse; +import com.antdsp.common.ResponseCode; + +/** + * + *

title:AntdspException.java

+ *

Description: 自定义异常处理

+ *

Copyright: Copyright (c) 2019

+ * + * @author ljt + * @date 2019年5月31日 + * @email a496401006@qq.com + * + */ +@RestControllerAdvice +public class AntdspException extends RuntimeException{ + + @ExceptionHandler(value= {UnauthorizedException.class}) + @ResponseBody + public AntdspResponse unauthorizedException() { + return new AntdspResponse( ResponseCode.FORBIDDEN , "权限不足,请联系管理员."); + } +} diff --git a/antdsp-admin/src/main/java/com/antdsp/common/pagination/Pagination.java b/antdsp-admin/src/main/java/com/antdsp/common/pagination/Pagination.java new file mode 100644 index 0000000..eae17de --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/common/pagination/Pagination.java @@ -0,0 +1,52 @@ +package com.antdsp.common.pagination; + +/** + * + *

title:Pagination.java

+ *

Description: 分页数据

+ *

Copyright: Copyright (c) 2019

+ * + * @author ljt + * @date 2019年5月31日 + * @email a496401006@qq.com + * + */ +public class Pagination { + + /** + * 当前页码 + */ + private int current; + + /** + * 总条数 + */ + private Long total; + + public Pagination() { + this(1 , 0L); + } + + public Pagination(int current, Long total) { + this.current = current; + this.total = total; + } + + public int getCurrent() { + return current; + } + + public void setCurrent(int current) { + this.current = current; + } + + public Long getTotal() { + return total; + } + + public void setTotal(Long total) { + this.total = total; + } + + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/common/pagination/PaginationData.java b/antdsp-admin/src/main/java/com/antdsp/common/pagination/PaginationData.java new file mode 100644 index 0000000..74c14e5 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/common/pagination/PaginationData.java @@ -0,0 +1,58 @@ +package com.antdsp.common.pagination; + +import java.util.List; + +/** + * + *

title:PaginationData

+ *

Description: 分页信息

+ *

Copyright: Copyright (c) 2019

+ * + * @author ljt + * @date 2019年5月31日 + * @email a496401006@qq.com + * + * @param 数据类型 + * data 数据 + * pagination 分页参数,字段与antd中对应 + */ +public class PaginationData { + + private List data; + private Pagination pagination; + + public PaginationData() { + super(); + } + public PaginationData(List data, Pagination pagination) { + super(); + this.data = data; + this.pagination = pagination; + } + + /** + * + * @param data 记录 + * @param current 当前页码 + * @param total 总条数 + */ + public PaginationData(List data , int current , Long total) { + this.data = data; + this.pagination = new Pagination(current , total); + } + + public List getData() { + return data; + } + public void setData(List data) { + this.data = data; + } + public Pagination getPagination() { + return pagination; + } + public void setPagination(Pagination pagination) { + this.pagination = pagination; + } + + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemMenuApi.java b/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemMenuApi.java new file mode 100644 index 0000000..f083885 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemMenuApi.java @@ -0,0 +1,10 @@ +package com.antdsp.web.sys; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/system/menu") +public class SystemMenuApi { + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemRoleApi.java b/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemRoleApi.java new file mode 100644 index 0000000..8041ad3 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemRoleApi.java @@ -0,0 +1,15 @@ +package com.antdsp.web.sys; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * + * @author ljt + * + */ +@RestController +@RequestMapping("/system/role") +public class SystemRoleApi { + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemUserApi.java b/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemUserApi.java new file mode 100644 index 0000000..13437a9 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemUserApi.java @@ -0,0 +1,66 @@ +package com.antdsp.web.sys; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Order; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.antdsp.common.pagination.PaginationData; +import com.antdsp.dao.jpa.UserJpa; +import com.antdsp.model.entity.User; +import com.antdsp.model.entityeenum.UserStatus; + +@RestController +@RequestMapping("/system/user") +public class SystemUserApi { + + @Autowired + private UserJpa userJpa; + + @GetMapping("") + public PaginationData list(int page , int count , String loginname , UserStatus status){ + + Map params = new HashMap<>(); + int start = (page -1 ) * count; + params.put("start", start); + params.put("count", count); + + Pageable pageable = PageRequest.of(page, count , Sort.by(Order.desc("creator"))); //Sort.and(Order.desc("creator")) + + Specification specification = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder builder) { + + List predicates = new ArrayList<>(); + if(!StringUtils.isEmpty(loginname)) { + predicates.add(builder.like(root.get("loginname"), "%"+loginname+"%")); + } + if(status != null) { + predicates.add(builder.equal(root.get("status"), status)); + } + return builder.and(predicates.toArray(new Predicate[predicates.size()])); + } + }; + + Page userList = userJpa.findAll(specification , pageable); + PaginationData pagination = new PaginationData<>(userList.getContent() , page , userList.getTotalElements()); + return pagination; + } +} diff --git a/antdsp-admin/src/main/web/.dockerignore b/antdsp-admin/src/main/web/.dockerignore new file mode 100644 index 0000000..8e90ca6 --- /dev/null +++ b/antdsp-admin/src/main/web/.dockerignore @@ -0,0 +1,35 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +**/node_modules +/src/utils/request-temp.js + +# production +/.vscode + +# misc +.DS_Store +npm-debug.log* +yarn-error.log + +/coverage +.idea +yarn.lock +package-lock.json +*bak +.vscode + +# visual studio code +.history +*.log + +functions/mock +.temp/** + +# umi +.umi +.umi-production + +# screenshot +screenshot +.firebase \ No newline at end of file diff --git a/antdsp-admin/src/main/web/.editorconfig b/antdsp-admin/src/main/web/.editorconfig new file mode 100644 index 0000000..d3b05cb --- /dev/null +++ b/antdsp-admin/src/main/web/.editorconfig @@ -0,0 +1,17 @@ + +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab \ No newline at end of file diff --git a/antdsp-admin/src/main/web/.eslintignore b/antdsp-admin/src/main/web/.eslintignore new file mode 100644 index 0000000..03232ae --- /dev/null +++ b/antdsp-admin/src/main/web/.eslintignore @@ -0,0 +1,3 @@ +/lambda/ +/scripts +/config \ No newline at end of file diff --git a/antdsp-admin/src/main/web/.eslintrc.js b/antdsp-admin/src/main/web/.eslintrc.js new file mode 100644 index 0000000..30e4710 --- /dev/null +++ b/antdsp-admin/src/main/web/.eslintrc.js @@ -0,0 +1,40 @@ +module.exports = { + parser: 'babel-eslint', + extends: ['airbnb', 'prettier', 'plugin:compat/recommended'], + env: { + browser: true, + node: true, + es6: true, + mocha: true, + jest: true, + jasmine: true, + }, + globals: { + ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: true, // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + page: true, + }, + rules: { + 'react/jsx-filename-extension': [1, { extensions: ['.js'] }], + 'react/jsx-wrap-multilines': 0, + 'react/prop-types': 0, + 'react/forbid-prop-types': 0, + 'react/jsx-one-expression-per-line': 0, + 'import/no-unresolved': [2, { ignore: ['^@/', '^umi/'] }], + 'import/no-extraneous-dependencies': [ + 2, + { + optionalDependencies: true, + devDependencies: ['**/tests/**.js', '/mock/**/**.js', '**/**.test.js'], + }, + ], + 'import/no-cycle': 0, + 'jsx-a11y/no-noninteractive-element-interactions': 0, + 'jsx-a11y/click-events-have-key-events': 0, + 'jsx-a11y/no-static-element-interactions': 0, + 'jsx-a11y/anchor-is-valid': 0, + 'linebreak-style': 0, + }, + settings: { + polyfills: ['fetch', 'promises', 'url', 'object-assign'], + }, +}; diff --git a/antdsp-admin/src/main/web/.gitignore b/antdsp-admin/src/main/web/.gitignore new file mode 100644 index 0000000..253591b --- /dev/null +++ b/antdsp-admin/src/main/web/.gitignore @@ -0,0 +1,38 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +**/node_modules +# roadhog-api-doc ignore +/src/utils/request-temp.js +_roadhog-api-doc + +# production +/dist +/.vscode + +# misc +.DS_Store +npm-debug.log* +yarn-error.log + +/coverage +.idea +yarn.lock +package-lock.json +*bak +.vscode + +# visual studio code +.history +*.log +functions/* +lambda/mock/index.js +.temp/** + +# umi +.umi +.umi-production + +# screenshot +screenshot +.firebase \ No newline at end of file diff --git a/antdsp-admin/src/main/web/.gitpod.yml b/antdsp-admin/src/main/web/.gitpod.yml new file mode 100644 index 0000000..211fe8b --- /dev/null +++ b/antdsp-admin/src/main/web/.gitpod.yml @@ -0,0 +1,6 @@ +ports: +- port: 8000 + onOpen: open-preview +tasks: +- init: npm install + command: npm start \ No newline at end of file diff --git a/antdsp-admin/src/main/web/.prettierignore b/antdsp-admin/src/main/web/.prettierignore new file mode 100644 index 0000000..e93f2eb --- /dev/null +++ b/antdsp-admin/src/main/web/.prettierignore @@ -0,0 +1,5 @@ + +**/*.svg +package.json +.umi +.umi-production \ No newline at end of file diff --git a/antdsp-admin/src/main/web/.prettierrc b/antdsp-admin/src/main/web/.prettierrc new file mode 100644 index 0000000..66b815b --- /dev/null +++ b/antdsp-admin/src/main/web/.prettierrc @@ -0,0 +1,13 @@ + +{ + "singleQuote": true, + "trailingComma": "es5", + "printWidth": 100, + "proseWrap": "never", + "overrides": [ + { + "files": ".prettierrc", + "options": { "parser": "json" } + } + ] + } \ No newline at end of file diff --git a/antdsp-admin/src/main/web/.stylelintrc.json b/antdsp-admin/src/main/web/.stylelintrc.json new file mode 100644 index 0000000..215bf08 --- /dev/null +++ b/antdsp-admin/src/main/web/.stylelintrc.json @@ -0,0 +1,13 @@ +{ + "extends": [ + "stylelint-config-standard", + "stylelint-config-css-modules", + "stylelint-config-rational-order", + "stylelint-config-prettier" + ], + "plugins": ["stylelint-order", "stylelint-declaration-block-no-ignored-properties"], + "rules": { + "no-descending-specificity": null, + "plugin/declaration-block-no-ignored-properties": true + } +} diff --git a/antdsp-admin/src/main/web/CODE_OF_CONDUCT.md b/antdsp-admin/src/main/web/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..9e41f2e --- /dev/null +++ b/antdsp-admin/src/main/web/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at afc163@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/antdsp-admin/src/main/web/Dockerfile b/antdsp-admin/src/main/web/Dockerfile new file mode 100644 index 0000000..7cbc5c3 --- /dev/null +++ b/antdsp-admin/src/main/web/Dockerfile @@ -0,0 +1,12 @@ +FROM circleci/node:latest-browsers + +WORKDIR /usr/src/app/ +USER root +COPY package.json ./ +RUN yarn + +COPY ./ ./ + +RUN npm run test:all + +CMD ["npm", "run", "build"] diff --git a/antdsp-admin/src/main/web/Dockerfile.dev b/antdsp-admin/src/main/web/Dockerfile.dev new file mode 100644 index 0000000..f5a50e5 --- /dev/null +++ b/antdsp-admin/src/main/web/Dockerfile.dev @@ -0,0 +1,11 @@ +FROM node:latest + +WORKDIR /usr/src/app/ + +COPY package.json ./ +RUN npm install --silent --no-cache + +COPY ./ ./ + + +CMD ["npm", "run", "start"] diff --git a/antdsp-admin/src/main/web/Dockerfile.hub b/antdsp-admin/src/main/web/Dockerfile.hub new file mode 100644 index 0000000..2e9c1ec --- /dev/null +++ b/antdsp-admin/src/main/web/Dockerfile.hub @@ -0,0 +1,11 @@ +FROM nginx + +WORKDIR /usr/src/app/ + +COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf + +COPY ./dist /usr/share/nginx/html/ + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/antdsp-admin/src/main/web/LICENSE b/antdsp-admin/src/main/web/LICENSE new file mode 100644 index 0000000..c17ba2f --- /dev/null +++ b/antdsp-admin/src/main/web/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Alipay.inc + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/antdsp-admin/src/main/web/README.md b/antdsp-admin/src/main/web/README.md new file mode 100644 index 0000000..b02c0ac --- /dev/null +++ b/antdsp-admin/src/main/web/README.md @@ -0,0 +1,23 @@ +# power-web + +#### 介绍 +power页面部分,使用基于React的ant design pro 框架构建 + +#### 软件架构 + + +#### 安装教程 + +#### 使用说明 + +#### 参与贡献 + + +#### 码云特技 + +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 +5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) \ No newline at end of file diff --git a/antdsp-admin/src/main/web/azure-pipelines.yml b/antdsp-admin/src/main/web/azure-pipelines.yml new file mode 100644 index 0000000..2df685a --- /dev/null +++ b/antdsp-admin/src/main/web/azure-pipelines.yml @@ -0,0 +1,78 @@ +# Node.js +# Build a general Node.js project with npm. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript +name: ant design pro + +trigger: + - master + +jobs: + - job: lintAndBuild + + pool: + vmImage: 'Ubuntu-16.04' + + steps: + - checkout: self + clean: false + - script: yarn install + displayName: install + - script: npm run lint + displayName: lint + - script: npm run build + env: + PROGRESS: none + displayName: build + + - job: test + pool: + vmImage: 'Ubuntu-16.04' + + container: + image: circleci/node:latest-browsers + options: '-u root' + + steps: + - script: yarn install + displayName: install + - script: npm run test:all + env: + PROGRESS: none + displayName: test + + - job: Windows + pool: + vmImage: 'vs2017-win2016' + steps: + - task: NodeTool@0 + inputs: + versionSpec: '11.x' + - script: yarn install + displayName: install + - script: npm run lint + displayName: lint + - script: npm run test:all + env: + PROGRESS: none + displayName: test + - script: npm run build + env: + PROGRESS: none + displayName: build + + - job: MacOS + pool: + vmImage: 'macOS-10.13' + steps: + - task: NodeTool@0 + inputs: + versionSpec: '11.x' + - script: yarn install + displayName: install + - script: npm run lint + displayName: lint + - script: npm run + env: + PROGRESS: none + displayName: build diff --git a/antdsp-admin/src/main/web/config/config.js b/antdsp-admin/src/main/web/config/config.js new file mode 100644 index 0000000..dc34a31 --- /dev/null +++ b/antdsp-admin/src/main/web/config/config.js @@ -0,0 +1,130 @@ +// https://umijs.org/config/ +import os from 'os'; +import pageRoutes from './router.config'; +import webpackPlugin from './plugin.config'; +import defaultSettings from '../src/defaultSettings'; +import slash from 'slash2'; + +const { pwa, primaryColor } = defaultSettings; +// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 +const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, TEST } = process.env; + +const plugins = [ + [ + 'umi-plugin-react', + { + antd: true, + dva: { + hmr: true, + }, + locale: { + enable: true, // default false + default: 'zh-CN', // default zh-CN + baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default + }, + dynamicImport: { + loadingComponent: './components/PageLoading/index', + webpackChunkName: true, + level: 3, + }, + pwa: pwa + ? { + workboxPluginMode: 'InjectManifest', + workboxOptions: { + importWorkboxFrom: 'local', + }, + } + : false, + ...(!TEST && os.platform() === 'darwin' + ? { + dll: { + include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'], + exclude: ['@babel/runtime', 'netlify-lambda'], + }, + hardSource: false, + } + : {}), + }, + ], +]; + +// 针对 preview.pro.ant.design 的 GA 统计代码 +// preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 +if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { + plugins.push([ + 'umi-plugin-ga', + { + code: 'UA-72788897-6', + }, + ]); +} + +export default { + // add for transfer to umi + plugins, + define: { + ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: + ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + }, + treeShaking: true, + targets: { + ie: 11, + }, + // 路由配置 + routes: pageRoutes, + // Theme for antd + // https://ant.design/docs/react/customize-theme-cn + theme: { + 'primary-color': primaryColor, + }, + // proxy: { + // '/server/api/': { + // target: 'https://preview.pro.ant.design/', + // changeOrigin: true, + // pathRewrite: { '^/server': '' }, + // }, + // }, + ignoreMomentLocale: true, + lessLoaderOptions: { + javascriptEnabled: true, + }, + disableRedirectHoist: true, + cssLoaderOptions: { + modules: true, + getLocalIdent: (context, localIdentName, localName) => { + if ( + context.resourcePath.includes('node_modules') || + context.resourcePath.includes('ant.design.pro.less') || + context.resourcePath.includes('global.less') + ) { + return localName; + } + const match = context.resourcePath.match(/src(.*)/); + if (match && match[1]) { + const antdProPath = match[1].replace('.less', ''); + const arr = slash(antdProPath) + .split('/') + .map(a => a.replace(/([A-Z])/g, '-$1')) + .map(a => a.toLowerCase()); + return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-'); + } + return localName; + }, + }, + manifest: { + basePath: '/', + }, + + chainWebpack: webpackPlugin, + + base: '/antdsp', + publicPath: '/antdsp', + + proxy: { + "/antdsp-api": { + "target": "http://localhost:8080/antdsp-api/", + "changeOrigin": true, + "pathRewrite": { "^/antdsp-api" : "" } + } + } +}; diff --git a/antdsp-admin/src/main/web/config/plugin.config.js b/antdsp-admin/src/main/web/config/plugin.config.js new file mode 100644 index 0000000..59ce550 --- /dev/null +++ b/antdsp-admin/src/main/web/config/plugin.config.js @@ -0,0 +1,83 @@ +// Change theme plugin + +import MergeLessPlugin from 'antd-pro-merge-less'; +import AntDesignThemePlugin from 'antd-theme-webpack-plugin'; +import path from 'path'; + +function getModulePackageName(module) { + if (!module.context) return null; + + const nodeModulesPath = path.join(__dirname, '../node_modules/'); + if (module.context.substring(0, nodeModulesPath.length) !== nodeModulesPath) { + return null; + } + + const moduleRelativePath = module.context.substring(nodeModulesPath.length); + const [moduleDirName] = moduleRelativePath.split(path.sep); + let packageName = moduleDirName; + // handle tree shaking + if (packageName.match('^_')) { + // eslint-disable-next-line prefer-destructuring + packageName = packageName.match(/^_(@?[^@]+)/)[1]; + } + return packageName; +} + +export default config => { + // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + if ( + process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' || + process.env.NODE_ENV !== 'production' + ) { + // 将所有 less 合并为一个供 themePlugin使用 + const outFile = path.join(__dirname, '../.temp/ant-design-pro.less'); + const stylesDir = path.join(__dirname, '../src/'); + + config.plugin('merge-less').use(MergeLessPlugin, [ + { + stylesDir, + outFile, + }, + ]); + + config.plugin('ant-design-theme').use(AntDesignThemePlugin, [ + { + antDir: path.join(__dirname, '../node_modules/antd'), + stylesDir, + varFile: path.join(__dirname, '../node_modules/antd/lib/style/themes/default.less'), + mainLessFile: outFile, // themeVariables: ['@primary-color'], + indexFileName: 'index.html', + generateOne: true, + lessUrl: 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js', + }, + ]); + } + // optimize chunks + config.optimization + .runtimeChunk(false) // share the same chunks across different modules + .splitChunks({ + chunks: 'async', + name: 'vendors', + maxInitialRequests: Infinity, + minSize: 0, + cacheGroups: { + vendors: { + test: module => { + const packageName = getModulePackageName(module); + if (packageName) { + return ['bizcharts', '@antv_data-set'].indexOf(packageName) >= 0; + } + return false; + }, + name(module) { + const packageName = getModulePackageName(module); + + if (['bizcharts', '@antv_data-set'].indexOf(packageName) >= 0) { + return 'viz'; // visualization package + } + return 'misc'; + }, + }, + }, + }); +}; diff --git a/antdsp-admin/src/main/web/config/router.config.js b/antdsp-admin/src/main/web/config/router.config.js new file mode 100644 index 0000000..2c4c173 --- /dev/null +++ b/antdsp-admin/src/main/web/config/router.config.js @@ -0,0 +1,30 @@ +export default [ + //login + { path: '/login', name: 'login', component: './User/Login' }, + // app + { + path: '/', + component: '../layouts/BasicLayout', + Routes: ['src/pages/Authorized'], + routes: [ + { + path: '/', + redirect:'/system/role', + authority: 'admin', + }, + { + path: '/system', + name: 'system', + icon: 'setting', + routes: [ + { path: '/system/role', name: 'role', component: './System/role' }, + { path: '/system/user', name: 'user', component: './System/user' }, + { path: '/system/menu', name: 'menu', component: './System/menu' }, + ], + }, + { + component: '404', + }, + ], + }, +]; diff --git a/antdsp-admin/src/main/web/docker/docker-compose.dev.yml b/antdsp-admin/src/main/web/docker/docker-compose.dev.yml new file mode 100644 index 0000000..d7ab213 --- /dev/null +++ b/antdsp-admin/src/main/web/docker/docker-compose.dev.yml @@ -0,0 +1,14 @@ +version: "3.5" + +services: + ant-design-pro_dev: + ports: + - 8000:8000 + build: + context: ../ + dockerfile: Dockerfile.dev + container_name: "ant-design-pro_dev" + volumes: + - ../src:/usr/src/app/src + - ../config:/usr/src/app/config + - ../mock:/usr/src/app/mock diff --git a/antdsp-admin/src/main/web/docker/docker-compose.yml b/antdsp-admin/src/main/web/docker/docker-compose.yml new file mode 100644 index 0000000..d055600 --- /dev/null +++ b/antdsp-admin/src/main/web/docker/docker-compose.yml @@ -0,0 +1,21 @@ +version: "3.5" + +services: + ant-design-pro_build: + build: ../ + container_name: "ant-design-pro_build" + volumes: + - dist:/usr/src/app/dist + + ant-design-pro_web: + image: nginx + ports: + - 80:80 + container_name: "ant-design-pro_web" + restart: unless-stopped + volumes: + - dist:/usr/share/nginx/html:ro + - ./nginx.conf:/etc/nginx/conf.d/default.conf + +volumes: + dist: diff --git a/antdsp-admin/src/main/web/docker/nginx.conf b/antdsp-admin/src/main/web/docker/nginx.conf new file mode 100644 index 0000000..5f86992 --- /dev/null +++ b/antdsp-admin/src/main/web/docker/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80; + # gzip config + gzip on; + gzip_min_length 1k; + gzip_comp_level 9; + gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; + gzip_vary on; + gzip_disable "MSIE [1-6]\."; + + root /usr/share/nginx/html; + + location / { + try_files $uri $uri/ /index.html; + } + location /api { + proxy_pass https://preview.pro.ant.design; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + } +} diff --git a/antdsp-admin/src/main/web/jest-puppeteer.config.js b/antdsp-admin/src/main/web/jest-puppeteer.config.js new file mode 100644 index 0000000..2494ca0 --- /dev/null +++ b/antdsp-admin/src/main/web/jest-puppeteer.config.js @@ -0,0 +1,12 @@ +// ps https://github.com/GoogleChrome/puppeteer/issues/3120 +module.exports = { + launch: { + args: [ + '--disable-gpu', + '--disable-dev-shm-usage', + '--no-first-run', + '--no-zygote', + '--no-sandbox' + ], + }, +}; diff --git a/antdsp-admin/src/main/web/jest.config.js b/antdsp-admin/src/main/web/jest.config.js new file mode 100644 index 0000000..ba22e52 --- /dev/null +++ b/antdsp-admin/src/main/web/jest.config.js @@ -0,0 +1,7 @@ +module.exports = { + testURL: 'http://localhost:8000', + preset: 'jest-puppeteer', + globals: { + ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION: false, // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + }, +}; diff --git a/antdsp-admin/src/main/web/jsconfig.json b/antdsp-admin/src/main/web/jsconfig.json new file mode 100644 index 0000000..f87334d --- /dev/null +++ b/antdsp-admin/src/main/web/jsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + } + } +} diff --git a/antdsp-admin/src/main/web/lambda/api.js b/antdsp-admin/src/main/web/lambda/api.js new file mode 100644 index 0000000..e0c147a --- /dev/null +++ b/antdsp-admin/src/main/web/lambda/api.js @@ -0,0 +1,11 @@ +// [START functions import] +const express = require('express'); +const serverLess = require('serverless-http'); + +const matchMock = require('./mock/matchMock'); + +const app = express(); + +app.use(matchMock); + +exports.handler = serverLess(app); diff --git a/antdsp-admin/src/main/web/lambda/mock/matchMock.js b/antdsp-admin/src/main/web/lambda/mock/matchMock.js new file mode 100644 index 0000000..d742361 --- /dev/null +++ b/antdsp-admin/src/main/web/lambda/mock/matchMock.js @@ -0,0 +1,116 @@ +const pathToRegexp = require('path-to-regexp'); +const bodyParser = require('body-parser'); + +const mockFile = require('./index'); + +const BODY_PARSED_METHODS = ['post', 'put', 'patch']; + +const debug = console.log; +function parseKey(key) { + let method = 'get'; + let path = key; + if (key.indexOf(' ') > -1) { + const spliced = key.split(' '); + method = spliced[0].toLowerCase(); + path = spliced[1]; // eslint-disable-line + } + const routerBasePath = `${path}`; + return { + method, + path: routerBasePath, + }; +} + +function createHandler(method, path, handler) { + return (req, res, next) => { + function sendData() { + if (typeof handler === 'function') { + handler(req, res, next); + } else { + res.json(handler); + } + } + if (BODY_PARSED_METHODS.includes(method)) { + bodyParser.json({ limit: '5mb', strict: false })(req, res, () => { + bodyParser.urlencoded({ limit: '5mb', extended: true })(req, res, () => { + sendData(); + }); + }); + } else { + sendData(); + } + }; +} + +function normalizeConfig(config) { + return Object.keys(config).reduce((memo, key) => { + const handler = config[key]; + const { method, path } = parseKey(key); + const keys = []; + const re = pathToRegexp(path, keys); + memo.push({ + method, + path, + re, + keys, + handler: createHandler(method, path, handler), + }); + return memo; + }, []); +} + +const mockData = normalizeConfig(mockFile); + +function matchMock(req) { + const { path: exceptPath } = req; + const exceptMethod = req.method.toLowerCase(); + function decodeParam(val) { + if (typeof val !== 'string' || val.length === 0) { + return val; + } + + try { + return decodeURIComponent(val); + } catch (err) { + if (err instanceof URIError) { + err.message = `Failed to decode param ' ${val} '`; + err.statusCode = 400; + err.status = 400; + } + + throw err; + } + } + // eslint-disable-next-line no-restricted-syntax + for (const mock of mockData) { + const { method, re, keys } = mock; + if (method === exceptMethod) { + const match = re.exec(req.path); + if (match) { + const params = {}; + + for (let i = 1; i < match.length; i += 1) { + const key = keys[i - 1]; + const prop = key.name; + const val = decodeParam(match[i]); + + if (val !== undefined || !hasOwnProperty.call(params, prop)) { + params[prop] = val; + } + } + req.params = params; + return mock; + } + } + } + + return mockData.filter(({ method, re }) => method === exceptMethod && re.test(exceptPath))[0]; +} +module.exports = (req, res, next) => { + const match = matchMock(req); + if (match) { + debug(`mock matched: [${match.method}] ${match.path}`); + return match.handler(req, res, next); + } + return next(); +}; diff --git a/antdsp-admin/src/main/web/mock/api.js b/antdsp-admin/src/main/web/mock/api.js new file mode 100644 index 0000000..0286d07 --- /dev/null +++ b/antdsp-admin/src/main/web/mock/api.js @@ -0,0 +1,336 @@ +import mockjs from 'mockjs'; + +const titles = [ + 'Alipay', + 'Angular', + 'Ant Design', + 'Ant Design Pro', + 'Bootstrap', + 'React', + 'Vue', + 'Webpack', +]; +const avatars = [ + 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay + 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular + 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design + 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro + 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap + 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React + 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue + 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack +]; + +const avatars2 = [ + 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png', + 'https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png', + 'https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png', + 'https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png', + 'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png', + 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png', + 'https://gw.alipayobjects.com/zos/rmsportal/psOgztMplJMGpVEqfcgF.png', + 'https://gw.alipayobjects.com/zos/rmsportal/ZpBqSxLxVEXfcUNoPKrz.png', + 'https://gw.alipayobjects.com/zos/rmsportal/laiEnJdGHVOhJrUShBaJ.png', + 'https://gw.alipayobjects.com/zos/rmsportal/UrQsqscbKEpNuJcvBZBu.png', +]; + +const covers = [ + 'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', + 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', + 'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png', + 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png', +]; +const desc = [ + '那是一种内在的东西, 他们到达不了,也无法触及的', + '希望是一个好东西,也许是最好的,好东西是不会消亡的', + '生命就像一盒巧克力,结果往往出人意料', + '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆', + '那时候我只会想自己想要什么,从不想自己拥有什么', +]; + +const user = [ + '付小小', + '曲丽丽', + '林东东', + '周星星', + '吴加好', + '朱偏右', + '鱼酱', + '乐哥', + '谭小仪', + '仲尼', +]; + +function fakeList(count) { + const list = []; + for (let i = 0; i < count; i += 1) { + list.push({ + id: `fake-list-${i}`, + owner: user[i % 10], + title: titles[i % 8], + avatar: avatars[i % 8], + cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)], + status: ['active', 'exception', 'normal'][i % 3], + percent: Math.ceil(Math.random() * 50) + 50, + logo: avatars[i % 8], + href: 'https://ant.design', + updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i), + createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i), + subDescription: desc[i % 5], + description: + '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', + activeUser: Math.ceil(Math.random() * 100000) + 100000, + newUser: Math.ceil(Math.random() * 1000) + 1000, + star: Math.ceil(Math.random() * 100) + 100, + like: Math.ceil(Math.random() * 100) + 100, + message: Math.ceil(Math.random() * 10) + 10, + content: + '段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。', + members: [ + { + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png', + name: '曲丽丽', + id: 'member1', + }, + { + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png', + name: '王昭君', + id: 'member2', + }, + { + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png', + name: '董娜娜', + id: 'member3', + }, + ], + }); + } + + return list; +} + +let sourceData; + +function getFakeList(req, res) { + const params = req.query; + + const count = params.count * 1 || 20; + + const result = fakeList(count); + sourceData = result; + return res.json(result); +} + +function postFakeList(req, res) { + const { /* url = '', */ body } = req; + // const params = getUrlParams(url); + const { method, id } = body; + // const count = (params.count * 1) || 20; + let result = sourceData; + + switch (method) { + case 'delete': + result = result.filter(item => item.id !== id); + break; + case 'update': + result.forEach((item, i) => { + if (item.id === id) { + result[i] = Object.assign(item, body); + } + }); + break; + case 'post': + result.unshift({ + body, + id: `fake-list-${result.length}`, + createdAt: new Date().getTime(), + }); + break; + default: + break; + } + + return res.json(result); +} + +const getNotice = [ + { + id: 'xxx1', + title: titles[0], + logo: avatars[0], + description: '那是一种内在的东西,他们到达不了,也无法触及的', + updatedAt: new Date(), + member: '科学搬砖组', + href: '', + memberLink: '', + }, + { + id: 'xxx2', + title: titles[1], + logo: avatars[1], + description: '希望是一个好东西,也许是最好的,好东西是不会消亡的', + updatedAt: new Date('2017-07-24'), + member: '全组都是吴彦祖', + href: '', + memberLink: '', + }, + { + id: 'xxx3', + title: titles[2], + logo: avatars[2], + description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆', + updatedAt: new Date(), + member: '中二少女团', + href: '', + memberLink: '', + }, + { + id: 'xxx4', + title: titles[3], + logo: avatars[3], + description: '那时候我只会想自己想要什么,从不想自己拥有什么', + updatedAt: new Date('2017-07-23'), + member: '程序员日常', + href: '', + memberLink: '', + }, + { + id: 'xxx5', + title: titles[4], + logo: avatars[4], + description: '凛冬将至', + updatedAt: new Date('2017-07-23'), + member: '高逼格设计天团', + href: '', + memberLink: '', + }, + { + id: 'xxx6', + title: titles[5], + logo: avatars[5], + description: '生命就像一盒巧克力,结果往往出人意料', + updatedAt: new Date('2017-07-23'), + member: '骗你来学计算机', + href: '', + memberLink: '', + }, +]; + +const getActivities = [ + { + id: 'trend-1', + updatedAt: new Date(), + user: { + name: '曲丽丽', + avatar: avatars2[0], + }, + group: { + name: '高逼格设计天团', + link: 'http://github.com/', + }, + project: { + name: '六月迭代', + link: 'http://github.com/', + }, + template: '在 @{group} 新建项目 @{project}', + }, + { + id: 'trend-2', + updatedAt: new Date(), + user: { + name: '付小小', + avatar: avatars2[1], + }, + group: { + name: '高逼格设计天团', + link: 'http://github.com/', + }, + project: { + name: '六月迭代', + link: 'http://github.com/', + }, + template: '在 @{group} 新建项目 @{project}', + }, + { + id: 'trend-3', + updatedAt: new Date(), + user: { + name: '林东东', + avatar: avatars2[2], + }, + group: { + name: '中二少女团', + link: 'http://github.com/', + }, + project: { + name: '六月迭代', + link: 'http://github.com/', + }, + template: '在 @{group} 新建项目 @{project}', + }, + { + id: 'trend-4', + updatedAt: new Date(), + user: { + name: '周星星', + avatar: avatars2[4], + }, + project: { + name: '5 月日常迭代', + link: 'http://github.com/', + }, + template: '将 @{project} 更新至已发布状态', + }, + { + id: 'trend-5', + updatedAt: new Date(), + user: { + name: '朱偏右', + avatar: avatars2[3], + }, + project: { + name: '工程效能', + link: 'http://github.com/', + }, + comment: { + name: '留言', + link: 'http://github.com/', + }, + template: '在 @{project} 发布了 @{comment}', + }, + { + id: 'trend-6', + updatedAt: new Date(), + user: { + name: '乐哥', + avatar: avatars2[5], + }, + group: { + name: '程序员日常', + link: 'http://github.com/', + }, + project: { + name: '品牌迭代', + link: 'http://github.com/', + }, + template: '在 @{group} 新建项目 @{project}', + }, +]; + +function getFakeCaptcha(req, res) { + return res.json('captcha-xxx'); +} + +export default { + 'GET /api/project/notice': getNotice, + 'GET /api/activities': getActivities, + 'POST /api/forms': (req, res) => { + res.send({ message: 'Ok' }); + }, + 'GET /api/tags': mockjs.mock({ + 'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }], + }), + 'GET /api/fake_list': getFakeList, + 'POST /api/fake_list': postFakeList, + 'GET /api/captcha': getFakeCaptcha, +}; diff --git a/antdsp-admin/src/main/web/mock/chart.js b/antdsp-admin/src/main/web/mock/chart.js new file mode 100644 index 0000000..6503775 --- /dev/null +++ b/antdsp-admin/src/main/web/mock/chart.js @@ -0,0 +1,196 @@ +import moment from 'moment'; + +// mock data +const visitData = []; +const beginDay = new Date().getTime(); + +const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5]; +for (let i = 0; i < fakeY.length; i += 1) { + visitData.push({ + x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'), + y: fakeY[i], + }); +} + +const visitData2 = []; +const fakeY2 = [1, 6, 4, 8, 3, 7, 2]; +for (let i = 0; i < fakeY2.length; i += 1) { + visitData2.push({ + x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'), + y: fakeY2[i], + }); +} + +const salesData = []; +for (let i = 0; i < 12; i += 1) { + salesData.push({ + x: `${i + 1}月`, + y: Math.floor(Math.random() * 1000) + 200, + }); +} +const searchData = []; +for (let i = 0; i < 50; i += 1) { + searchData.push({ + index: i + 1, + keyword: `搜索关键词-${i}`, + count: Math.floor(Math.random() * 1000), + range: Math.floor(Math.random() * 100), + status: Math.floor((Math.random() * 10) % 2), + }); +} +const salesTypeData = [ + { + x: '家用电器', + y: 4544, + }, + { + x: '食用酒水', + y: 3321, + }, + { + x: '个护健康', + y: 3113, + }, + { + x: '服饰箱包', + y: 2341, + }, + { + x: '母婴产品', + y: 1231, + }, + { + x: '其他', + y: 1231, + }, +]; + +const salesTypeDataOnline = [ + { + x: '家用电器', + y: 244, + }, + { + x: '食用酒水', + y: 321, + }, + { + x: '个护健康', + y: 311, + }, + { + x: '服饰箱包', + y: 41, + }, + { + x: '母婴产品', + y: 121, + }, + { + x: '其他', + y: 111, + }, +]; + +const salesTypeDataOffline = [ + { + x: '家用电器', + y: 99, + }, + { + x: '食用酒水', + y: 188, + }, + { + x: '个护健康', + y: 344, + }, + { + x: '服饰箱包', + y: 255, + }, + { + x: '其他', + y: 65, + }, +]; + +const offlineData = []; +for (let i = 0; i < 10; i += 1) { + offlineData.push({ + name: `Stores ${i}`, + cvr: Math.ceil(Math.random() * 9) / 10, + }); +} +const offlineChartData = []; +for (let i = 0; i < 20; i += 1) { + offlineChartData.push({ + x: new Date().getTime() + 1000 * 60 * 30 * i, + y1: Math.floor(Math.random() * 100) + 10, + y2: Math.floor(Math.random() * 100) + 10, + }); +} + +const radarOriginData = [ + { + name: '个人', + ref: 10, + koubei: 8, + output: 4, + contribute: 5, + hot: 7, + }, + { + name: '团队', + ref: 3, + koubei: 9, + output: 6, + contribute: 3, + hot: 1, + }, + { + name: '部门', + ref: 4, + koubei: 1, + output: 6, + contribute: 5, + hot: 7, + }, +]; + +const radarData = []; +const radarTitleMap = { + ref: '引用', + koubei: '口碑', + output: '产量', + contribute: '贡献', + hot: '热度', +}; +radarOriginData.forEach(item => { + Object.keys(item).forEach(key => { + if (key !== 'name') { + radarData.push({ + name: item.name, + label: radarTitleMap[key], + value: item[key], + }); + } + }); +}); + +const getFakeChartData = { + visitData, + visitData2, + salesData, + searchData, + offlineData, + offlineChartData, + salesTypeData, + salesTypeDataOnline, + salesTypeDataOffline, + radarData, +}; + +export default { + 'GET /api/fake_chart_data': getFakeChartData, +}; diff --git a/antdsp-admin/src/main/web/mock/geographic.js b/antdsp-admin/src/main/web/mock/geographic.js new file mode 100644 index 0000000..e7772e8 --- /dev/null +++ b/antdsp-admin/src/main/web/mock/geographic.js @@ -0,0 +1,15 @@ +import city from './geographic/city.json'; +import province from './geographic/province.json'; + +function getProvince(req, res) { + return res.json(province); +} + +function getCity(req, res) { + return res.json(city[req.params.province]); +} + +export default { + 'GET /api/geographic/province': getProvince, + 'GET /api/geographic/city/:province': getCity, +}; diff --git a/antdsp-admin/src/main/web/mock/geographic/city.json b/antdsp-admin/src/main/web/mock/geographic/city.json new file mode 100644 index 0000000..2978374 --- /dev/null +++ b/antdsp-admin/src/main/web/mock/geographic/city.json @@ -0,0 +1,1784 @@ +{ + "110000": [ + { + "province": "北京市", + "name": "市辖区", + "id": "110100" + } + ], + "120000": [ + { + "province": "天津市", + "name": "市辖区", + "id": "120100" + } + ], + "130000": [ + { + "province": "河北省", + "name": "石家庄市", + "id": "130100" + }, + { + "province": "河北省", + "name": "唐山市", + "id": "130200" + }, + { + "province": "河北省", + "name": "秦皇岛市", + "id": "130300" + }, + { + "province": "河北省", + "name": "邯郸市", + "id": "130400" + }, + { + "province": "河北省", + "name": "邢台市", + "id": "130500" + }, + { + "province": "河北省", + "name": "保定市", + "id": "130600" + }, + { + "province": "河北省", + "name": "张家口市", + "id": "130700" + }, + { + "province": "河北省", + "name": "承德市", + "id": "130800" + }, + { + "province": "河北省", + "name": "沧州市", + "id": "130900" + }, + { + "province": "河北省", + "name": "廊坊市", + "id": "131000" + }, + { + "province": "河北省", + "name": "衡水市", + "id": "131100" + }, + { + "province": "河北省", + "name": "省直辖县级行政区划", + "id": "139000" + } + ], + "140000": [ + { + "province": "山西省", + "name": "太原市", + "id": "140100" + }, + { + "province": "山西省", + "name": "大同市", + "id": "140200" + }, + { + "province": "山西省", + "name": "阳泉市", + "id": "140300" + }, + { + "province": "山西省", + "name": "长治市", + "id": "140400" + }, + { + "province": "山西省", + "name": "晋城市", + "id": "140500" + }, + { + "province": "山西省", + "name": "朔州市", + "id": "140600" + }, + { + "province": "山西省", + "name": "晋中市", + "id": "140700" + }, + { + "province": "山西省", + "name": "运城市", + "id": "140800" + }, + { + "province": "山西省", + "name": "忻州市", + "id": "140900" + }, + { + "province": "山西省", + "name": "临汾市", + "id": "141000" + }, + { + "province": "山西省", + "name": "吕梁市", + "id": "141100" + } + ], + "150000": [ + { + "province": "内蒙古自治区", + "name": "呼和浩特市", + "id": "150100" + }, + { + "province": "内蒙古自治区", + "name": "包头市", + "id": "150200" + }, + { + "province": "内蒙古自治区", + "name": "乌海市", + "id": "150300" + }, + { + "province": "内蒙古自治区", + "name": "赤峰市", + "id": "150400" + }, + { + "province": "内蒙古自治区", + "name": "通辽市", + "id": "150500" + }, + { + "province": "内蒙古自治区", + "name": "鄂尔多斯市", + "id": "150600" + }, + { + "province": "内蒙古自治区", + "name": "呼伦贝尔市", + "id": "150700" + }, + { + "province": "内蒙古自治区", + "name": "巴彦淖尔市", + "id": "150800" + }, + { + "province": "内蒙古自治区", + "name": "乌兰察布市", + "id": "150900" + }, + { + "province": "内蒙古自治区", + "name": "兴安盟", + "id": "152200" + }, + { + "province": "内蒙古自治区", + "name": "锡林郭勒盟", + "id": "152500" + }, + { + "province": "内蒙古自治区", + "name": "阿拉善盟", + "id": "152900" + } + ], + "210000": [ + { + "province": "辽宁省", + "name": "沈阳市", + "id": "210100" + }, + { + "province": "辽宁省", + "name": "大连市", + "id": "210200" + }, + { + "province": "辽宁省", + "name": "鞍山市", + "id": "210300" + }, + { + "province": "辽宁省", + "name": "抚顺市", + "id": "210400" + }, + { + "province": "辽宁省", + "name": "本溪市", + "id": "210500" + }, + { + "province": "辽宁省", + "name": "丹东市", + "id": "210600" + }, + { + "province": "辽宁省", + "name": "锦州市", + "id": "210700" + }, + { + "province": "辽宁省", + "name": "营口市", + "id": "210800" + }, + { + "province": "辽宁省", + "name": "阜新市", + "id": "210900" + }, + { + "province": "辽宁省", + "name": "辽阳市", + "id": "211000" + }, + { + "province": "辽宁省", + "name": "盘锦市", + "id": "211100" + }, + { + "province": "辽宁省", + "name": "铁岭市", + "id": "211200" + }, + { + "province": "辽宁省", + "name": "朝阳市", + "id": "211300" + }, + { + "province": "辽宁省", + "name": "葫芦岛市", + "id": "211400" + } + ], + "220000": [ + { + "province": "吉林省", + "name": "长春市", + "id": "220100" + }, + { + "province": "吉林省", + "name": "吉林市", + "id": "220200" + }, + { + "province": "吉林省", + "name": "四平市", + "id": "220300" + }, + { + "province": "吉林省", + "name": "辽源市", + "id": "220400" + }, + { + "province": "吉林省", + "name": "通化市", + "id": "220500" + }, + { + "province": "吉林省", + "name": "白山市", + "id": "220600" + }, + { + "province": "吉林省", + "name": "松原市", + "id": "220700" + }, + { + "province": "吉林省", + "name": "白城市", + "id": "220800" + }, + { + "province": "吉林省", + "name": "延边朝鲜族自治州", + "id": "222400" + } + ], + "230000": [ + { + "province": "黑龙江省", + "name": "哈尔滨市", + "id": "230100" + }, + { + "province": "黑龙江省", + "name": "齐齐哈尔市", + "id": "230200" + }, + { + "province": "黑龙江省", + "name": "鸡西市", + "id": "230300" + }, + { + "province": "黑龙江省", + "name": "鹤岗市", + "id": "230400" + }, + { + "province": "黑龙江省", + "name": "双鸭山市", + "id": "230500" + }, + { + "province": "黑龙江省", + "name": "大庆市", + "id": "230600" + }, + { + "province": "黑龙江省", + "name": "伊春市", + "id": "230700" + }, + { + "province": "黑龙江省", + "name": "佳木斯市", + "id": "230800" + }, + { + "province": "黑龙江省", + "name": "七台河市", + "id": "230900" + }, + { + "province": "黑龙江省", + "name": "牡丹江市", + "id": "231000" + }, + { + "province": "黑龙江省", + "name": "黑河市", + "id": "231100" + }, + { + "province": "黑龙江省", + "name": "绥化市", + "id": "231200" + }, + { + "province": "黑龙江省", + "name": "大兴安岭地区", + "id": "232700" + } + ], + "310000": [ + { + "province": "上海市", + "name": "市辖区", + "id": "310100" + } + ], + "320000": [ + { + "province": "江苏省", + "name": "南京市", + "id": "320100" + }, + { + "province": "江苏省", + "name": "无锡市", + "id": "320200" + }, + { + "province": "江苏省", + "name": "徐州市", + "id": "320300" + }, + { + "province": "江苏省", + "name": "常州市", + "id": "320400" + }, + { + "province": "江苏省", + "name": "苏州市", + "id": "320500" + }, + { + "province": "江苏省", + "name": "南通市", + "id": "320600" + }, + { + "province": "江苏省", + "name": "连云港市", + "id": "320700" + }, + { + "province": "江苏省", + "name": "淮安市", + "id": "320800" + }, + { + "province": "江苏省", + "name": "盐城市", + "id": "320900" + }, + { + "province": "江苏省", + "name": "扬州市", + "id": "321000" + }, + { + "province": "江苏省", + "name": "镇江市", + "id": "321100" + }, + { + "province": "江苏省", + "name": "泰州市", + "id": "321200" + }, + { + "province": "江苏省", + "name": "宿迁市", + "id": "321300" + } + ], + "330000": [ + { + "province": "浙江省", + "name": "杭州市", + "id": "330100" + }, + { + "province": "浙江省", + "name": "宁波市", + "id": "330200" + }, + { + "province": "浙江省", + "name": "温州市", + "id": "330300" + }, + { + "province": "浙江省", + "name": "嘉兴市", + "id": "330400" + }, + { + "province": "浙江省", + "name": "湖州市", + "id": "330500" + }, + { + "province": "浙江省", + "name": "绍兴市", + "id": "330600" + }, + { + "province": "浙江省", + "name": "金华市", + "id": "330700" + }, + { + "province": "浙江省", + "name": "衢州市", + "id": "330800" + }, + { + "province": "浙江省", + "name": "舟山市", + "id": "330900" + }, + { + "province": "浙江省", + "name": "台州市", + "id": "331000" + }, + { + "province": "浙江省", + "name": "丽水市", + "id": "331100" + } + ], + "340000": [ + { + "province": "安徽省", + "name": "合肥市", + "id": "340100" + }, + { + "province": "安徽省", + "name": "芜湖市", + "id": "340200" + }, + { + "province": "安徽省", + "name": "蚌埠市", + "id": "340300" + }, + { + "province": "安徽省", + "name": "淮南市", + "id": "340400" + }, + { + "province": "安徽省", + "name": "马鞍山市", + "id": "340500" + }, + { + "province": "安徽省", + "name": "淮北市", + "id": "340600" + }, + { + "province": "安徽省", + "name": "铜陵市", + "id": "340700" + }, + { + "province": "安徽省", + "name": "安庆市", + "id": "340800" + }, + { + "province": "安徽省", + "name": "黄山市", + "id": "341000" + }, + { + "province": "安徽省", + "name": "滁州市", + "id": "341100" + }, + { + "province": "安徽省", + "name": "阜阳市", + "id": "341200" + }, + { + "province": "安徽省", + "name": "宿州市", + "id": "341300" + }, + { + "province": "安徽省", + "name": "六安市", + "id": "341500" + }, + { + "province": "安徽省", + "name": "亳州市", + "id": "341600" + }, + { + "province": "安徽省", + "name": "池州市", + "id": "341700" + }, + { + "province": "安徽省", + "name": "宣城市", + "id": "341800" + } + ], + "350000": [ + { + "province": "福建省", + "name": "福州市", + "id": "350100" + }, + { + "province": "福建省", + "name": "厦门市", + "id": "350200" + }, + { + "province": "福建省", + "name": "莆田市", + "id": "350300" + }, + { + "province": "福建省", + "name": "三明市", + "id": "350400" + }, + { + "province": "福建省", + "name": "泉州市", + "id": "350500" + }, + { + "province": "福建省", + "name": "漳州市", + "id": "350600" + }, + { + "province": "福建省", + "name": "南平市", + "id": "350700" + }, + { + "province": "福建省", + "name": "龙岩市", + "id": "350800" + }, + { + "province": "福建省", + "name": "宁德市", + "id": "350900" + } + ], + "360000": [ + { + "province": "江西省", + "name": "南昌市", + "id": "360100" + }, + { + "province": "江西省", + "name": "景德镇市", + "id": "360200" + }, + { + "province": "江西省", + "name": "萍乡市", + "id": "360300" + }, + { + "province": "江西省", + "name": "九江市", + "id": "360400" + }, + { + "province": "江西省", + "name": "新余市", + "id": "360500" + }, + { + "province": "江西省", + "name": "鹰潭市", + "id": "360600" + }, + { + "province": "江西省", + "name": "赣州市", + "id": "360700" + }, + { + "province": "江西省", + "name": "吉安市", + "id": "360800" + }, + { + "province": "江西省", + "name": "宜春市", + "id": "360900" + }, + { + "province": "江西省", + "name": "抚州市", + "id": "361000" + }, + { + "province": "江西省", + "name": "上饶市", + "id": "361100" + } + ], + "370000": [ + { + "province": "山东省", + "name": "济南市", + "id": "370100" + }, + { + "province": "山东省", + "name": "青岛市", + "id": "370200" + }, + { + "province": "山东省", + "name": "淄博市", + "id": "370300" + }, + { + "province": "山东省", + "name": "枣庄市", + "id": "370400" + }, + { + "province": "山东省", + "name": "东营市", + "id": "370500" + }, + { + "province": "山东省", + "name": "烟台市", + "id": "370600" + }, + { + "province": "山东省", + "name": "潍坊市", + "id": "370700" + }, + { + "province": "山东省", + "name": "济宁市", + "id": "370800" + }, + { + "province": "山东省", + "name": "泰安市", + "id": "370900" + }, + { + "province": "山东省", + "name": "威海市", + "id": "371000" + }, + { + "province": "山东省", + "name": "日照市", + "id": "371100" + }, + { + "province": "山东省", + "name": "莱芜市", + "id": "371200" + }, + { + "province": "山东省", + "name": "临沂市", + "id": "371300" + }, + { + "province": "山东省", + "name": "德州市", + "id": "371400" + }, + { + "province": "山东省", + "name": "聊城市", + "id": "371500" + }, + { + "province": "山东省", + "name": "滨州市", + "id": "371600" + }, + { + "province": "山东省", + "name": "菏泽市", + "id": "371700" + } + ], + "410000": [ + { + "province": "河南省", + "name": "郑州市", + "id": "410100" + }, + { + "province": "河南省", + "name": "开封市", + "id": "410200" + }, + { + "province": "河南省", + "name": "洛阳市", + "id": "410300" + }, + { + "province": "河南省", + "name": "平顶山市", + "id": "410400" + }, + { + "province": "河南省", + "name": "安阳市", + "id": "410500" + }, + { + "province": "河南省", + "name": "鹤壁市", + "id": "410600" + }, + { + "province": "河南省", + "name": "新乡市", + "id": "410700" + }, + { + "province": "河南省", + "name": "焦作市", + "id": "410800" + }, + { + "province": "河南省", + "name": "濮阳市", + "id": "410900" + }, + { + "province": "河南省", + "name": "许昌市", + "id": "411000" + }, + { + "province": "河南省", + "name": "漯河市", + "id": "411100" + }, + { + "province": "河南省", + "name": "三门峡市", + "id": "411200" + }, + { + "province": "河南省", + "name": "南阳市", + "id": "411300" + }, + { + "province": "河南省", + "name": "商丘市", + "id": "411400" + }, + { + "province": "河南省", + "name": "信阳市", + "id": "411500" + }, + { + "province": "河南省", + "name": "周口市", + "id": "411600" + }, + { + "province": "河南省", + "name": "驻马店市", + "id": "411700" + }, + { + "province": "河南省", + "name": "省直辖县级行政区划", + "id": "419000" + } + ], + "420000": [ + { + "province": "湖北省", + "name": "武汉市", + "id": "420100" + }, + { + "province": "湖北省", + "name": "黄石市", + "id": "420200" + }, + { + "province": "湖北省", + "name": "十堰市", + "id": "420300" + }, + { + "province": "湖北省", + "name": "宜昌市", + "id": "420500" + }, + { + "province": "湖北省", + "name": "襄阳市", + "id": "420600" + }, + { + "province": "湖北省", + "name": "鄂州市", + "id": "420700" + }, + { + "province": "湖北省", + "name": "荆门市", + "id": "420800" + }, + { + "province": "湖北省", + "name": "孝感市", + "id": "420900" + }, + { + "province": "湖北省", + "name": "荆州市", + "id": "421000" + }, + { + "province": "湖北省", + "name": "黄冈市", + "id": "421100" + }, + { + "province": "湖北省", + "name": "咸宁市", + "id": "421200" + }, + { + "province": "湖北省", + "name": "随州市", + "id": "421300" + }, + { + "province": "湖北省", + "name": "恩施土家族苗族自治州", + "id": "422800" + }, + { + "province": "湖北省", + "name": "省直辖县级行政区划", + "id": "429000" + } + ], + "430000": [ + { + "province": "湖南省", + "name": "长沙市", + "id": "430100" + }, + { + "province": "湖南省", + "name": "株洲市", + "id": "430200" + }, + { + "province": "湖南省", + "name": "湘潭市", + "id": "430300" + }, + { + "province": "湖南省", + "name": "衡阳市", + "id": "430400" + }, + { + "province": "湖南省", + "name": "邵阳市", + "id": "430500" + }, + { + "province": "湖南省", + "name": "岳阳市", + "id": "430600" + }, + { + "province": "湖南省", + "name": "常德市", + "id": "430700" + }, + { + "province": "湖南省", + "name": "张家界市", + "id": "430800" + }, + { + "province": "湖南省", + "name": "益阳市", + "id": "430900" + }, + { + "province": "湖南省", + "name": "郴州市", + "id": "431000" + }, + { + "province": "湖南省", + "name": "永州市", + "id": "431100" + }, + { + "province": "湖南省", + "name": "怀化市", + "id": "431200" + }, + { + "province": "湖南省", + "name": "娄底市", + "id": "431300" + }, + { + "province": "湖南省", + "name": "湘西土家族苗族自治州", + "id": "433100" + } + ], + "440000": [ + { + "province": "广东省", + "name": "广州市", + "id": "440100" + }, + { + "province": "广东省", + "name": "韶关市", + "id": "440200" + }, + { + "province": "广东省", + "name": "深圳市", + "id": "440300" + }, + { + "province": "广东省", + "name": "珠海市", + "id": "440400" + }, + { + "province": "广东省", + "name": "汕头市", + "id": "440500" + }, + { + "province": "广东省", + "name": "佛山市", + "id": "440600" + }, + { + "province": "广东省", + "name": "江门市", + "id": "440700" + }, + { + "province": "广东省", + "name": "湛江市", + "id": "440800" + }, + { + "province": "广东省", + "name": "茂名市", + "id": "440900" + }, + { + "province": "广东省", + "name": "肇庆市", + "id": "441200" + }, + { + "province": "广东省", + "name": "惠州市", + "id": "441300" + }, + { + "province": "广东省", + "name": "梅州市", + "id": "441400" + }, + { + "province": "广东省", + "name": "汕尾市", + "id": "441500" + }, + { + "province": "广东省", + "name": "河源市", + "id": "441600" + }, + { + "province": "广东省", + "name": "阳江市", + "id": "441700" + }, + { + "province": "广东省", + "name": "清远市", + "id": "441800" + }, + { + "province": "广东省", + "name": "东莞市", + "id": "441900" + }, + { + "province": "广东省", + "name": "中山市", + "id": "442000" + }, + { + "province": "广东省", + "name": "潮州市", + "id": "445100" + }, + { + "province": "广东省", + "name": "揭阳市", + "id": "445200" + }, + { + "province": "广东省", + "name": "云浮市", + "id": "445300" + } + ], + "450000": [ + { + "province": "广西壮族自治区", + "name": "南宁市", + "id": "450100" + }, + { + "province": "广西壮族自治区", + "name": "柳州市", + "id": "450200" + }, + { + "province": "广西壮族自治区", + "name": "桂林市", + "id": "450300" + }, + { + "province": "广西壮族自治区", + "name": "梧州市", + "id": "450400" + }, + { + "province": "广西壮族自治区", + "name": "北海市", + "id": "450500" + }, + { + "province": "广西壮族自治区", + "name": "防城港市", + "id": "450600" + }, + { + "province": "广西壮族自治区", + "name": "钦州市", + "id": "450700" + }, + { + "province": "广西壮族自治区", + "name": "贵港市", + "id": "450800" + }, + { + "province": "广西壮族自治区", + "name": "玉林市", + "id": "450900" + }, + { + "province": "广西壮族自治区", + "name": "百色市", + "id": "451000" + }, + { + "province": "广西壮族自治区", + "name": "贺州市", + "id": "451100" + }, + { + "province": "广西壮族自治区", + "name": "河池市", + "id": "451200" + }, + { + "province": "广西壮族自治区", + "name": "来宾市", + "id": "451300" + }, + { + "province": "广西壮族自治区", + "name": "崇左市", + "id": "451400" + } + ], + "460000": [ + { + "province": "海南省", + "name": "海口市", + "id": "460100" + }, + { + "province": "海南省", + "name": "三亚市", + "id": "460200" + }, + { + "province": "海南省", + "name": "三沙市", + "id": "460300" + }, + { + "province": "海南省", + "name": "儋州市", + "id": "460400" + }, + { + "province": "海南省", + "name": "省直辖县级行政区划", + "id": "469000" + } + ], + "500000": [ + { + "province": "重庆市", + "name": "市辖区", + "id": "500100" + }, + { + "province": "重庆市", + "name": "县", + "id": "500200" + } + ], + "510000": [ + { + "province": "四川省", + "name": "成都市", + "id": "510100" + }, + { + "province": "四川省", + "name": "自贡市", + "id": "510300" + }, + { + "province": "四川省", + "name": "攀枝花市", + "id": "510400" + }, + { + "province": "四川省", + "name": "泸州市", + "id": "510500" + }, + { + "province": "四川省", + "name": "德阳市", + "id": "510600" + }, + { + "province": "四川省", + "name": "绵阳市", + "id": "510700" + }, + { + "province": "四川省", + "name": "广元市", + "id": "510800" + }, + { + "province": "四川省", + "name": "遂宁市", + "id": "510900" + }, + { + "province": "四川省", + "name": "内江市", + "id": "511000" + }, + { + "province": "四川省", + "name": "乐山市", + "id": "511100" + }, + { + "province": "四川省", + "name": "南充市", + "id": "511300" + }, + { + "province": "四川省", + "name": "眉山市", + "id": "511400" + }, + { + "province": "四川省", + "name": "宜宾市", + "id": "511500" + }, + { + "province": "四川省", + "name": "广安市", + "id": "511600" + }, + { + "province": "四川省", + "name": "达州市", + "id": "511700" + }, + { + "province": "四川省", + "name": "雅安市", + "id": "511800" + }, + { + "province": "四川省", + "name": "巴中市", + "id": "511900" + }, + { + "province": "四川省", + "name": "资阳市", + "id": "512000" + }, + { + "province": "四川省", + "name": "阿坝藏族羌族自治州", + "id": "513200" + }, + { + "province": "四川省", + "name": "甘孜藏族自治州", + "id": "513300" + }, + { + "province": "四川省", + "name": "凉山彝族自治州", + "id": "513400" + } + ], + "520000": [ + { + "province": "贵州省", + "name": "贵阳市", + "id": "520100" + }, + { + "province": "贵州省", + "name": "六盘水市", + "id": "520200" + }, + { + "province": "贵州省", + "name": "遵义市", + "id": "520300" + }, + { + "province": "贵州省", + "name": "安顺市", + "id": "520400" + }, + { + "province": "贵州省", + "name": "毕节市", + "id": "520500" + }, + { + "province": "贵州省", + "name": "铜仁市", + "id": "520600" + }, + { + "province": "贵州省", + "name": "黔西南布依族苗族自治州", + "id": "522300" + }, + { + "province": "贵州省", + "name": "黔东南苗族侗族自治州", + "id": "522600" + }, + { + "province": "贵州省", + "name": "黔南布依族苗族自治州", + "id": "522700" + } + ], + "530000": [ + { + "province": "云南省", + "name": "昆明市", + "id": "530100" + }, + { + "province": "云南省", + "name": "曲靖市", + "id": "530300" + }, + { + "province": "云南省", + "name": "玉溪市", + "id": "530400" + }, + { + "province": "云南省", + "name": "保山市", + "id": "530500" + }, + { + "province": "云南省", + "name": "昭通市", + "id": "530600" + }, + { + "province": "云南省", + "name": "丽江市", + "id": "530700" + }, + { + "province": "云南省", + "name": "普洱市", + "id": "530800" + }, + { + "province": "云南省", + "name": "临沧市", + "id": "530900" + }, + { + "province": "云南省", + "name": "楚雄彝族自治州", + "id": "532300" + }, + { + "province": "云南省", + "name": "红河哈尼族彝族自治州", + "id": "532500" + }, + { + "province": "云南省", + "name": "文山壮族苗族自治州", + "id": "532600" + }, + { + "province": "云南省", + "name": "西双版纳傣族自治州", + "id": "532800" + }, + { + "province": "云南省", + "name": "大理白族自治州", + "id": "532900" + }, + { + "province": "云南省", + "name": "德宏傣族景颇族自治州", + "id": "533100" + }, + { + "province": "云南省", + "name": "怒江傈僳族自治州", + "id": "533300" + }, + { + "province": "云南省", + "name": "迪庆藏族自治州", + "id": "533400" + } + ], + "540000": [ + { + "province": "西藏自治区", + "name": "拉萨市", + "id": "540100" + }, + { + "province": "西藏自治区", + "name": "日喀则市", + "id": "540200" + }, + { + "province": "西藏自治区", + "name": "昌都市", + "id": "540300" + }, + { + "province": "西藏自治区", + "name": "林芝市", + "id": "540400" + }, + { + "province": "西藏自治区", + "name": "山南市", + "id": "540500" + }, + { + "province": "西藏自治区", + "name": "那曲地区", + "id": "542400" + }, + { + "province": "西藏自治区", + "name": "阿里地区", + "id": "542500" + } + ], + "610000": [ + { + "province": "陕西省", + "name": "西安市", + "id": "610100" + }, + { + "province": "陕西省", + "name": "铜川市", + "id": "610200" + }, + { + "province": "陕西省", + "name": "宝鸡市", + "id": "610300" + }, + { + "province": "陕西省", + "name": "咸阳市", + "id": "610400" + }, + { + "province": "陕西省", + "name": "渭南市", + "id": "610500" + }, + { + "province": "陕西省", + "name": "延安市", + "id": "610600" + }, + { + "province": "陕西省", + "name": "汉中市", + "id": "610700" + }, + { + "province": "陕西省", + "name": "榆林市", + "id": "610800" + }, + { + "province": "陕西省", + "name": "安康市", + "id": "610900" + }, + { + "province": "陕西省", + "name": "商洛市", + "id": "611000" + } + ], + "620000": [ + { + "province": "甘肃省", + "name": "兰州市", + "id": "620100" + }, + { + "province": "甘肃省", + "name": "嘉峪关市", + "id": "620200" + }, + { + "province": "甘肃省", + "name": "金昌市", + "id": "620300" + }, + { + "province": "甘肃省", + "name": "白银市", + "id": "620400" + }, + { + "province": "甘肃省", + "name": "天水市", + "id": "620500" + }, + { + "province": "甘肃省", + "name": "武威市", + "id": "620600" + }, + { + "province": "甘肃省", + "name": "张掖市", + "id": "620700" + }, + { + "province": "甘肃省", + "name": "平凉市", + "id": "620800" + }, + { + "province": "甘肃省", + "name": "酒泉市", + "id": "620900" + }, + { + "province": "甘肃省", + "name": "庆阳市", + "id": "621000" + }, + { + "province": "甘肃省", + "name": "定西市", + "id": "621100" + }, + { + "province": "甘肃省", + "name": "陇南市", + "id": "621200" + }, + { + "province": "甘肃省", + "name": "临夏回族自治州", + "id": "622900" + }, + { + "province": "甘肃省", + "name": "甘南藏族自治州", + "id": "623000" + } + ], + "630000": [ + { + "province": "青海省", + "name": "西宁市", + "id": "630100" + }, + { + "province": "青海省", + "name": "海东市", + "id": "630200" + }, + { + "province": "青海省", + "name": "海北藏族自治州", + "id": "632200" + }, + { + "province": "青海省", + "name": "黄南藏族自治州", + "id": "632300" + }, + { + "province": "青海省", + "name": "海南藏族自治州", + "id": "632500" + }, + { + "province": "青海省", + "name": "果洛藏族自治州", + "id": "632600" + }, + { + "province": "青海省", + "name": "玉树藏族自治州", + "id": "632700" + }, + { + "province": "青海省", + "name": "海西蒙古族藏族自治州", + "id": "632800" + } + ], + "640000": [ + { + "province": "宁夏回族自治区", + "name": "银川市", + "id": "640100" + }, + { + "province": "宁夏回族自治区", + "name": "石嘴山市", + "id": "640200" + }, + { + "province": "宁夏回族自治区", + "name": "吴忠市", + "id": "640300" + }, + { + "province": "宁夏回族自治区", + "name": "固原市", + "id": "640400" + }, + { + "province": "宁夏回族自治区", + "name": "中卫市", + "id": "640500" + } + ], + "650000": [ + { + "province": "新疆维吾尔自治区", + "name": "乌鲁木齐市", + "id": "650100" + }, + { + "province": "新疆维吾尔自治区", + "name": "克拉玛依市", + "id": "650200" + }, + { + "province": "新疆维吾尔自治区", + "name": "吐鲁番市", + "id": "650400" + }, + { + "province": "新疆维吾尔自治区", + "name": "哈密市", + "id": "650500" + }, + { + "province": "新疆维吾尔自治区", + "name": "昌吉回族自治州", + "id": "652300" + }, + { + "province": "新疆维吾尔自治区", + "name": "博尔塔拉蒙古自治州", + "id": "652700" + }, + { + "province": "新疆维吾尔自治区", + "name": "巴音郭楞蒙古自治州", + "id": "652800" + }, + { + "province": "新疆维吾尔自治区", + "name": "阿克苏地区", + "id": "652900" + }, + { + "province": "新疆维吾尔自治区", + "name": "克孜勒苏柯尔克孜自治州", + "id": "653000" + }, + { + "province": "新疆维吾尔自治区", + "name": "喀什地区", + "id": "653100" + }, + { + "province": "新疆维吾尔自治区", + "name": "和田地区", + "id": "653200" + }, + { + "province": "新疆维吾尔自治区", + "name": "伊犁哈萨克自治州", + "id": "654000" + }, + { + "province": "新疆维吾尔自治区", + "name": "塔城地区", + "id": "654200" + }, + { + "province": "新疆维吾尔自治区", + "name": "阿勒泰地区", + "id": "654300" + }, + { + "province": "新疆维吾尔自治区", + "name": "自治区直辖县级行政区划", + "id": "659000" + } + ] +} diff --git a/antdsp-admin/src/main/web/mock/geographic/province.json b/antdsp-admin/src/main/web/mock/geographic/province.json new file mode 100644 index 0000000..910c83f --- /dev/null +++ b/antdsp-admin/src/main/web/mock/geographic/province.json @@ -0,0 +1,138 @@ +[ + { + "name": "北京市", + "id": "110000" + }, + { + "name": "天津市", + "id": "120000" + }, + { + "name": "河北省", + "id": "130000" + }, + { + "name": "山西省", + "id": "140000" + }, + { + "name": "内蒙古自治区", + "id": "150000" + }, + { + "name": "辽宁省", + "id": "210000" + }, + { + "name": "吉林省", + "id": "220000" + }, + { + "name": "黑龙江省", + "id": "230000" + }, + { + "name": "上海市", + "id": "310000" + }, + { + "name": "江苏省", + "id": "320000" + }, + { + "name": "浙江省", + "id": "330000" + }, + { + "name": "安徽省", + "id": "340000" + }, + { + "name": "福建省", + "id": "350000" + }, + { + "name": "江西省", + "id": "360000" + }, + { + "name": "山东省", + "id": "370000" + }, + { + "name": "河南省", + "id": "410000" + }, + { + "name": "湖北省", + "id": "420000" + }, + { + "name": "湖南省", + "id": "430000" + }, + { + "name": "广东省", + "id": "440000" + }, + { + "name": "广西壮族自治区", + "id": "450000" + }, + { + "name": "海南省", + "id": "460000" + }, + { + "name": "重庆市", + "id": "500000" + }, + { + "name": "四川省", + "id": "510000" + }, + { + "name": "贵州省", + "id": "520000" + }, + { + "name": "云南省", + "id": "530000" + }, + { + "name": "西藏自治区", + "id": "540000" + }, + { + "name": "陕西省", + "id": "610000" + }, + { + "name": "甘肃省", + "id": "620000" + }, + { + "name": "青海省", + "id": "630000" + }, + { + "name": "宁夏回族自治区", + "id": "640000" + }, + { + "name": "新疆维吾尔自治区", + "id": "650000" + }, + { + "name": "台湾省", + "id": "710000" + }, + { + "name": "香港特别行政区", + "id": "810000" + }, + { + "name": "澳门特别行政区", + "id": "820000" + } +] diff --git a/antdsp-admin/src/main/web/mock/notices.js b/antdsp-admin/src/main/web/mock/notices.js new file mode 100644 index 0000000..505088e --- /dev/null +++ b/antdsp-admin/src/main/web/mock/notices.js @@ -0,0 +1,102 @@ +const getNotices = (req, res) => + res.json([ + { + id: '000000001', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png', + title: '你收到了 14 份新周报', + datetime: '2017-08-09', + type: 'notification', + }, + { + id: '000000002', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png', + title: '你推荐的 曲妮妮 已通过第三轮面试', + datetime: '2017-08-08', + type: 'notification', + }, + { + id: '000000003', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png', + title: '这种模板可以区分多种通知类型', + datetime: '2017-08-07', + read: true, + type: 'notification', + }, + { + id: '000000004', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png', + title: '左侧图标用于区分不同的类型', + datetime: '2017-08-07', + type: 'notification', + }, + { + id: '000000005', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png', + title: '内容不要超过两行字,超出时自动截断', + datetime: '2017-08-07', + type: 'notification', + }, + { + id: '000000006', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg', + title: '曲丽丽 评论了你', + description: '描述信息描述信息描述信息', + datetime: '2017-08-07', + type: 'message', + clickClose: true, + }, + { + id: '000000007', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg', + title: '朱偏右 回复了你', + description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像', + datetime: '2017-08-07', + type: 'message', + clickClose: true, + }, + { + id: '000000008', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg', + title: '标题', + description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像', + datetime: '2017-08-07', + type: 'message', + clickClose: true, + }, + { + id: '000000009', + title: '任务名称', + description: '任务需要在 2017-01-12 20:00 前启动', + extra: '未开始', + status: 'todo', + type: 'event', + }, + { + id: '000000010', + title: '第三方紧急代码变更', + description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务', + extra: '马上到期', + status: 'urgent', + type: 'event', + }, + { + id: '000000011', + title: '信息安全考试', + description: '指派竹尔于 2017-01-09 前完成更新并发布', + extra: '已耗时 8 天', + status: 'doing', + type: 'event', + }, + { + id: '000000012', + title: 'ABCD 版本发布', + description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务', + extra: '进行中', + status: 'processing', + type: 'event', + }, + ]); + +export default { + 'GET /api/notices': getNotices, +}; diff --git a/antdsp-admin/src/main/web/mock/profile.js b/antdsp-admin/src/main/web/mock/profile.js new file mode 100644 index 0000000..228d686 --- /dev/null +++ b/antdsp-admin/src/main/web/mock/profile.js @@ -0,0 +1,177 @@ +import mockjs from 'mockjs'; + +const basicGoods = [ + { + id: '1234561', + name: '矿泉水 550ml', + barcode: '12421432143214321', + price: '2.00', + num: '1', + amount: '2.00', + }, + { + id: '1234562', + name: '凉茶 300ml', + barcode: '12421432143214322', + price: '3.00', + num: '2', + amount: '6.00', + }, + { + id: '1234563', + name: '好吃的薯片', + barcode: '12421432143214323', + price: '7.00', + num: '4', + amount: '28.00', + }, + { + id: '1234564', + name: '特别好吃的蛋卷', + barcode: '12421432143214324', + price: '8.50', + num: '3', + amount: '25.50', + }, +]; + +const basicProgress = [ + { + key: '1', + time: '2017-10-01 14:10', + rate: '联系客户', + status: 'processing', + operator: '取货员 ID1234', + cost: '5mins', + }, + { + key: '2', + time: '2017-10-01 14:05', + rate: '取货员出发', + status: 'success', + operator: '取货员 ID1234', + cost: '1h', + }, + { + key: '3', + time: '2017-10-01 13:05', + rate: '取货员接单', + status: 'success', + operator: '取货员 ID1234', + cost: '5mins', + }, + { + key: '4', + time: '2017-10-01 13:00', + rate: '申请审批通过', + status: 'success', + operator: '系统', + cost: '1h', + }, + { + key: '5', + time: '2017-10-01 12:00', + rate: '发起退货申请', + status: 'success', + operator: '用户', + cost: '5mins', + }, +]; + +const advancedOperation1 = [ + { + key: 'op1', + type: '订购关系生效', + name: '曲丽丽', + status: 'agree', + updatedAt: '2017-10-03 19:23:12', + memo: '-', + }, + { + key: 'op2', + type: '财务复审', + name: '付小小', + status: 'reject', + updatedAt: '2017-10-03 19:23:12', + memo: '不通过原因', + }, + { + key: 'op3', + type: '部门初审', + name: '周毛毛', + status: 'agree', + updatedAt: '2017-10-03 19:23:12', + memo: '-', + }, + { + key: 'op4', + type: '提交订单', + name: '林东东', + status: 'agree', + updatedAt: '2017-10-03 19:23:12', + memo: '很棒', + }, + { + key: 'op5', + type: '创建订单', + name: '汗牙牙', + status: 'agree', + updatedAt: '2017-10-03 19:23:12', + memo: '-', + }, +]; + +const advancedOperation2 = [ + { + key: 'op1', + type: '订购关系生效', + name: '曲丽丽', + status: 'agree', + updatedAt: '2017-10-03 19:23:12', + memo: '-', + }, +]; + +const advancedOperation3 = [ + { + key: 'op1', + type: '创建订单', + name: '汗牙牙', + status: 'agree', + updatedAt: '2017-10-03 19:23:12', + memo: '-', + }, +]; +const getProfileAdvancedData = { + advancedOperation1, + advancedOperation2, + advancedOperation3, +}; + +const { Random } = mockjs; + +export default { + 'GET /api/profile/advanced': getProfileAdvancedData, + 'GET /api/profile/basic': (req, res) => { + const { id } = req.query; + const application = { + id, + status: '已取货', + orderNo: Random.id(), + childOrderNo: Random.id(), + }; + const userInfo = { + name: Random.cname(), + tel: '18100000000', + delivery: '菜鸟物流', + addr: '浙江省杭州市西湖区万塘路18号', + remark: '备注', + }; + res.json({ + userInfo, + application, + basicGoods, + basicProgress, + }); + }, +}; diff --git a/antdsp-admin/src/main/web/mock/rule.js b/antdsp-admin/src/main/web/mock/rule.js new file mode 100644 index 0000000..87d235b --- /dev/null +++ b/antdsp-admin/src/main/web/mock/rule.js @@ -0,0 +1,131 @@ +import { parse } from 'url'; + +// mock tableListDataSource +let tableListDataSource = []; +for (let i = 0; i < 46; i += 1) { + tableListDataSource.push({ + key: i, + disabled: i % 6 === 0, + href: 'https://ant.design', + avatar: [ + 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', + 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', + ][i % 2], + name: `TradeCode ${i}`, + title: `一个任务名称 ${i}`, + owner: '曲丽丽', + desc: '这是一段描述', + callNo: Math.floor(Math.random() * 1000), + status: Math.floor(Math.random() * 10) % 4, + updatedAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`), + createdAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`), + progress: Math.ceil(Math.random() * 100), + }); +} + +function getRule(req, res, u) { + let url = u; + if (!url || Object.prototype.toString.call(url) !== '[object String]') { + url = req.url; // eslint-disable-line + } + + const params = parse(url, true).query; + + let dataSource = tableListDataSource; + + if (params.sorter) { + const s = params.sorter.split('_'); + dataSource = dataSource.sort((prev, next) => { + if (s[1] === 'descend') { + return next[s[0]] - prev[s[0]]; + } + return prev[s[0]] - next[s[0]]; + }); + } + + if (params.status) { + const status = params.status.split(','); + let filterDataSource = []; + status.forEach(s => { + filterDataSource = filterDataSource.concat( + dataSource.filter(data => parseInt(data.status, 10) === parseInt(s[0], 10)) + ); + }); + dataSource = filterDataSource; + } + + if (params.name) { + dataSource = dataSource.filter(data => data.name.indexOf(params.name) > -1); + } + + let pageSize = 10; + if (params.pageSize) { + pageSize = params.pageSize * 1; + } + + const result = { + list: dataSource, + pagination: { + total: dataSource.length, + pageSize, + current: parseInt(params.currentPage, 10) || 1, + }, + }; + + return res.json(result); +} + +function postRule(req, res, u, b) { + let url = u; + if (!url || Object.prototype.toString.call(url) !== '[object String]') { + url = req.url; // eslint-disable-line + } + + const body = (b && b.body) || req.body; + const { method, name, desc, key } = body; + + switch (method) { + /* eslint no-case-declarations:0 */ + case 'delete': + tableListDataSource = tableListDataSource.filter(item => key.indexOf(item.key) === -1); + break; + case 'post': + const i = Math.ceil(Math.random() * 10000); + tableListDataSource.unshift({ + key: i, + href: 'https://ant.design', + avatar: [ + 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', + 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png', + ][i % 2], + name: `TradeCode ${i}`, + title: `一个任务名称 ${i}`, + owner: '曲丽丽', + desc, + callNo: Math.floor(Math.random() * 1000), + status: Math.floor(Math.random() * 10) % 2, + updatedAt: new Date(), + createdAt: new Date(), + progress: Math.ceil(Math.random() * 100), + }); + break; + case 'update': + tableListDataSource = tableListDataSource.map(item => { + if (item.key === key) { + Object.assign(item, { desc, name }); + return item; + } + return item; + }); + break; + default: + break; + } + + return getRule(req, res, u); +} + +export default { + 'GET /api/rule': getRule, + 'POST /api/rule': postRule, +}; diff --git a/antdsp-admin/src/main/web/mock/user.js b/antdsp-admin/src/main/web/mock/user.js new file mode 100644 index 0000000..2fb6c60 --- /dev/null +++ b/antdsp-admin/src/main/web/mock/user.js @@ -0,0 +1,138 @@ +// 代码中会兼容本地 service mock 以及部署站点的静态数据 +export default { + // 支持值为 Object 和 Array + 'GET /api/currentUser': { + name: 'Serati Ma', + avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png', + userid: '00000001', + email: 'antdesign@alipay.com', + signature: '海纳百川,有容乃大', + title: '交互专家', + group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED', + tags: [ + { + key: '0', + label: '很有想法的', + }, + { + key: '1', + label: '专注设计', + }, + { + key: '2', + label: '辣~', + }, + { + key: '3', + label: '大长腿', + }, + { + key: '4', + label: '川妹子', + }, + { + key: '5', + label: '海纳百川', + }, + ], + notifyCount: 12, + unreadCount: 11, + country: 'China', + geographic: { + province: { + label: '浙江省', + key: '330000', + }, + city: { + label: '杭州市', + key: '330100', + }, + }, + address: '西湖区工专路 77 号', + phone: '0752-268888888', + }, + // GET POST 可省略 + 'GET /api/users': [ + { + key: '1', + name: 'John Brown', + age: 32, + address: 'New York No. 1 Lake Park', + }, + { + key: '2', + name: 'Jim Green', + age: 42, + address: 'London No. 1 Lake Park', + }, + { + key: '3', + name: 'Joe Black', + age: 32, + address: 'Sidney No. 1 Lake Park', + }, + ], + 'POST /api/login/account': (req, res) => { + const { password, userName, type } = req.body; + if (password === 'ant.design' && userName === 'admin') { + res.send({ + status: 'ok', + type, + currentAuthority: 'admin', + }); + return; + } + if (password === 'ant.design' && userName === 'user') { + res.send({ + status: 'ok', + type, + currentAuthority: 'user', + }); + return; + } + res.send({ + status: 'error', + type, + currentAuthority: 'guest', + }); + }, + 'POST /api/register': (req, res) => { + res.send({ status: 'ok', currentAuthority: 'user' }); + }, + 'GET /api/500': (req, res) => { + res.status(500).send({ + timestamp: 1513932555104, + status: 500, + error: 'error', + message: 'error', + path: '/base/category/list', + }); + }, + 'GET /api/404': (req, res) => { + res.status(404).send({ + timestamp: 1513932643431, + status: 404, + error: 'Not Found', + message: 'No message available', + path: '/base/category/list/2121212', + }); + }, + 'GET /api/403': (req, res) => { + res.status(403).send({ + timestamp: 1513932555104, + status: 403, + error: 'Unauthorized', + message: 'Unauthorized', + path: '/base/category/list', + }); + }, + 'GET /api/401': (req, res) => { + res.status(401).send({ + timestamp: 1513932555104, + status: 401, + error: 'Unauthorized', + message: 'Unauthorized', + path: '/base/category/list', + }); + }, +}; diff --git a/antdsp-admin/src/main/web/netlify.toml b/antdsp-admin/src/main/web/netlify.toml new file mode 100644 index 0000000..9d3438c --- /dev/null +++ b/antdsp-admin/src/main/web/netlify.toml @@ -0,0 +1,16 @@ +[build] + functions = "./functions" + +[[redirects]] + from = "/api/*" + to = "/.netlify/functions/api/:splat" + status = 200 + force = true + [redirects.headers] + X-From = "Netlify" + X-Api-Key = "some-api-key-string" + +[[redirects]] + from = "/*" + to = "/index.html" + status = 200 \ No newline at end of file diff --git a/antdsp-admin/src/main/web/package.json b/antdsp-admin/src/main/web/package.json new file mode 100644 index 0000000..8b71bcb --- /dev/null +++ b/antdsp-admin/src/main/web/package.json @@ -0,0 +1,142 @@ +{ + "name": "ant-design-pro", + "version": "2.3.1", + "private": true, + "description": "An out-of-box UI solution for enterprise applications", + "scripts": { + "analyze": "cross-env ANALYZE=1 umi build", + "build": "umi build", + "docker-hub:build": "docker build -f Dockerfile.hub -t ant-design-pro ./", + "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build", + "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up", + "docker:build": "docker-compose -f ./docker/docker-compose.dev.yml build", + "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up", + "docker:push": "npm run docker-hub:build && npm run docker:tag && docker push antdesign/ant-design-pro", + "docker:tag": "docker tag ant-design-pro antdesign/ant-design-pro", + "functions:build": "npm run generateMock && netlify-lambda build ./lambda", + "functions:run": "npm run generateMock && cross-env NODE_ENV=dev netlify-lambda serve ./lambda", + "generateMock": "node ./scripts/generateMock", + "lint": "eslint --ext .js src mock tests && npm run lint:style && npm run lint:prettier", + "lint-staged": "lint-staged", + "lint-staged:js": "eslint --ext .js", + "lint:fix": "eslint --fix --ext .js src mock tests && stylelint --fix 'src/**/*.less' --syntax less", + "lint:prettier": "check-prettier lint", + "lint:style": "stylelint 'src/**/*.less' --syntax less", + "prettier": "node ./scripts/prettier.js", + "site": "umi build && npm run functions:build", + "start": "cross-env ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION=site umi dev", + "start:no-mock": "cross-env MOCK=none umi dev", + "test": "umi test", + "test:all": "node ./tests/run-tests.js", + "test:component": "umi test ./src/components", + "tslint": "npm run tslint:fix", + "tslint:fix": "tslint --fix 'src/**/*.ts*'" + }, + "husky": { + "hooks": { + "pre-commit": "npm run lint-staged" + } + }, + "lint-staged": { + "**/*.less": "stylelint --syntax less", + "**/*.{js,jsx}": "npm run lint-staged:js", + "**/*.{js,ts,tsx,json,jsx,less}": [ + "node ./scripts/lint-prettier.js", + "git add" + ] + }, + "browserslist": [ + "> 1%", + "last 2 versions", + "not ie <= 10" + ], + "dependencies": { + "@antv/data-set": "^0.10.1", + "antd": "^3.16.1", + "bizcharts": "^3.4.3", + "bizcharts-plugin-slider": "^2.1.1-beta.1", + "classnames": "^2.2.6", + "dva": "^2.4.1", + "enquire-js": "^0.2.1", + "express": "^4.16.4", + "gg-editor": "^2.0.2", + "lodash": "^4.17.11", + "lodash-decorators": "^6.0.1", + "memoize-one": "^5.0.0", + "moment": "^2.24.0", + "netlify-lambda": "^1.4.3", + "numeral": "^2.0.6", + "nzh": "^1.0.4", + "omit.js": "^1.0.0", + "path-to-regexp": "^3.0.0", + "prop-types": "^15.6.2", + "qs": "^6.6.0", + "rc-animate": "^2.6.0", + "react": "^16.7.0", + "react-container-query": "^0.11.0", + "react-copy-to-clipboard": "^5.0.1", + "react-document-title": "^2.0.3", + "react-dom": "^16.7.0", + "react-fittext": "^1.0.0", + "react-media": "^1.9.2", + "umi": "^2.4.4", + "umi-plugin-react": "^1.7.2", + "umi-request": "^1.0.5" + }, + "devDependencies": { + "@types/history": "^4.7.2", + "@types/react": "^16.8.1", + "@types/react-dom": "^16.0.11", + "antd-pro-merge-less": "^1.0.0", + "antd-theme-webpack-plugin": "^1.2.0", + "babel-eslint": "^10.0.1", + "chalk": "^2.4.2", + "check-prettier": "^1.0.1", + "cross-env": "^5.2.0", + "cross-port-killer": "^1.0.1", + "enzyme": "^3.9.0", + "eslint": "^5.13.0", + "eslint-config-airbnb": "^17.1.0", + "eslint-config-prettier": "^4.1.0", + "eslint-plugin-babel": "^5.3.0", + "eslint-plugin-compat": "^2.6.3", + "eslint-plugin-import": "^2.16.0", + "eslint-plugin-jsx-a11y": "^6.2.1", + "eslint-plugin-markdown": "^1.0.0", + "eslint-plugin-react": "^7.12.4", + "gh-pages": "^2.0.1", + "husky": "^1.3.1", + "jest-puppeteer": "^4.1.0", + "less": "^3.9.0", + "lint-staged": "^8.1.1", + "merge-umi-mock-data": "^1.0.4", + "mockjs": "^1.0.1-beta3", + "prettier": "^1.16.4", + "serverless-http": "^1.9.1", + "slash2": "^2.0.0", + "stylelint": "^9.10.1", + "stylelint-config-css-modules": "^1.3.0", + "stylelint-config-prettier": "^5.0.0", + "stylelint-config-rational-order": "^0.1.0", + "stylelint-config-standard": "^18.2.0", + "stylelint-declaration-block-no-ignored-properties": "^1.1.0", + "stylelint-order": "^2.0.0", + "tslint": "^5.12.1", + "tslint-config-prettier": "^1.17.0", + "tslint-react": "^3.6.0", + "umi-plugin-ga": "^1.1.3" + }, + "optionalDependencies": { + "puppeteer": "^1.12.1" + }, + "engines": { + "node": ">=8.0.0" + }, + "checkFiles": [ + "src/**/*.js*", + "src/**/*.ts*", + "src/**/*.less", + "config/**/*.js*", + "scripts/**/*.js" + ] +} diff --git a/antdsp-admin/src/main/web/public/favicon.png b/antdsp-admin/src/main/web/public/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..ece59ce54690c0e1c1e6984ec9dd815645ab4cb8 GIT binary patch literal 2849 zcmb7FX*iS(7k=h>$uf~G>dij(jE0DiM#wVAzVDGWOC-Co6obk>#xllELYBl3BU{2) zvy<#gmb_V#<(v2C_v8EVoj>=v@9W&xIX}+14n|K`oq_&udH?_zG&NKW002TsApq@P z6mWlQW<&uhXJs8_0H}TqJ+Y^zaNdU+208!`Bm@BHXaG2-Na!^Hc!~gk4Lbmk&j0`p z?`)#JA^?E>dfG;6027bZBQIQT5jLmbb$WKptF-W#SI@#@93T6mOzb4@XmJSM1etly z&(HVw4|@6rvhqqE`-jP@Jot-+Z+mCA{M~yte#G(daYaqNj+p}$EC2U}CD$jxH0**) z%d5`bf!$yF;qv$Y{P`0U83$qFxp+-Izkdr$D>r^@)3b2e z*!-dTz(T{&#>~MZFap!j-FtX=*h?N-SX`!NgWbBPyS2S@N7IPzijb4%vz68Lx7GFU z8$ZS;<4o+_ip$^8UlpF7{dP_C*2L6|ft7P`R6Gl>gwRdoZ8d#qq_%*h67+A841D3Q zU;AfgXHzqCg=JN`<`32MESp-}XXfUQj*f^epPq(3zo%oiyZiG~XV2KgR9(YIO(R=l zTi4FdeQWC*ZoVPpp^=l56NI8>-@tHX?T0Hu(vg@XR=yjVgyMQ)%lPE9=d-bcA*Oxa{bz-tA%PVVti^$M&2)#_rlv2{#{INARzrYJuP}VjxvT<48*ks~{ zN5m$I-cq^5EsjK))_!Pym6m1x@bN>Br*}~%BVQ*<-d6L#<@fgf35kwRr}U_(X>IR% zo{(ba>MMU=-^Rt~U0vhi(u$0-PC^QgclXEEwxWiiR{%OOJ%?RDicnO3T~5`~ z$rBy(I`(yXUh&)0)6>zh$;s(iEn_ZI{evSzBV+oO zk6?&90q9t3XKy)GJzLi&{$Vew>KYoFN%n4jSB0g2{@hz#TNjbJS5w~<9iOaiYOii! z{jsex^m&4kmNBQ8?9IEVqBm7J1*O&Ri7LA07LJ||EF9Ca^87-gJ)VYs=^s2eI84pV zBei$C_ypb8w=%vUrc2p)hyzMpmEoYyexE{U{4{mcXcnN<;B8rlP52N+(brT}HVT;9 z%KmL@WPByY_HxG{YNLTEpZ#KFlcq=#Ds@33b_HKbNLh%?&%0n2UE1hiuo8DaBNG>A znV*5nOiOW8f0OCoWBq>u!71bR zrEGcGdb)%RYk9hP)d;DhCK&d5%xiGa!2#kV?PgViDWgsu9zCxH451=L=61fmP`y-k z_$JO0ov(Nn-9s&++-5@2*v^?!pn4Y1Gp*3WZ!i?uzCuR=>FVJR(YjU(b(tnFfvE?N zI0$|SJo;6RSU`=hUBkE`GYiBzL6}f(ZL~Bpr+@FSfea*4be4F?M7!q72vN-&*aP|R zY4fAs4mC%t_EGTcEqYZ4h7Q^{k?y>v3w*VUK_&!JnH_tB$C>KD{vy>;X(f3ooJ3NN zk`d2`SEt9IkSe;!Y$7ovYWk9B{A(WhAJjBi(2AHpqnwgbZlgKl9!5JuJ`cOPlsG~0 z8(JKyi(*?vf(f~LzdvCx#+90x0%s$Pad?l~flvNF!`Atjkk%Q{VsCI8@m|qaQKU~P zr^9(HrQ{_WnfT{d*0vkuW*vP-k5wW+3!#tLlpb3ziS2(B_aH}7t3_SGxsnXptQ>ra z2IbQkBI*J?oL8nVw~(%X{=OGHTIWfe1AY3a?|iu%T6C(Qa5){Qf1<=;Kq75GynC-eH9+TOno5-D#`yip2e_!rCZb6SWLg)? zveV5RtBRKBRrpozgvP~P*d-?KtTPNlt{#c_3ZN*r8$7fA(H zb`94&BNE$W7M_eM_6ve>@j-NdC-z|~dRijs8;g8C((v-GnNfF--%9(|+qo`Ab(BVX z4e_GMbgViL*QxDMLc@z>HRe%i23lDcE(o~E1^l984K{Fwln--4V{=6+&w+nTAM?p4 zD2)rDy4PU@i*GhQ2>qHxL!mj;mHx}&TBZ;+F^eOdI400yBq`-o+mC<;+11}L>G7AJ zXM~0%AGIlAMbGM9f#jvKD+R%hUt`$Z6+986N+I!KAo;-5H-$UhxHU?&K35%jnAd&cCM<#TYjtW>@1;kc8@ORD>66 zkv`DD7%yP04D_>2AeiA(FxY{saLEcbzn4ef(yK!r*)?{p0PiDu!puXg(}W*$&mT0n zQ(M_fU936s-Pnu4!_c>V*!bcfU_JYT2G|nU+hQfhxq~wzU}?vS>Um6Iiapi4m~c+LlWSKsfY~we`Daq8z^3NQ z(^g~`3n@2@*=zVr`2{O-_0;IFbx1~v0DRHbpFF?o+mi^o1a8q@p8Yn~m3BTo-3fNh zVuAbweCMm;R&^|MlCnC9Yw9cZ6pCp*BMVB^1Nnob@FROWOC#ZzR{i9x162jv?AM{L zExK&J>tkEB#)1<8e)Vvy1!>Kf5Sf literal 0 HcmV?d00001 diff --git a/antdsp-admin/src/main/web/public/ggeditor/flow/decision.svg b/antdsp-admin/src/main/web/public/ggeditor/flow/decision.svg new file mode 100644 index 0000000..7af317c --- /dev/null +++ b/antdsp-admin/src/main/web/public/ggeditor/flow/decision.svg @@ -0,0 +1,29 @@ + + + + Group 3 + Created with Sketch. + + + + + + + + + + + + + + + + + + + Decision + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/public/ggeditor/flow/model.svg b/antdsp-admin/src/main/web/public/ggeditor/flow/model.svg new file mode 100644 index 0000000..3fd8afa --- /dev/null +++ b/antdsp-admin/src/main/web/public/ggeditor/flow/model.svg @@ -0,0 +1,29 @@ + + + + Group 4 + Created with Sketch. + + + + + + + + + + + + + + + + + + + Model + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/public/ggeditor/flow/normal.svg b/antdsp-admin/src/main/web/public/ggeditor/flow/normal.svg new file mode 100644 index 0000000..53791e9 --- /dev/null +++ b/antdsp-admin/src/main/web/public/ggeditor/flow/normal.svg @@ -0,0 +1,29 @@ + + + + Group + Created with Sketch. + + + + + + + + + + + + + + + + + + + Normal + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/public/ggeditor/flow/start.svg b/antdsp-admin/src/main/web/public/ggeditor/flow/start.svg new file mode 100644 index 0000000..3ab4c3c --- /dev/null +++ b/antdsp-admin/src/main/web/public/ggeditor/flow/start.svg @@ -0,0 +1,29 @@ + + + + Group 2 + Created with Sketch. + + + + + + + + + + + + + + + + + + + Start + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/public/ggeditor/koni/bank.svg b/antdsp-admin/src/main/web/public/ggeditor/koni/bank.svg new file mode 100644 index 0000000..7ec1164 --- /dev/null +++ b/antdsp-admin/src/main/web/public/ggeditor/koni/bank.svg @@ -0,0 +1,29 @@ + + + + Group 16 + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/public/ggeditor/koni/country.svg b/antdsp-admin/src/main/web/public/ggeditor/koni/country.svg new file mode 100644 index 0000000..eeb861a --- /dev/null +++ b/antdsp-admin/src/main/web/public/ggeditor/koni/country.svg @@ -0,0 +1,29 @@ + + + + Group 18 + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/public/ggeditor/koni/icon.svg b/antdsp-admin/src/main/web/public/ggeditor/koni/icon.svg new file mode 100644 index 0000000..0c3eba6 --- /dev/null +++ b/antdsp-admin/src/main/web/public/ggeditor/koni/icon.svg @@ -0,0 +1,14 @@ + + + + earth copy 53 + Created with Sketch. + + + + + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/public/ggeditor/koni/person.svg b/antdsp-admin/src/main/web/public/ggeditor/koni/person.svg new file mode 100644 index 0000000..c9dcad0 --- /dev/null +++ b/antdsp-admin/src/main/web/public/ggeditor/koni/person.svg @@ -0,0 +1,29 @@ + + + + Group 17 + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/public/icons/icon-128x128.png b/antdsp-admin/src/main/web/public/icons/icon-128x128.png new file mode 100644 index 0000000000000000000000000000000000000000..48d0e2339a60a637b94319c65e8654289b4f4b6c GIT binary patch literal 1329 zcmV-11C0002qP)t-s01zMl z|Nj6D8~_Fu01Fxg6ePmN$p8o!Wo~x>2^n*Hg!uURG(b#MUupdO{0J2!4IC;FATIs> z{@dN(0umtr1r+b_@!;a*CNn?_87S=S?pR`MN>yMYFg?=M*UQe)wYk2qw7Hs~re<$= zUubdX=<2(_!=9w6l9``_ijrw^dn`Fc6(TV7_4V=c^R2SBrmV4+ouiMHoQsl~euj;D zf{I&ZZXPQ+87DQ^+ugv!$3;(CLQPmWL{HY)+rGlaqNuHRe}`^&fKXdyK1x+FK1#;P z&4`be_4fDTmuWjt2mKnbI+d3dfa z_PK3Vs;zn;Ot~u#==o*X;a^nmOa{(_o(tmupuw*`!> z#lUp|BbBD0;J$!S0To9DO4Z9XkCjq#?=s{WNE{XLCFmLibLLfxLm3nt7Wj-&k{L;X zo_Y$L6(Ax^@lhJo2uNHK09we3_>jt`DV`HX8L^}WDJO|ULbS4T1b_}iycq`oGqNH4 zQJi@^@H`%ly#;k8%FIH(J#9^VH>(ITJX3)9M7)?mVD;pNM){2bV!rABC{yFeZXJ$q ztx`Yw*~Rj#FGR_Att-g zD?cOlXM^rD8S|s+a(LB7MePP8cKc zywqQW@o0gm8Qu`-)UW-9#K*uQ5WQT5&CGnc%phPyF4p1{wj=@#5xikX3uI#(QrZ2A z66>Nxz+a;r*Km#iEGXxR4BFJu%9#^UG{?XqFlA~7sH!J&2X_C6*P7#50#^tYfm`)p zW2Pupno-5;QoKQ)pCj;SS_MKc4Ai#W7h-YyLi$8b7l@8b3KjwX8wCk}6<4mh7hj6_ z@bnBUa)|InAVBSV)+C{3Cf$?e`b2@nQysp0$(swOoN^Eg(SO9p-Q1JJAAwzQCMaKm&bGV`U^9&pp0Gf^+nkRf5 zTo3@>xi{%p{gIpTF5iJBic@aIws^IC=-v{M~W@Y%aj8G0o!r2b|HdROb8D$LP+n;FWCW`~3a=G(k;6PFes57kh(>00a~S6Cwx} zCE()Z^7Hf|E zp{K0H$jr97ziM-QXK;BCA1!ozgl>0$_4f8XNmSCn^FkCmKwfQVshbU{p46e2L| z?Ct65?BnI;*4f+4&(glZ#fXoVgo~3^UusNOVjC$ov9`LWtg%K>TsK2c$;{8e#mKwA z!>qBksjjnFVr-b6q?4MUQCw!>t&JT300tCEL_t(|+U?tESK2@nfZ>~&tE5s!683!u zK~Xjr+;FLD`~QDWsaSMof{9Cdrsv$}Q$GacB{NB8tUw4Mgb+dqA%qY@2qA(L2bqdsgXsNTkuvsd$l2J=n5?~ND zV51VpX8=z3{QjGMB}&;~4lO{w(%Zazp$0@daWIEhfP~dcYQd#z&@Au`02`W0K*FSZ zfqww-)R9s!Ht2yOKmf3z60nW%2IP#}oH2Xl0XAm~+{S+rP&t$X9^nbbm-x&1;@!yj zY%9B7sWA>ZWO1jKtCah(e))TD=Eenv9so{D4rn_thqYd2VK|ELzaOufx!t$^NZw>p z+Iyj>U-gQu^kN;GPyD#d{Hh5IJ3uJYc+Z77Ufo$Ggo+WA3Y*@1Ky13)LZP31QSeOBPQ+XWH1FRE< znBBKzO$T4zWLDa@R>>EuJj^qYQEmht0qwfj(!SqQ@iKSEQ|m2>2OGl+_^GUFJOcJ= zXWHkFZpC2%v9sp4{dDSJXp{It8QP8>kQnV+s>T(A1*ey{eEoDWoB-?=l!qbE1M&?^ zlg>TQVZNQW0vG^>5+Gs?WoT;w-lorADbq%mw`k7}=L`%i*#i$2a3L12&mCI9?2mZ} z0W6}7?qr1p3pjZ?4xKwIs2_Fw@&LQuwzS(*uz)OwIWgMMHdb!T{tPE4SL`S{H8xBn!v4)5iQu&kynG zu&g>v%A749U2|<^9&fVG1>_^~CFZ7LP5t_J?7+%^=uNif%+;?)oeFwB$`&F5UWnO^ z@}M}gKew%NvbE6ZWlDEPmWMOGGN93O87@!W;veOx{0)tnve;1G63u~Z#6xV7>iY035`Xj%Y> z^Q5IJ+!Y6p_dlYRYQ(^}0Dwm;s0$Yi48Tdj3g$4vO$-3uKeU2KKGd0O0O0VXbm7s4;+l9&n%p_`cvI z?LB&meH%ahXIS9}0Jn2n$9YS(u{W#$gO9RPz0KE#GlYO}vMs$dg#n^%CpUU*6%xDq zjs0(lqaT-@s*4=qi*zHU+H4m-VgiXywKHFAtzxV0RWJzsovKI0FJxD0TBWR9R(cUae(Kj zsHF%%MItH28Xp(4*{bSm0T9Fm0Q3xia~uV&0pKeFz=jn7(rEx(_sVL}lf@aG=xQ21 z0F-Q4EcX2Td}n9x&+_W8>Dj@bW1Zc-_04UCC6!U}srDWLO4_FE!gBaD92g8{VR7ke zeM?AW92o=O(D2yXclnR)y=d4(E-o&bT05P*g06FjUtV6efBWI#2OS@uWaJd^OFd|4 zX;(M2f>E+f{F>2!?AX@%T}(mq>gp=@<7Y-5siUJ~-_R&H)yX)dzBXt+ zw3(irC-{#uAUx*V_rCAF0|y6(^qk`23R+NfVtI9aeo@&CE(t4VpY6XpJmUB8uHDiy zwv9=Ab9i`ka&k&{ODsM)GxBB9kG{dJ?Y|`SJP2xb|L_=>Cn3tZ=GbsG#NjrD{p8lZ+I*;#ZnN-&`)3V#iUD zMPI6J3dwTaR#efm@D7ZSx~Kc$)0fQLLZ9GgMwTwT5=zbJZ|@6AUcO3G4f|Pz+YOkF zhRS^y7A`o43kXqaS`P?+li?F^ab$DRnFBz%pmtx;FkotX)-fdI0SkIBo$3`kjGW}D zZoDeqLtS3Q2M@@N^6~Cb6R{D+s3aFqxA6=o*eHod92P`F`24wEin51>RC@xG+Cw7; zO)`T9mP{{KyOZ{F0<#_c5Bhd4GTu4*uXH<{{3_)6x4r)lr){`JohSKG%?$A}zhMc= zW|@O)q8WsJQ6EdzmKROG;U@_#(HhDuk8bo;Ho`*6l-2u9HLE*dOv$E=6gvnZLNCqP zprds6w}?9hZO+b`b-ggB&>$s;nRQSt|AE@)FA7Ls_I33&;P}~m=VyWbcR}f(OIN21 zGvpB_DYkJ<3MQsNhOEYodj;5({(pE0$4P!F$)xqVIwo83~69g=48RK+49na7Q(C zC7>Jw*DbzEje?QUe|LGt3nX|7Uz)%oP2zR&b4Op@R)(SMB<|5c3@$a63w&>G*}*

*C7T$?5!b= z&nPVm(<;~Sw_*kJlio|*qhI8#F?9y#@jvQ4Y?j2~r_a^)YoQ-co4WFOwF)i5mFnrV zp3rz^`K|nrI`guQ$X^%JuCI5qSS(}Tc|%+~o}P6dC={o1Q&<)3lnFnXE=l2Po$K4W zYZ0|2<3Cp|&)NE>;p=Muwg#BLXuboTJ(mwtjLbtdOE_A4n^}l29p9@>4vpS+t*^qG zb2Uo-W$@vKeR}iztf6tJTUh8=^kh_EBe^3f?1b(p_oBq&dpqW$pAyBB**bIt4BhwK zX02JE@mc}FExq0q+5_8B#EP&@;6-lx4t~)@$HBEBXnIqX0E$mhb$(} zt|vYUzekLn0SQ;Cd)J1 zXF3gv$u52+$>oQVvh7DxPpKeWD4yJgdWQQ`D#($Z=j%Df!iAxvR)-y7Ie5nI39+zG z4a3_4mE;SBh@MK8p%(n|yGj>Ao>j51ETLI#vuUt#g|%FDZG}&kbEb(|*9!RyL&U?| zvNnv+oEL_*R{Mw_;x+O`vNWUXL6>@M)sQr_lmlng7?sCaDH0YaGf%+R1ZM}9#$j$3 zi}N01^7uoRgvG74Fxi{415}={tg=gDHuqwR$1?9qlK<#~ zLG@an>_SlEY6+k8PD+S)C&NU7!~`$+Sin{JS2aLn_Jm#q|8H%OnLqt&n-f~C7KW9K z>QxTE1D!cV+(E>-8N#r>Aw98T*8=odDM_y2&?=ag7-=Rj&p%xvU zq=o{%T2@T(b@VqinV#`~IN4t3^z$HE=3~ZiDQ=xP6Gt)g;q1Wv2N&CBx=Ndw5 z6U*fS@;@VBF^MGsyag~+Eq&2UZ@5SG$!SM2ckBL!E1lBg>*t^{Lqn=cK^-Rhc#S(% zuAqbI(^+PqN#)t&5xr~v&*Y$qZ$3Yz)nRe`ZZcJUU8hd=)9$7 z6n-k7p||Esq}igp(IoxtD&_5A!OwcTvM3p-HHJGcVh|>N13O;!W%RXd{Y6@BEp1Jz zHCH!~H~lR%<3E0b>}>_dD6Ef8r_)LSp}O5L`DerkKk|Jc@n6*BmU&r@TKhG$-x=>`wv*Vj%M=6<7!P7~3+)?^D>AA~&^F+{mzBAMLh zuTiItS}IqcPpj-t;W15ahnBV9rHnrShN-@GCY+EyXV6Gass&4cM~^;F?z{3+SXKe7 zX8rBU7Fc!Kr5M!K@lDd)Bl)VMR)yb6;AHxpH?Q1Bx14XQy~`&ggyC$4u>az;q|C7G ziTI-A3y9BZbxP7rW4_G!ju{^(NOZstl}tvVR+j8_B`~)2cWn2~;amI9u@_9oSC+Xc z_+DcYbc7S~MIl7Fjk6qEWXDo6>n5U0O4P_k15Z^c%P@0?*Oaj8%BIU*uy|Vgi@eqH zPKZqrW$wXWQ9=QoQrY4VBCFzACRJhEv+U(FOmx1_uwVirtukLVbyF&%?xKU6D>Yot zj6ZW-1$@|ASwJlAu1;!K9!5uPdov-?7RK^;L%bs%6z9abcvP!i20^{1|g}`{&O=}R+#D;J+z#Fj(x6k%xY0!5_DrzSsTCn;pu^6 zIZV~_c4b?yxFutJZTc`BT4+(N21dx%Bxx5_=*+^Gl`PCmvS7QnNZUr>RqS>smtAo7 z%1fV4h6YI+Y2X$?ZuQmeFj!XWfPJxAc1<0;;3C|?V?=BITB{AnSkYW;+Vbas9ODwo zC?uf|l|KjLdt@iP*&!CGbh&OT1l3&s3RD|7knGOc{T%o)WLqmqSnTE5-M^OKN+8ct1C(XwQJJg%OozV)cJ^w# zVxbg~z7OMwn+eEPaBRR0KIDX14Kb^G-Strc8r6QmoINnF;F1;|U5n3%rdT9(U0dcP zI*}ZU>2wFp1u1KmK2cwSwk|=oZ8?l*@yIPBD3BPN(BINzFh#VAKBpVxZ71*JgwpWXLZfS%KkGa_tQn0bX5)h8 z6Q7LGdb=)NQ}a}>SD{8~!ga|bE*aS_Nxg_+ojhQ1{b@sVzaX)Z{rV-1%Qa*ioSy65 zb4ke$#&Mf>xuBg{&aCGNbhbOGbN4XT4?qQpRW^!2z;9eCH6fH7)+qpWe;n~*tCIq= z&w&jc@_tBWRiS3IyovPwt~fl#1Z-%o%T_B%)sO*FrOIkz-1r$#mr+&N2J06a?u1<~QB}EoR?wnU)c32Ew0(EP^w=K@< zM;7MeoWTwa-$09MwD#{-p5K@kGTM6q@*9`~NBz#snAQt$W%fZr`qk|A%IEM4|B(?x zOpx+g1-*Q?a%JHpKf|Cs>MCBj^^EmKDb?*U1(_uF({whek67oi^wL)^XH3=`&u$U^ z*K&AEIc$ISs)O2r7emK9XW_i^6Jxw-Ug6tIn{3gqAYG+j_U1<)>HovW7l7Z>STIh4 z7OH$pfQM^<6ZPN`%FY^PFKzq89tYsIi0B { + let files = []; + const jsFiles = glob.sync('src/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] }); + const tsFiles = glob.sync('src/**/*.ts*', { ignore: ['**/node_modules/**', 'build/**'] }); + const configFiles = glob.sync('config/**/*.js*', { ignore: ['**/node_modules/**', 'build/**'] }); + const scriptFiles = glob.sync('scripts/**/*.js'); + const lessFiles = glob.sync('src/**/*.less*', { ignore: ['**/node_modules/**', 'build/**'] }); + files = files.concat(jsFiles); + files = files.concat(tsFiles); + files = files.concat(configFiles); + files = files.concat(scriptFiles); + files = files.concat(lessFiles); + if (!files.length) { + return; + } + return files; +}; + +module.exports = getPrettierFiles; diff --git a/antdsp-admin/src/main/web/scripts/lint-prettier.js b/antdsp-admin/src/main/web/scripts/lint-prettier.js new file mode 100644 index 0000000..677f793 --- /dev/null +++ b/antdsp-admin/src/main/web/scripts/lint-prettier.js @@ -0,0 +1,50 @@ +/** + * copy to https://github.com/facebook/react/blob/master/scripts/prettier/index.js + * prettier api doc https://prettier.io/docs/en/api.html + *----------*****-------------- + * lint file is prettier + *----------*****-------------- + */ + +const prettier = require('prettier'); +const fs = require('fs'); +const chalk = require('chalk'); +const prettierConfigPath = require.resolve('../.prettierrc'); + +const files = process.argv.slice(2); + +let didError = false; + +files.forEach(file => { + Promise.all([ + prettier.resolveConfig(file, { + config: prettierConfigPath, + }), + prettier.getFileInfo(file), + ]) + .then(resolves => { + const [options, fileInfo] = resolves; + if (fileInfo.ignored) { + return; + } + const input = fs.readFileSync(file, 'utf8'); + const withParserOptions = { + ...options, + parser: fileInfo.inferredParser, + }; + const output = prettier.format(input, withParserOptions); + if (output !== input) { + fs.writeFileSync(file, output, 'utf8'); + console.log(chalk.green(`${file} is prettier`)); + } + }) + .catch(e => { + didError = true; + }) + .finally(() => { + if (didError) { + process.exit(1); + } + console.log(chalk.hex('#1890FF')('prettier success!')); + }); +}); diff --git a/antdsp-admin/src/main/web/scripts/prettier.js b/antdsp-admin/src/main/web/scripts/prettier.js new file mode 100644 index 0000000..17ded6c --- /dev/null +++ b/antdsp-admin/src/main/web/scripts/prettier.js @@ -0,0 +1,46 @@ +/** + * copy to https://github.com/facebook/react/blob/master/scripts/prettier/index.js + * prettier api doc https://prettier.io/docs/en/api.html + *----------*****-------------- + * prettier all js and all ts. + *----------*****-------------- + */ + +const prettier = require('prettier'); +const fs = require('fs'); +const getPrettierFiles = require('./getPrettierFiles'); +const prettierConfigPath = require.resolve('../.prettierrc'); +const chalk = require('chalk'); + +let didError = false; + +const files = getPrettierFiles(); + +files.forEach(file => { + const options = prettier.resolveConfig.sync(file, { + config: prettierConfigPath, + }); + const fileInfo = prettier.getFileInfo.sync(file); + if (fileInfo.ignored) { + return; + } + try { + const input = fs.readFileSync(file, 'utf8'); + const withParserOptions = { + ...options, + parser: fileInfo.inferredParser, + }; + const output = prettier.format(input, withParserOptions); + if (output !== input) { + fs.writeFileSync(file, output, 'utf8'); + console.log(chalk.green(`${file} is prettier`)); + } + } catch (e) { + didError = true; + } +}); + +if (didError) { + process.exit(1); +} +console.log(chalk.hex('#1890FF')('prettier success!')); diff --git a/antdsp-admin/src/main/web/src/app.js b/antdsp-admin/src/main/web/src/app.js new file mode 100644 index 0000000..2e98b22 --- /dev/null +++ b/antdsp-admin/src/main/web/src/app.js @@ -0,0 +1,11 @@ +export const dva = { + config: { + onError(err) { + err.preventDefault(); + }, + }, +}; + +export function render(oldRender) { + oldRender(); +} diff --git a/antdsp-admin/src/main/web/src/assets/logo.svg b/antdsp-admin/src/main/web/src/assets/logo.svg new file mode 100644 index 0000000..e9f8c2a --- /dev/null +++ b/antdsp-admin/src/main/web/src/assets/logo.svg @@ -0,0 +1,43 @@ + + + + Group 28 Copy 5 + Created with Sketch. + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/components/ActiveChart/index.js b/antdsp-admin/src/main/web/src/components/ActiveChart/index.js new file mode 100644 index 0000000..a7bf0bf --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/ActiveChart/index.js @@ -0,0 +1,98 @@ +import React, { Component } from 'react'; +import { MiniArea } from '../Charts'; +import NumberInfo from '../NumberInfo'; +import styles from './index.less'; + +function fixedZero(val) { + return val * 1 < 10 ? `0${val}` : val; +} + +function getActiveData() { + const activeData = []; + for (let i = 0; i < 24; i += 1) { + activeData.push({ + x: `${fixedZero(i)}:00`, + y: Math.floor(Math.random() * 200) + i * 50, + }); + } + return activeData; +} + +export default class ActiveChart extends Component { + state = { + activeData: getActiveData(), + }; + + componentDidMount() { + this.loopData(); + } + + componentWillUnmount() { + clearTimeout(this.timer); + cancelAnimationFrame(this.requestRef); + } + + loopData = () => { + this.timer = setTimeout(() => { + this.setState( + { + activeData: getActiveData(), + }, + () => { + this.loopData(); + } + ); + }, 500); + }; + + render() { + const { activeData = [] } = this.state; + + return ( +

+ +
+ +
+ {activeData && ( +
+
+

{[...activeData].sort()[activeData.length - 1].y + 200} 亿元

+

{[...activeData].sort()[Math.floor(activeData.length / 2)].y} 亿元

+
+
+
+
+
+
+
+
+ )} + {activeData && ( +
+ 00:00 + {activeData[Math.floor(activeData.length / 2)].x} + {activeData[activeData.length - 1].x} +
+ )} +
+ ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/ActiveChart/index.less b/antdsp-admin/src/main/web/src/components/ActiveChart/index.less new file mode 100644 index 0000000..2f5d15f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/ActiveChart/index.less @@ -0,0 +1,51 @@ +.activeChart { + position: relative; +} +.activeChartGrid { + p { + position: absolute; + top: 80px; + } + p:last-child { + top: 115px; + } +} +.activeChartLegend { + position: relative; + height: 20px; + margin-top: 8px; + font-size: 0; + line-height: 20px; + span { + display: inline-block; + width: 33.33%; + font-size: 12px; + text-align: center; + } + span:first-child { + text-align: left; + } + span:last-child { + text-align: right; + } +} +.dashedLine { + position: relative; + top: -70px; + left: -3px; + height: 1px; + + .line { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-image: linear-gradient(to right, transparent 50%, #e9e9e9 50%); + background-size: 6px; + } +} + +.dashedLine:last-child { + top: -36px; +} diff --git a/antdsp-admin/src/main/web/src/components/ArticleListContent/index.d.ts b/antdsp-admin/src/main/web/src/components/ArticleListContent/index.d.ts new file mode 100644 index 0000000..bb4988a --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/ArticleListContent/index.d.ts @@ -0,0 +1,13 @@ +import React from 'react'; + +export interface ApplicationsProps { + data: { + content?: string; + updatedAt?: any; + avatar?: string; + owner?: string; + href?: string; + }; +} + +export default class ArticleListContent extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/ArticleListContent/index.js b/antdsp-admin/src/main/web/src/components/ArticleListContent/index.js new file mode 100644 index 0000000..c4525d6 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/ArticleListContent/index.js @@ -0,0 +1,17 @@ +import React from 'react'; +import moment from 'moment'; +import { Avatar } from 'antd'; +import styles from './index.less'; + +const ArticleListContent = ({ data: { content, updatedAt, avatar, owner, href } }) => ( +
+
{content}
+
+ + {owner} 发布在 {href} + {moment(updatedAt).format('YYYY-MM-DD HH:mm')} +
+
+); + +export default ArticleListContent; diff --git a/antdsp-admin/src/main/web/src/components/ArticleListContent/index.less b/antdsp-admin/src/main/web/src/components/ArticleListContent/index.less new file mode 100644 index 0000000..dd0baa1 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/ArticleListContent/index.less @@ -0,0 +1,38 @@ +@import '~antd/lib/style/themes/default.less'; + +.listContent { + .description { + max-width: 720px; + line-height: 22px; + } + .extra { + margin-top: 16px; + color: @text-color-secondary; + line-height: 22px; + & > :global(.ant-avatar) { + position: relative; + top: 1px; + width: 20px; + height: 20px; + margin-right: 8px; + vertical-align: top; + } + & > em { + margin-left: 16px; + color: @disabled-color; + font-style: normal; + } + } +} + +@media screen and (max-width: @screen-xs) { + .listContent { + .extra { + & > em { + display: block; + margin-top: 8px; + margin-left: 0; + } + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/Authorized/Authorized.js b/antdsp-admin/src/main/web/src/components/Authorized/Authorized.js new file mode 100644 index 0000000..75d57b8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/Authorized.js @@ -0,0 +1,8 @@ +import CheckPermissions from './CheckPermissions'; + +const Authorized = ({ children, authority, noMatch = null }) => { + const childrenRender = typeof children === 'undefined' ? null : children; + return CheckPermissions(authority, childrenRender, noMatch); +}; + +export default Authorized; diff --git a/antdsp-admin/src/main/web/src/components/Authorized/AuthorizedRoute.d.ts b/antdsp-admin/src/main/web/src/components/Authorized/AuthorizedRoute.d.ts new file mode 100644 index 0000000..f94427d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/AuthorizedRoute.d.ts @@ -0,0 +1,13 @@ +import React from 'react'; +import { RouteProps } from 'react-router'; + +type authorityFN = (currentAuthority?: string) => boolean; + +type authority = string | string[] | authorityFN | Promise; + +export interface IAuthorizedRouteProps extends RouteProps { + authority: authority; +} +export { authority }; + +export default class AuthorizedRoute extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Authorized/AuthorizedRoute.js b/antdsp-admin/src/main/web/src/components/Authorized/AuthorizedRoute.js new file mode 100644 index 0000000..a622ed3 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/AuthorizedRoute.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { Route, Redirect } from 'umi'; +import Authorized from './Authorized'; + +// TODO: umi只会返回render和rest +const AuthorizedRoute = ({ component: Component, render, authority, redirectPath, ...rest }) => ( + } />} + > + (Component ? : render(props))} /> + +); + +export default AuthorizedRoute; diff --git a/antdsp-admin/src/main/web/src/components/Authorized/CheckPermissions.js b/antdsp-admin/src/main/web/src/components/Authorized/CheckPermissions.js new file mode 100644 index 0000000..a1da261 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/CheckPermissions.js @@ -0,0 +1,70 @@ +import React from 'react'; +// eslint-disable-next-line import/no-cycle +import PromiseRender from './PromiseRender'; +import { CURRENT } from './renderAuthorize'; + +/** + * 通用权限检查方法 + * Common check permissions method + * @param { 权限判定 | Permission judgment } authority + * @param { 你的权限 | Your permission description } currentAuthority + * @param { 通过的组件 | Passing components } target + * @param { 未通过的组件 | no pass components } Exception + */ +const checkPermissions = (authority, currentAuthority, target, Exception) => { + // 没有判定权限.默认查看所有 + // Retirement authority, return target; + if (!authority) { + return target; + } + // 数组处理 + if (Array.isArray(authority)) { + if (Array.isArray(currentAuthority)) { + if (currentAuthority.some(item => authority.includes(item))) { + return target; + } + } else if (authority.includes(currentAuthority)) { + return target; + } + return Exception; + } + // string 处理 + if (typeof authority === 'string') { + if (Array.isArray(currentAuthority)) { + if (currentAuthority.some(item => authority === item)) { + return target; + } + } else if (authority === currentAuthority) { + return target; + } + return Exception; + } + // Promise 处理 + if (authority instanceof Promise) { + return ; + } + // Function 处理 + if (typeof authority === 'function') { + try { + const bool = authority(currentAuthority); + // 函数执行后返回值是 Promise + if (bool instanceof Promise) { + return ; + } + if (bool) { + return target; + } + return Exception; + } catch (error) { + throw error; + } + } + throw new Error('unsupported parameters'); +}; + +export { checkPermissions }; + +const check = (authority, target, Exception) => + checkPermissions(authority, CURRENT, target, Exception); + +export default check; diff --git a/antdsp-admin/src/main/web/src/components/Authorized/CheckPermissions.test.js b/antdsp-admin/src/main/web/src/components/Authorized/CheckPermissions.test.js new file mode 100644 index 0000000..3988d85 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/CheckPermissions.test.js @@ -0,0 +1,55 @@ +import { checkPermissions } from './CheckPermissions'; + +const target = 'ok'; +const error = 'error'; + +describe('test CheckPermissions', () => { + it('Correct string permission authentication', () => { + expect(checkPermissions('user', 'user', target, error)).toEqual('ok'); + }); + it('Correct string permission authentication', () => { + expect(checkPermissions('user', 'NULL', target, error)).toEqual('error'); + }); + it('authority is undefined , return ok', () => { + expect(checkPermissions(null, 'NULL', target, error)).toEqual('ok'); + }); + it('currentAuthority is undefined , return error', () => { + expect(checkPermissions('admin', null, target, error)).toEqual('error'); + }); + it('Wrong string permission authentication', () => { + expect(checkPermissions('admin', 'user', target, error)).toEqual('error'); + }); + it('Correct Array permission authentication', () => { + expect(checkPermissions(['user', 'admin'], 'user', target, error)).toEqual('ok'); + }); + it('Wrong Array permission authentication,currentAuthority error', () => { + expect(checkPermissions(['user', 'admin'], 'user,admin', target, error)).toEqual('error'); + }); + it('Wrong Array permission authentication', () => { + expect(checkPermissions(['user', 'admin'], 'guest', target, error)).toEqual('error'); + }); + it('Wrong Function permission authentication', () => { + expect(checkPermissions(() => false, 'guest', target, error)).toEqual('error'); + }); + it('Correct Function permission authentication', () => { + expect(checkPermissions(() => true, 'guest', target, error)).toEqual('ok'); + }); + it('authority is string, currentAuthority is array, return ok', () => { + expect(checkPermissions('user', ['user'], target, error)).toEqual('ok'); + }); + it('authority is string, currentAuthority is array, return ok', () => { + expect(checkPermissions('user', ['user', 'admin'], target, error)).toEqual('ok'); + }); + it('authority is array, currentAuthority is array, return ok', () => { + expect(checkPermissions(['user', 'admin'], ['user', 'admin'], target, error)).toEqual('ok'); + }); + it('Wrong Function permission authentication', () => { + expect(checkPermissions(() => false, ['user'], target, error)).toEqual('error'); + }); + it('Correct Function permission authentication', () => { + expect(checkPermissions(() => true, ['user'], target, error)).toEqual('ok'); + }); + it('authority is undefined , return ok', () => { + expect(checkPermissions(null, ['user'], target, error)).toEqual('ok'); + }); +}); diff --git a/antdsp-admin/src/main/web/src/components/Authorized/PromiseRender.js b/antdsp-admin/src/main/web/src/components/Authorized/PromiseRender.js new file mode 100644 index 0000000..c03a41d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/PromiseRender.js @@ -0,0 +1,76 @@ +import { Spin } from 'antd'; +import isEqual from 'lodash/isEqual'; +import React from 'react'; +// eslint-disable-next-line import/no-cycle +import { isComponentClass } from './Secured'; + +export default class PromiseRender extends React.Component { + state = { + component: null, + }; + + componentDidMount() { + this.setRenderComponent(this.props); + } + + shouldComponentUpdate = (nextProps, nextState) => { + const { component } = this.state; + if (!isEqual(nextProps, this.props)) { + this.setRenderComponent(nextProps); + } + if (nextState.component !== component) return true; + return false; + }; + + // set render Component : ok or error + setRenderComponent(props) { + const ok = this.checkIsInstantiation(props.ok); + const error = this.checkIsInstantiation(props.error); + props.promise + .then(() => { + this.setState({ + component: ok, + }); + }) + .catch(() => { + this.setState({ + component: error, + }); + }); + } + + // Determine whether the incoming component has been instantiated + // AuthorizedRoute is already instantiated + // Authorized render is already instantiated, children is no instantiated + // Secured is not instantiated + checkIsInstantiation = target => { + if (isComponentClass(target)) { + const Target = target; + return props => ; + } + if (React.isValidElement(target)) { + return props => React.cloneElement(target, props); + } + return () => target; + }; + + render() { + const { component: Component } = this.state; + const { ok, error, promise, ...rest } = this.props; + return Component ? ( + + ) : ( +
+ +
+ ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/Authorized/Secured.js b/antdsp-admin/src/main/web/src/components/Authorized/Secured.js new file mode 100644 index 0000000..bd53b2f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/Secured.js @@ -0,0 +1,68 @@ +import React from 'react'; +import Exception from '../Exception'; +// eslint-disable-next-line import/no-cycle +import CheckPermissions from './CheckPermissions'; + +/** + * 默认不能访问任何页面 + * default is "NULL" + */ +const Exception403 = () => ; + +export const isComponentClass = component => { + if (!component) return false; + const proto = Object.getPrototypeOf(component); + if (proto === React.Component || proto === Function.prototype) return true; + return isComponentClass(proto); +}; + +// Determine whether the incoming component has been instantiated +// AuthorizedRoute is already instantiated +// Authorized render is already instantiated, children is no instantiated +// Secured is not instantiated +const checkIsInstantiation = target => { + if (isComponentClass(target)) { + const Target = target; + return props => ; + } + if (React.isValidElement(target)) { + return props => React.cloneElement(target, props); + } + return () => target; +}; + +/** + * 用于判断是否拥有权限访问此 view 权限 + * authority 支持传入 string, () => boolean | Promise + * e.g. 'user' 只有 user 用户能访问 + * e.g. 'user,admin' user 和 admin 都能访问 + * e.g. ()=>boolean 返回true能访问,返回false不能访问 + * e.g. Promise then 能访问 catch不能访问 + * e.g. authority support incoming string, () => boolean | Promise + * e.g. 'user' only user user can access + * e.g. 'user, admin' user and admin can access + * e.g. () => boolean true to be able to visit, return false can not be accessed + * e.g. Promise then can not access the visit to catch + * @param {string | function | Promise} authority + * @param {ReactNode} error 非必需参数 + */ +const authorize = (authority, error) => { + /** + * conversion into a class + * 防止传入字符串时找不到staticContext造成报错 + * String parameters can cause staticContext not found error + */ + let classError = false; + if (error) { + classError = () => error; + } + if (!authority) { + throw new Error('authority is required'); + } + return function decideAuthority(target) { + const component = CheckPermissions(authority, target, classError || Exception403); + return checkIsInstantiation(component); + }; +}; + +export default authorize; diff --git a/antdsp-admin/src/main/web/src/components/Authorized/demo/AuthorizedArray.md b/antdsp-admin/src/main/web/src/components/Authorized/demo/AuthorizedArray.md new file mode 100644 index 0000000..46eaf76 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/demo/AuthorizedArray.md @@ -0,0 +1,23 @@ +--- +order: 1 +title: + zh-CN: 使用数组作为参数 + en-US: Use Array as a parameter +--- + +Use Array as a parameter + +```jsx +import RenderAuthorized from 'ant-design-pro/lib/Authorized'; +import { Alert } from 'antd'; + +const Authorized = RenderAuthorized('user'); +const noMatch = ; + +ReactDOM.render( + + + , + mountNode, +); +``` diff --git a/antdsp-admin/src/main/web/src/components/Authorized/demo/AuthorizedFunction.md b/antdsp-admin/src/main/web/src/components/Authorized/demo/AuthorizedFunction.md new file mode 100644 index 0000000..8ad8b91 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/demo/AuthorizedFunction.md @@ -0,0 +1,31 @@ +--- +order: 2 +title: + zh-CN: 使用方法作为参数 + en-US: Use function as a parameter +--- + +Use Function as a parameter + +```jsx +import RenderAuthorized from 'ant-design-pro/lib/Authorized'; +import { Alert } from 'antd'; + +const Authorized = RenderAuthorized('user'); +const noMatch = ; + +const havePermission = () => { + return false; +}; + +ReactDOM.render( + + + , + mountNode, +); +``` diff --git a/antdsp-admin/src/main/web/src/components/Authorized/demo/basic.md b/antdsp-admin/src/main/web/src/components/Authorized/demo/basic.md new file mode 100644 index 0000000..a5f12f2 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/demo/basic.md @@ -0,0 +1,25 @@ +--- +order: 0 +title: + zh-CN: 基本使用 + en-US: Basic use +--- + +Basic use + +```jsx +import RenderAuthorized from 'ant-design-pro/lib/Authorized'; +import { Alert } from 'antd'; + +const Authorized = RenderAuthorized('user'); +const noMatch = ; + +ReactDOM.render( +
+ + + +
, + mountNode, +); +``` diff --git a/antdsp-admin/src/main/web/src/components/Authorized/demo/secured.md b/antdsp-admin/src/main/web/src/components/Authorized/demo/secured.md new file mode 100644 index 0000000..1999852 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/demo/secured.md @@ -0,0 +1,30 @@ +--- +order: 3 +title: + zh-CN: 注解基本使用 + en-US: Basic use secured +--- + +secured demo used + +```jsx +import RenderAuthorized from 'ant-design-pro/lib/Authorized'; +import { Alert } from 'antd'; + +const { Secured } = RenderAuthorized('user'); + +@Secured('admin') +class TestSecuredString extends React.Component { + render() { + return ( + + ) + } +} +ReactDOM.render( +
+ +
, + mountNode, +); +``` diff --git a/antdsp-admin/src/main/web/src/components/Authorized/index.d.ts b/antdsp-admin/src/main/web/src/components/Authorized/index.d.ts new file mode 100644 index 0000000..72c9858 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/index.d.ts @@ -0,0 +1,32 @@ +import React from 'react'; +import AuthorizedRoute, { authority } from './AuthorizedRoute'; +export type IReactComponent

= + | React.StatelessComponent

+ | React.ComponentClass

+ | React.ClassicComponentClass

; + +type Secured = ( + authority: authority, + error?: React.ReactNode +) => (target: T) => T; + +type check = ( + authority: authority, + target: T, + Exception: S +) => T | S; + +export interface IAuthorizedProps { + authority: authority; + noMatch?: React.ReactNode; +} + +export class Authorized extends React.Component { + public static Secured: Secured; + public static AuthorizedRoute: typeof AuthorizedRoute; + public static check: check; +} + +declare function renderAuthorize(currentAuthority: string): typeof Authorized; + +export default renderAuthorize; diff --git a/antdsp-admin/src/main/web/src/components/Authorized/index.js b/antdsp-admin/src/main/web/src/components/Authorized/index.js new file mode 100644 index 0000000..22ac664 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/index.js @@ -0,0 +1,11 @@ +import Authorized from './Authorized'; +import AuthorizedRoute from './AuthorizedRoute'; +import Secured from './Secured'; +import check from './CheckPermissions'; +import renderAuthorize from './renderAuthorize'; + +Authorized.Secured = Secured; +Authorized.AuthorizedRoute = AuthorizedRoute; +Authorized.check = check; + +export default renderAuthorize(Authorized); diff --git a/antdsp-admin/src/main/web/src/components/Authorized/index.md b/antdsp-admin/src/main/web/src/components/Authorized/index.md new file mode 100644 index 0000000..48c93f8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/index.md @@ -0,0 +1,56 @@ +--- +title: Authorized +subtitle: 权限 +cols: 1 +order: 15 +--- + +权限组件,通过比对现有权限与准入权限,决定相关元素的展示。 + +## API + +### RenderAuthorized + +`RenderAuthorized: (currentAuthority: string | () => string) => Authorized` + +权限组件默认 export RenderAuthorized 函数,它接收当前权限作为参数,返回一个权限对象,该对象提供以下几种使用方式。 + + +### Authorized + +最基础的权限控制。 + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| children | 正常渲染的元素,权限判断通过时展示 | ReactNode | - | +| authority | 准入权限/权限判断 | `string | array | Promise | (currentAuthority) => boolean | Promise` | - | +| noMatch | 权限异常渲染元素,权限判断不通过时展示 | ReactNode | - | + +### Authorized.AuthorizedRoute + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| authority | 准入权限/权限判断 | `string | array | Promise | (currentAuthority) => boolean | Promise` | - | +| redirectPath | 权限异常时重定向的页面路由 | string | - | + +其余参数与 `Route` 相同。 + +### Authorized.Secured + +注解方式,`@Authorized.Secured(authority, error)` + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| authority | 准入权限/权限判断 | `string | Promise | (currentAuthority) => boolean | Promise` | - | +| error | 权限异常时渲染元素 | ReactNode | | + +### Authorized.check + +函数形式的 Authorized,用于某些不能被 HOC 包裹的组件。 `Authorized.check(authority, target, Exception)` +注意:传入一个 Promise 时,无论正确还是错误返回的都是一个 ReactClass。 + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| authority | 准入权限/权限判断 | `string | Promise | (currentAuthority) => boolean | Promise` | - | +| target | 权限判断通过时渲染的元素 | ReactNode | - | +| Exception | 权限异常时渲染元素 | ReactNode | - | diff --git a/antdsp-admin/src/main/web/src/components/Authorized/renderAuthorize.js b/antdsp-admin/src/main/web/src/components/Authorized/renderAuthorize.js new file mode 100644 index 0000000..be373d9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Authorized/renderAuthorize.js @@ -0,0 +1,25 @@ +/* eslint-disable import/no-mutable-exports */ +let CURRENT = 'NULL'; +/** + * use authority or getAuthority + * @param {string|()=>String} currentAuthority + */ +const renderAuthorize = Authorized => currentAuthority => { + if (currentAuthority) { + if (typeof currentAuthority === 'function') { + CURRENT = currentAuthority(); + } + if ( + Object.prototype.toString.call(currentAuthority) === '[object String]' || + Array.isArray(currentAuthority) + ) { + CURRENT = currentAuthority; + } + } else { + CURRENT = 'NULL'; + } + return Authorized; +}; + +export { CURRENT }; +export default Authorized => renderAuthorize(Authorized); diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/AvatarItem.d.ts b/antdsp-admin/src/main/web/src/components/AvatarList/AvatarItem.d.ts new file mode 100644 index 0000000..0e809ab --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/AvatarItem.d.ts @@ -0,0 +1,15 @@ +import React from 'react'; + +export declare type SizeType = number | 'small' | 'default' | 'large'; + +export interface AvatarItemProps { + tips: React.ReactNode; + src: string; + size?: SizeType; + style?: React.CSSProperties; + onClick?: () => void; +} + +export default class AvatarItem extends React.Component { + constructor(props: AvatarItemProps); +} diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/demo/maxLength.md b/antdsp-admin/src/main/web/src/components/AvatarList/demo/maxLength.md new file mode 100644 index 0000000..76c6b42 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/demo/maxLength.md @@ -0,0 +1,24 @@ +--- +order: 0 +title: + zh-CN: 要显示的最大项目 + en-US: Max Items to Show +--- + +`maxLength` attribute specifies the maximum number of items to show while `excessItemsStyle` style the excess +item component. + +````jsx +import AvatarList from 'ant-design-pro/lib/AvatarList'; + +ReactDOM.render( + + + + + + + + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/demo/simple.md b/antdsp-admin/src/main/web/src/components/AvatarList/demo/simple.md new file mode 100644 index 0000000..e941aea --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/demo/simple.md @@ -0,0 +1,20 @@ +--- +order: 0 +title: + zh-CN: 基础样例 + en-US: Basic Usage +--- + +Simplest of usage. + +````jsx +import AvatarList from 'ant-design-pro/lib/AvatarList'; + +ReactDOM.render( + + + + + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/index.d.ts b/antdsp-admin/src/main/web/src/components/AvatarList/index.d.ts new file mode 100644 index 0000000..e454a8b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/index.d.ts @@ -0,0 +1,14 @@ +import React from 'react'; +import AvatarItem, { AvatarItemProps, SizeType } from './AvatarItem'; + +export interface AvatarListProps { + Item?: React.ReactElement; + size?: SizeType; + maxLength?: number; + excessItemsStyle?: React.CSSProperties; + style?: React.CSSProperties; + children: React.ReactElement | Array>; +} +export default class AvatarList extends React.Component { + public static Item: typeof AvatarItem; +} diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/index.en-US.md b/antdsp-admin/src/main/web/src/components/AvatarList/index.en-US.md new file mode 100644 index 0000000..7fc39cc --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/index.en-US.md @@ -0,0 +1,24 @@ +--- +title: AvatarList +order: 1 +cols: 1 +--- + +A list of user's avatar for project or group member list frequently. If a large or small AvatarList is desired, set the `size` property to either `large` or `small` and `mini` respectively. Omit the `size` property for a AvatarList with the default size. + +## API + +### AvatarList + +| Property | Description | Type | Default | +| ---------------- | --------------------- | ---------------------------------- | --------- | +| size | size of list | `large`、`small` 、`mini`, `default` | `default` | +| maxLength | max items to show | number | - | +| excessItemsStyle | the excess item style | CSSProperties | - | + +### AvatarList.Item + +| Property | Description | Type | Default | +| -------- | -------------------------------------------- | --------- | ------- | +| tips | title tips for avatar item | ReactNode | - | +| src | the address of the image for an image avatar | string | - | diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/index.js b/antdsp-admin/src/main/web/src/components/AvatarList/index.js new file mode 100644 index 0000000..9af32bc --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/index.js @@ -0,0 +1,61 @@ +import React from 'react'; +import { Tooltip, Avatar } from 'antd'; +import classNames from 'classnames'; + +import styles from './index.less'; + +const avatarSizeToClassName = size => + classNames(styles.avatarItem, { + [styles.avatarItemLarge]: size === 'large', + [styles.avatarItemSmall]: size === 'small', + [styles.avatarItemMini]: size === 'mini', + }); + +const AvatarList = ({ children, size, maxLength, excessItemsStyle, ...other }) => { + const numOfChildren = React.Children.count(children); + const numToShow = maxLength >= numOfChildren ? numOfChildren : maxLength; + + const childrenWithProps = React.Children.toArray(children) + .slice(0, numToShow) + .map(child => + React.cloneElement(child, { + size, + }) + ); + + if (numToShow < numOfChildren) { + const cls = avatarSizeToClassName(size); + + childrenWithProps.push( +

  • + {`+${numOfChildren - maxLength}`} +
  • + ); + } + + return ( +
    +
      {childrenWithProps}
    +
    + ); +}; + +const Item = ({ src, size, tips, onClick = () => {} }) => { + const cls = avatarSizeToClassName(size); + + return ( +
  • + {tips ? ( + + + + ) : ( + + )} +
  • + ); +}; + +AvatarList.Item = Item; + +export default AvatarList; diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/index.less b/antdsp-admin/src/main/web/src/components/AvatarList/index.less new file mode 100644 index 0000000..45904ce --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/index.less @@ -0,0 +1,50 @@ +@import '~antd/lib/style/themes/default.less'; + +.avatarList { + display: inline-block; + ul { + display: inline-block; + margin-left: 8px; + font-size: 0; + } +} + +.avatarItem { + display: inline-block; + width: @avatar-size-base; + height: @avatar-size-base; + margin-left: -8px; + font-size: @font-size-base; + :global { + .ant-avatar { + border: 1px solid #fff; + } + } +} + +.avatarItemLarge { + width: @avatar-size-lg; + height: @avatar-size-lg; +} + +.avatarItemSmall { + width: @avatar-size-sm; + height: @avatar-size-sm; +} + +.avatarItemMini { + width: 20px; + height: 20px; + :global { + .ant-avatar { + width: 20px; + height: 20px; + line-height: 20px; + + .ant-avatar-string { + font-size: 12px; + line-height: 18px; + } + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/index.test.js b/antdsp-admin/src/main/web/src/components/AvatarList/index.test.js new file mode 100644 index 0000000..2b5bc43 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/index.test.js @@ -0,0 +1,29 @@ +import React from 'react'; +import range from 'lodash/range'; +import { mount } from 'enzyme'; +import AvatarList from './index'; + +const renderItems = numItems => + range(numItems).map(i => ( + + )); + +describe('AvatarList', () => { + it('renders all items', () => { + const wrapper = mount({renderItems(4)}); + expect(wrapper.find('AvatarList').length).toBe(1); + expect(wrapper.find('Item').length).toBe(4); + expect(wrapper.findWhere(node => node.key() === 'exceed').length).toBe(0); + }); + + it('renders max of 3 items', () => { + const wrapper = mount({renderItems(4)}); + expect(wrapper.find('AvatarList').length).toBe(1); + expect(wrapper.find('Item').length).toBe(3); + expect(wrapper.findWhere(node => node.key() === 'exceed').length).toBe(1); + }); +}); diff --git a/antdsp-admin/src/main/web/src/components/AvatarList/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/AvatarList/index.zh-CN.md new file mode 100644 index 0000000..bdab181 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/AvatarList/index.zh-CN.md @@ -0,0 +1,25 @@ +--- +title: AvatarList +subtitle: 用户头像列表 +order: 1 +cols: 1 +--- + +一组用户头像,常用在项目/团队成员列表。可通过设置 `size` 属性来指定头像大小。 + +## API + +### AvatarList + +| 参数 | 说明 | 类型 | 默认值 | +| ---------------- | -------- | ---------------------------------- | --------- | +| size | 头像大小 | `large`、`small` 、`mini`, `default` | `default` | +| maxLength | 要显示的最大项目 | number | - | +| excessItemsStyle | 多余的项目风格 | CSSProperties | - | + +### AvatarList.Item + +| 参数 | 说明 | 类型 | 默认值 | +| ---- | ------ | --------- | --- | +| tips | 头像展示文案 | ReactNode | - | +| src | 头像图片连接 | string | - | diff --git a/antdsp-admin/src/main/web/src/components/Charts/Bar/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/Bar/index.d.ts new file mode 100644 index 0000000..67bb1dd --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Bar/index.d.ts @@ -0,0 +1,15 @@ +import React from 'react'; +export interface IBarProps { + title: React.ReactNode; + color?: string; + padding?: [number, number, number, number]; + height: number; + data: Array<{ + x: string; + y: number; + }>; + autoLabel?: boolean; + style?: React.CSSProperties; +} + +export default class Bar extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Bar/index.js b/antdsp-admin/src/main/web/src/components/Charts/Bar/index.js new file mode 100644 index 0000000..f0cb65f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Bar/index.js @@ -0,0 +1,113 @@ +import React, { Component } from 'react'; +import { Chart, Axis, Tooltip, Geom } from 'bizcharts'; +import Debounce from 'lodash-decorators/debounce'; +import Bind from 'lodash-decorators/bind'; +import autoHeight from '../autoHeight'; +import styles from '../index.less'; + +@autoHeight() +class Bar extends Component { + state = { + autoHideXLabels: false, + }; + + componentDidMount() { + window.addEventListener('resize', this.resize, { passive: true }); + } + + componentWillUnmount() { + window.removeEventListener('resize', this.resize); + } + + handleRoot = n => { + this.root = n; + }; + + handleRef = n => { + this.node = n; + }; + + @Bind() + @Debounce(400) + resize() { + if (!this.node) { + return; + } + const canvasWidth = this.node.parentNode.clientWidth; + const { data = [], autoLabel = true } = this.props; + if (!autoLabel) { + return; + } + const minWidth = data.length * 30; + const { autoHideXLabels } = this.state; + + if (canvasWidth <= minWidth) { + if (!autoHideXLabels) { + this.setState({ + autoHideXLabels: true, + }); + } + } else if (autoHideXLabels) { + this.setState({ + autoHideXLabels: false, + }); + } + } + + render() { + const { + height, + title, + forceFit = true, + data, + color = 'rgba(24, 144, 255, 0.85)', + padding, + } = this.props; + + const { autoHideXLabels } = this.state; + + const scale = { + x: { + type: 'cat', + }, + y: { + min: 0, + }, + }; + + const tooltip = [ + 'x*y', + (x, y) => ({ + name: x, + value: y, + }), + ]; + + return ( +
    +
    + {title &&

    {title}

    } + + + + + + +
    +
    + ); + } +} + +export default Bar; diff --git a/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.d.ts new file mode 100644 index 0000000..5153f5e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.d.ts @@ -0,0 +1,14 @@ +import { CardProps } from 'antd/lib/card'; +import React from 'react'; + +export interface IChartCardProps extends CardProps { + title: React.ReactNode; + action?: React.ReactNode; + total?: React.ReactNode | number | (() => React.ReactNode | number); + footer?: React.ReactNode; + contentHeight?: number; + avatar?: React.ReactNode; + style?: React.CSSProperties; +} + +export default class ChartCard extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.js b/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.js new file mode 100644 index 0000000..ca6bcb2 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.js @@ -0,0 +1,82 @@ +import React from 'react'; +import { Card } from 'antd'; +import classNames from 'classnames'; + +import styles from './index.less'; + +const renderTotal = total => { + let totalDom; + switch (typeof total) { + case 'undefined': + totalDom = null; + break; + case 'function': + totalDom =
    {total()}
    ; + break; + default: + totalDom =
    {total}
    ; + } + return totalDom; +}; + +class ChartCard extends React.PureComponent { + renderConnet = () => { + const { contentHeight, title, avatar, action, total, footer, children, loading } = this.props; + if (loading) { + return false; + } + return ( +
    +
    +
    {avatar}
    +
    +
    + {title} + {action} +
    + {renderTotal(total)} +
    +
    + {children && ( +
    +
    {children}
    +
    + )} + {footer && ( +
    + {footer} +
    + )} +
    + ); + }; + + render() { + const { + loading = false, + contentHeight, + title, + avatar, + action, + total, + footer, + children, + ...rest + } = this.props; + return ( + + {this.renderConnet()} + + ); + } +} + +export default ChartCard; diff --git a/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.less b/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.less new file mode 100644 index 0000000..282f17d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/ChartCard/index.less @@ -0,0 +1,75 @@ +@import '~antd/lib/style/themes/default.less'; + +.chartCard { + position: relative; + .chartTop { + position: relative; + width: 100%; + overflow: hidden; + } + .chartTopMargin { + margin-bottom: 12px; + } + .chartTopHasMargin { + margin-bottom: 20px; + } + .metaWrap { + float: left; + } + .avatar { + position: relative; + top: 4px; + float: left; + margin-right: 20px; + img { + border-radius: 100%; + } + } + .meta { + height: 22px; + color: @text-color-secondary; + font-size: @font-size-base; + line-height: 22px; + } + .action { + position: absolute; + top: 4px; + right: 0; + line-height: 1; + cursor: pointer; + } + .total { + height: 38px; + margin-top: 4px; + margin-bottom: 0; + overflow: hidden; + color: @heading-color; + font-size: 30px; + line-height: 38px; + white-space: nowrap; + text-overflow: ellipsis; + word-break: break-all; + } + .content { + position: relative; + width: 100%; + margin-bottom: 12px; + } + .contentFixed { + position: absolute; + bottom: 0; + left: 0; + width: 100%; + } + .footer { + margin-top: 8px; + padding-top: 9px; + border-top: 1px solid @border-color-split; + & > * { + position: relative; + } + } + .footerMargin { + margin-top: 20px; + } +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Field/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/Field/index.d.ts new file mode 100644 index 0000000..80b1bf1 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Field/index.d.ts @@ -0,0 +1,8 @@ +import React from 'react'; +export interface IFieldProps { + label: React.ReactNode; + value: React.ReactNode; + style?: React.CSSProperties; +} + +export default class Field extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Field/index.js b/antdsp-admin/src/main/web/src/components/Charts/Field/index.js new file mode 100644 index 0000000..22dca86 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Field/index.js @@ -0,0 +1,12 @@ +import React from 'react'; + +import styles from './index.less'; + +const Field = ({ label, value, ...rest }) => ( +
    + {label} + {value} +
    +); + +export default Field; diff --git a/antdsp-admin/src/main/web/src/components/Charts/Field/index.less b/antdsp-admin/src/main/web/src/components/Charts/Field/index.less new file mode 100644 index 0000000..4124471 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Field/index.less @@ -0,0 +1,17 @@ +@import '~antd/lib/style/themes/default.less'; + +.field { + margin: 0; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + .label, + .number { + font-size: @font-size-base; + line-height: 22px; + } + .number { + margin-left: 8px; + color: @heading-color; + } +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Gauge/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/Gauge/index.d.ts new file mode 100644 index 0000000..fe55009 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Gauge/index.d.ts @@ -0,0 +1,11 @@ +import React from 'react'; +export interface IGaugeProps { + title: React.ReactNode; + color?: string; + height: number; + bgColor?: number; + percent: number; + style?: React.CSSProperties; +} + +export default class Gauge extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Gauge/index.js b/antdsp-admin/src/main/web/src/components/Charts/Gauge/index.js new file mode 100644 index 0000000..e97f126 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Gauge/index.js @@ -0,0 +1,167 @@ +import React from 'react'; +import { Chart, Geom, Axis, Coord, Guide, Shape } from 'bizcharts'; +import autoHeight from '../autoHeight'; + +const { Arc, Html, Line } = Guide; + +const defaultFormatter = val => { + switch (val) { + case '2': + return '差'; + case '4': + return '中'; + case '6': + return '良'; + case '8': + return '优'; + default: + return ''; + } +}; + +Shape.registerShape('point', 'pointer', { + drawShape(cfg, group) { + let point = cfg.points[0]; + point = this.parsePoint(point); + const center = this.parsePoint({ + x: 0, + y: 0, + }); + group.addShape('line', { + attrs: { + x1: center.x, + y1: center.y, + x2: point.x, + y2: point.y, + stroke: cfg.color, + lineWidth: 2, + lineCap: 'round', + }, + }); + return group.addShape('circle', { + attrs: { + x: center.x, + y: center.y, + r: 6, + stroke: cfg.color, + lineWidth: 3, + fill: '#fff', + }, + }); + }, +}); + +@autoHeight() +class Gauge extends React.Component { + render() { + const { + title, + height, + percent, + forceFit = true, + formatter = defaultFormatter, + color = '#2F9CFF', + bgColor = '#F0F2F5', + } = this.props; + const cols = { + value: { + type: 'linear', + min: 0, + max: 10, + tickCount: 6, + nice: true, + }, + }; + const data = [{ value: percent / 10 }]; + return ( + + + + + + + + + + + ` +
    +

    ${title}

    +

    + ${(data[0].value * 10).toFixed(2)}% +

    +
    `} + /> +
    + +
    + ); + } +} + +export default Gauge; diff --git a/antdsp-admin/src/main/web/src/components/Charts/MiniArea/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/MiniArea/index.d.ts new file mode 100644 index 0000000..8b4e71c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/MiniArea/index.d.ts @@ -0,0 +1,29 @@ +import React from 'react'; + +// g2已经更新到3.0 +// 不带的写了 + +export interface IAxis { + title: any; + line: any; + gridAlign: any; + labels: any; + tickLine: any; + grid: any; +} + +export interface IMiniAreaProps { + color?: string; + height: number; + borderColor?: string; + line?: boolean; + animate?: boolean; + xAxis?: IAxis; + yAxis?: IAxis; + data: Array<{ + x: number | string; + y: number; + }>; +} + +export default class MiniArea extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/MiniArea/index.js b/antdsp-admin/src/main/web/src/components/Charts/MiniArea/index.js new file mode 100644 index 0000000..d3209be --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/MiniArea/index.js @@ -0,0 +1,108 @@ +import React from 'react'; +import { Chart, Axis, Tooltip, Geom } from 'bizcharts'; +import autoHeight from '../autoHeight'; +import styles from '../index.less'; + +@autoHeight() +class MiniArea extends React.PureComponent { + render() { + const { + height, + data = [], + forceFit = true, + color = 'rgba(24, 144, 255, 0.2)', + borderColor = '#1089ff', + scale = {}, + borderWidth = 2, + line, + xAxis, + yAxis, + animate = true, + } = this.props; + + const padding = [36, 5, 30, 5]; + + const scaleProps = { + x: { + type: 'cat', + range: [0, 1], + ...scale.x, + }, + y: { + min: 0, + ...scale.y, + }, + }; + + const tooltip = [ + 'x*y', + (x, y) => ({ + name: x, + value: y, + }), + ]; + + const chartHeight = height + 54; + + return ( +
    +
    + {height > 0 && ( + + + + + + {line ? ( + + ) : ( + + )} + + )} +
    +
    + ); + } +} + +export default MiniArea; diff --git a/antdsp-admin/src/main/web/src/components/Charts/MiniBar/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/MiniBar/index.d.ts new file mode 100644 index 0000000..b268533 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/MiniBar/index.d.ts @@ -0,0 +1,12 @@ +import React from 'react'; +export interface IMiniBarProps { + color?: string; + height: number; + data: Array<{ + x: number | string; + y: number; + }>; + style?: React.CSSProperties; +} + +export default class MiniBar extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/MiniBar/index.js b/antdsp-admin/src/main/web/src/components/Charts/MiniBar/index.js new file mode 100644 index 0000000..18e4d8c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/MiniBar/index.js @@ -0,0 +1,51 @@ +import React from 'react'; +import { Chart, Tooltip, Geom } from 'bizcharts'; +import autoHeight from '../autoHeight'; +import styles from '../index.less'; + +@autoHeight() +class MiniBar extends React.Component { + render() { + const { height, forceFit = true, color = '#1890FF', data = [] } = this.props; + + const scale = { + x: { + type: 'cat', + }, + y: { + min: 0, + }, + }; + + const padding = [36, 5, 30, 5]; + + const tooltip = [ + 'x*y', + (x, y) => ({ + name: x, + value: y, + }), + ]; + + // for tooltip not to be hide + const chartHeight = height + 54; + + return ( +
    +
    + + + + +
    +
    + ); + } +} +export default MiniBar; diff --git a/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.d.ts new file mode 100644 index 0000000..6111d88 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.d.ts @@ -0,0 +1,11 @@ +import React from 'react'; +export interface IMiniProgressProps { + target: number; + targetLabel: string; + color?: string; + strokeWidth?: number; + percent?: number; + style?: React.CSSProperties; +} + +export default class MiniProgress extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.js b/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.js new file mode 100644 index 0000000..dd5712e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.js @@ -0,0 +1,34 @@ +import React from 'react'; +import { Tooltip } from 'antd'; +import styles from './index.less'; + +const MiniProgress = ({ + targetLabel, + target, + color = 'rgb(19, 194, 194)', + strokeWidth, + percent, +}) => { + return ( +
    + +
    + + +
    +
    +
    +
    +
    +
    + ); +}; + +export default MiniProgress; diff --git a/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.less b/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.less new file mode 100644 index 0000000..e1e0b4f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/MiniProgress/index.less @@ -0,0 +1,37 @@ +@import '~antd/lib/style/themes/default.less'; + +.miniProgress { + position: relative; + width: 100%; + padding: 5px 0; + .progressWrap { + position: relative; + background-color: @background-color-base; + } + .progress { + width: 0; + height: 100%; + background-color: @primary-color; + border-radius: 1px 0 0 1px; + transition: all 0.4s cubic-bezier(0.08, 0.82, 0.17, 1) 0s; + } + .target { + position: absolute; + top: 0; + bottom: 0; + z-index: 9; + width: 20px; + span { + position: absolute; + top: 0; + left: 0; + width: 2px; + height: 4px; + border-radius: 100px; + } + span:last-child { + top: auto; + bottom: 0; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Pie/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/Pie/index.d.ts new file mode 100644 index 0000000..63aecfa --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Pie/index.d.ts @@ -0,0 +1,21 @@ +import React from 'react'; +export interface IPieProps { + animate?: boolean; + color?: string; + colors?: string[]; + height: number; + hasLegend?: boolean; + padding?: [number, number, number, number]; + percent?: number; + data?: Array<{ + x: string | string; + y: number; + }>; + total?: React.ReactNode | number | (() => React.ReactNode | number); + title?: React.ReactNode; + tooltip?: boolean; + valueFormat?: (value: string) => string | React.ReactNode; + subTitle?: React.ReactNode; +} + +export default class Pie extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Pie/index.js b/antdsp-admin/src/main/web/src/components/Charts/Pie/index.js new file mode 100644 index 0000000..7dff512 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Pie/index.js @@ -0,0 +1,271 @@ +import React, { Component } from 'react'; +import { Chart, Tooltip, Geom, Coord } from 'bizcharts'; +import { DataView } from '@antv/data-set'; +import { Divider } from 'antd'; +import classNames from 'classnames'; +import ReactFitText from 'react-fittext'; +import Debounce from 'lodash-decorators/debounce'; +import Bind from 'lodash-decorators/bind'; +import autoHeight from '../autoHeight'; + +import styles from './index.less'; + +/* eslint react/no-danger:0 */ +@autoHeight() +class Pie extends Component { + state = { + legendData: [], + legendBlock: false, + }; + + componentDidMount() { + window.addEventListener( + 'resize', + () => { + this.requestRef = requestAnimationFrame(() => this.resize()); + }, + { passive: true } + ); + } + + componentDidUpdate(preProps) { + const { data } = this.props; + if (data !== preProps.data) { + // because of charts data create when rendered + // so there is a trick for get rendered time + this.getLegendData(); + } + } + + componentWillUnmount() { + window.cancelAnimationFrame(this.requestRef); + window.removeEventListener('resize', this.resize); + this.resize.cancel(); + } + + getG2Instance = chart => { + this.chart = chart; + requestAnimationFrame(() => { + this.getLegendData(); + this.resize(); + }); + }; + + // for custom lengend view + getLegendData = () => { + if (!this.chart) return; + const geom = this.chart.getAllGeoms()[0]; // 获取所有的图形 + if (!geom) return; + const items = geom.get('dataArray') || []; // 获取图形对应的 + + const legendData = items.map(item => { + /* eslint no-underscore-dangle:0 */ + const origin = item[0]._origin; + origin.color = item[0].color; + origin.checked = true; + return origin; + }); + + this.setState({ + legendData, + }); + }; + + handleRoot = n => { + this.root = n; + }; + + handleLegendClick = (item, i) => { + const newItem = item; + newItem.checked = !newItem.checked; + + const { legendData } = this.state; + legendData[i] = newItem; + + const filteredLegendData = legendData.filter(l => l.checked).map(l => l.x); + + if (this.chart) { + this.chart.filter('x', val => filteredLegendData.indexOf(val) > -1); + } + + this.setState({ + legendData, + }); + }; + + // for window resize auto responsive legend + @Bind() + @Debounce(300) + resize() { + const { hasLegend } = this.props; + const { legendBlock } = this.state; + if (!hasLegend || !this.root) { + window.removeEventListener('resize', this.resize); + return; + } + if (this.root.parentNode.clientWidth <= 380) { + if (!legendBlock) { + this.setState({ + legendBlock: true, + }); + } + } else if (legendBlock) { + this.setState({ + legendBlock: false, + }); + } + } + + render() { + const { + valueFormat, + subTitle, + total, + hasLegend = false, + className, + style, + height, + forceFit = true, + percent, + color, + inner = 0.75, + animate = true, + colors, + lineWidth = 1, + } = this.props; + + const { legendData, legendBlock } = this.state; + const pieClassName = classNames(styles.pie, className, { + [styles.hasLegend]: !!hasLegend, + [styles.legendBlock]: legendBlock, + }); + + const { + data: propsData, + selected: propsSelected = true, + tooltip: propsTooltip = true, + } = this.props; + + let data = propsData || []; + let selected = propsSelected; + let tooltip = propsTooltip; + + const defaultColors = colors; + data = data || []; + selected = selected || true; + tooltip = tooltip || true; + let formatColor; + + const scale = { + x: { + type: 'cat', + range: [0, 1], + }, + y: { + min: 0, + }, + }; + + if (percent || percent === 0) { + selected = false; + tooltip = false; + formatColor = value => { + if (value === '占比') { + return color || 'rgba(24, 144, 255, 0.85)'; + } + return '#F0F2F5'; + }; + + data = [ + { + x: '占比', + y: parseFloat(percent), + }, + { + x: '反比', + y: 100 - parseFloat(percent), + }, + ]; + } + + const tooltipFormat = [ + 'x*percent', + (x, p) => ({ + name: x, + value: `${(p * 100).toFixed(2)}%`, + }), + ]; + + const padding = [12, 0, 12, 0]; + + const dv = new DataView(); + dv.source(data).transform({ + type: 'percent', + field: 'y', + dimension: 'x', + as: 'percent', + }); + + return ( +
    + +
    + + {!!tooltip && } + + + + + {(subTitle || total) && ( +
    + {subTitle &&

    {subTitle}

    } + {/* eslint-disable-next-line */} + {total && ( +
    {typeof total === 'function' ? total() : total}
    + )} +
    + )} +
    +
    + + {hasLegend && ( +
      + {legendData.map((item, i) => ( +
    • this.handleLegendClick(item, i)}> + + {item.x} + + + {`${(Number.isNaN(item.percent) ? 0 : item.percent * 100).toFixed(2)}%`} + + {valueFormat ? valueFormat(item.y) : item.y} +
    • + ))} +
    + )} +
    + ); + } +} + +export default Pie; diff --git a/antdsp-admin/src/main/web/src/components/Charts/Pie/index.less b/antdsp-admin/src/main/web/src/components/Charts/Pie/index.less new file mode 100644 index 0000000..fc961b4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Pie/index.less @@ -0,0 +1,94 @@ +@import '~antd/lib/style/themes/default.less'; + +.pie { + position: relative; + .chart { + position: relative; + } + &.hasLegend .chart { + width: ~'calc(100% - 240px)'; + } + .legend { + position: absolute; + top: 50%; + right: 0; + min-width: 200px; + margin: 0 20px; + padding: 0; + list-style: none; + transform: translateY(-50%); + li { + height: 22px; + margin-bottom: 16px; + line-height: 22px; + cursor: pointer; + &:last-child { + margin-bottom: 0; + } + } + } + .dot { + position: relative; + top: -1px; + display: inline-block; + width: 8px; + height: 8px; + margin-right: 8px; + border-radius: 8px; + } + .line { + display: inline-block; + width: 1px; + height: 16px; + margin-right: 8px; + background-color: @border-color-split; + } + .legendTitle { + color: @text-color; + } + .percent { + color: @text-color-secondary; + } + .value { + position: absolute; + right: 0; + } + .title { + margin-bottom: 8px; + } + .total { + position: absolute; + top: 50%; + left: 50%; + max-height: 62px; + text-align: center; + transform: translate(-50%, -50%); + & > h4 { + height: 22px; + margin-bottom: 8px; + color: @text-color-secondary; + font-weight: normal; + font-size: 14px; + line-height: 22px; + } + & > p { + display: block; + height: 32px; + color: @heading-color; + font-size: 1.2em; + line-height: 32px; + white-space: nowrap; + } + } +} + +.legendBlock { + &.hasLegend .chart { + width: 100%; + margin: 0 0 32px 0; + } + .legend { + position: relative; + transform: none; + } +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Radar/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/Radar/index.d.ts new file mode 100644 index 0000000..6a7dd42 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Radar/index.d.ts @@ -0,0 +1,15 @@ +import React from 'react'; +export interface IRadarProps { + title?: React.ReactNode; + height: number; + padding?: [number, number, number, number]; + hasLegend?: boolean; + data: Array<{ + name: string; + label: string; + value: string; + }>; + style?: React.CSSProperties; +} + +export default class Radar extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/Radar/index.js b/antdsp-admin/src/main/web/src/components/Charts/Radar/index.js new file mode 100644 index 0000000..a0aa7fa --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Radar/index.js @@ -0,0 +1,184 @@ +import React, { Component } from 'react'; +import { Chart, Tooltip, Geom, Coord, Axis } from 'bizcharts'; +import { Row, Col } from 'antd'; +import autoHeight from '../autoHeight'; +import styles from './index.less'; + +/* eslint react/no-danger:0 */ +@autoHeight() +class Radar extends Component { + state = { + legendData: [], + }; + + componentDidMount() { + this.getLegendData(); + } + + componentDidUpdate(preProps) { + const { data } = this.props; + if (data !== preProps.data) { + this.getLegendData(); + } + } + + getG2Instance = chart => { + this.chart = chart; + }; + + // for custom lengend view + getLegendData = () => { + if (!this.chart) return; + const geom = this.chart.getAllGeoms()[0]; // 获取所有的图形 + if (!geom) return; + const items = geom.get('dataArray') || []; // 获取图形对应的 + + const legendData = items.map(item => { + // eslint-disable-next-line + const origins = item.map(t => t._origin); + const result = { + name: origins[0].name, + color: item[0].color, + checked: true, + value: origins.reduce((p, n) => p + n.value, 0), + }; + + return result; + }); + + this.setState({ + legendData, + }); + }; + + handleRef = n => { + this.node = n; + }; + + handleLegendClick = (item, i) => { + const newItem = item; + newItem.checked = !newItem.checked; + + const { legendData } = this.state; + legendData[i] = newItem; + + const filteredLegendData = legendData.filter(l => l.checked).map(l => l.name); + + if (this.chart) { + this.chart.filter('name', val => filteredLegendData.indexOf(val) > -1); + this.chart.repaint(); + } + + this.setState({ + legendData, + }); + }; + + render() { + const defaultColors = [ + '#1890FF', + '#FACC14', + '#2FC25B', + '#8543E0', + '#F04864', + '#13C2C2', + '#fa8c16', + '#a0d911', + ]; + + const { + data = [], + height = 0, + title, + hasLegend = false, + forceFit = true, + tickCount = 5, + padding = [35, 30, 16, 30], + animate = true, + colors = defaultColors, + } = this.props; + + const { legendData } = this.state; + + const scale = { + value: { + min: 0, + tickCount, + }, + }; + + const chartHeight = height - (hasLegend ? 80 : 22); + + return ( +
    + {title &&

    {title}

    } + + + + + + + + + {hasLegend && ( + + {legendData.map((item, i) => ( + this.handleLegendClick(item, i)} + > +
    +

    + + {item.name} +

    +
    {item.value}
    +
    + + ))} +
    + )} +
    + ); + } +} + +export default Radar; diff --git a/antdsp-admin/src/main/web/src/components/Charts/Radar/index.less b/antdsp-admin/src/main/web/src/components/Charts/Radar/index.less new file mode 100644 index 0000000..437a712 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/Radar/index.less @@ -0,0 +1,46 @@ +@import '~antd/lib/style/themes/default.less'; + +.radar { + .legend { + margin-top: 16px; + .legendItem { + position: relative; + color: @text-color-secondary; + line-height: 22px; + text-align: center; + cursor: pointer; + p { + margin: 0; + } + h6 { + margin-top: 4px; + margin-bottom: 0; + padding-left: 16px; + color: @heading-color; + font-size: 24px; + line-height: 32px; + } + &::after { + position: absolute; + top: 8px; + right: 0; + width: 1px; + height: 40px; + background-color: @border-color-split; + content: ''; + } + } + > :last-child .legendItem::after { + display: none; + } + .dot { + position: relative; + top: -1px; + display: inline-block; + width: 6px; + height: 6px; + margin-right: 6px; + border-radius: 6px; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.d.ts new file mode 100644 index 0000000..ac25269 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.d.ts @@ -0,0 +1,11 @@ +import React from 'react'; +export interface ITagCloudProps { + data: Array<{ + name: string; + value: number; + }>; + height: number; + style?: React.CSSProperties; +} + +export default class TagCloud extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.js b/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.js new file mode 100644 index 0000000..4898d82 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.js @@ -0,0 +1,178 @@ +import React, { Component } from 'react'; +import { Chart, Geom, Coord, Shape, Tooltip } from 'bizcharts'; +import DataSet from '@antv/data-set'; +import Debounce from 'lodash-decorators/debounce'; +import Bind from 'lodash-decorators/bind'; +import classNames from 'classnames'; +import autoHeight from '../autoHeight'; +import styles from './index.less'; + +/* eslint no-underscore-dangle: 0 */ +/* eslint no-param-reassign: 0 */ + +const imgUrl = 'https://gw.alipayobjects.com/zos/rmsportal/gWyeGLCdFFRavBGIDzWk.png'; + +@autoHeight() +class TagCloud extends Component { + state = { + dv: null, + }; + + componentDidMount() { + requestAnimationFrame(() => { + this.initTagCloud(); + this.renderChart(); + }); + window.addEventListener('resize', this.resize, { passive: true }); + } + + componentDidUpdate(preProps) { + const { data } = this.props; + if (JSON.stringify(preProps.data) !== JSON.stringify(data)) { + this.renderChart(this.props); + } + } + + componentWillUnmount() { + this.isUnmount = true; + window.cancelAnimationFrame(this.requestRef); + window.removeEventListener('resize', this.resize); + } + + resize = () => { + this.requestRef = requestAnimationFrame(() => { + this.renderChart(); + }); + }; + + saveRootRef = node => { + this.root = node; + }; + + initTagCloud = () => { + function getTextAttrs(cfg) { + return Object.assign({}, cfg.style, { + fillOpacity: cfg.opacity, + fontSize: cfg.origin._origin.size, + rotate: cfg.origin._origin.rotate, + text: cfg.origin._origin.text, + textAlign: 'center', + fontFamily: cfg.origin._origin.font, + fill: cfg.color, + textBaseline: 'Alphabetic', + }); + } + + // 给point注册一个词云的shape + Shape.registerShape('point', 'cloud', { + drawShape(cfg, container) { + const attrs = getTextAttrs(cfg); + return container.addShape('text', { + attrs: Object.assign(attrs, { + x: cfg.x, + y: cfg.y, + }), + }); + }, + }); + }; + + @Bind() + @Debounce(500) + renderChart(nextProps) { + // const colors = ['#1890FF', '#41D9C7', '#2FC25B', '#FACC14', '#9AE65C']; + const { data, height } = nextProps || this.props; + + if (data.length < 1 || !this.root) { + return; + } + + const h = height; + const w = this.root.offsetWidth; + + const onload = () => { + const dv = new DataSet.View().source(data); + const range = dv.range('value'); + const [min, max] = range; + dv.transform({ + type: 'tag-cloud', + fields: ['name', 'value'], + imageMask: this.imageMask, + font: 'Verdana', + size: [w, h], // 宽高设置最好根据 imageMask 做调整 + padding: 0, + timeInterval: 5000, // max execute time + rotate() { + return 0; + }, + fontSize(d) { + // eslint-disable-next-line + return Math.pow((d.value - min) / (max - min), 2) * (17.5 - 5) + 5; + }, + }); + + if (this.isUnmount) { + return; + } + + this.setState({ + dv, + w, + h, + }); + }; + + if (!this.imageMask) { + this.imageMask = new Image(); + this.imageMask.crossOrigin = ''; + this.imageMask.src = imgUrl; + + this.imageMask.onload = onload; + } else { + onload(); + } + } + + render() { + const { className, height } = this.props; + const { dv, w, h } = this.state; + + return ( +
    + {dv && ( + + + + + + )} +
    + ); + } +} + +export default TagCloud; diff --git a/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.less b/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.less new file mode 100644 index 0000000..db8e4da --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/TagCloud/index.less @@ -0,0 +1,6 @@ +.tagCloud { + overflow: hidden; + canvas { + transform-origin: 0 0; + } +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.d.ts new file mode 100644 index 0000000..0f547e7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.d.ts @@ -0,0 +1,14 @@ +import React from 'react'; +export interface ITimelineChartProps { + data: Array<{ + x: number; + y1: number; + y2?: number; + }>; + titleMap: { y1: string; y2?: string }; + padding?: [number, number, number, number]; + height?: number; + style?: React.CSSProperties; +} + +export default class TimelineChart extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.js b/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.js new file mode 100644 index 0000000..d82623c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.js @@ -0,0 +1,120 @@ +import React from 'react'; +import { Chart, Tooltip, Geom, Legend, Axis } from 'bizcharts'; +import DataSet from '@antv/data-set'; +import Slider from 'bizcharts-plugin-slider'; +import autoHeight from '../autoHeight'; +import styles from './index.less'; + +@autoHeight() +class TimelineChart extends React.Component { + render() { + const { + title, + height = 400, + padding = [60, 20, 40, 40], + titleMap = { + y1: 'y1', + y2: 'y2', + }, + borderWidth = 2, + data: sourceData, + } = this.props; + + const data = Array.isArray(sourceData) ? sourceData : [{ x: 0, y1: 0, y2: 0 }]; + + data.sort((a, b) => a.x - b.x); + + let max; + if (data[0] && data[0].y1 && data[0].y2) { + max = Math.max( + [...data].sort((a, b) => b.y1 - a.y1)[0].y1, + [...data].sort((a, b) => b.y2 - a.y2)[0].y2 + ); + } + + const ds = new DataSet({ + state: { + start: data[0].x, + end: data[data.length - 1].x, + }, + }); + + const dv = ds.createView(); + dv.source(data) + .transform({ + type: 'filter', + callback: obj => { + const date = obj.x; + return date <= ds.state.end && date >= ds.state.start; + }, + }) + .transform({ + type: 'map', + callback(row) { + const newRow = { ...row }; + newRow[titleMap.y1] = row.y1; + newRow[titleMap.y2] = row.y2; + return newRow; + }, + }) + .transform({ + type: 'fold', + fields: [titleMap.y1, titleMap.y2], // 展开字段集 + key: 'key', // key字段 + value: 'value', // value字段 + }); + + const timeScale = { + type: 'time', + tickInterval: 60 * 60 * 1000, + mask: 'HH:mm', + range: [0, 1], + }; + + const cols = { + x: timeScale, + value: { + max, + min: 0, + }, + }; + + const SliderGen = () => ( + { + ds.setState('start', startValue); + ds.setState('end', endValue); + }} + /> + ); + + return ( +
    +
    + {title &&

    {title}

    } + + + + + + +
    + +
    +
    +
    + ); + } +} + +export default TimelineChart; diff --git a/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.less b/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.less new file mode 100644 index 0000000..1751975 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/TimelineChart/index.less @@ -0,0 +1,3 @@ +.timelineChart { + background: #fff; +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.d.ts new file mode 100644 index 0000000..e30a7e4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.d.ts @@ -0,0 +1,10 @@ +import React from 'react'; +export interface IWaterWaveProps { + title: React.ReactNode; + color?: string; + height: number; + percent: number; + style?: React.CSSProperties; +} + +export default class WaterWave extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.js b/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.js new file mode 100644 index 0000000..055f7c7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.js @@ -0,0 +1,213 @@ +import React, { PureComponent } from 'react'; +import autoHeight from '../autoHeight'; +import styles from './index.less'; + +/* eslint no-return-assign: 0 */ +/* eslint no-mixed-operators: 0 */ +// riddle: https://riddle.alibaba-inc.com/riddles/2d9a4b90 + +@autoHeight() +class WaterWave extends PureComponent { + state = { + radio: 1, + }; + + componentDidMount() { + this.renderChart(); + this.resize(); + window.addEventListener( + 'resize', + () => { + requestAnimationFrame(() => this.resize()); + }, + { passive: true } + ); + } + + componentDidUpdate(props) { + const { percent } = this.props; + if (props.percent !== percent) { + // 不加这个会造成绘制缓慢 + this.renderChart('update'); + } + } + + componentWillUnmount() { + cancelAnimationFrame(this.timer); + if (this.node) { + this.node.innerHTML = ''; + } + window.removeEventListener('resize', this.resize); + } + + resize = () => { + if (this.root) { + const { height } = this.props; + const { offsetWidth } = this.root.parentNode; + this.setState({ + radio: offsetWidth < height ? offsetWidth / height : 1, + }); + } + }; + + renderChart(type) { + const { percent, color = '#1890FF' } = this.props; + const data = percent / 100; + const self = this; + cancelAnimationFrame(this.timer); + + if (!this.node || (data !== 0 && !data)) { + return; + } + + const canvas = this.node; + const ctx = canvas.getContext('2d'); + const canvasWidth = canvas.width; + const canvasHeight = canvas.height; + const radius = canvasWidth / 2; + const lineWidth = 2; + const cR = radius - lineWidth; + + ctx.beginPath(); + ctx.lineWidth = lineWidth * 2; + + const axisLength = canvasWidth - lineWidth; + const unit = axisLength / 8; + const range = 0.2; // 振幅 + let currRange = range; + const xOffset = lineWidth; + let sp = 0; // 周期偏移量 + let currData = 0; + const waveupsp = 0.005; // 水波上涨速度 + + let arcStack = []; + const bR = radius - lineWidth; + const circleOffset = -(Math.PI / 2); + let circleLock = true; + + for (let i = circleOffset; i < circleOffset + 2 * Math.PI; i += 1 / (8 * Math.PI)) { + arcStack.push([radius + bR * Math.cos(i), radius + bR * Math.sin(i)]); + } + + const cStartPoint = arcStack.shift(); + ctx.strokeStyle = color; + ctx.moveTo(cStartPoint[0], cStartPoint[1]); + + function drawSin() { + ctx.beginPath(); + ctx.save(); + + const sinStack = []; + for (let i = xOffset; i <= xOffset + axisLength; i += 20 / axisLength) { + const x = sp + (xOffset + i) / unit; + const y = Math.sin(x) * currRange; + const dx = i; + const dy = 2 * cR * (1 - currData) + (radius - cR) - unit * y; + + ctx.lineTo(dx, dy); + sinStack.push([dx, dy]); + } + + const startPoint = sinStack.shift(); + + ctx.lineTo(xOffset + axisLength, canvasHeight); + ctx.lineTo(xOffset, canvasHeight); + ctx.lineTo(startPoint[0], startPoint[1]); + + const gradient = ctx.createLinearGradient(0, 0, 0, canvasHeight); + gradient.addColorStop(0, '#ffffff'); + gradient.addColorStop(1, color); + ctx.fillStyle = gradient; + ctx.fill(); + ctx.restore(); + } + + function render() { + ctx.clearRect(0, 0, canvasWidth, canvasHeight); + if (circleLock && type !== 'update') { + if (arcStack.length) { + const temp = arcStack.shift(); + ctx.lineTo(temp[0], temp[1]); + ctx.stroke(); + } else { + circleLock = false; + ctx.lineTo(cStartPoint[0], cStartPoint[1]); + ctx.stroke(); + arcStack = null; + + ctx.globalCompositeOperation = 'destination-over'; + ctx.beginPath(); + ctx.lineWidth = lineWidth; + ctx.arc(radius, radius, bR, 0, 2 * Math.PI, 1); + + ctx.beginPath(); + ctx.save(); + ctx.arc(radius, radius, radius - 3 * lineWidth, 0, 2 * Math.PI, 1); + + ctx.restore(); + ctx.clip(); + ctx.fillStyle = color; + } + } else { + if (data >= 0.85) { + if (currRange > range / 4) { + const t = range * 0.01; + currRange -= t; + } + } else if (data <= 0.1) { + if (currRange < range * 1.5) { + const t = range * 0.01; + currRange += t; + } + } else { + if (currRange <= range) { + const t = range * 0.01; + currRange += t; + } + if (currRange >= range) { + const t = range * 0.01; + currRange -= t; + } + } + if (data - currData > 0) { + currData += waveupsp; + } + if (data - currData < 0) { + currData -= waveupsp; + } + + sp += 0.07; + drawSin(); + } + self.timer = requestAnimationFrame(render); + } + render(); + } + + render() { + const { radio } = this.state; + const { percent, title, height } = this.props; + return ( +
    (this.root = n)} + style={{ transform: `scale(${radio})` }} + > +
    + (this.node = n)} + width={height * 2} + height={height * 2} + /> +
    +
    + {title && {title}} +

    {percent}%

    +
    +
    + ); + } +} + +export default WaterWave; diff --git a/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.less b/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.less new file mode 100644 index 0000000..2e75f21 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/WaterWave/index.less @@ -0,0 +1,28 @@ +@import '~antd/lib/style/themes/default.less'; + +.waterWave { + position: relative; + display: inline-block; + transform-origin: left; + .text { + position: absolute; + top: 32px; + left: 0; + width: 100%; + text-align: center; + span { + color: @text-color-secondary; + font-size: 14px; + line-height: 22px; + } + h4 { + color: @heading-color; + font-size: 24px; + line-height: 32px; + } + } + .waterWaveCanvasWrapper { + transform: scale(0.5); + transform-origin: 0 0; + } +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/autoHeight.js b/antdsp-admin/src/main/web/src/components/Charts/autoHeight.js new file mode 100644 index 0000000..6ee9e09 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/autoHeight.js @@ -0,0 +1,62 @@ +/* eslint eqeqeq: 0 */ +import React from 'react'; + +function computeHeight(node) { + const totalHeight = parseInt(getComputedStyle(node).height, 10); + const padding = + parseInt(getComputedStyle(node).paddingTop, 10) + + parseInt(getComputedStyle(node).paddingBottom, 10); + return totalHeight - padding; +} + +function getAutoHeight(n) { + if (!n) { + return 0; + } + + let node = n; + + let height = computeHeight(node); + + while (!height) { + node = node.parentNode; + if (node) { + height = computeHeight(node); + } else { + break; + } + } + + return height; +} + +const autoHeight = () => WrappedComponent => + class extends React.Component { + state = { + computedHeight: 0, + }; + + componentDidMount() { + const { height } = this.props; + if (!height) { + const h = getAutoHeight(this.root); + // eslint-disable-next-line + this.setState({ computedHeight: h }); + } + } + + handleRoot = node => { + this.root = node; + }; + + render() { + const { height } = this.props; + const { computedHeight } = this.state; + const h = height || computedHeight; + return ( +
    {h > 0 && }
    + ); + } + }; + +export default autoHeight; diff --git a/antdsp-admin/src/main/web/src/components/Charts/bizcharts.d.ts b/antdsp-admin/src/main/web/src/components/Charts/bizcharts.d.ts new file mode 100644 index 0000000..0815ffe --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/bizcharts.d.ts @@ -0,0 +1,3 @@ +import * as BizChart from 'bizcharts'; + +export = BizChart; diff --git a/antdsp-admin/src/main/web/src/components/Charts/bizcharts.js b/antdsp-admin/src/main/web/src/components/Charts/bizcharts.js new file mode 100644 index 0000000..e08db8d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/bizcharts.js @@ -0,0 +1,3 @@ +import * as BizChart from 'bizcharts'; + +export default BizChart; diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/bar.md b/antdsp-admin/src/main/web/src/components/Charts/demo/bar.md new file mode 100644 index 0000000..955f44e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/bar.md @@ -0,0 +1,26 @@ +--- +order: 4 +title: 柱状图 +--- + +通过设置 `x`,`y` 属性,可以快速的构建出一个漂亮的柱状图,各种纬度的关系则是通过自定义的数据展现。 + +````jsx +import { Bar } from 'ant-design-pro/lib/Charts'; + +const salesData = []; +for (let i = 0; i < 12; i += 1) { + salesData.push({ + x: `${i + 1}月`, + y: Math.floor(Math.random() * 1000) + 200, + }); +} + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/chart-card.md b/antdsp-admin/src/main/web/src/components/Charts/demo/chart-card.md new file mode 100644 index 0000000..4da852b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/chart-card.md @@ -0,0 +1,95 @@ +--- +order: 1 +title: 图表卡片 +--- + +用于展示图表的卡片容器,可以方便的配合其它图表套件展示丰富信息。 + +```jsx +import { ChartCard, yuan, Field } from 'ant-design-pro/lib/Charts'; +import Trend from 'ant-design-pro/lib/Trend'; +import { Row, Col, Icon, Tooltip } from 'antd'; +import numeral from 'numeral'; + +ReactDOM.render( + + + + + + } + total={() => ( + + )} + footer={ + + } + contentHeight={46} + > + + 周同比 + + 12% + + + + 日环比 + + 11% + + + + + + + } + action={ + + + + } + total={() => ( + + )} + footer={ + + } + /> + + + + } + action={ + + + + } + total={() => ( + + )} + /> + + , + mountNode, +); +``` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/gauge.md b/antdsp-admin/src/main/web/src/components/Charts/demo/gauge.md new file mode 100644 index 0000000..f53465d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/gauge.md @@ -0,0 +1,18 @@ +--- +order: 7 +title: 仪表盘 +--- + +仪表盘是一种进度展示方式,可以更直观的展示当前的进展情况,通常也可表示占比。 + +````jsx +import { Gauge } from 'ant-design-pro/lib/Charts'; + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/mini-area.md b/antdsp-admin/src/main/web/src/components/Charts/demo/mini-area.md new file mode 100644 index 0000000..2b9bfb4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/mini-area.md @@ -0,0 +1,28 @@ +--- +order: 2 +col: 2 +title: 迷你区域图 +--- + +````jsx +import { MiniArea } from 'ant-design-pro/lib/Charts'; +import moment from 'moment'; + +const visitData = []; +const beginDay = new Date().getTime(); +for (let i = 0; i < 20; i += 1) { + visitData.push({ + x: moment(new Date(beginDay + (1000 * 60 * 60 * 24 * i))).format('YYYY-MM-DD'), + y: Math.floor(Math.random() * 100) + 10, + }); +} + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/mini-bar.md b/antdsp-admin/src/main/web/src/components/Charts/demo/mini-bar.md new file mode 100644 index 0000000..fef301b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/mini-bar.md @@ -0,0 +1,28 @@ +--- +order: 2 +col: 2 +title: 迷你柱状图 +--- + +迷你柱状图更适合展示简单的区间数据,简洁的表现方式可以很好的减少大数据量的视觉展现压力。 + +````jsx +import { MiniBar } from 'ant-design-pro/lib/Charts'; +import moment from 'moment'; + +const visitData = []; +const beginDay = new Date().getTime(); +for (let i = 0; i < 20; i += 1) { + visitData.push({ + x: moment(new Date(beginDay + (1000 * 60 * 60 * 24 * i))).format('YYYY-MM-DD'), + y: Math.floor(Math.random() * 100) + 10, + }); +} + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/mini-pie.md b/antdsp-admin/src/main/web/src/components/Charts/demo/mini-pie.md new file mode 100644 index 0000000..9b1abf0 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/mini-pie.md @@ -0,0 +1,16 @@ +--- +order: 6 +title: 迷你饼状图 +--- + +通过简化 `Pie` 属性的设置,可以快速的实现极简的饼状图,可配合 `ChartCard` 组合展 +现更多业务场景。 + +```jsx +import { Pie } from 'ant-design-pro/lib/Charts'; + +ReactDOM.render( + , + mountNode +); +``` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/mini-progress.md b/antdsp-admin/src/main/web/src/components/Charts/demo/mini-progress.md new file mode 100644 index 0000000..6308a8f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/mini-progress.md @@ -0,0 +1,12 @@ +--- +order: 3 +title: 迷你进度条 +--- + +````jsx +import { MiniProgress } from 'ant-design-pro/lib/Charts'; + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/mix.md b/antdsp-admin/src/main/web/src/components/Charts/demo/mix.md new file mode 100644 index 0000000..fc64110 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/mix.md @@ -0,0 +1,84 @@ +--- +order: 0 +title: 图表套件组合展示 +--- + +利用 Ant Design Pro 提供的图表套件,可以灵活组合符合设计规范的图表来满足复杂的业务需求。 + +````jsx +import { ChartCard, Field, MiniArea, MiniBar, MiniProgress } from 'ant-design-pro/lib/Charts'; +import Trend from 'ant-design-pro/lib/Trend'; +import NumberInfo from 'ant-design-pro/lib/NumberInfo'; +import { Row, Col, Icon, Tooltip } from 'antd'; +import numeral from 'numeral'; +import moment from 'moment'; + +const visitData = []; +const beginDay = new Date().getTime(); +for (let i = 0; i < 20; i += 1) { + visitData.push({ + x: moment(new Date(beginDay + (1000 * 60 * 60 * 24 * i))).format('YYYY-MM-DD'), + y: Math.floor(Math.random() * 100) + 10, + }); +} + +ReactDOM.render( + + + + 本周访问} + total={numeral(12321).format('0,0')} + status="up" + subTotal={17.1} + /> + + + + + } + total={numeral(8846).format('0,0')} + footer={} + contentHeight={46} + > + + + + + } + total="78%" + footer={ +
    + + 周同比 + 12% + + + 日环比 + 11% + +
    + } + contentHeight={46} + > + +
    + +
    +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/pie.md b/antdsp-admin/src/main/web/src/components/Charts/demo/pie.md new file mode 100644 index 0000000..9c87161 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/pie.md @@ -0,0 +1,54 @@ +--- +order: 5 +title: 饼状图 +--- + +```jsx +import { Pie, yuan } from 'ant-design-pro/lib/Charts'; + +const salesPieData = [ + { + x: '家用电器', + y: 4544, + }, + { + x: '食用酒水', + y: 3321, + }, + { + x: '个护健康', + y: 3113, + }, + { + x: '服饰箱包', + y: 2341, + }, + { + x: '母婴产品', + y: 1231, + }, + { + x: '其他', + y: 1231, + }, +]; + +ReactDOM.render( + ( + now.y + pre, 0)) + }} + /> + )} + data={salesPieData} + valueFormat={val => } + height={294} + />, + mountNode, +); +``` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/radar.md b/antdsp-admin/src/main/web/src/components/Charts/demo/radar.md new file mode 100644 index 0000000..584344a --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/radar.md @@ -0,0 +1,64 @@ +--- +order: 7 +title: 雷达图 +--- + +````jsx +import { Radar, ChartCard } from 'ant-design-pro/lib/Charts'; + +const radarOriginData = [ + { + name: '个人', + ref: 10, + koubei: 8, + output: 4, + contribute: 5, + hot: 7, + }, + { + name: '团队', + ref: 3, + koubei: 9, + output: 6, + contribute: 3, + hot: 1, + }, + { + name: '部门', + ref: 4, + koubei: 1, + output: 6, + contribute: 5, + hot: 7, + }, +]; +const radarData = []; +const radarTitleMap = { + ref: '引用', + koubei: '口碑', + output: '产量', + contribute: '贡献', + hot: '热度', +}; +radarOriginData.forEach((item) => { + Object.keys(item).forEach((key) => { + if (key !== 'name') { + radarData.push({ + name: item.name, + label: radarTitleMap[key], + value: item[key], + }); + } + }); +}); + +ReactDOM.render( + + + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/tag-cloud.md b/antdsp-admin/src/main/web/src/components/Charts/demo/tag-cloud.md new file mode 100644 index 0000000..c66f6fe --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/tag-cloud.md @@ -0,0 +1,25 @@ +--- +order: 9 +title: 标签云 +--- + +标签云是一套相关的标签以及与此相应的权重展示方式,一般典型的标签云有 30 至 150 个标签,而权重影响使用的字体大小或其他视觉效果。 + +````jsx +import { TagCloud } from 'ant-design-pro/lib/Charts'; + +const tags = []; +for (let i = 0; i < 50; i += 1) { + tags.push({ + name: `TagClout-Title-${i}`, + value: Math.floor((Math.random() * 50)) + 20, + }); +} + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/timeline-chart.md b/antdsp-admin/src/main/web/src/components/Charts/demo/timeline-chart.md new file mode 100644 index 0000000..60773b5 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/timeline-chart.md @@ -0,0 +1,27 @@ +--- +order: 9 +title: 带有时间轴的图表 +--- + +使用 `TimelineChart` 组件可以实现带有时间轴的柱状图展现,而其中的 `x` 属性,则是时间值的指向,默认最多支持同时展现两个指标,分别是 `y1` 和 `y2`。 + +````jsx +import { TimelineChart } from 'ant-design-pro/lib/Charts'; + +const chartData = []; +for (let i = 0; i < 20; i += 1) { + chartData.push({ + x: (new Date().getTime()) + (1000 * 60 * 30 * i), + y1: Math.floor(Math.random() * 100) + 1000, + y2: Math.floor(Math.random() * 100) + 10, + }); +} + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/demo/waterwave.md b/antdsp-admin/src/main/web/src/components/Charts/demo/waterwave.md new file mode 100644 index 0000000..74d290f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/demo/waterwave.md @@ -0,0 +1,20 @@ +--- +order: 8 +title: 水波图 +--- + +水波图是一种比例的展示方式,可以更直观的展示关键值的占比。 + +````jsx +import { WaterWave } from 'ant-design-pro/lib/Charts'; + +ReactDOM.render( +
    + +
    +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Charts/index.d.ts b/antdsp-admin/src/main/web/src/components/Charts/index.d.ts new file mode 100644 index 0000000..57f1d52 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/index.d.ts @@ -0,0 +1,48 @@ +import * as numeral from 'numeral'; +import { default as Bar } from './Bar'; +import { default as ChartCard } from './ChartCard'; +import { default as Field } from './Field'; +import { default as Gauge } from './Gauge'; +import { default as MiniArea } from './MiniArea'; +import { default as MiniBar } from './MiniBar'; +import { default as MiniProgress } from './MiniProgress'; +import { default as Pie } from './Pie'; +import { default as Radar } from './Radar'; +import { default as TagCloud } from './TagCloud'; +import { default as TimelineChart } from './TimelineChart'; +import { default as WaterWave } from './WaterWave'; + +declare const yuan: (value: number | string) => string; + +declare const Charts: { + yuan: (value: number | string) => string; + Bar: Bar; + Pie: Pie; + Gauge: Gauge; + Radar: Radar; + MiniBar: MiniBar; + MiniArea: MiniArea; + MiniProgress: MiniProgress; + ChartCard: ChartCard; + Field: Field; + WaterWave: WaterWave; + TagCloud: TagCloud; + TimelineChart: TimelineChart; +}; + +export { + Charts as default, + yuan, + Bar, + Pie, + Gauge, + Radar, + MiniBar, + MiniArea, + MiniProgress, + ChartCard, + Field, + WaterWave, + TagCloud, + TimelineChart, +}; diff --git a/antdsp-admin/src/main/web/src/components/Charts/index.js b/antdsp-admin/src/main/web/src/components/Charts/index.js new file mode 100644 index 0000000..294eeb6 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/index.js @@ -0,0 +1,48 @@ +import numeral from 'numeral'; +import ChartCard from './ChartCard'; +import Field from './Field'; +import Bar from './Bar'; +import Pie from './Pie'; +import Radar from './Radar'; +import Gauge from './Gauge'; +import MiniArea from './MiniArea'; +import MiniBar from './MiniBar'; +import MiniProgress from './MiniProgress'; +import WaterWave from './WaterWave'; +import TagCloud from './TagCloud'; +import TimelineChart from './TimelineChart'; + +const yuan = val => `¥ ${numeral(val).format('0,0')}`; + +const Charts = { + yuan, + Bar, + Pie, + Gauge, + Radar, + MiniBar, + MiniArea, + MiniProgress, + ChartCard, + Field, + WaterWave, + TagCloud, + TimelineChart, +}; + +export { + Charts as default, + yuan, + Bar, + Pie, + Gauge, + Radar, + MiniBar, + MiniArea, + MiniProgress, + ChartCard, + Field, + WaterWave, + TagCloud, + TimelineChart, +}; diff --git a/antdsp-admin/src/main/web/src/components/Charts/index.less b/antdsp-admin/src/main/web/src/components/Charts/index.less new file mode 100644 index 0000000..190428b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/index.less @@ -0,0 +1,19 @@ +.miniChart { + position: relative; + width: 100%; + .chartContent { + position: absolute; + bottom: -28px; + width: 100%; + > div { + margin: 0 -5px; + overflow: hidden; + } + } + .chartLoading { + position: absolute; + top: 16px; + left: 50%; + margin-left: -7px; + } +} diff --git a/antdsp-admin/src/main/web/src/components/Charts/index.md b/antdsp-admin/src/main/web/src/components/Charts/index.md new file mode 100644 index 0000000..e5f41c8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Charts/index.md @@ -0,0 +1,130 @@ +--- +title: Charts +subtitle: 图表 +order: 2 +cols: 2 +--- + +Ant Design Pro 提供的业务中常用的图表类型,都是基于 [G2](https://antv.alipay.com/g2/doc/index.html) 按照 Ant Design 图表规范封装,需要注意的是 Ant Design Pro 的图表组件以套件形式提供,可以任意组合实现复杂的业务需求。 + +因为结合了 Ant Design 的标准设计,本着极简的设计思想以及开箱即用的理念,简化了大量 API 配置,所以如果需要灵活定制图表,可以参考 Ant Design Pro 图表实现,自行基于 [G2](https://antv.alipay.com/g2/doc/index.html) 封装图表组件使用。 + +## API + +### ChartCard + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| title | 卡片标题 | ReactNode\|string | - | +| action | 卡片操作 | ReactNode | - | +| total | 数据总量 | ReactNode \| number \| function | - | +| footer | 卡片底部 | ReactNode | - | +| contentHeight | 内容区域高度 | number | - | +| avatar | 右侧图标 | React.ReactNode | - | +### MiniBar + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| color | 图表颜色 | string | `#1890FF` | +| height | 图表高度 | number | - | +| data | 数据 | array<{x, y}> | - | + +### MiniArea + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| color | 图表颜色 | string | `rgba(24, 144, 255, 0.2)` | +| borderColor | 图表边颜色 | string | `#1890FF` | +| height | 图表高度 | number | - | +| line | 是否显示描边 | boolean | false | +| animate | 是否显示动画 | boolean | true | +| xAxis | [x 轴配置](http://antvis.github.io/g2/doc/tutorial/start/axis.html) | object | - | +| yAxis | [y 轴配置](http://antvis.github.io/g2/doc/tutorial/start/axis.html) | object | - | +| data | 数据 | array<{x, y}> | - | + +### MiniProgress + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| target | 目标比例 | number | - | +| color | 进度条颜色 | string | - | +| strokeWidth | 进度条高度 | number | - | +| percent | 进度比例 | number | - | + +### Bar + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| title | 图表标题 | ReactNode\|string | - | +| color | 图表颜色 | string | `rgba(24, 144, 255, 0.85)` | +| padding | 图表内部间距 | [array](https://github.com/alibaba/BizCharts/blob/master/doc/api/chart.md#7padding-object--number--array-) | `'auto'` | +| height | 图表高度 | number | - | +| data | 数据 | array<{x, y}> | - | +| autoLabel | 在宽度不足时,自动隐藏 x 轴的 label | boolean | `true` | + +### Pie + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| animate | 是否显示动画 | boolean | true | +| color | 图表颜色 | string | `rgba(24, 144, 255, 0.85)` | +| height | 图表高度 | number | - | +| hasLegend | 是否显示 legend | boolean | `false` | +| padding | 图表内部间距 | [array](https://github.com/alibaba/BizCharts/blob/master/doc/api/chart.md#7padding-object--number--array-) | `'auto'` | +| percent | 占比 | number | - | +| tooltip | 是否显示 tooltip | boolean | true | +| valueFormat | 显示值的格式化函数 | function | - | +| title | 图表标题 | ReactNode\|string | - | +| subTitle | 图表子标题 | ReactNode\|string | - | +| total | 图标中央的总数 | string | function | - | + +### Radar + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| title | 图表标题 | ReactNode\|string | - | +| height | 图表高度 | number | - | +| hasLegend | 是否显示 legend | boolean | `false` | +| padding | 图表内部间距 | [array](https://github.com/alibaba/BizCharts/blob/master/doc/api/chart.md#7padding-object--number--array-) | `'auto'` | +| data | 图标数据 | array<{name,label,value}> | - | + +### Gauge + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| title | 图表标题 | ReactNode\|string | - | +| height | 图表高度 | number | - | +| color | 图表颜色 | string | `#2F9CFF` | +| bgColor | 图表背景颜色 | string | `#F0F2F5` | +| percent | 进度比例 | number | - | + +### WaterWave + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| title | 图表标题 | ReactNode\|string | - | +| height | 图表高度 | number | - | +| color | 图表颜色 | string | `#1890FF` | +| percent | 进度比例 | number | - | + +### TagCloud + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| data | 标题 | Array | - | +| height | 高度值 | number | - | + +### TimelineChart + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| data | 标题 | Array | - | +| titleMap | 指标别名 | Object{y1: '客流量', y2: '支付笔数'} | - | +| height | 高度值 | number | 400 | + +### Field + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| label | 标题 | ReactNode\|string | - | +| value | 值 | ReactNode\|string | - | diff --git a/antdsp-admin/src/main/web/src/components/CountDown/demo/simple.md b/antdsp-admin/src/main/web/src/components/CountDown/demo/simple.md new file mode 100644 index 0000000..e42cbf1 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/CountDown/demo/simple.md @@ -0,0 +1,24 @@ +--- +order: 0 +title: + zh-CN: 基本 + en-US: Basic +--- + +## zh-CN + +简单的倒计时组件使用。 + +## en-US + +The simplest usage. + +````jsx +import CountDown from 'ant-design-pro/lib/CountDown'; + +const targetTime = new Date().getTime() + 3900000; + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/CountDown/index.d.ts b/antdsp-admin/src/main/web/src/components/CountDown/index.d.ts new file mode 100644 index 0000000..af658e3 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/CountDown/index.d.ts @@ -0,0 +1,9 @@ +import React from 'react'; +export interface ICountDownProps { + format?: (time: number) => void; + target: Date | number; + onEnd?: () => void; + style?: React.CSSProperties; +} + +export default class CountDown extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/CountDown/index.en-US.md b/antdsp-admin/src/main/web/src/components/CountDown/index.en-US.md new file mode 100644 index 0000000..7b45240 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/CountDown/index.en-US.md @@ -0,0 +1,15 @@ +--- +title: CountDown +cols: 1 +order: 3 +--- + +Simple CountDown Component. + +## API + +| Property | Description | Type | Default | +|----------|------------------------------------------|-------------|-------| +| format | Formatter of time | Function(time) | | +| target | Target time | Date | - | +| onEnd | Countdown to the end callback | funtion | -| diff --git a/antdsp-admin/src/main/web/src/components/CountDown/index.js b/antdsp-admin/src/main/web/src/components/CountDown/index.js new file mode 100644 index 0000000..7565bd8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/CountDown/index.js @@ -0,0 +1,121 @@ +import React, { Component } from 'react'; + +function fixedZero(val) { + return val * 1 < 10 ? `0${val}` : val; +} +const initTime = props => { + let lastTime = 0; + let targetTime = 0; + try { + if (Object.prototype.toString.call(props.target) === '[object Date]') { + targetTime = props.target.getTime(); + } else { + targetTime = new Date(props.target).getTime(); + } + } catch (e) { + throw new Error('invalid target prop', e); + } + + lastTime = targetTime - new Date().getTime(); + return { + lastTime: lastTime < 0 ? 0 : lastTime, + }; +}; + +class CountDown extends Component { + timer = 0; + + interval = 1000; + + constructor(props) { + super(props); + const { lastTime } = initTime(props); + this.state = { + lastTime, + }; + } + + static getDerivedStateFromProps(nextProps, preState) { + const { lastTime } = initTime(nextProps); + if (preState.lastTime !== lastTime) { + return { + lastTime, + }; + } + return null; + } + + componentDidMount() { + this.tick(); + } + + componentDidUpdate(prevProps) { + const { target } = this.props; + if (target !== prevProps.target) { + clearTimeout(this.timer); + this.tick(); + } + } + + componentWillUnmount() { + clearTimeout(this.timer); + } + + // defaultFormat = time => ( + // {moment(time).format('hh:mm:ss')} + // ); + defaultFormat = time => { + const hours = 60 * 60 * 1000; + const minutes = 60 * 1000; + + const h = Math.floor(time / hours); + const m = Math.floor((time - h * hours) / minutes); + const s = Math.floor((time - h * hours - m * minutes) / 1000); + return ( + + {fixedZero(h)}:{fixedZero(m)}:{fixedZero(s)} + + ); + }; + + tick = () => { + const { onEnd } = this.props; + let { lastTime } = this.state; + + this.timer = setTimeout(() => { + if (lastTime < this.interval) { + clearTimeout(this.timer); + this.setState( + { + lastTime: 0, + }, + () => { + if (onEnd) { + onEnd(); + } + } + ); + } else { + lastTime -= this.interval; + this.setState( + { + lastTime, + }, + () => { + this.tick(); + } + ); + } + }, this.interval); + }; + + render() { + const { format = this.defaultFormat, onEnd, ...rest } = this.props; + const { lastTime } = this.state; + const result = format(lastTime); + + return {result}; + } +} + +export default CountDown; diff --git a/antdsp-admin/src/main/web/src/components/CountDown/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/CountDown/index.zh-CN.md new file mode 100644 index 0000000..7e00ba1 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/CountDown/index.zh-CN.md @@ -0,0 +1,16 @@ +--- +title: CountDown +subtitle: 倒计时 +cols: 1 +order: 3 +--- + +倒计时组件。 + +## API + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| format | 时间格式化显示 | Function(time) | | +| target | 目标时间 | Date | - | +| onEnd | 倒计时结束回调 | funtion | -| diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/Description.d.ts b/antdsp-admin/src/main/web/src/components/DescriptionList/Description.d.ts new file mode 100644 index 0000000..41c0497 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/Description.d.ts @@ -0,0 +1,11 @@ +import React from 'react'; +import { ColProps } from 'antd/es/col'; + +export interface DescriptionProps extends ColProps { + column?: number; + key?: string | number; + style?: React.CSSProperties; + term?: React.ReactNode; +} + +export default class Description extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/Description.js b/antdsp-admin/src/main/web/src/components/DescriptionList/Description.js new file mode 100644 index 0000000..fce9fd3 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/Description.js @@ -0,0 +1,22 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { Col } from 'antd'; +import styles from './index.less'; +import responsive from './responsive'; + +const Description = ({ term, column, children, ...restProps }) => ( + + {term &&
    {term}
    } + {children !== null && children !== undefined &&
    {children}
    } + +); + +Description.defaultProps = { + term: '', +}; + +Description.propTypes = { + term: PropTypes.node, +}; + +export default Description; diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/DescriptionList.js b/antdsp-admin/src/main/web/src/components/DescriptionList/DescriptionList.js new file mode 100644 index 0000000..84bdbd7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/DescriptionList.js @@ -0,0 +1,33 @@ +import React from 'react'; +import classNames from 'classnames'; +import { Row } from 'antd'; +import styles from './index.less'; + +const DescriptionList = ({ + className, + title, + col = 3, + layout = 'horizontal', + gutter = 32, + children, + size, + ...restProps +}) => { + const clsString = classNames(styles.descriptionList, styles[layout], className, { + [styles.small]: size === 'small', + [styles.large]: size === 'large', + }); + const column = col > 4 ? 4 : col; + return ( +
    + {title ?
    {title}
    : null} + + {React.Children.map(children, child => + child ? React.cloneElement(child, { column }) : child + )} + +
    + ); +}; + +export default DescriptionList; diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/demo/basic.md b/antdsp-admin/src/main/web/src/components/DescriptionList/demo/basic.md new file mode 100644 index 0000000..8795455 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/demo/basic.md @@ -0,0 +1,43 @@ +--- +order: 0 +title: + zh-CN: 基本 + en-US: Basic +--- + +## zh-CN + +基本描述列表。 + +## en-US + +Basic DescriptionList. + +````jsx +import DescriptionList from 'ant-design-pro/lib/DescriptionList'; + +const { Description } = DescriptionList; + +ReactDOM.render( + + + A free, open source, cross-platform, + graphical web browser developed by the + Mozilla Corporation and hundreds of + volunteers. + + + A free, open source, cross-platform, + graphical web browser developed by the + Mozilla Corporation and hundreds of + volunteers. + + + A free, open source, cross-platform, + graphical web browser developed by the + Mozilla Corporation and hundreds of + volunteers. + + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/demo/vertical.md b/antdsp-admin/src/main/web/src/components/DescriptionList/demo/vertical.md new file mode 100644 index 0000000..2742f7c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/demo/vertical.md @@ -0,0 +1,43 @@ +--- +order: 1 +title: + zh-CN: 垂直型 + en-US: Vertical +--- + +## zh-CN + +垂直布局。 + +## en-US + +Vertical layout. + +````jsx +import DescriptionList from 'ant-design-pro/lib/DescriptionList'; + +const { Description } = DescriptionList; + +ReactDOM.render( + + + A free, open source, cross-platform, + graphical web browser developed by the + Mozilla Corporation and hundreds of + volunteers. + + + A free, open source, cross-platform, + graphical web browser developed by the + Mozilla Corporation and hundreds of + volunteers. + + + A free, open source, cross-platform, + graphical web browser developed by the + Mozilla Corporation and hundreds of + volunteers. + + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/index.d.ts b/antdsp-admin/src/main/web/src/components/DescriptionList/index.d.ts new file mode 100644 index 0000000..c0bb071 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/index.d.ts @@ -0,0 +1,17 @@ +import React from 'react'; +import Description, { DescriptionProps } from './Description'; + +export interface DescriptionListProps { + className?: string; + col?: number; + description?: DescriptionProps[]; + gutter?: number; + layout?: 'horizontal' | 'vertical'; + size?: 'large' | 'small'; + style?: React.CSSProperties; + title?: React.ReactNode; +} + +export default class DescriptionList extends React.Component { + public static Description: typeof Description; +} diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/index.en-US.md b/antdsp-admin/src/main/web/src/components/DescriptionList/index.en-US.md new file mode 100644 index 0000000..089f30b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/index.en-US.md @@ -0,0 +1,33 @@ +--- +title: DescriptionList +cols: 1 +order: 4 +--- + +Groups display multiple read-only fields, which are common to informational displays on detail pages. + +## API + +### DescriptionList + +| Property | Description | Type | Default | +|----------|------------------------------------------|-------------|---------| +| layout | type of layout | Enum{'horizontal', 'vertical'} | 'horizontal' | +| col | specify the maximum number of columns to display, the final columns number is determined by col setting combined with [Responsive Rules](/components/DescriptionList#Responsive-Rules) | number(0 < col <= 4) | 3 | +| title | title | ReactNode | - | +| gutter | specify the distance between two items, unit is `px` | number | 32 | +| size | size of list | Enum{'large', 'small'} | - | + +#### Responsive Rules + +| Window Width | Columns Number | +|---------------------|---------------------------------------------| +| `≥768px` | `col` | +| `≥576px` | `col < 2 ? col : 2` | +| `<576px` | `1` | + +### DescriptionList.Description + +| Property | Description | Type | Default | +|----------|------------------------------------------|-------------|-------| +| term | item title | ReactNode | - | diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/index.js b/antdsp-admin/src/main/web/src/components/DescriptionList/index.js new file mode 100644 index 0000000..357f479 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/index.js @@ -0,0 +1,5 @@ +import DescriptionList from './DescriptionList'; +import Description from './Description'; + +DescriptionList.Description = Description; +export default DescriptionList; diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/index.less b/antdsp-admin/src/main/web/src/components/DescriptionList/index.less new file mode 100644 index 0000000..c3cf8e6 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/index.less @@ -0,0 +1,92 @@ +@import '~antd/lib/style/themes/default.less'; + +.descriptionList { + // offset the padding-bottom of last row + :global { + .ant-row { + margin-bottom: -16px; + overflow: hidden; + } + } + // fix margin top error of following descriptionList + & + & { + :global { + .ant-row { + margin-top: 16px; + } + } + } + + .title { + margin-bottom: 16px; + color: @heading-color; + font-weight: 500; + font-size: 14px; + } + + .term { + display: table-cell; + padding-bottom: 16px; + color: @heading-color; + // Line-height is 22px IE dom height will calculate error + line-height: 20px; + white-space: nowrap; + + &::after { + position: relative; + top: -0.5px; + margin: 0 8px 0 2px; + content: ':'; + } + } + + .detail { + display: table-cell; + width: 100%; + padding-bottom: 16px; + color: @text-color; + line-height: 20px; + } + + &.small { + // offset the padding-bottom of last row + :global { + .ant-row { + margin-bottom: -8px; + } + } + // fix margin top error of following descriptionList + & + .descriptionList { + :global { + .ant-row { + margin-top: 8px; + } + } + } + .title { + margin-bottom: 12px; + color: @text-color; + } + .term, + .detail { + padding-bottom: 8px; + } + } + + &.large { + .title { + font-size: 16px; + } + } + + &.vertical { + .term { + display: block; + padding-bottom: 8px; + } + + .detail { + display: block; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/DescriptionList/index.zh-CN.md new file mode 100644 index 0000000..b16a7fe --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/index.zh-CN.md @@ -0,0 +1,37 @@ +--- +title: DescriptionList +subtitle: 描述列表 +cols: 1 +order: 4 +--- + +成组展示多个只读字段,常见于详情页的信息展示。 + +## API + +### DescriptionList + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| layout | 布局方式 | Enum{'horizontal', 'vertical'} | 'horizontal' | +| col | 指定信息最多分几列展示,最终一行几列由 col 配置结合[响应式规则](/components/DescriptionList#响应式规则)决定 | number(0 < col <= 4) | 3 | +| title | 列表标题 | ReactNode | - | +| gutter | 列表项间距,单位为 `px` | number | 32 | +| size | 列表型号 | Enum{'large', 'small'} | - | + +#### 响应式规则 + +| 窗口宽度 | 展示列数 | +|---------------------|---------------------------------------------| +| `≥768px` | `col` | +| `≥576px` | `col < 2 ? col : 2` | +| `<576px` | `1` | + +### DescriptionList.Description + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| term | 列表项标题 | ReactNode | - | + + + diff --git a/antdsp-admin/src/main/web/src/components/DescriptionList/responsive.js b/antdsp-admin/src/main/web/src/components/DescriptionList/responsive.js new file mode 100644 index 0000000..a5aa73f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/DescriptionList/responsive.js @@ -0,0 +1,6 @@ +export default { + 1: { xs: 24 }, + 2: { xs: 24, sm: 12 }, + 3: { xs: 24, sm: 12, md: 8 }, + 4: { xs: 24, sm: 12, md: 6 }, +}; diff --git a/antdsp-admin/src/main/web/src/components/EditableItem/index.d.ts b/antdsp-admin/src/main/web/src/components/EditableItem/index.d.ts new file mode 100644 index 0000000..fc69b27 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/EditableItem/index.d.ts @@ -0,0 +1,7 @@ +import React from 'react'; + +export interface EditableItemProps { + onChange?: (value?: string | string[] | number) => void; +} + +export default class EditableItem extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/EditableItem/index.js b/antdsp-admin/src/main/web/src/components/EditableItem/index.js new file mode 100644 index 0000000..40034d0 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/EditableItem/index.js @@ -0,0 +1,50 @@ +import React, { PureComponent } from 'react'; +import { Input, Icon } from 'antd'; +import styles from './index.less'; + +export default class EditableItem extends PureComponent { + constructor(props) { + super(props); + this.state = { + value: props.value, + editable: false, + }; + } + + handleChange = e => { + const { value } = e.target; + this.setState({ value }); + }; + + check = () => { + this.setState({ editable: false }); + const { value } = this.state; + const { onChange } = this.props; + if (onChange) { + onChange(value); + } + }; + + edit = () => { + this.setState({ editable: true }); + }; + + render() { + const { value, editable } = this.state; + return ( +
    + {editable ? ( +
    + + +
    + ) : ( +
    + {value || ' '} + +
    + )} +
    + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/EditableItem/index.less b/antdsp-admin/src/main/web/src/components/EditableItem/index.less new file mode 100644 index 0000000..7fdf337 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/EditableItem/index.less @@ -0,0 +1,25 @@ +@import '~antd/lib/style/themes/default.less'; + +.editableItem { + display: table; + width: 100%; + margin-top: (@font-size-base * @line-height-base - @input-height-base) / 2; + line-height: @input-height-base; + + .wrapper { + display: table-row; + + & > * { + display: table-cell; + } + + & > *:first-child { + width: 85%; + } + + .icon { + text-align: right; + cursor: pointer; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.d.ts b/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.d.ts new file mode 100644 index 0000000..07a42ab --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.d.ts @@ -0,0 +1,9 @@ +import React from 'react'; + +export interface EditableLinkGroupProps { + links: any[]; + onAdd: () => void; + linkElement: string; +} + +export default class EditableLinkGroup extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.js b/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.js new file mode 100644 index 0000000..ae3d93c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.js @@ -0,0 +1,46 @@ +import React, { PureComponent, createElement } from 'react'; +import PropTypes from 'prop-types'; +import { Button } from 'antd'; +import styles from './index.less'; + +// TODO: 添加逻辑 + +class EditableLinkGroup extends PureComponent { + static propTypes = { + links: PropTypes.array, + onAdd: PropTypes.func, + linkElement: PropTypes.oneOfType([PropTypes.func, PropTypes.string]), + }; + + static defaultProps = { + links: [], + onAdd: () => {}, + linkElement: 'a', + }; + + render() { + const { links, linkElement, onAdd } = this.props; + return ( +
    + {links.map(link => + createElement( + linkElement, + { + key: `linkGroup-item-${link.id || link.title}`, + to: link.href, + href: link.href, + }, + link.title + ) + )} + { + + } +
    + ); + } +} + +export default EditableLinkGroup; diff --git a/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.less b/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.less new file mode 100644 index 0000000..ba53315 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/EditableLinkGroup/index.less @@ -0,0 +1,16 @@ +@import '~antd/lib/style/themes/default.less'; + +.linkGroup { + padding: 20px 0 8px 24px; + font-size: 0; + & > a { + display: inline-block; + width: 25%; + margin-bottom: 13px; + color: @text-color; + font-size: @font-size-base; + &:hover { + color: @primary-color; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/Ellipsis/demo/line.md b/antdsp-admin/src/main/web/src/components/Ellipsis/demo/line.md new file mode 100644 index 0000000..bc31170 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Ellipsis/demo/line.md @@ -0,0 +1,31 @@ +--- +order: 1 +title: + zh-CN: 按照行数省略 + en-US: Truncate according to the number of rows +--- + +## zh-CN + +通过设置 `lines` 属性指定最大行数,如果超过这个行数的文本会自动截取。但是在这种模式下所有 `children` 将会被转换成纯文本。 + +并且注意在这种模式下,外容器需要有指定的宽度(或设置自身宽度)。 + +## en-US + +`lines` attribute specifies the maximum number of rows where the text will automatically be truncated when exceeded. In this mode, all children will be converted to plain text. + +Also note that, in this mode, the outer container needs to have a specified width (or set its own width). + + +````jsx +import Ellipsis from 'ant-design-pro/lib/Ellipsis'; + +const article =

    There were injuries alleged in three cases in 2015, and a fourth incident in September, according to the safety recall report. After meeting with US regulators in October, the firm decided to issue a voluntary recall.

    ; + +ReactDOM.render( +
    + {article} +
    +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Ellipsis/demo/number.md b/antdsp-admin/src/main/web/src/components/Ellipsis/demo/number.md new file mode 100644 index 0000000..0bc1a0f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Ellipsis/demo/number.md @@ -0,0 +1,28 @@ +--- +order: 0 +title: + zh-CN: 按照字符数省略 + en-US: Truncate according to the number of character +--- + +## zh-CN + +通过设置 `length` 属性指定文本最长长度,如果超过这个长度会自动截取。 + +## en-US + +`length` attribute specifies the maximum length where the text will automatically be truncated when exceeded. + +````jsx +import Ellipsis from 'ant-design-pro/lib/Ellipsis'; + +const article = 'There were injuries alleged in three cases in 2015, and a fourth incident in September, according to the safety recall report. After meeting with US regulators in October, the firm decided to issue a voluntary recall.'; + +ReactDOM.render( +
    + {article} +

    Show Tooltip

    + {article} +
    +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Ellipsis/index.d.ts b/antdsp-admin/src/main/web/src/components/Ellipsis/index.d.ts new file mode 100644 index 0000000..075fa78 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Ellipsis/index.d.ts @@ -0,0 +1,21 @@ +import React from 'react'; +import { TooltipProps } from 'antd/lib/tooltip'; + +export interface EllipsisTooltipProps extends TooltipProps { + title?: undefined; + overlayStyle?: undefined; +} + +export interface EllipsisProps { + tooltip?: boolean | EllipsisTooltipProps; + length?: number; + lines?: number; + style?: React.CSSProperties; + className?: string; + fullWidthRecognition?: boolean; +} + +export function getStrFullLength(str: string): number; +export function cutStrByFullLength(str: string, maxLength: number): string; + +export default class Ellipsis extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Ellipsis/index.en-US.md b/antdsp-admin/src/main/web/src/components/Ellipsis/index.en-US.md new file mode 100644 index 0000000..15139cc --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Ellipsis/index.en-US.md @@ -0,0 +1,16 @@ +--- +title: Ellipsis +cols: 1 +order: 10 +--- + +When the text is too long, the Ellipsis automatically shortens it according to its length or the maximum number of lines. + +## API + +Property | Description | Type | Default +----|------|-----|------ +tooltip | tooltip for showing the full text content when hovering over | boolean | - +length | maximum number of characters in the text before being truncated | number | - +lines | maximum number of rows in the text before being truncated | number | `1` +fullWidthRecognition | whether consider full-width character length as 2 when calculate string length | boolean | - diff --git a/antdsp-admin/src/main/web/src/components/Ellipsis/index.js b/antdsp-admin/src/main/web/src/components/Ellipsis/index.js new file mode 100644 index 0000000..de700b7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Ellipsis/index.js @@ -0,0 +1,270 @@ +import React, { Component } from 'react'; +import { Tooltip } from 'antd'; +import classNames from 'classnames'; +import styles from './index.less'; + +/* eslint react/no-did-mount-set-state: 0 */ +/* eslint no-param-reassign: 0 */ + +const isSupportLineClamp = document.body.style.webkitLineClamp !== undefined; + +const TooltipOverlayStyle = { + overflowWrap: 'break-word', + wordWrap: 'break-word', +}; + +export const getStrFullLength = (str = '') => + str.split('').reduce((pre, cur) => { + const charCode = cur.charCodeAt(0); + if (charCode >= 0 && charCode <= 128) { + return pre + 1; + } + return pre + 2; + }, 0); + +export const cutStrByFullLength = (str = '', maxLength) => { + let showLength = 0; + return str.split('').reduce((pre, cur) => { + const charCode = cur.charCodeAt(0); + if (charCode >= 0 && charCode <= 128) { + showLength += 1; + } else { + showLength += 2; + } + if (showLength <= maxLength) { + return pre + cur; + } + return pre; + }, ''); +}; + +const getTooltip = ({ tooltip, overlayStyle, title, children }) => { + if (tooltip) { + const props = tooltip === true ? { overlayStyle, title } : { ...tooltip, overlayStyle, title }; + return {children}; + } + return children; +}; + +const EllipsisText = ({ text, length, tooltip, fullWidthRecognition, ...other }) => { + if (typeof text !== 'string') { + throw new Error('Ellipsis children must be string.'); + } + const textLength = fullWidthRecognition ? getStrFullLength(text) : text.length; + if (textLength <= length || length < 0) { + return {text}; + } + const tail = '...'; + let displayText; + if (length - tail.length <= 0) { + displayText = ''; + } else { + displayText = fullWidthRecognition ? cutStrByFullLength(text, length) : text.slice(0, length); + } + + const spanAttrs = tooltip ? {} : { ...other }; + return getTooltip({ + tooltip, + overlayStyle: TooltipOverlayStyle, + title: text, + children: ( + + {displayText} + {tail} + + ), + }); +}; + +export default class Ellipsis extends Component { + state = { + text: '', + targetCount: 0, + }; + + componentDidMount() { + if (this.node) { + this.computeLine(); + } + } + + componentDidUpdate(perProps) { + const { lines } = this.props; + if (lines !== perProps.lines) { + this.computeLine(); + } + } + + computeLine = () => { + const { lines } = this.props; + if (lines && !isSupportLineClamp) { + const text = this.shadowChildren.innerText || this.shadowChildren.textContent; + const lineHeight = parseInt(getComputedStyle(this.root).lineHeight, 10); + const targetHeight = lines * lineHeight; + this.content.style.height = `${targetHeight}px`; + const totalHeight = this.shadowChildren.offsetHeight; + const shadowNode = this.shadow.firstChild; + + if (totalHeight <= targetHeight) { + this.setState({ + text, + targetCount: text.length, + }); + return; + } + + // bisection + const len = text.length; + const mid = Math.ceil(len / 2); + + const count = this.bisection(targetHeight, mid, 0, len, text, shadowNode); + + this.setState({ + text, + targetCount: count, + }); + } + }; + + bisection = (th, m, b, e, text, shadowNode) => { + const suffix = '...'; + let mid = m; + let end = e; + let begin = b; + shadowNode.innerHTML = text.substring(0, mid) + suffix; + let sh = shadowNode.offsetHeight; + + if (sh <= th) { + shadowNode.innerHTML = text.substring(0, mid + 1) + suffix; + sh = shadowNode.offsetHeight; + if (sh > th || mid === begin) { + return mid; + } + begin = mid; + if (end - begin === 1) { + mid = 1 + begin; + } else { + mid = Math.floor((end - begin) / 2) + begin; + } + return this.bisection(th, mid, begin, end, text, shadowNode); + } + if (mid - 1 < 0) { + return mid; + } + shadowNode.innerHTML = text.substring(0, mid - 1) + suffix; + sh = shadowNode.offsetHeight; + if (sh <= th) { + return mid - 1; + } + end = mid; + mid = Math.floor((end - begin) / 2) + begin; + return this.bisection(th, mid, begin, end, text, shadowNode); + }; + + handleRoot = n => { + this.root = n; + }; + + handleContent = n => { + this.content = n; + }; + + handleNode = n => { + this.node = n; + }; + + handleShadow = n => { + this.shadow = n; + }; + + handleShadowChildren = n => { + this.shadowChildren = n; + }; + + render() { + const { text, targetCount } = this.state; + const { + children, + lines, + length, + className, + tooltip, + fullWidthRecognition, + ...restProps + } = this.props; + + const cls = classNames(styles.ellipsis, className, { + [styles.lines]: lines && !isSupportLineClamp, + [styles.lineClamp]: lines && isSupportLineClamp, + }); + + if (!lines && !length) { + return ( + + {children} + + ); + } + + // length + if (!lines) { + return ( + + ); + } + + const id = `antd-pro-ellipsis-${`${new Date().getTime()}${Math.floor(Math.random() * 100)}`}`; + + // support document.body.style.webkitLineClamp + if (isSupportLineClamp) { + const style = `#${id}{-webkit-line-clamp:${lines};-webkit-box-orient: vertical;}`; + + const node = ( +
    + + {children} +
    + ); + + return getTooltip({ + tooltip, + overlayStyle: TooltipOverlayStyle, + title: children, + children: node, + }); + } + + const childNode = ( + + {targetCount > 0 && text.substring(0, targetCount)} + {targetCount > 0 && targetCount < text.length && '...'} + + ); + + return ( +
    +
    + {getTooltip({ + tooltip, + overlayStyle: TooltipOverlayStyle, + title: text, + children: childNode, + })} +
    + {children} +
    +
    + {text} +
    +
    +
    + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/Ellipsis/index.less b/antdsp-admin/src/main/web/src/components/Ellipsis/index.less new file mode 100644 index 0000000..3c0360c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Ellipsis/index.less @@ -0,0 +1,24 @@ +.ellipsis { + display: inline-block; + width: 100%; + overflow: hidden; + word-break: break-all; +} + +.lines { + position: relative; + .shadow { + position: absolute; + z-index: -999; + display: block; + color: transparent; + opacity: 0; + } +} + +.lineClamp { + position: relative; + display: -webkit-box; + overflow: hidden; + text-overflow: ellipsis; +} diff --git a/antdsp-admin/src/main/web/src/components/Ellipsis/index.test.js b/antdsp-admin/src/main/web/src/components/Ellipsis/index.test.js new file mode 100644 index 0000000..4d057b2 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Ellipsis/index.test.js @@ -0,0 +1,13 @@ +import { getStrFullLength, cutStrByFullLength } from './index'; + +describe('test calculateShowLength', () => { + it('get full length', () => { + expect(getStrFullLength('一二,a,')).toEqual(8); + }); + it('cut str by full length', () => { + expect(cutStrByFullLength('一二,a,', 7)).toEqual('一二,a'); + }); + it('cut str when length small', () => { + expect(cutStrByFullLength('一22三', 5)).toEqual('一22'); + }); +}); diff --git a/antdsp-admin/src/main/web/src/components/Ellipsis/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/Ellipsis/index.zh-CN.md new file mode 100644 index 0000000..f7a70ea --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Ellipsis/index.zh-CN.md @@ -0,0 +1,17 @@ +--- +title: Ellipsis +subtitle: 文本自动省略号 +cols: 1 +order: 10 +--- + +文本过长自动处理省略号,支持按照文本长度和最大行数两种方式截取。 + +## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +tooltip | 移动到文本展示完整内容的提示 | boolean | - +length | 在按照长度截取下的文本最大字符数,超过则截取省略 | number | - +lines | 在按照行数截取下最大的行数,超过则截取省略 | number | `1` +fullWidthRecognition | 是否将全角字符的长度视为2来计算字符串长度 | boolean | - diff --git a/antdsp-admin/src/main/web/src/components/Exception/demo/403.md b/antdsp-admin/src/main/web/src/components/Exception/demo/403.md new file mode 100644 index 0000000..c0244ab --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/demo/403.md @@ -0,0 +1,29 @@ +--- +order: 2 +title: + zh-CN: 403 页面 + en-US: 403 Page +--- + +## zh-CN + +403 页面,配合自定义操作。 + +## en-US + +403 page with custom operations. + +````jsx +import Exception from 'ant-design-pro/lib/Exception'; +import { Button } from 'antd'; + +const actions = ( +
    + + +
    +); +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Exception/demo/404.md b/antdsp-admin/src/main/web/src/components/Exception/demo/404.md new file mode 100644 index 0000000..c54e99d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/demo/404.md @@ -0,0 +1,22 @@ +--- +order: 0 +title: + zh-CN: 404 页面 + en-US: 404 Page +--- + +## zh-CN + +404 页面。 + +## en-US + +404 page. + +````jsx +import Exception from 'ant-design-pro/lib/Exception'; + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Exception/demo/500.md b/antdsp-admin/src/main/web/src/components/Exception/demo/500.md new file mode 100644 index 0000000..2336e41 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/demo/500.md @@ -0,0 +1,22 @@ +--- +order: 1 +title: + zh-CN: 500 页面 + en-US: 500 Page +--- + +## zh-CN + +500 页面。 + +## en-US + +500 page. + +````jsx +import Exception from 'ant-design-pro/lib/Exception'; + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Exception/index.d.ts b/antdsp-admin/src/main/web/src/components/Exception/index.d.ts new file mode 100644 index 0000000..b8cb65d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/index.d.ts @@ -0,0 +1,23 @@ +import React from 'react'; +import * as H from 'history'; + +export interface ExceptionProps< + L = { + to: H.LocationDescriptor; + href?: H.LocationDescriptor; + replace?: boolean; + innerRef?: (node: HTMLAnchorElement | null) => void; + } +> { + type?: '403' | '404' | '500'; + title?: React.ReactNode; + desc?: React.ReactNode; + img?: string; + actions?: React.ReactNode; + linkElement?: string | React.ComponentType; + style?: React.CSSProperties; + className?: string; + backText?: React.ReactNode; + redirect?: string; +} +export default class Exception extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Exception/index.en-US.md b/antdsp-admin/src/main/web/src/components/Exception/index.en-US.md new file mode 100644 index 0000000..37e7e80 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/index.en-US.md @@ -0,0 +1,20 @@ +--- +title: Exception +cols: 1 +order: 5 +--- + +Exceptions page is used to provide feedback on specific abnormal state. Usually, it contains an explanation of the error status, and provides users with suggestions or operations, to prevent users from feeling lost and confused. + +## API + +Property | Description | Type | Default +---------|-------------|------|-------- +| backText | default return button text | ReactNode | back to home | +type | type of exception, the corresponding default `title`, `desc`, `img` will be given if set, which can be overridden by explicit setting of `title`, `desc`, `img` | Enum {'403', '404', '500'} | - +title | title | ReactNode | - +desc | supplementary description | ReactNode | - +img | the url of background image | string | - +actions | suggested operations, a default 'Home' link will show if not set | ReactNode | - +linkElement | to specify the element of link | string\|ReactElement | 'a' +redirect | redirect path | string | '/' \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/components/Exception/index.js b/antdsp-admin/src/main/web/src/components/Exception/index.js new file mode 100644 index 0000000..2c7223c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/index.js @@ -0,0 +1,61 @@ +import React, { createElement } from 'react'; +import classNames from 'classnames'; +import { Button } from 'antd'; +import config from './typeConfig'; +import styles from './index.less'; + +class Exception extends React.PureComponent { + static defaultProps = { + backText: 'back to home', + redirect: '/', + }; + + constructor(props) { + super(props); + this.state = {}; + } + + render() { + const { + className, + backText, + linkElement = 'a', + type, + title, + desc, + img, + actions, + redirect, + ...rest + } = this.props; + const pageType = type in config ? type : '404'; + const clsString = classNames(styles.exception, className); + return ( +
    +
    +
    +
    +
    +

    {title || config[pageType].title}

    +
    {desc || config[pageType].desc}
    +
    + {actions || + createElement( + linkElement, + { + to: redirect, + href: redirect, + }, + + )} +
    +
    +
    + ); + } +} + +export default Exception; diff --git a/antdsp-admin/src/main/web/src/components/Exception/index.less b/antdsp-admin/src/main/web/src/components/Exception/index.less new file mode 100644 index 0000000..5393bb7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/index.less @@ -0,0 +1,89 @@ +@import '~antd/lib/style/themes/default.less'; + +.exception { + display: flex; + align-items: center; + height: 80%; + min-height: 500px; + + .imgBlock { + flex: 0 0 62.5%; + width: 62.5%; + padding-right: 152px; + zoom: 1; + &::before, + &::after { + display: table; + content: ' '; + } + &::after { + clear: both; + height: 0; + font-size: 0; + visibility: hidden; + } + } + + .imgEle { + float: right; + width: 100%; + max-width: 430px; + height: 360px; + background-repeat: no-repeat; + background-position: 50% 50%; + background-size: contain; + } + + .content { + flex: auto; + + h1 { + margin-bottom: 24px; + color: #434e59; + font-weight: 600; + font-size: 72px; + line-height: 72px; + } + + .desc { + margin-bottom: 16px; + color: @text-color-secondary; + font-size: 20px; + line-height: 28px; + } + + .actions { + button:not(:last-child) { + margin-right: 8px; + } + } + } +} + +@media screen and (max-width: @screen-xl) { + .exception { + .imgBlock { + padding-right: 88px; + } + } +} + +@media screen and (max-width: @screen-sm) { + .exception { + display: block; + text-align: center; + .imgBlock { + margin: 0 auto 24px; + padding-right: 0; + } + } +} + +@media screen and (max-width: @screen-xs) { + .exception { + .imgBlock { + margin-bottom: -24px; + overflow: hidden; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/Exception/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/Exception/index.zh-CN.md new file mode 100644 index 0000000..2e64399 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/index.zh-CN.md @@ -0,0 +1,21 @@ +--- +title: Exception +subtitle: 异常 +cols: 1 +order: 5 +--- + +异常页用于对页面特定的异常状态进行反馈。通常,它包含对错误状态的阐述,并向用户提供建议或操作,避免用户感到迷失和困惑。 + +## API + +| 参数 | 说明| 类型 | 默认值 | +|-------------|------------------------------------------|-------------|-------| +| backText| 默认的返回按钮文本 | ReactNode| back to home | +| type| 页面类型,若配置,则自带对应类型默认的 `title`,`desc`,`img`,此默认设置可以被 `title`,`desc`,`img` 覆盖 | Enum {'403', '404', '500'} | - | +| title | 标题 | ReactNode| -| +| desc| 补充描述| ReactNode| -| +| img | 背景图片地址 | string| -| +| actions | 建议操作,配置此属性时默认的『返回首页』按钮不生效| ReactNode| -| +| linkElement | 定义链接的元素 | string\|ReactElement | 'a' | +| redirect | 返回按钮的跳转地址 | string | '/' diff --git a/antdsp-admin/src/main/web/src/components/Exception/typeConfig.js b/antdsp-admin/src/main/web/src/components/Exception/typeConfig.js new file mode 100644 index 0000000..b6e1ee5 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Exception/typeConfig.js @@ -0,0 +1,19 @@ +const config = { + 403: { + img: 'https://gw.alipayobjects.com/zos/rmsportal/wZcnGqRDyhPOEYFcZDnb.svg', + title: '403', + desc: '抱歉,你无权访问该页面', + }, + 404: { + img: 'https://gw.alipayobjects.com/zos/rmsportal/KpnpchXsobRgLElEozzI.svg', + title: '404', + desc: '抱歉,你访问的页面不存在', + }, + 500: { + img: 'https://gw.alipayobjects.com/zos/rmsportal/RVRUAYdCGeYNBWoKiIwB.svg', + title: '500', + desc: '抱歉,服务器出错了', + }, +}; + +export default config; diff --git a/antdsp-admin/src/main/web/src/components/FooterToolbar/demo/basic.md b/antdsp-admin/src/main/web/src/components/FooterToolbar/demo/basic.md new file mode 100644 index 0000000..3043dbf --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/FooterToolbar/demo/basic.md @@ -0,0 +1,44 @@ +--- +order: 0 +title: + zh-CN: 演示 + en-US: demo +iframe: 400 +--- + +## zh-CN + +浮动固定页脚。 + +## en-US + +Fixed to the footer. + +````jsx +import FooterToolbar from 'ant-design-pro/lib/FooterToolbar'; +import { Button } from 'antd'; + +ReactDOM.render( +
    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    +

    Content Content Content Content

    + + + + +
    +, mountNode); +```` \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/components/FooterToolbar/index.d.ts b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.d.ts new file mode 100644 index 0000000..9ec202c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.d.ts @@ -0,0 +1,8 @@ +import React from 'react'; +export interface FooterToolbarProps { + extra: React.ReactNode; + style?: React.CSSProperties; + className?: string; +} + +export default class FooterToolbar extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/FooterToolbar/index.en-US.md b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.en-US.md new file mode 100644 index 0000000..69fd80b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.en-US.md @@ -0,0 +1,18 @@ +--- +title: FooterToolbar +cols: 1 +order: 6 +--- + +A toolbar fixed at the bottom. + +## Usage + +It is fixed at the bottom of the content area and does not move along with the scroll bar, which is usually used for data collection and submission for long pages. + +## API + +Property | Description | Type | Default +---------|-------------|------|-------- +children | toolbar content, align to the right | ReactNode | - +extra | extra information, align to the left | ReactNode | - \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/components/FooterToolbar/index.js b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.js new file mode 100644 index 0000000..d43f72f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.js @@ -0,0 +1,47 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import classNames from 'classnames'; +import styles from './index.less'; + +export default class FooterToolbar extends Component { + static contextTypes = { + isMobile: PropTypes.bool, + }; + + state = { + width: undefined, + }; + + componentDidMount() { + window.addEventListener('resize', this.resizeFooterToolbar); + this.resizeFooterToolbar(); + } + + componentWillUnmount() { + window.removeEventListener('resize', this.resizeFooterToolbar); + } + + resizeFooterToolbar = () => { + const sider = document.querySelector('.ant-layout-sider'); + if (sider == null) { + return; + } + const { isMobile } = this.context; + const width = isMobile ? null : `calc(100% - ${sider.style.width})`; + const { width: stateWidth } = this.state; + if (stateWidth !== width) { + this.setState({ width }); + } + }; + + render() { + const { children, className, extra, ...restProps } = this.props; + const { width } = this.state; + return ( +
    +
    {extra}
    +
    {children}
    +
    + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/FooterToolbar/index.less b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.less new file mode 100644 index 0000000..5073cff --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.less @@ -0,0 +1,33 @@ +@import '~antd/lib/style/themes/default.less'; + +.toolbar { + position: fixed; + right: 0; + bottom: 0; + z-index: 9; + width: 100%; + height: 56px; + padding: 0 24px; + line-height: 56px; + background: #fff; + border-top: 1px solid @border-color-split; + box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.03); + + &::after { + display: block; + clear: both; + content: ''; + } + + .left { + float: left; + } + + .right { + float: right; + } + + button + button { + margin-left: 8px; + } +} diff --git a/antdsp-admin/src/main/web/src/components/FooterToolbar/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.zh-CN.md new file mode 100644 index 0000000..421ac08 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/FooterToolbar/index.zh-CN.md @@ -0,0 +1,19 @@ +--- +title: FooterToolbar +subtitle: 底部工具栏 +cols: 1 +order: 6 +--- + +固定在底部的工具栏。 + +## 何时使用 + +固定在内容区域的底部,不随滚动条移动,常用于长页面的数据搜集和提交工作。 + +## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +children | 工具栏内容,向右对齐 | ReactNode | - +extra | 额外信息,向左对齐 | ReactNode | - diff --git a/antdsp-admin/src/main/web/src/components/GlobalFooter/demo/basic.md b/antdsp-admin/src/main/web/src/components/GlobalFooter/demo/basic.md new file mode 100644 index 0000000..9a06bad --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalFooter/demo/basic.md @@ -0,0 +1,37 @@ +--- +order: 0 +title: 演示 +iframe: 400 +--- + +基本页脚。 + +````jsx +import GlobalFooter from 'ant-design-pro/lib/GlobalFooter'; +import { Icon } from 'antd'; + +const links = [{ + key: '帮助', + title: '帮助', + href: '', +}, { + key: 'github', + title: , + href: 'https://github.com/ant-design/ant-design-pro', + blankTarget: true, +}, { + key: '条款', + title: '条款', + href: '', + blankTarget: true, +}]; + +const copyright =
    Copyright 2017 蚂蚁金服体验技术部出品
    ; + +ReactDOM.render( +
    +
    + +
    +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/GlobalFooter/index.d.ts b/antdsp-admin/src/main/web/src/components/GlobalFooter/index.d.ts new file mode 100644 index 0000000..efde77d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalFooter/index.d.ts @@ -0,0 +1,14 @@ +import React from 'react'; +export interface GlobalFooterProps { + links?: Array<{ + key?: string; + title: React.ReactNode; + href: string; + blankTarget?: boolean; + }>; + copyright?: React.ReactNode; + style?: React.CSSProperties; + className?: string; +} + +export default class GlobalFooter extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/GlobalFooter/index.js b/antdsp-admin/src/main/web/src/components/GlobalFooter/index.js new file mode 100644 index 0000000..1c2fb74 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalFooter/index.js @@ -0,0 +1,28 @@ +import React from 'react'; +import classNames from 'classnames'; +import styles from './index.less'; + +const GlobalFooter = ({ className, links, copyright }) => { + const clsString = classNames(styles.globalFooter, className); + return ( +
    + {links && ( +
    + {links.map(link => ( + + {link.title} + + ))} +
    + )} + {copyright &&
    {copyright}
    } +
    + ); +}; + +export default GlobalFooter; diff --git a/antdsp-admin/src/main/web/src/components/GlobalFooter/index.less b/antdsp-admin/src/main/web/src/components/GlobalFooter/index.less new file mode 100644 index 0000000..e4b3dfd --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalFooter/index.less @@ -0,0 +1,29 @@ +@import '~antd/lib/style/themes/default.less'; + +.globalFooter { + margin: 48px 0 24px 0; + padding: 0 16px; + text-align: center; + + .links { + margin-bottom: 8px; + + a { + color: @text-color-secondary; + transition: all 0.3s; + + &:not(:last-child) { + margin-right: 40px; + } + + &:hover { + color: @text-color; + } + } + } + + .copyright { + color: @text-color-secondary; + font-size: @font-size-base; + } +} diff --git a/antdsp-admin/src/main/web/src/components/GlobalFooter/index.md b/antdsp-admin/src/main/web/src/components/GlobalFooter/index.md new file mode 100644 index 0000000..96e04fe --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalFooter/index.md @@ -0,0 +1,15 @@ +--- +title: GlobalFooter +subtitle: 全局页脚 +cols: 1 +order: 7 +--- + +页脚属于全局导航的一部分,作为对顶部导航的补充,通过传递数据控制展示内容。 + +## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +links | 链接数据 | array<{ title: ReactNode, href: string, blankTarget?: boolean }> | - +copyright | 版权信息 | ReactNode | - diff --git a/antdsp-admin/src/main/web/src/components/GlobalHeader/RightContent.d.ts b/antdsp-admin/src/main/web/src/components/GlobalHeader/RightContent.d.ts new file mode 100644 index 0000000..275d999 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalHeader/RightContent.d.ts @@ -0,0 +1,26 @@ +import React from 'react'; +import { DropDownProps } from 'antd/lib/dropdown'; +import { ClickParam } from 'antd/es/menu'; +import { SiderTheme } from 'antd/es/Layout/Sider'; + +export interface GlobalHeaderRightProps { + notices?: any[]; + dispatch?: (args: any) => void; + currentUser?: { + avatar?: string; + name?: string; + title?: string; + group?: string; + signature?: string; + geographic?: any; + tags?: any[]; + unreadCount: number; + }; + fetchingNotices?: boolean; + onNoticeVisibleChange?: (visible: boolean) => void; + onMenuClick?: (param: ClickParam) => void; + onNoticeClear?: (tabName: string) => void; + theme?: SiderTheme; +} + +export default class GlobalHeaderRight extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/GlobalHeader/RightContent.js b/antdsp-admin/src/main/web/src/components/GlobalHeader/RightContent.js new file mode 100644 index 0000000..d40e116 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalHeader/RightContent.js @@ -0,0 +1,194 @@ +import React, { PureComponent } from 'react'; +import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale'; +import { Spin, Tag, Menu, Icon, Avatar, Tooltip, message } from 'antd'; +import moment from 'moment'; +import groupBy from 'lodash/groupBy'; +import NoticeIcon from '../NoticeIcon'; +import HeaderSearch from '../HeaderSearch'; +import HeaderDropdown from '../HeaderDropdown'; +import SelectLang from '../SelectLang'; +import styles from './index.less'; + +export default class GlobalHeaderRight extends PureComponent { + getNoticeData() { + const { notices = [] } = this.props; + if (notices.length === 0) { + return {}; + } + const newNotices = notices.map(notice => { + const newNotice = { ...notice }; + if (newNotice.datetime) { + newNotice.datetime = moment(notice.datetime).fromNow(); + } + if (newNotice.id) { + newNotice.key = newNotice.id; + } + if (newNotice.extra && newNotice.status) { + const color = { + todo: '', + processing: 'blue', + urgent: 'red', + doing: 'gold', + }[newNotice.status]; + newNotice.extra = ( + + {newNotice.extra} + + ); + } + return newNotice; + }); + return groupBy(newNotices, 'type'); + } + + getUnreadData = noticeData => { + const unreadMsg = {}; + Object.entries(noticeData).forEach(([key, value]) => { + if (!unreadMsg[key]) { + unreadMsg[key] = 0; + } + if (Array.isArray(value)) { + unreadMsg[key] = value.filter(item => !item.read).length; + } + }); + return unreadMsg; + }; + + changeReadState = clickedItem => { + const { id } = clickedItem; + const { dispatch } = this.props; + dispatch({ + type: 'global/changeNoticeReadState', + payload: id, + }); + }; + + render() { + const { + currentUser, + fetchingNotices, + onNoticeVisibleChange, + onMenuClick, + onNoticeClear, + theme, + } = this.props; + const menu = ( + + + + + + + + + + + + + + + + + + + + ); + const noticeData = this.getNoticeData(); + const unreadMsg = this.getUnreadData(noticeData); + let className = styles.right; + if (theme === 'dark') { + className = `${styles.right} ${styles.dark}`; + } + return ( +
    + { + console.log('input', value); // eslint-disable-line + }} + onPressEnter={value => { + console.log('enter', value); // eslint-disable-line + }} + /> + + + + + + { + console.log(item, tabProps); // eslint-disable-line + this.changeReadState(item, tabProps); + }} + loading={fetchingNotices} + locale={{ + emptyText: formatMessage({ id: 'component.noticeIcon.empty' }), + clear: formatMessage({ id: 'component.noticeIcon.clear' }), + viewMore: formatMessage({ id: 'component.noticeIcon.view-more' }), + notification: formatMessage({ id: 'component.globalHeader.notification' }), + message: formatMessage({ id: 'component.globalHeader.message' }), + event: formatMessage({ id: 'component.globalHeader.event' }), + }} + onClear={onNoticeClear} + onPopupVisibleChange={onNoticeVisibleChange} + onViewMore={() => message.info('Click on view more')} + clearClose + > + + + + + {currentUser.name ? ( + + + + {currentUser.name} + + + ) : ( + + )} + +
    + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/GlobalHeader/index.d.ts b/antdsp-admin/src/main/web/src/components/GlobalHeader/index.d.ts new file mode 100644 index 0000000..7d2fcf6 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalHeader/index.d.ts @@ -0,0 +1,13 @@ +import React from 'react'; + +export interface GlobalHeaderProps { + collapsed?: boolean; + onCollapse?: (collapsed: boolean) => void; + isMobile?: boolean; + logo?: string; + onNoticeClear?: (type: string) => void; + onMenuClick?: ({ key: string }) => void; + onNoticeVisibleChange?: (b: boolean) => void; +} + +export default class GlobalHeader extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/GlobalHeader/index.js b/antdsp-admin/src/main/web/src/components/GlobalHeader/index.js new file mode 100644 index 0000000..fe96cde --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalHeader/index.js @@ -0,0 +1,41 @@ +import React, { PureComponent } from 'react'; +import { Icon } from 'antd'; +import Link from 'umi/link'; +import Debounce from 'lodash-decorators/debounce'; +import styles from './index.less'; +import RightContent from './RightContent'; + +export default class GlobalHeader extends PureComponent { + componentWillUnmount() { + this.triggerResizeEvent.cancel(); + } + /* eslint-disable*/ + @Debounce(600) + triggerResizeEvent() { + // eslint-disable-line + const event = document.createEvent('HTMLEvents'); + event.initEvent('resize', true, false); + window.dispatchEvent(event); + } + toggle = () => { + const { collapsed, onCollapse } = this.props; + onCollapse(!collapsed); + this.triggerResizeEvent(); + }; + render() { + const { collapsed, isMobile, logo } = this.props; + return ( +
    + {isMobile && ( + + logo + + )} + + + + +
    + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/GlobalHeader/index.less b/antdsp-admin/src/main/web/src/components/GlobalHeader/index.less new file mode 100644 index 0000000..e66510b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/GlobalHeader/index.less @@ -0,0 +1,130 @@ +@import '~antd/lib/style/themes/default.less'; + +@pro-header-hover-bg: rgba(0, 0, 0, 0.025); + +.header { + position: relative; + height: @layout-header-height; + padding: 0; + background: #fff; + box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); +} + +.logo { + display: inline-block; + height: @layout-header-height; + padding: 0 0 0 24px; + font-size: 20px; + line-height: @layout-header-height; + vertical-align: top; + cursor: pointer; + img { + display: inline-block; + vertical-align: middle; + } +} + +.menu { + :global(.anticon) { + margin-right: 8px; + } + :global(.ant-dropdown-menu-item) { + min-width: 160px; + } +} + +.trigger { + height: @layout-header-height; + padding: ~'calc((@{layout-header-height} - 20px) / 2)' 24px; + font-size: 20px; + cursor: pointer; + transition: all 0.3s, padding 0s; + &:hover { + background: @pro-header-hover-bg; + } +} + +.right { + float: right; + height: 100%; + overflow: hidden; + .action { + display: inline-block; + height: 100%; + padding: 0 12px; + cursor: pointer; + transition: all 0.3s; + > i { + color: @text-color; + vertical-align: middle; + } + &:hover { + background: @pro-header-hover-bg; + } + &:global(.opened) { + background: @pro-header-hover-bg; + } + } + .search { + padding: 0 12px; + &:hover { + background: transparent; + } + } + .account { + .avatar { + margin: ~'calc((@{layout-header-height} - 24px) / 2)' 0; + margin-right: 8px; + color: @primary-color; + vertical-align: top; + background: rgba(255, 255, 255, 0.85); + } + } +} + +.dark { + height: @layout-header-height; + .action { + color: rgba(255, 255, 255, 0.85); + > i { + color: rgba(255, 255, 255, 0.85); + } + &:hover, + &:global(.opened) { + background: @primary-color; + } + :global(.ant-badge) { + color: rgba(255, 255, 255, 0.85); + } + } +} + +@media only screen and (max-width: @screen-md) { + .header { + :global(.ant-divider-vertical) { + vertical-align: unset; + } + .name { + display: none; + } + i.trigger { + padding: 22px 12px; + } + .logo { + position: relative; + padding-right: 12px; + padding-left: 12px; + } + .right { + position: absolute; + top: 0; + right: 12px; + background: #fff; + .account { + .avatar { + margin-right: 0; + } + } + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.d.ts b/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.d.ts new file mode 100644 index 0000000..a1fd50a --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.d.ts @@ -0,0 +1,12 @@ +import React from 'react'; +import { DropDownProps } from 'antd/lib/dropdown'; + +declare type OverlayFunc = () => React.ReactNode; + +export interface HeaderDropdownProps extends DropDownProps { + overlayClassName?: string; + overlay: React.ReactNode | OverlayFunc; + placement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topCenter' | 'topRight' | 'bottomCenter'; +} + +export default class HeaderDropdown extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.js b/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.js new file mode 100644 index 0000000..a19c471 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.js @@ -0,0 +1,13 @@ +import React, { PureComponent } from 'react'; +import { Dropdown } from 'antd'; +import classNames from 'classnames'; +import styles from './index.less'; + +export default class HeaderDropdown extends PureComponent { + render() { + const { overlayClassName, ...props } = this.props; + return ( + + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.less b/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.less new file mode 100644 index 0000000..ef0c759 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderDropdown/index.less @@ -0,0 +1,16 @@ +@import '~antd/lib/style/themes/default.less'; + +.container > * { + background-color: #fff; + border-radius: 4px; + box-shadow: @shadow-1-down; +} + +@media screen and (max-width: @screen-xs) { + .container { + width: 100% !important; + } + .container > * { + border-radius: 0 !important; + } +} diff --git a/antdsp-admin/src/main/web/src/components/HeaderSearch/demo/basic.md b/antdsp-admin/src/main/web/src/components/HeaderSearch/demo/basic.md new file mode 100644 index 0000000..2139207 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderSearch/demo/basic.md @@ -0,0 +1,34 @@ +--- +order: 0 +title: 全局搜索 +--- + +通常放置在导航工具条右侧。(点击搜索图标预览效果) + +````jsx +import HeaderSearch from 'ant-design-pro/lib/HeaderSearch'; + +ReactDOM.render( +
    + { + console.log('input', value); // eslint-disable-line + }} + onPressEnter={(value) => { + console.log('enter', value); // eslint-disable-line + }} + /> +
    +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/HeaderSearch/index.d.ts b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.d.ts new file mode 100644 index 0000000..fcf7c11 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.d.ts @@ -0,0 +1,15 @@ +import React from 'react'; +export interface HeaderSearchProps { + placeholder?: string; + dataSource?: string[]; + defaultOpen?: boolean; + open?: boolean; + onSearch?: (value: string) => void; + onChange?: (value: string) => void; + onVisibleChange?: (visible: boolean) => void; + onPressEnter?: (value: string) => void; + style?: React.CSSProperties; + className?: string; +} + +export default class HeaderSearch extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/HeaderSearch/index.en-US.md b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.en-US.md new file mode 100644 index 0000000..9f2b5e8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.en-US.md @@ -0,0 +1,22 @@ +--- +title: HeaderSearch +subtitle: +cols: 1 +order: 8 +--- + +Usually placed as an entry to the global search, placed on the right side of the navigation toolbar. + +## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +placeholder | placeholder text | string | - +dataSource | current list of prompts | string[] | - +onSearch | Called when searching items. | function(value) | - +onChange | Called when select an option or input value change, or value of input is changed | function(value) | - +onSelect | Called when a option is selected. param is option's value and option instance. | function(value) | - +onPressEnter | Callback when pressing Enter | function(value) | - +onVisibleChange | Show or hide the callback of the text box | function(value) |- +defaultOpen | The input box is displayed for the first time. | boolean | false +open | The input box is displayed | boolean |false \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/components/HeaderSearch/index.js b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.js new file mode 100644 index 0000000..04f8b38 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.js @@ -0,0 +1,145 @@ +import React, { PureComponent } from 'react'; +import PropTypes from 'prop-types'; +import { Input, Icon, AutoComplete } from 'antd'; +import classNames from 'classnames'; +import Debounce from 'lodash-decorators/debounce'; +import Bind from 'lodash-decorators/bind'; +import styles from './index.less'; + +export default class HeaderSearch extends PureComponent { + static propTypes = { + className: PropTypes.string, + placeholder: PropTypes.string, + onSearch: PropTypes.func, + onChange: PropTypes.func, + onPressEnter: PropTypes.func, + defaultActiveFirstOption: PropTypes.bool, + dataSource: PropTypes.array, + defaultOpen: PropTypes.bool, + onVisibleChange: PropTypes.func, + }; + + static defaultProps = { + defaultActiveFirstOption: false, + onPressEnter: () => {}, + onSearch: () => {}, + onChange: () => {}, + className: '', + placeholder: '', + dataSource: [], + defaultOpen: false, + onVisibleChange: () => {}, + }; + + static getDerivedStateFromProps(props) { + if ('open' in props) { + return { + searchMode: props.open, + }; + } + return null; + } + + constructor(props) { + super(props); + this.state = { + searchMode: props.defaultOpen, + value: '', + }; + } + + componentWillUnmount() { + clearTimeout(this.timeout); + } + + onKeyDown = e => { + if (e.key === 'Enter') { + const { onPressEnter } = this.props; + const { value } = this.state; + this.timeout = setTimeout(() => { + onPressEnter(value); // Fix duplicate onPressEnter + }, 0); + } + }; + + onChange = value => { + const { onSearch, onChange } = this.props; + this.setState({ value }); + if (onSearch) { + onSearch(value); + } + if (onChange) { + onChange(value); + } + }; + + enterSearchMode = () => { + const { onVisibleChange } = this.props; + onVisibleChange(true); + this.setState({ searchMode: true }, () => { + const { searchMode } = this.state; + if (searchMode) { + this.input.focus(); + } + }); + }; + + leaveSearchMode = () => { + this.setState({ + searchMode: false, + value: '', + }); + }; + + // NOTE: 不能小于500,如果长按某键,第一次触发auto repeat的间隔是500ms,小于500会导致触发2次 + @Bind() + @Debounce(500, { + leading: true, + trailing: false, + }) + debouncePressEnter() { + const { onPressEnter } = this.props; + const { value } = this.state; + onPressEnter(value); + } + + render() { + const { className, placeholder, open, ...restProps } = this.props; + const { searchMode, value } = this.state; + delete restProps.defaultOpen; // for rc-select not affected + const inputClass = classNames(styles.input, { + [styles.show]: searchMode, + }); + return ( + { + if (propertyName === 'width' && !searchMode) { + const { onVisibleChange } = this.props; + onVisibleChange(searchMode); + } + }} + > + + + { + this.input = node; + }} + aria-label={placeholder} + placeholder={placeholder} + onKeyDown={this.onKeyDown} + onBlur={this.leaveSearchMode} + /> + + + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/HeaderSearch/index.less b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.less new file mode 100644 index 0000000..88fadec --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.less @@ -0,0 +1,32 @@ +@import '~antd/lib/style/themes/default.less'; + +.headerSearch { + :global(.anticon-search) { + font-size: 16px; + cursor: pointer; + } + .input { + width: 0; + background: transparent; + border-radius: 0; + transition: width 0.3s, margin-left 0.3s; + :global(.ant-select-selection) { + background: transparent; + } + input { + padding-right: 0; + padding-left: 0; + border: 0; + box-shadow: none !important; + } + &, + &:hover, + &:focus { + border-bottom: 1px solid @border-color-base; + } + &.show { + width: 210px; + margin-left: 8px; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/HeaderSearch/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.zh-CN.md new file mode 100644 index 0000000..83e7488 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/HeaderSearch/index.zh-CN.md @@ -0,0 +1,22 @@ +--- +title: HeaderSearch +subtitle: 顶部搜索框 +cols: 1 +order: 8 +--- + +通常作为全局搜索的入口,放置在导航工具条右侧。 + +## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +placeholder | 占位文字 | string | - +dataSource | 当前提示内容列表 | string[] | - +onSearch | 搜索补全项的时候调用 | function(value) | - +onChange | 选中 option,或 input 的 value 变化时,调用此函数 | function(value) | - +onSelect | 被选中时调用,参数为选中项的 value 值 | function(value) | - +onPressEnter | 按下回车时的回调 | function(value) | - +onVisibleChange | 显示或隐藏文本框的回调 | function(value) |- +defaultOpen | 输入框首次显示是否显示 | boolean | false +open | 控制输入框是否显示 | boolean |false \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/components/IconFont/index.js b/antdsp-admin/src/main/web/src/components/IconFont/index.js new file mode 100644 index 0000000..0b99dec --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/IconFont/index.js @@ -0,0 +1,7 @@ +import { Icon } from 'antd'; +import { iconfontUrl as scriptUrl } from '../../defaultSettings'; + +// 使用: +// import IconFont from '@/components/IconFont'; +// +export default Icon.createFromIconfontCN({ scriptUrl }); diff --git a/antdsp-admin/src/main/web/src/components/Login/LoginItem.d.ts b/antdsp-admin/src/main/web/src/components/Login/LoginItem.d.ts new file mode 100644 index 0000000..563e94e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Login/LoginItem.d.ts @@ -0,0 +1,28 @@ +import React from 'react'; +import { WrappedFormUtils } from 'antd/es/form/Form'; +import ItemMap from './map'; +import { Omit } from 'antd/es/_util/type'; + +export type WrappedLoginItemProps = Omit; +export type LoginItemType = { [K in keyof typeof ItemMap]: React.FC }; + +export interface LoginItemProps { + name?: string; + rules?: any[]; + style?: React.CSSProperties; + onGetCaptcha?: (event?: MouseEvent) => void; + placeholder?: string; + buttonText?: React.ReactNode; + onPressEnter?: (e: any) => void; + countDown?: number; + getCaptchaButtonText?: string; + getCaptchaSecondText?: string; + updateActive: (activeItem: any) => void; + form: WrappedFormUtils; + type: string; + defaultValue?: string; + customprops?: any; + onChange?: (e: any) => void; +} + +export default class LoginItem extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Login/LoginItem.js b/antdsp-admin/src/main/web/src/components/Login/LoginItem.js new file mode 100644 index 0000000..b3cc4d4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Login/LoginItem.js @@ -0,0 +1,147 @@ +import React, { Component } from 'react'; +import { Form, Input, Button, Row, Col } from 'antd'; +import omit from 'omit.js'; +import styles from './index.less'; +import ItemMap from './map'; +import LoginContext from './loginContext'; + +const FormItem = Form.Item; + +class WrapFormItem extends Component { + static defaultProps = { + getCaptchaButtonText: 'captcha', + getCaptchaSecondText: 'second', + }; + + constructor(props) { + super(props); + this.state = { + count: 0, + }; + } + + componentDidMount() { + const { updateActive, name } = this.props; + if (updateActive) { + updateActive(name); + } + } + + componentWillUnmount() { + clearInterval(this.interval); + } + + onGetCaptcha = () => { + const { onGetCaptcha } = this.props; + const result = onGetCaptcha ? onGetCaptcha() : null; + if (result === false) { + return; + } + if (result instanceof Promise) { + result.then(this.runGetCaptchaCountDown); + } else { + this.runGetCaptchaCountDown(); + } + }; + + getFormItemOptions = ({ onChange, defaultValue, customprops, rules }) => { + const options = { + rules: rules || customprops.rules, + }; + if (onChange) { + options.onChange = onChange; + } + if (defaultValue) { + options.initialValue = defaultValue; + } + return options; + }; + + runGetCaptchaCountDown = () => { + const { countDown } = this.props; + let count = countDown || 59; + this.setState({ count }); + this.interval = setInterval(() => { + count -= 1; + this.setState({ count }); + if (count === 0) { + clearInterval(this.interval); + } + }, 1000); + }; + + render() { + const { count } = this.state; + + const { + form: { getFieldDecorator }, + } = this.props; + + // 这么写是为了防止restProps中 带入 onChange, defaultValue, rules props + const { + onChange, + customprops, + defaultValue, + rules, + name, + getCaptchaButtonText, + getCaptchaSecondText, + updateActive, + type, + ...restProps + } = this.props; + + // get getFieldDecorator props + const options = this.getFormItemOptions(this.props); + + const otherProps = restProps || {}; + if (type === 'Captcha') { + const inputProps = omit(otherProps, ['onGetCaptcha', 'countDown']); + return ( + + + + {getFieldDecorator(name, options)()} + + + + + + + ); + } + return ( + + {getFieldDecorator(name, options)()} + + ); + } +} + +const LoginItem = {}; +Object.keys(ItemMap).forEach(key => { + const item = ItemMap[key]; + LoginItem[key] = props => ( + + {context => ( + + )} + + ); +}); + +export default LoginItem; diff --git a/antdsp-admin/src/main/web/src/components/Login/LoginSubmit.js b/antdsp-admin/src/main/web/src/components/Login/LoginSubmit.js new file mode 100644 index 0000000..4aebabf --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Login/LoginSubmit.js @@ -0,0 +1,17 @@ +import React from 'react'; +import classNames from 'classnames'; +import { Button, Form } from 'antd'; +import styles from './index.less'; + +const FormItem = Form.Item; + +const LoginSubmit = ({ className, ...rest }) => { + const clsString = classNames(styles.submit, className); + return ( + +
    + ); +} diff --git a/antdsp-admin/src/main/web/src/components/NoticeIcon/NoticeList.less b/antdsp-admin/src/main/web/src/components/NoticeIcon/NoticeList.less new file mode 100644 index 0000000..efa686c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NoticeIcon/NoticeList.less @@ -0,0 +1,105 @@ +@import '~antd/lib/style/themes/default.less'; + +.list { + max-height: 400px; + overflow: auto; + &::-webkit-scrollbar { + display: none; + } + .item { + padding-right: 24px; + padding-left: 24px; + overflow: hidden; + cursor: pointer; + transition: all 0.3s; + + .meta { + width: 100%; + } + + .avatar { + margin-top: 4px; + background: #fff; + } + .iconElement { + font-size: 32px; + } + + &.read { + opacity: 0.4; + } + &:last-child { + border-bottom: 0; + } + &:hover { + background: @primary-1; + } + .title { + margin-bottom: 8px; + font-weight: normal; + } + .description { + font-size: 12px; + line-height: @line-height-base; + } + .datetime { + margin-top: 4px; + font-size: 12px; + line-height: @line-height-base; + } + .extra { + float: right; + margin-top: -1.5px; + margin-right: 0; + color: @text-color-secondary; + font-weight: normal; + } + } + .loadMore { + padding: 8px 0; + color: @primary-6; + text-align: center; + cursor: pointer; + &.loadedAll { + color: rgba(0, 0, 0, 0.25); + cursor: unset; + } + } +} + +.notFound { + padding: 73px 0 88px 0; + color: @text-color-secondary; + text-align: center; + img { + display: inline-block; + height: 76px; + margin-bottom: 16px; + } +} + +.bottomBar { + height: 46px; + color: @text-color; + line-height: 46px; + text-align: center; + border-top: 1px solid @border-color-split; + border-radius: 0 0 @border-radius-base @border-radius-base; + transition: all 0.3s; + div { + display: inline-block; + width: 50%; + cursor: pointer; + transition: all 0.3s; + user-select: none; + &:hover { + color: @heading-color; + } + &:only-child { + width: 100%; + } + &:not(:only-child):last-child { + border-left: 1px solid @border-color-split; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/NoticeIcon/demo/basic.md b/antdsp-admin/src/main/web/src/components/NoticeIcon/demo/basic.md new file mode 100644 index 0000000..dc9afea --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NoticeIcon/demo/basic.md @@ -0,0 +1,12 @@ +--- +order: 1 +title: 通知图标 +--- + +通常用在导航工具栏上。 + +````jsx +import NoticeIcon from 'ant-design-pro/lib/NoticeIcon'; + +ReactDOM.render(, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/NoticeIcon/demo/popover.md b/antdsp-admin/src/main/web/src/components/NoticeIcon/demo/popover.md new file mode 100644 index 0000000..9694c5e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NoticeIcon/demo/popover.md @@ -0,0 +1,175 @@ +--- +order: 2 +title: 带浮层卡片 +--- + +点击展开通知卡片,展现多种类型的通知,通常放在导航工具栏。 + +```jsx +import NoticeIcon from 'ant-design-pro/lib/NoticeIcon'; +import { Tag } from 'antd'; + +const data = [{ + id: '000000001', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png', + title: '你收到了 14 份新周报', + datetime: '2017-08-09', + type: 'notification', +}, { + id: '000000002', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png', + title: '你推荐的 曲妮妮 已通过第三轮面试', + datetime: '2017-08-08', + type: 'notification', +}, { + id: '000000003', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png', + title: '这种模板可以区分多种通知类型', + datetime: '2017-08-07', + read: true, + type: 'notification', +}, { + id: '000000004', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png', + title: '左侧图标用于区分不同的类型', + datetime: '2017-08-07', + type: 'notification', +}, { + id: '000000005', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png', + title: '内容不要超过两行字,超出时自动截断', + datetime: '2017-08-07', + type: 'notification', +}, { + id: '000000006', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg', + title: '曲丽丽 评论了你', + description: '描述信息描述信息描述信息', + datetime: '2017-08-07', + type: 'message', + clickClose: true, +}, { + id: '000000007', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg', + title: '朱偏右 回复了你', + description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像', + datetime: '2017-08-07', + type: 'message', + clickClose: true, +}, { + id: '000000008', + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg', + title: '标题', + description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像', + datetime: '2017-08-07', + type: 'message', + clickClose: true, +}, { + id: '000000009', + title: '任务名称', + description: '任务需要在 2017-01-12 20:00 前启动', + extra: '未开始', + status: 'todo', + type: 'event', +}, { + id: '000000010', + title: '第三方紧急代码变更', + description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务', + extra: '马上到期', + status: 'urgent', + type: 'event', +}, { + id: '000000011', + title: '信息安全考试', + description: '指派竹尔于 2017-01-09 前完成更新并发布', + extra: '已耗时 8 天', + status: 'doing', + type: 'event', +}, { + id: '000000012', + title: 'ABCD 版本发布', + description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务', + extra: '进行中', + status: 'processing', + type: 'event', +}]; + +function onItemClick(item, tabProps) { + console.log(item, tabProps); +} + +function onClear(tabTitle) { + console.log(tabTitle); +} + +function getNoticeData(notices) { + if (notices.length === 0) { + return {}; + } + const newNotices = notices.map(notice => { + const newNotice = { ...notice }; + // transform id to item key + if (newNotice.id) { + newNotice.key = newNotice.id; + } + if (newNotice.extra && newNotice.status) { + const color = { + todo: '', + processing: 'blue', + urgent: 'red', + doing: 'gold', + }[newNotice.status]; + newNotice.extra = ( + + {newNotice.extra} + + ); + } + return newNotice; + }); + return newNotices.reduce((pre, data) => { + if (!pre[data.type]) { + pre[data.type] = []; + } + pre[data.type].push(data); + return pre; + }, {}); +} + +const noticeData = getNoticeData(data); +const Demo = () => ( +
    + + + + + +
    +); + +ReactDOM.render(, mountNode); +``` diff --git a/antdsp-admin/src/main/web/src/components/NoticeIcon/index.d.ts b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.d.ts new file mode 100644 index 0000000..18b3c43 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.d.ts @@ -0,0 +1,27 @@ +import React from 'react'; +import NoticeIconTab, { NoticeIconData } from './NoticeIconTab'; + +export interface NoticeIconProps { + count?: number; + bell?: React.ReactNode; + className?: string; + loading?: boolean; + onClear?: (tabName: string) => void; + onItemClick?: (item: NoticeIconData, tabProps: NoticeIconProps) => void; + onViewMore?: (tabProps: NoticeIconProps, e: MouseEvent) => void; + onTabChange?: (tabTile: string) => void; + style?: React.CSSProperties; + onPopupVisibleChange?: (visible: boolean) => void; + popupVisible?: boolean; + locale?: { + emptyText: string; + clear: string; + viewMore: string; + [key: string]: string; + }; + clearClose?: boolean; +} + +export default class NoticeIcon extends React.Component { + public static Tab: typeof NoticeIconTab; +} diff --git a/antdsp-admin/src/main/web/src/components/NoticeIcon/index.en-US.md b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.en-US.md new file mode 100644 index 0000000..677fa21 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.en-US.md @@ -0,0 +1,47 @@ +--- +title: NoticeIcon +subtitle: +cols: 1 +order: 9 +--- + +Used in navigation toolbar as a unified notification center for the entire product. + +## API + +Property | Description | Type | Default +----|------|-----|------ +count | Total number of messages | number | - +bell | Change the bell Icon | ReactNode | `` +loading | Popup card loading status | boolean | `false` +onClear | Click to clear button the callback | function(tabName) | - +onItemClick | Click on the list item's callback | function(item, tabProps) | - +onPopupVisibleChange | Popup Card Showing or Hiding Callbacks | function(visible) | - +onTabChange | Switching callbacks for tabs | function(tabTitle) | - +onViewMore | Callback of click for view more | function(tabProps, event) | - +popupVisible | Popup card display state | boolean | - +locale | Default message text | Object | `{ emptyText: 'No notifications', clear: 'Clear', viewMore: 'Loading more' }` +clearClose | Close menu after clear | boolean | `false` + +### NoticeIcon.Tab + +Property | Description | Type | Default +----|------|-----|------ +count | Unread messages count of this tab | number | list.length +emptyText | Message text when list is empty | ReactNode | - +emptyImage | Image when list is empty | string | - +list | List data, format refer to the following table | Array | `[]` +showClear | Clear button display status | boolean | `true` +showViewMore | View more button display status | boolean | `false` +title | header for message Tab, the actual text is `locale[title] || title` | string | - + +### Tab data + +Property | Description | Type | Default +----|------|-----|------ +avatar | avatar img url | string \| ReactNode | - +title | title | ReactNode | - +description | description info | ReactNode | - +datetime | Timestamps | ReactNode | - +extra | Additional information in the upper right corner of the list item | ReactNode | - +clickClose | Close menu after clicking list item | boolean | `false` diff --git a/antdsp-admin/src/main/web/src/components/NoticeIcon/index.js b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.js new file mode 100644 index 0000000..5ba4a70 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.js @@ -0,0 +1,141 @@ +import React, { PureComponent, Fragment } from 'react'; +import ReactDOM from 'react-dom'; +import { Icon, Tabs, Badge, Spin } from 'antd'; +import classNames from 'classnames'; +import HeaderDropdown from '../HeaderDropdown'; +import List from './NoticeList'; +import styles from './index.less'; + +const { TabPane } = Tabs; + +export default class NoticeIcon extends PureComponent { + static Tab = TabPane; + + static defaultProps = { + onItemClick: () => {}, + onPopupVisibleChange: () => {}, + onTabChange: () => {}, + onClear: () => {}, + onViewMore: () => {}, + loading: false, + clearClose: false, + locale: { + emptyText: 'No notifications', + clear: 'Clear', + viewMore: 'More', + }, + emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg', + }; + + state = { + visible: false, + }; + + onItemClick = (item, tabProps) => { + const { onItemClick } = this.props; + const { clickClose } = item; + onItemClick(item, tabProps); + if (clickClose) { + this.popover.click(); + } + }; + + onClear = name => { + const { onClear, clearClose } = this.props; + onClear(name); + if (clearClose) { + this.popover.click(); + } + }; + + onTabChange = tabType => { + const { onTabChange } = this.props; + onTabChange(tabType); + }; + + onViewMore = (tabProps, event) => { + const { onViewMore } = this.props; + onViewMore(tabProps, event); + }; + + getNotificationBox() { + const { children, loading, locale } = this.props; + if (!children) { + return null; + } + const panes = React.Children.map(children, child => { + const { list, title, count, emptyText, emptyImage, showClear, showViewMore } = child.props; + const len = list && list.length ? list.length : 0; + const msgCount = count || count === 0 ? count : len; + const localeTitle = locale[title] || title; + const tabTitle = msgCount > 0 ? `${localeTitle} (${msgCount})` : localeTitle; + return ( + + this.onClear(title)} + onClick={item => this.onItemClick(item, child.props)} + onViewMore={event => this.onViewMore(child.props, event)} + showClear={showClear} + showViewMore={showViewMore} + title={title} + /> + + ); + }); + return ( + + + + {panes} + + + + ); + } + + handleVisibleChange = visible => { + const { onPopupVisibleChange } = this.props; + this.setState({ visible }); + onPopupVisibleChange(visible); + }; + + render() { + const { className, count, popupVisible, bell } = this.props; + const { visible } = this.state; + const noticeButtonClass = classNames(className, styles.noticeButton); + const notificationBox = this.getNotificationBox(); + const NoticeBellIcon = bell || ; + const trigger = ( + + + {NoticeBellIcon} + + + ); + if (!notificationBox) { + return trigger; + } + const popoverProps = {}; + if ('popupVisible' in this.props) { + popoverProps.visible = popupVisible; + } + return ( + (this.popover = ReactDOM.findDOMNode(node))} // eslint-disable-line + > + {trigger} + + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/NoticeIcon/index.less b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.less new file mode 100644 index 0000000..1c0593e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.less @@ -0,0 +1,31 @@ +@import '~antd/lib/style/themes/default.less'; + +.popover { + position: relative; + width: 336px; +} + +.noticeButton { + display: inline-block; + cursor: pointer; + transition: all 0.3s; +} +.icon { + padding: 4px; + vertical-align: middle; +} + +.badge { + font-size: 16px; +} + +.tabs { + :global { + .ant-tabs-nav-scroll { + text-align: center; + } + .ant-tabs-bar { + margin-bottom: 0; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/NoticeIcon/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.zh-CN.md new file mode 100644 index 0000000..fe722de --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NoticeIcon/index.zh-CN.md @@ -0,0 +1,47 @@ +--- +title: NoticeIcon +subtitle: 通知菜单 +cols: 1 +order: 9 +--- + +用在导航工具栏上,作为整个产品统一的通知中心。 + +## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +count | 图标上的消息总数 | number | - +bell | translate this please -> Change the bell Icon | ReactNode | `` +loading | 弹出卡片加载状态 | boolean | `false` +onClear | 点击清空按钮的回调 | function(tabName) | - +onItemClick | 点击列表项的回调 | function(item, tabProps) | - +onPopupVisibleChange | 弹出卡片显隐的回调 | function(visible) | - +onTabChange | 切换页签的回调 | function(tabTitle) | - +onViewMore | 点击查看更多的回调 | function(tabProps, event) | - +popupVisible | 控制弹层显隐 | boolean | - +locale | 默认文案 | Object | `{ emptyText: 'No notifications', clear: 'Clear', viewMore: 'Loading more' }` +clearClose | 点击清空按钮后关闭通知菜单 | boolean | `false` + +### NoticeIcon.Tab + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +count | 当前 Tab 未读消息数量 | number | list.length +emptyText | 针对每个 Tab 定制空数据文案 | ReactNode | - +emptyImage | 针对每个 Tab 定制空数据图片 | string | - +list | 列表数据,格式参照下表 | Array | `[]` +showClear | 是否显示清空按钮 | boolean | `true` +showViewMore | 是否显示查看更多按钮 | boolean | `false` +title | 消息分类的页签标题,实际的文案是 `locale[title] || title` | string | - + +### Tab data + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +avatar | 头像图片链接 | string \| ReactNode | - +title | 标题 | ReactNode | - +description | 描述信息 | ReactNode | - +datetime | 时间戳 | ReactNode | - +extra | 额外信息,在列表项右上角 | ReactNode | - +clickClose | 点击列表项关闭通知菜单 | boolean | `false` diff --git a/antdsp-admin/src/main/web/src/components/NumberInfo/demo/basic.md b/antdsp-admin/src/main/web/src/components/NumberInfo/demo/basic.md new file mode 100644 index 0000000..b399655 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NumberInfo/demo/basic.md @@ -0,0 +1,30 @@ +--- +order: 0 +title: + zh-CN: 演示 + en-US: Demo +--- + +## zh-CN + +各种数据文案的展现方式。 + +## en-US + +Used for presenting various numerical data. + +````jsx +import NumberInfo from 'ant-design-pro/lib/NumberInfo'; +import numeral from 'numeral'; + +ReactDOM.render( +
    + Visits this week} + total={numeral(12321).format('0,0')} + status="up" + subTotal={17.1} + /> +
    +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/NumberInfo/index.d.ts b/antdsp-admin/src/main/web/src/components/NumberInfo/index.d.ts new file mode 100644 index 0000000..6636db9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NumberInfo/index.d.ts @@ -0,0 +1,14 @@ +import React from 'react'; +export interface NumberInfoProps { + title?: React.ReactNode | string; + subTitle?: React.ReactNode | string; + total?: React.ReactNode | string; + status?: 'up' | 'down'; + theme?: string; + gap?: number; + subTotal?: number; + suffix?: string; + style?: React.CSSProperties; +} + +export default class NumberInfo extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/NumberInfo/index.en-US.md b/antdsp-admin/src/main/web/src/components/NumberInfo/index.en-US.md new file mode 100644 index 0000000..b82afbe --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NumberInfo/index.en-US.md @@ -0,0 +1,19 @@ +--- +title: NumberInfo +cols: 1 +order: 10 +--- + +Often used in data cards for highlighting the business data. + +## API + +Property | Description | Type | Default +----|------|-----|------ +title | title | ReactNode\|string | - +subTitle | subtitle | ReactNode\|string | - +total | total amount | ReactNode\|string | - +subTotal | total amount of additional information | ReactNode\|string | - +status | increase state | 'up \| down' | - +theme | state style | string | 'light' +gap | set the spacing (pixels) between numbers and descriptions | number | 8 diff --git a/antdsp-admin/src/main/web/src/components/NumberInfo/index.js b/antdsp-admin/src/main/web/src/components/NumberInfo/index.js new file mode 100644 index 0000000..717aee9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NumberInfo/index.js @@ -0,0 +1,41 @@ +import React from 'react'; +import { Icon } from 'antd'; +import classNames from 'classnames'; +import styles from './index.less'; + +const NumberInfo = ({ theme, title, subTitle, total, subTotal, status, suffix, gap, ...rest }) => ( +
    + {title && ( +
    + {title} +
    + )} + {subTitle && ( +
    + {subTitle} +
    + )} +
    + + {total} + {suffix && {suffix}} + + {(status || subTotal) && ( + + {subTotal} + {status && } + + )} +
    +
    +); + +export default NumberInfo; diff --git a/antdsp-admin/src/main/web/src/components/NumberInfo/index.less b/antdsp-admin/src/main/web/src/components/NumberInfo/index.less new file mode 100644 index 0000000..4a77288 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NumberInfo/index.less @@ -0,0 +1,68 @@ +@import '~antd/lib/style/themes/default.less'; + +.numberInfo { + .suffix { + margin-left: 4px; + color: @text-color; + font-size: 16px; + font-style: normal; + } + .numberInfoTitle { + margin-bottom: 16px; + color: @text-color; + font-size: @font-size-lg; + transition: all 0.3s; + } + .numberInfoSubTitle { + height: 22px; + overflow: hidden; + color: @text-color-secondary; + font-size: @font-size-base; + line-height: 22px; + white-space: nowrap; + text-overflow: ellipsis; + word-break: break-all; + } + .numberInfoValue { + margin-top: 4px; + overflow: hidden; + font-size: 0; + white-space: nowrap; + text-overflow: ellipsis; + word-break: break-all; + & > span { + display: inline-block; + height: 32px; + margin-right: 32px; + color: @heading-color; + font-size: 24px; + line-height: 32px; + } + .subTotal { + margin-right: 0; + color: @text-color-secondary; + font-size: @font-size-lg; + vertical-align: top; + i { + margin-left: 4px; + font-size: 12px; + transform: scale(0.82); + } + :global { + .anticon-caret-up { + color: @red-6; + } + .anticon-caret-down { + color: @green-6; + } + } + } + } +} +.numberInfolight { + .numberInfoValue { + & > span { + color: @text-color; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/NumberInfo/index.zh-CN.md b/antdsp-admin/src/main/web/src/components/NumberInfo/index.zh-CN.md new file mode 100644 index 0000000..7198539 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/NumberInfo/index.zh-CN.md @@ -0,0 +1,20 @@ +--- +title: NumberInfo +subtitle: 数据文本 +cols: 1 +order: 10 +--- + +常用在数据卡片中,用于突出展示某个业务数据。 + +## API + +参数 | 说明 | 类型 | 默认值 +----|------|-----|------ +title | 标题 | ReactNode\|string | - +subTitle | 子标题 | ReactNode\|string | - +total | 总量 | ReactNode\|string | - +subTotal | 子总量 | ReactNode\|string | - +status | 增加状态 | 'up \| down' | - +theme | 状态样式 | string | 'light' +gap | 设置数字和描述之间的间距(像素)| number | 8 diff --git a/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.d.ts b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.d.ts new file mode 100644 index 0000000..a3d3a30 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.d.ts @@ -0,0 +1,8 @@ +import React from 'react'; + +export interface GridContentProps { + contentWidth: string; + children: React.ReactNode; +} + +export default class GridContent extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.js b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.js new file mode 100644 index 0000000..931ea20 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.js @@ -0,0 +1,18 @@ +import React, { PureComponent } from 'react'; +import { connect } from 'dva'; +import styles from './GridContent.less'; + +class GridContent extends PureComponent { + render() { + const { contentWidth, children } = this.props; + let className = `${styles.main}`; + if (contentWidth === 'Fixed') { + className = `${styles.main} ${styles.wide}`; + } + return
    {children}
    ; + } +} + +export default connect(({ setting }) => ({ + contentWidth: setting.contentWidth, +}))(GridContent); diff --git a/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.less b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.less new file mode 100644 index 0000000..d5496e9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/GridContent.less @@ -0,0 +1,10 @@ +.main { + width: 100%; + height: 100%; + min-height: 100%; + transition: 0.3s; + &.wide { + max-width: 1200px; + margin: 0 auto; + } +} diff --git a/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/breadcrumb.js b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/breadcrumb.js new file mode 100644 index 0000000..4264fef --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/breadcrumb.js @@ -0,0 +1,130 @@ +import React from 'react'; +import pathToRegexp from 'path-to-regexp'; +import Link from 'umi/link'; +import { formatMessage } from 'umi-plugin-react/locale'; +import { urlToList } from '../_utils/pathTools'; +import { menu } from '../../defaultSettings'; + +// 渲染Breadcrumb 子节点 +// Render the Breadcrumb child node +const itemRender = (route, params, routes, paths) => { + const last = routes.indexOf(route) === routes.length - 1; + // if path is home, use Link。 + if (route.path === '/') { + return {route.breadcrumbName}; + } + return last || !route.component ? ( + {route.breadcrumbName} + ) : ( + {route.breadcrumbName} + ); +}; + +const renderItemLocal = item => { + if (item.locale) { + const name = menu.disableLocal + ? item.name + : formatMessage({ id: item.locale, defaultMessage: item.name }); + return name; + } + return item.name; +}; + +export const getBreadcrumb = (breadcrumbNameMap, url) => { + let breadcrumb = breadcrumbNameMap[url]; + if (!breadcrumb) { + Object.keys(breadcrumbNameMap).forEach(item => { + if (pathToRegexp(item).test(url)) { + breadcrumb = breadcrumbNameMap[item]; + } + }); + } + return breadcrumb || {}; +}; + +export const getBreadcrumbProps = props => { + const { routes, params, location, breadcrumbNameMap } = props; + return { + routes, + params, + routerLocation: location, + breadcrumbNameMap, + }; +}; + +// Generated according to props +const conversionFromProps = props => { + const { breadcrumbList } = props; + return breadcrumbList.map(item => { + const { title, href } = item; + return { + path: href, + breadcrumbName: title, + }; + }); +}; + +const conversionFromLocation = (routerLocation, breadcrumbNameMap, props) => { + const { home } = props; + // Convert the url to an array + const pathSnippets = urlToList(routerLocation.pathname); + // Loop data mosaic routing + const extraBreadcrumbItems = pathSnippets + .map(url => { + const currentBreadcrumb = getBreadcrumb(breadcrumbNameMap, url); + if (currentBreadcrumb.inherited) { + return null; + } + const name = renderItemLocal(currentBreadcrumb); + const { hideInBreadcrumb } = currentBreadcrumb; + return name && !hideInBreadcrumb + ? { + path: url, + breadcrumbName: name, + } + : null; + }) + .filter(item => item !== null); + // Add home breadcrumbs to your head if defined + if (home) { + extraBreadcrumbItems.unshift({ + path: '/', + breadcrumbName: home, + }); + } + return extraBreadcrumbItems; +}; + +/** + * 将参数转化为面包屑 + * Convert parameters into breadcrumbs + */ +export const conversionBreadcrumbList = props => { + const { breadcrumbList } = props; + const { routes, params, routerLocation, breadcrumbNameMap } = getBreadcrumbProps(props); + if (breadcrumbList && breadcrumbList.length) { + return { + routes: conversionFromProps(props), + params, + itemRender, + }; + } + // 如果传入 routes 和 params 属性 + // If pass routes and params attributes + if (routes && params) { + return { + routes: routes.filter(route => route.breadcrumbName), + params, + itemRender, + }; + } + // 根据 location 生成 面包屑 + // Generate breadcrumbs based on location + if (routerLocation && routerLocation.pathname) { + return { + routes: conversionFromLocation(routerLocation, breadcrumbNameMap, props), + itemRender, + }; + } + return {}; +}; diff --git a/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.d.ts b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.d.ts new file mode 100644 index 0000000..3ed6d0f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.d.ts @@ -0,0 +1,11 @@ +import React from 'react'; +export interface ResultProps { + className?: string; + description?: React.ReactNode; + extra?: React.ReactNode; + style?: React.CSSProperties; + title?: React.ReactNode; + type: 'success' | 'error'; +} + +export default class Result extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.js b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.js new file mode 100644 index 0000000..1e5318f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.js @@ -0,0 +1,106 @@ +import React from 'react'; +import { FormattedMessage } from 'umi-plugin-react/locale'; +import Link from 'umi/link'; +import { PageHeader, Tabs, Typography } from 'antd'; +import { connect } from 'dva'; +import classNames from 'classnames'; +import GridContent from './GridContent'; +import styles from './index.less'; +import MenuContext from '@/layouts/MenuContext'; +import { conversionBreadcrumbList } from './breadcrumb'; + +const { Title } = Typography; + +/** + * render Footer tabList + * In order to be compatible with the old version of the PageHeader + * basically all the functions are implemented. + */ +const renderFooter = ({ tabList, tabActiveKey, onTabChange, tabBarExtraContent }) => { + return tabList && tabList.length ? ( + { + if (onTabChange) { + onTabChange(key); + } + }} + tabBarExtraContent={tabBarExtraContent} + > + {tabList.map(item => ( + + ))} + + ) : null; +}; + +const PageHeaderWrapper = ({ + children, + contentWidth, + wrapperClassName, + top, + title, + content, + logo, + extraContent, + hiddenBreadcrumb, + ...restProps +}) => { + return ( +
    + {top} + + {value => { + return ( + + {title} + + } + key="pageheader" + {...restProps} + breadcrumb={ + !hiddenBreadcrumb && + conversionBreadcrumbList({ + ...value, + ...restProps, + home: , + }) + } + className={styles.pageHeader} + linkElement={Link} + footer={renderFooter(restProps)} + > +
    + {logo &&
    {logo}
    } +
    +
    + {content &&
    {content}
    } + {extraContent &&
    {extraContent}
    } +
    +
    +
    +
    + ); + }} +
    + {children ? ( +
    + {children} +
    + ) : null} +
    + ); +}; + +export default connect(({ setting }) => ({ + contentWidth: setting.contentWidth, +}))(PageHeaderWrapper); diff --git a/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.less b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.less new file mode 100644 index 0000000..119585b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/PageHeaderWrapper/index.less @@ -0,0 +1,110 @@ +@import '~antd/lib/style/themes/default.less'; + +.children-content { + margin: 24px 24px 0; +} + +.main { + :global { + .ant-page-header { + padding: 16px 32px 0; + background: #fff; + border-bottom: 1px solid #e8e8e8; + } + } + + .wide { + max-width: 1200px; + margin: auto; + } + .detail { + display: flex; + } + + .row { + display: flex; + width: 100%; + } + + .logo { + flex: 0 1 auto; + margin-right: 16px; + padding-top: 1px; + > img { + display: block; + width: 28px; + height: 28px; + border-radius: @border-radius-base; + } + } + + .title-content { + margin-bottom: 16px; + } + + @media screen and (max-width: @screen-sm) { + .content { + margin: 24px 0 0; + } + } + + .title, + .content { + flex: auto; + } + + .extraContent, + .main { + flex: 0 1 auto; + } + + .main { + width: 100%; + } + + .title { + margin-bottom: 16px; + } + + .logo, + .content, + .extraContent { + margin-bottom: 16px; + } + + .extraContent { + min-width: 242px; + margin-left: 88px; + text-align: right; + } +} + +@media screen and (max-width: @screen-xl) { + .extraContent { + margin-left: 44px; + } +} + +@media screen and (max-width: @screen-lg) { + .extraContent { + margin-left: 20px; + } +} + +@media screen and (max-width: @screen-md) { + .row { + display: block; + } + + .action, + .extraContent { + margin-left: 0; + text-align: left; + } +} + +@media screen and (max-width: @screen-sm) { + .detail { + display: block; + } +} diff --git a/antdsp-admin/src/main/web/src/components/PageLoading/index.js b/antdsp-admin/src/main/web/src/components/PageLoading/index.js new file mode 100644 index 0000000..77c0f16 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/PageLoading/index.js @@ -0,0 +1,10 @@ +import React from 'react'; +import { Spin } from 'antd'; + +// loading components from code split +// https://umijs.org/plugin/umi-plugin-react.html#dynamicimport +export default () => ( +
    + +
    +); diff --git a/antdsp-admin/src/main/web/src/components/Result/demo/classic.md b/antdsp-admin/src/main/web/src/components/Result/demo/classic.md new file mode 100644 index 0000000..0cd9d14 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Result/demo/classic.md @@ -0,0 +1,80 @@ +--- +order: 1 +title: Classic +--- + +典型结果页面。 + +````jsx +import Result from 'ant-design-pro/lib/Result'; +import { Button, Row, Col, Icon, Steps } from 'antd'; + +const { Step } = Steps; + +const desc1 = ( +
    +
    + 曲丽丽 + +
    +
    2016-12-12 12:32
    +
    +); + +const desc2 = ( +
    +
    + 周毛毛 + +
    + +
    +); + +const extra = ( +
    +
    + 项目名称 +
    + + + 项目 ID: + 23421 + + + 负责人: + 曲丽丽 + + + 生效时间: + 2016-12-12 ~ 2017-12-12 + + + + + + + + +
    +); + +const actions = ( +
    + + + +
    +); + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Result/demo/error.md b/antdsp-admin/src/main/web/src/components/Result/demo/error.md new file mode 100644 index 0000000..5fd25cf --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Result/demo/error.md @@ -0,0 +1,39 @@ +--- +order: 2 +title: Failed +--- + +提交失败。 + +````jsx +import Result from 'ant-design-pro/lib/Result'; +import { Button, Icon } from 'antd'; + +const extra = ( +
    +
    + 您提交的内容有如下错误: +
    +
    + 您的账户已被冻结 + 立即解冻 +
    +
    + 您的账户还不具备申请资格 + 立即升级 +
    +
    +); + +const actions = ; + +ReactDOM.render( + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Result/demo/structure.md b/antdsp-admin/src/main/web/src/components/Result/demo/structure.md new file mode 100644 index 0000000..7fcecfd --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Result/demo/structure.md @@ -0,0 +1,20 @@ +--- +order: 0 +title: Structure +--- + +结构包含 `处理结果`,`补充信息` 以及 `操作建议` 三个部分,其中 `处理结果` 由 `提示图标`,`标题` 和 `结果描述` 组成。 + +````jsx +import Result from 'ant-design-pro/lib/Result'; + +ReactDOM.render( + 标题
    } + description={
    结果描述
    } + extra="其他补充信息,自带灰底效果" + actions={
    操作建议,一般放置按钮组
    } + /> +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/Result/index.d.ts b/antdsp-admin/src/main/web/src/components/Result/index.d.ts new file mode 100644 index 0000000..21c8759 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Result/index.d.ts @@ -0,0 +1,12 @@ +import React from 'react'; +export interface ResultProps { + actions?: React.ReactNode; + className?: string; + description?: React.ReactNode; + extra?: React.ReactNode; + style?: React.CSSProperties; + title?: React.ReactNode; + type: 'success' | 'error'; +} + +export default class Result extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Result/index.js b/antdsp-admin/src/main/web/src/components/Result/index.js new file mode 100644 index 0000000..89f9f31 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Result/index.js @@ -0,0 +1,29 @@ +import React from 'react'; +import classNames from 'classnames'; +import { Icon } from 'antd'; +import styles from './index.less'; + +export default function Result({ + className, + type, + title, + description, + extra, + actions, + ...restProps +}) { + const iconMap = { + error: , + success: , + }; + const clsString = classNames(styles.result, className); + return ( +
    +
    {iconMap[type]}
    +
    {title}
    + {description &&
    {description}
    } + {extra &&
    {extra}
    } + {actions &&
    {actions}
    } +
    + ); +} diff --git a/antdsp-admin/src/main/web/src/components/Result/index.less b/antdsp-admin/src/main/web/src/components/Result/index.less new file mode 100644 index 0000000..00c9587 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Result/index.less @@ -0,0 +1,58 @@ +@import '~antd/lib/style/themes/default.less'; + +.result { + width: 72%; + margin: 0 auto; + text-align: center; + @media screen and (max-width: @screen-xs) { + width: 100%; + } + + .icon { + margin-bottom: 24px; + font-size: 72px; + line-height: 72px; + + & > .success { + color: @success-color; + } + + & > .error { + color: @error-color; + } + } + + .title { + margin-bottom: 16px; + color: @heading-color; + font-weight: 500; + font-size: 24px; + line-height: 32px; + } + + .description { + margin-bottom: 24px; + color: @text-color-secondary; + font-size: 14px; + line-height: 22px; + } + + .extra { + padding: 24px 40px; + text-align: left; + background: #fafafa; + border-radius: @border-radius-sm; + + @media screen and (max-width: @screen-xs) { + padding: 18px 20px; + } + } + + .actions { + margin-top: 32px; + + button:not(:last-child) { + margin-right: 8px; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/Result/index.md b/antdsp-admin/src/main/web/src/components/Result/index.md new file mode 100644 index 0000000..05e1c0e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Result/index.md @@ -0,0 +1,18 @@ +--- +title: Result +subtitle: 处理结果 +cols: 1 +order: 12 +--- + +结果页用于对用户进行的一系列任务处理结果进行反馈。 + +## API + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| type | 类型,不同类型自带对应的图标 | Enum {'success', 'error'} | - | +| title | 标题 | ReactNode | - | +| description | 结果描述 | ReactNode | - | +| extra | 补充信息,有默认的灰色背景 | ReactNode | - | +| actions | 操作建议,推荐放置跳转链接,按钮组等 | ReactNode | - | diff --git a/antdsp-admin/src/main/web/src/components/SelectLang/index.d.ts b/antdsp-admin/src/main/web/src/components/SelectLang/index.d.ts new file mode 100644 index 0000000..d2c53fa --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SelectLang/index.d.ts @@ -0,0 +1,7 @@ +import React from 'react'; + +export interface SelectLangProps { + className?: string; +} + +export default class SelectLang extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/SelectLang/index.js b/antdsp-admin/src/main/web/src/components/SelectLang/index.js new file mode 100644 index 0000000..3ce3fb8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SelectLang/index.js @@ -0,0 +1,49 @@ +import React, { PureComponent } from 'react'; +import { formatMessage, setLocale, getLocale } from 'umi-plugin-react/locale'; +import { Menu, Icon } from 'antd'; +import classNames from 'classnames'; +import HeaderDropdown from '../HeaderDropdown'; +import styles from './index.less'; + +export default class SelectLang extends PureComponent { + changeLang = ({ key }) => { + setLocale(key); + }; + + render() { + const { className } = this.props; + const selectedLang = getLocale(); + const locales = ['zh-CN', 'zh-TW', 'en-US', 'pt-BR']; + const languageLabels = { + 'zh-CN': '简体中文', + 'zh-TW': '繁体中文', + 'en-US': 'English', + 'pt-BR': 'Português', + }; + const languageIcons = { + 'zh-CN': '🇨🇳', + 'zh-TW': '🇭🇰', + 'en-US': '🇬🇧', + 'pt-BR': '🇧🇷', + }; + const langMenu = ( + + {locales.map(locale => ( + + + {languageIcons[locale]} + {' '} + {languageLabels[locale]} + + ))} + + ); + return ( + + + + + + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/SelectLang/index.less b/antdsp-admin/src/main/web/src/components/SelectLang/index.less new file mode 100644 index 0000000..9f41ade --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SelectLang/index.less @@ -0,0 +1,24 @@ +@import '~antd/lib/style/themes/default.less'; + +.menu { + :global(.anticon) { + margin-right: 8px; + } + :global(.ant-dropdown-menu-item) { + min-width: 160px; + } +} + +.dropDown { + line-height: @layout-header-height; + vertical-align: top; + cursor: pointer; + > i { + font-size: 16px !important; + transform: none !important; + svg { + position: relative; + top: -1px; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/SettingDrawer/BlockCheckbox.d.ts b/antdsp-admin/src/main/web/src/components/SettingDrawer/BlockCheckbox.d.ts new file mode 100644 index 0000000..1012294 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SettingDrawer/BlockCheckbox.d.ts @@ -0,0 +1,9 @@ +import React from 'react'; + +export interface BlockChecboxProps { + value: string; + onChange: (key: string) => void; + list: any[]; +} + +export default class BlockChecbox extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/SettingDrawer/BlockCheckbox.js b/antdsp-admin/src/main/web/src/components/SettingDrawer/BlockCheckbox.js new file mode 100644 index 0000000..49af42c --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SettingDrawer/BlockCheckbox.js @@ -0,0 +1,25 @@ +import React from 'react'; +import { Tooltip, Icon } from 'antd'; +import style from './index.less'; + +const BlockChecbox = ({ value, onChange, list }) => ( +
    + {list.map(item => ( + +
    onChange(item.key)}> + {item.key} +
    + +
    +
    +
    + ))} +
    +); + +export default BlockChecbox; diff --git a/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.d.ts b/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.d.ts new file mode 100644 index 0000000..17bc3e8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.d.ts @@ -0,0 +1,10 @@ +import React from 'react'; + +export interface TagProps { + color: string; + check: boolean; + className?: string; + onClick?: () => void; +} + +export default class ThemeColor extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.js b/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.js new file mode 100644 index 0000000..9765b73 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.js @@ -0,0 +1,74 @@ +import React from 'react'; +import { Tooltip, Icon } from 'antd'; +import { formatMessage } from 'umi-plugin-react/locale'; +import styles from './ThemeColor.less'; + +const Tag = ({ color, check, ...rest }) => ( +
    + {check ? : ''} +
    +); + +const ThemeColor = ({ colors, title, value, onChange }) => { + let colorList = colors; + if (!colors) { + colorList = [ + { + key: 'dust', + color: '#F5222D', + }, + { + key: 'volcano', + color: '#FA541C', + }, + { + key: 'sunset', + color: '#FAAD14', + }, + { + key: 'cyan', + color: '#13C2C2', + }, + { + key: 'green', + color: '#52C41A', + }, + { + key: 'daybreak', + color: '#1890FF', + }, + { + key: 'geekblue', + color: '#2F54EB', + }, + { + key: 'purple', + color: '#722ED1', + }, + ]; + } + return ( +
    +

    {title}

    +
    + {colorList.map(({ key, color }) => ( + + onChange && onChange(color)} + /> + + ))} +
    +
    + ); +}; + +export default ThemeColor; diff --git a/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.less b/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.less new file mode 100644 index 0000000..52e63be --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SettingDrawer/ThemeColor.less @@ -0,0 +1,21 @@ +.themeColor { + margin-top: 24px; + overflow: hidden; + .title { + margin-bottom: 12px; + color: rgba(0, 0, 0, 0.65); + font-size: 14px; + line-height: 22px; + } + .colorBlock { + float: left; + width: 20px; + height: 20px; + margin-right: 8px; + color: #fff; + font-weight: bold; + text-align: center; + border-radius: 2px; + cursor: pointer; + } +} diff --git a/antdsp-admin/src/main/web/src/components/SettingDrawer/index.d.ts b/antdsp-admin/src/main/web/src/components/SettingDrawer/index.d.ts new file mode 100644 index 0000000..2227308 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SettingDrawer/index.d.ts @@ -0,0 +1,24 @@ +import React from 'react'; +import { SiderTheme } from 'antd/es/Layout/Sider'; + +export interface SettingModelState { + navTheme: string | SiderTheme; + primaryColor: string; + layout: string; + contentWidth: string; + fixedHeader: boolean; + autoHideHeader: boolean; + fixSiderbar: boolean; + menu: { disableLocal: boolean }; + title: string; + pwa: boolean; + iconfontUrl: string; + colorWeak: boolean; +} + +export interface SettingDrawerProps { + setting?: SettingModelState; + dispatch?: (args: any) => void; +} + +export default class SettingDrawer extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/SettingDrawer/index.js b/antdsp-admin/src/main/web/src/components/SettingDrawer/index.js new file mode 100644 index 0000000..dcf341a --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SettingDrawer/index.js @@ -0,0 +1,258 @@ +import React, { Component } from 'react'; +import { Select, message, Drawer, List, Switch, Divider, Icon, Button, Alert, Tooltip } from 'antd'; +import { formatMessage } from 'umi-plugin-react/locale'; +import { CopyToClipboard } from 'react-copy-to-clipboard'; +import { connect } from 'dva'; +import omit from 'omit.js'; +import styles from './index.less'; +import ThemeColor from './ThemeColor'; +import BlockCheckbox from './BlockCheckbox'; + +const { Option } = Select; + +const Body = ({ children, title, style }) => ( +
    +

    {title}

    + {children} +
    +); + +@connect(({ setting }) => ({ setting })) +class SettingDrawer extends Component { + state = { + collapse: false, + }; + + getLayoutSetting = () => { + const { + setting: { contentWidth, fixedHeader, layout, autoHideHeader, fixSiderbar }, + } = this.props; + return [ + { + title: formatMessage({ id: 'app.setting.content-width' }), + action: ( + + ), + }, + { + title: formatMessage({ id: 'app.setting.fixedheader' }), + action: ( + this.changeSetting('fixedHeader', checked)} + /> + ), + }, + { + title: formatMessage({ id: 'app.setting.hideheader' }), + disabled: !fixedHeader, + disabledReason: formatMessage({ id: 'app.setting.hideheader.hint' }), + action: ( + this.changeSetting('autoHideHeader', checked)} + /> + ), + }, + { + title: formatMessage({ id: 'app.setting.fixedsidebar' }), + disabled: layout === 'topmenu', + disabledReason: formatMessage({ id: 'app.setting.fixedsidebar.hint' }), + action: ( + this.changeSetting('fixSiderbar', checked)} + /> + ), + }, + ]; + }; + + changeSetting = (key, value) => { + const { setting } = this.props; + const nextState = { ...setting }; + nextState[key] = value; + if (key === 'layout') { + nextState.contentWidth = value === 'topmenu' ? 'Fixed' : 'Fluid'; + } else if (key === 'fixedHeader' && !value) { + nextState.autoHideHeader = false; + } + this.setState(nextState, () => { + const { dispatch } = this.props; + dispatch({ + type: 'setting/changeSetting', + payload: this.state, + }); + }); + }; + + togglerContent = () => { + const { collapse } = this.state; + this.setState({ collapse: !collapse }); + }; + + renderLayoutSettingItem = item => { + const action = React.cloneElement(item.action, { + disabled: item.disabled, + }); + return ( + + + {item.title} + + + ); + }; + + render() { + const { setting } = this.props; + const { navTheme, primaryColor, layout, colorWeak } = setting; + const { collapse } = this.state; + return ( + + +
    + } + style={{ + zIndex: 999, + }} + > +
    + + this.changeSetting('navTheme', value)} + /> + + + this.changeSetting('primaryColor', color)} + /> + + + + + this.changeSetting('layout', value)} + /> + + + + + + + + this.changeSetting('colorWeak', checked)} + /> + ), + }, + ]} + /> + + + message.success(formatMessage({ id: 'app.setting.copyinfo' }))} + > + + + + {formatMessage({ id: 'app.setting.production.hint' })}{' '} + + src/defaultSettings.js + +
    + } + /> +
    + + ); + } +} + +export default SettingDrawer; diff --git a/antdsp-admin/src/main/web/src/components/SettingDrawer/index.less b/antdsp-admin/src/main/web/src/components/SettingDrawer/index.less new file mode 100644 index 0000000..0654878 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SettingDrawer/index.less @@ -0,0 +1,81 @@ +@import '~antd/lib/style/themes/default.less'; + +.content { + position: relative; + min-height: 100%; + background: #fff; + :global { + .ant-list-item { + span { + flex: 1; + } + } + } +} + +.blockChecbox { + display: flex; + .item { + position: relative; + margin-right: 16px; + // box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1); + border-radius: @border-radius-base; + cursor: pointer; + img { + width: 48px; + } + } + .selectIcon { + position: absolute; + top: 0; + right: 0; + width: 100%; + height: 100%; + padding-top: 15px; + padding-left: 24px; + color: @primary-color; + font-weight: bold; + font-size: 14px; + } +} + +.color_block { + display: inline-block; + width: 38px; + height: 22px; + margin: 4px; + margin-right: 12px; + vertical-align: middle; + border-radius: 4px; + cursor: pointer; +} + +.title { + margin-bottom: 12px; + color: @heading-color; + font-size: 14px; + line-height: 22px; +} + +.handle { + position: absolute; + top: 240px; + right: 300px; + z-index: 0; + display: flex; + align-items: center; + justify-content: center; + width: 48px; + height: 48px; + font-size: 16px; + text-align: center; + background: @primary-color; + border-radius: 4px 0 0 4px; + cursor: pointer; + pointer-events: auto; +} + +.productionHint { + margin-top: 16px; + font-size: 12px; +} diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/BaseMenu.d.ts b/antdsp-admin/src/main/web/src/components/SiderMenu/BaseMenu.d.ts new file mode 100644 index 0000000..79fcf46 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/BaseMenu.d.ts @@ -0,0 +1,23 @@ +import React from 'react'; +import * as H from 'history'; +import { SiderTheme, CollapseType } from 'antd/es/Layout/Sider'; + +import { MenuMode } from 'antd/es/menu'; + +export interface BaseMenuProps { + flatMenuKeys?: any[]; + location?: H.Location; + onCollapse?: (collapsed: boolean, type?: CollapseType) => void; + isMobile?: boolean; + openKeys?: any; + theme?: SiderTheme; + mode?: MenuMode; + className?: string; + collapsed?: boolean; + handleOpenChange?: (openKeys: any[]) => void; + menuData?: any[]; + style?: React.CSSProperties; + onOpenChange?: (openKeys: string[]) => void; +} + +export default class BaseMenu extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/BaseMenu.js b/antdsp-admin/src/main/web/src/components/SiderMenu/BaseMenu.js new file mode 100644 index 0000000..9ab66ec --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/BaseMenu.js @@ -0,0 +1,166 @@ +import React, { PureComponent } from 'react'; +import classNames from 'classnames'; +import { Menu, Icon } from 'antd'; +import Link from 'umi/link'; +import { urlToList } from '../_utils/pathTools'; +import { getMenuMatches } from './SiderMenuUtils'; +import { isUrl } from '@/utils/utils'; +import styles from './index.less'; +import IconFont from '@/components/IconFont'; + +const { SubMenu } = Menu; + +// Allow menu.js config icon as string or ReactNode +// icon: 'setting', +// icon: 'icon-geren' #For Iconfont , +// icon: 'http://demo.com/icon.png', +// icon: , +const getIcon = icon => { + if (typeof icon === 'string') { + if (isUrl(icon)) { + return icon} />; + } + if (icon.startsWith('icon-')) { + return ; + } + return ; + } + return icon; +}; + +export default class BaseMenu extends PureComponent { + /** + * 获得菜单子节点 + * @memberof SiderMenu + */ + getNavMenuItems = menusData => { + if (!menusData) { + return []; + } + return menusData + .filter(item => item.name && !item.hideInMenu) + .map(item => this.getSubMenuOrItem(item)) + .filter(item => item); + }; + + // Get the currently selected menu + getSelectedMenuKeys = pathname => { + const { flatMenuKeys } = this.props; + return urlToList(pathname).map(itemPath => getMenuMatches(flatMenuKeys, itemPath).pop()); + }; + + /** + * get SubMenu or Item + */ + getSubMenuOrItem = item => { + // doc: add hideChildrenInMenu + if (item.children && !item.hideChildrenInMenu && item.children.some(child => child.name)) { + const { name } = item; + return ( + + {getIcon(item.icon)} + {name} + + ) : ( + name + ) + } + key={item.path} + > + {this.getNavMenuItems(item.children)} + + ); + } + return {this.getMenuItemPath(item)}; + }; + + /** + * 判断是否是http链接.返回 Link 或 a + * Judge whether it is http link.return a or Link + * @memberof SiderMenu + */ + getMenuItemPath = item => { + const { name } = item; + const itemPath = this.conversionPath(item.path); + const icon = getIcon(item.icon); + const { target } = item; + // Is it a http link + if (/^https?:\/\//.test(itemPath)) { + return ( + + {icon} + {name} + + ); + } + const { location, isMobile, onCollapse } = this.props; + return ( + { + onCollapse(true); + } + : undefined + } + > + {icon} + {name} + + ); + }; + + conversionPath = path => { + if (path && path.indexOf('http') === 0) { + return path; + } + return `/${path || ''}`.replace(/\/+/g, '/'); + }; + + render() { + const { + openKeys, + theme, + mode, + location: { pathname }, + className, + collapsed, + } = this.props; + // if pathname can't match, use the nearest parent's key + let selectedKeys = this.getSelectedMenuKeys(pathname); + if (!selectedKeys.length && openKeys) { + selectedKeys = [openKeys[openKeys.length - 1]]; + } + let props = {}; + if (openKeys && !collapsed) { + props = { + openKeys: openKeys.length === 0 ? [...selectedKeys] : openKeys, + }; + } + const { handleOpenChange, style, menuData } = this.props; + const cls = classNames(className, { + 'top-nav-menu': mode === 'horizontal', + }); + + return ( + + {this.getNavMenuItems(menuData)} + + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.d.ts b/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.d.ts new file mode 100644 index 0000000..c18162a --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.d.ts @@ -0,0 +1,11 @@ +import React from 'react'; +import * as H from 'history'; +import { BaseMenuProps } from './BaseMenu'; +import { SiderTheme } from 'antd/es/Layout/Sider'; + +export interface SiderMenuProps extends BaseMenuProps { + logo?: string; + fixSiderbar?: boolean; +} + +export default class SiderMenu extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.js b/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.js new file mode 100644 index 0000000..da9520f --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.js @@ -0,0 +1,99 @@ +import React, { PureComponent, Suspense } from 'react'; +import { Layout } from 'antd'; +import classNames from 'classnames'; +import Link from 'umi/link'; +import styles from './index.less'; +import PageLoading from '../PageLoading'; +import { getDefaultCollapsedSubMenus } from './SiderMenuUtils'; +import { title } from '../../defaultSettings'; + +const BaseMenu = React.lazy(() => import('./BaseMenu')); +const { Sider } = Layout; + +let firstMount = true; + +export default class SiderMenu extends PureComponent { + constructor(props) { + super(props); + this.state = { + openKeys: getDefaultCollapsedSubMenus(props), + }; + } + + componentDidMount() { + firstMount = false; + } + + static getDerivedStateFromProps(props, state) { + const { pathname, flatMenuKeysLen } = state; + if (props.location.pathname !== pathname || props.flatMenuKeys.length !== flatMenuKeysLen) { + return { + pathname: props.location.pathname, + flatMenuKeysLen: props.flatMenuKeys.length, + openKeys: getDefaultCollapsedSubMenus(props), + }; + } + return null; + } + + isMainMenu = key => { + const { menuData } = this.props; + return menuData.some(item => { + if (key) { + return item.key === key || item.path === key; + } + return false; + }); + }; + + handleOpenChange = openKeys => { + const moreThanOne = openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1; + this.setState({ + openKeys: moreThanOne ? [openKeys.pop()] : [...openKeys], + }); + }; + + render() { + const { logo, collapsed, onCollapse, fixSiderbar, theme, isMobile } = this.props; + const { openKeys } = this.state; + const defaultProps = collapsed ? {} : { openKeys }; + + const siderClassName = classNames(styles.sider, { + [styles.fixSiderBar]: fixSiderbar, + [styles.light]: theme === 'light', + }); + return ( + { + if (firstMount || !isMobile) { + onCollapse(collapse); + } + }} + width={256} + theme={theme} + className={siderClassName} + > + + }> + + + + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.test.js b/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.test.js new file mode 100644 index 0000000..3d280da --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenu.test.js @@ -0,0 +1,39 @@ +import { getFlatMenuKeys } from './SiderMenuUtils'; + +const menu = [ + { + path: '/dashboard', + children: [ + { + path: '/dashboard/name', + }, + ], + }, + { + path: '/userinfo', + children: [ + { + path: '/userinfo/:id', + children: [ + { + path: '/userinfo/:id/info', + }, + ], + }, + ], + }, +]; + +const flatMenuKeys = getFlatMenuKeys(menu); + +describe('test convert nested menu to flat menu', () => { + it('simple menu', () => { + expect(flatMenuKeys).toEqual([ + '/dashboard', + '/dashboard/name', + '/userinfo', + '/userinfo/:id', + '/userinfo/:id/info', + ]); + }); +}); diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenuUtils.js b/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenuUtils.js new file mode 100644 index 0000000..6e04ec1 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/SiderMenuUtils.js @@ -0,0 +1,40 @@ +import pathToRegexp from 'path-to-regexp'; +import { urlToList } from '../_utils/pathTools'; + +/** + * Recursively flatten the data + * [{path:string},{path:string}] => {path,path2} + * @param menus + */ +export const getFlatMenuKeys = menuData => { + let keys = []; + menuData.forEach(item => { + keys.push(item.path); + if (item.children) { + keys = keys.concat(getFlatMenuKeys(item.children)); + } + }); + return keys; +}; + +export const getMenuMatches = (flatMenuKeys, path) => + flatMenuKeys.filter(item => { + if (item) { + return pathToRegexp(item).test(path); + } + return false; + }); +/** + * 获得菜单子节点 + * @memberof SiderMenu + */ +export const getDefaultCollapsedSubMenus = props => { + const { + location: { pathname }, + flatMenuKeys, + } = props; + return urlToList(pathname) + .map(item => getMenuMatches(flatMenuKeys, item)[0]) + .filter(item => item) + .reduce((acc, curr) => [...acc, curr], ['/']); +}; diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/index.d.ts b/antdsp-admin/src/main/web/src/components/SiderMenu/index.d.ts new file mode 100644 index 0000000..383df9e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/index.d.ts @@ -0,0 +1,13 @@ +import React from 'react'; +import { SiderTheme } from 'antd/es/Layout/Sider'; + +export interface SiderMenuProps { + isMobile: boolean; + menuData: any[]; + collapsed: boolean; + logo?: string; + theme?: SiderTheme; + onCollapse: (payload: boolean) => void; +} + +export default class SiderMenuWrapper extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/index.js b/antdsp-admin/src/main/web/src/components/SiderMenu/index.js new file mode 100644 index 0000000..0be2733 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/index.js @@ -0,0 +1,26 @@ +import React from 'react'; +import { Drawer } from 'antd'; +import SiderMenu from './SiderMenu'; +import { getFlatMenuKeys } from './SiderMenuUtils'; + +const SiderMenuWrapper = React.memo(props => { + const { isMobile, menuData, collapsed, onCollapse } = props; + const flatMenuKeys = getFlatMenuKeys(menuData); + return isMobile ? ( + onCollapse(true)} + style={{ + padding: 0, + height: '100vh', + }} + > + + + ) : ( + + ); +}); + +export default SiderMenuWrapper; diff --git a/antdsp-admin/src/main/web/src/components/SiderMenu/index.less b/antdsp-admin/src/main/web/src/components/SiderMenu/index.less new file mode 100644 index 0000000..88722c8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/SiderMenu/index.less @@ -0,0 +1,105 @@ +@import '~antd/lib/style/themes/default.less'; + +@nav-header-height: @layout-header-height; + +.logo { + position: relative; + height: @nav-header-height; + padding-left: (@menu-collapsed-width - 32px) / 2; + overflow: hidden; + line-height: @nav-header-height; + background: #002140; + transition: all 0.3s; + img { + display: inline-block; + height: 32px; + vertical-align: middle; + } + h1 { + display: inline-block; + margin: 0 0 0 12px; + color: white; + font-weight: 600; + font-size: 20px; + font-family: Avenir, 'Helvetica Neue', Arial, Helvetica, sans-serif; + vertical-align: middle; + } +} +.sider { + position: relative; + z-index: 10; + min-height: 100vh; + box-shadow: 2px 0 6px rgba(0, 21, 41, 0.35); + &.fixSiderBar { + position: fixed; + top: 0; + left: 0; + box-shadow: 2px 0 8px 0 rgba(29, 35, 41, 0.05); + :global { + .ant-menu-root { + height: ~'calc(100vh - @{nav-header-height})'; + overflow-y: auto; + } + .ant-menu-inline { + border-right: 0; + .ant-menu-item, + .ant-menu-submenu-title { + width: 100%; + } + } + } + } + &.light { + background-color: white; + box-shadow: 2px 0 8px 0 rgba(29, 35, 41, 0.05); + .logo { + background: white; + box-shadow: 1px 1px 0 0 @border-color-split; + h1 { + color: @primary-color; + } + } + :global(.ant-menu-light) { + border-right-color: transparent; + } + } +} + +.icon { + width: 14px; + vertical-align: baseline; +} + +:global { + .top-nav-menu li.ant-menu-item { + height: @nav-header-height; + line-height: @nav-header-height; + } + .drawer .drawer-content { + background: #001529; + } + .ant-menu-inline-collapsed { + & > .ant-menu-item .sider-menu-item-img + span, + & + > .ant-menu-item-group + > .ant-menu-item-group-list + > .ant-menu-item + .sider-menu-item-img + + span, + & > .ant-menu-submenu > .ant-menu-submenu-title .sider-menu-item-img + span { + display: inline-block; + max-width: 0; + opacity: 0; + } + } + .ant-menu-item .sider-menu-item-img + span, + .ant-menu-submenu-title .sider-menu-item-img + span { + opacity: 1; + transition: opacity 0.3s @ease-in-out, width 0.3s @ease-in-out; + } + .ant-drawer-left { + .ant-drawer-body { + padding: 0; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/StandardFormRow/index.d.ts b/antdsp-admin/src/main/web/src/components/StandardFormRow/index.d.ts new file mode 100644 index 0000000..de06c9b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/StandardFormRow/index.d.ts @@ -0,0 +1,11 @@ +import React from 'react'; + +export interface StandardFormRowProps { + title: string; + last?: boolean; + block?: boolean; + grid?: boolean; + style?: React.CSSProperties; +} + +export default class StandardFormRow extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/StandardFormRow/index.js b/antdsp-admin/src/main/web/src/components/StandardFormRow/index.js new file mode 100644 index 0000000..8cb0e44 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/StandardFormRow/index.js @@ -0,0 +1,24 @@ +import React from 'react'; +import classNames from 'classnames'; +import styles from './index.less'; + +const StandardFormRow = ({ title, children, last, block, grid, ...rest }) => { + const cls = classNames(styles.standardFormRow, { + [styles.standardFormRowBlock]: block, + [styles.standardFormRowLast]: last, + [styles.standardFormRowGrid]: grid, + }); + + return ( +
    + {title && ( +
    + {title} +
    + )} +
    {children}
    +
    + ); +}; + +export default StandardFormRow; diff --git a/antdsp-admin/src/main/web/src/components/StandardFormRow/index.less b/antdsp-admin/src/main/web/src/components/StandardFormRow/index.less new file mode 100644 index 0000000..0427233 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/StandardFormRow/index.less @@ -0,0 +1,72 @@ +@import '~antd/lib/style/themes/default.less'; + +.standardFormRow { + display: flex; + margin-bottom: 16px; + padding-bottom: 16px; + border-bottom: 1px dashed @border-color-split; + :global { + .ant-form-item { + margin-right: 24px; + } + .ant-form-item-label label { + margin-right: 0; + color: @text-color; + } + .ant-form-item-label, + .ant-form-item-control { + padding: 0; + line-height: 32px; + } + } + .label { + flex: 0 0 auto; + margin-right: 24px; + color: @heading-color; + font-size: @font-size-base; + text-align: right; + & > span { + display: inline-block; + height: 32px; + line-height: 32px; + &::after { + content: ':'; + } + } + } + .content { + flex: 1 1 0; + :global { + .ant-form-item:last-child { + margin-right: 0; + } + } + } +} + +.standardFormRowLast { + margin-bottom: 0; + padding-bottom: 0; + border: none; +} + +.standardFormRowBlock { + :global { + .ant-form-item, + div.ant-form-item-control-wrapper { + display: block; + } + } +} + +.standardFormRowGrid { + :global { + .ant-form-item, + div.ant-form-item-control-wrapper { + display: block; + } + .ant-form-item-label { + float: left; + } + } +} diff --git a/antdsp-admin/src/main/web/src/components/StandardTable/index.d.ts b/antdsp-admin/src/main/web/src/components/StandardTable/index.d.ts new file mode 100644 index 0000000..d9addef --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/StandardTable/index.d.ts @@ -0,0 +1,19 @@ +import React from 'react'; +import { PaginationConfig, SorterResult, TableCurrentDataSource } from 'antd/lib/table'; + +export interface StandardTableProps { + columns: any; + onSelectRow: (row: any) => void; + data: any; + rowKey?: string; + selectedRows: any[]; + onChange?: ( + pagination: PaginationConfig, + filters: Record, + sorter: SorterResult, + extra?: TableCurrentDataSource + ) => void; + loading?: boolean; +} + +export default class StandardTable extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/StandardTable/index.js b/antdsp-admin/src/main/web/src/components/StandardTable/index.js new file mode 100644 index 0000000..c0c1725 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/StandardTable/index.js @@ -0,0 +1,121 @@ +import React, { PureComponent, Fragment } from 'react'; +import { Table, Alert } from 'antd'; +import styles from './index.less'; + +function initTotalList(columns) { + const totalList = []; + columns.forEach(column => { + if (column.needTotal) { + totalList.push({ ...column, total: 0 }); + } + }); + return totalList; +} + +class StandardTable extends PureComponent { + constructor(props) { + super(props); + const { columns } = props; + const needTotalList = initTotalList(columns); + + this.state = { + selectedRowKeys: [], + needTotalList, + }; + } + + static getDerivedStateFromProps(nextProps) { + // clean state + if (nextProps.selectedRows.length === 0) { + const needTotalList = initTotalList(nextProps.columns); + return { + selectedRowKeys: [], + needTotalList, + }; + } + return null; + } + + handleRowSelectChange = (selectedRowKeys, selectedRows) => { + let { needTotalList } = this.state; + needTotalList = needTotalList.map(item => ({ + ...item, + total: selectedRows.reduce((sum, val) => sum + parseFloat(val[item.dataIndex], 10), 0), + })); + const { onSelectRow } = this.props; + if (onSelectRow) { + onSelectRow(selectedRows); + } + + this.setState({ selectedRowKeys, needTotalList }); + }; + + handleTableChange = (pagination, filters, sorter) => { + const { onChange } = this.props; + if (onChange) { + onChange(pagination, filters, sorter); + } + }; + + cleanSelectedKeys = () => { + this.handleRowSelectChange([], []); + }; + + render() { + const { selectedRowKeys, needTotalList } = this.state; + const { data = {}, rowKey, ...rest } = this.props; + const { list = [], pagination } = data; + + const paginationProps = { + showSizeChanger: true, + showQuickJumper: true, + ...pagination, + }; + + const rowSelection = { + selectedRowKeys, + onChange: this.handleRowSelectChange, + getCheckboxProps: record => ({ + disabled: record.disabled, + }), + }; + + return ( +
    +
    + + 已选择 {selectedRowKeys.length} 项   + {needTotalList.map(item => ( + + {item.title} + 总计  + + {item.render ? item.render(item.total) : item.total} + + + ))} + + 清空 + + + } + type="info" + showIcon + /> +
    + + + ); + } +} + +export default StandardTable; diff --git a/antdsp-admin/src/main/web/src/components/StandardTable/index.less b/antdsp-admin/src/main/web/src/components/StandardTable/index.less new file mode 100644 index 0000000..817be99 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/StandardTable/index.less @@ -0,0 +1,13 @@ +@import '~antd/lib/style/themes/default.less'; + +.standardTable { + :global { + .ant-table-pagination { + margin-top: 24px; + } + } + + .tableAlert { + margin-bottom: 16px; + } +} diff --git a/antdsp-admin/src/main/web/src/components/TagSelect/TagSelectOption.d.ts b/antdsp-admin/src/main/web/src/components/TagSelect/TagSelectOption.d.ts new file mode 100644 index 0000000..3343d74 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TagSelect/TagSelectOption.d.ts @@ -0,0 +1,12 @@ +import React from 'react'; + +export interface TagSelectOptionProps { + value?: string | number; + style?: React.CSSProperties; + checked?: boolean; + onChange?: (value: string | number, state: boolean) => void; +} + +export default class TagSelectOption extends React.Component { + public static isTagSelectOption?: boolean; +} diff --git a/antdsp-admin/src/main/web/src/components/TagSelect/demo/controlled.md b/antdsp-admin/src/main/web/src/components/TagSelect/demo/controlled.md new file mode 100644 index 0000000..4e9defa --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TagSelect/demo/controlled.md @@ -0,0 +1,50 @@ +--- +order: 3 +title: 受控模式 +--- + +结合 `Tag` 的 `TagSelect` 组件,方便的应用于筛选类目的业务场景中。 + +```jsx +import { Button } from 'antd'; +import TagSelect from 'ant-design-pro/lib/TagSelect'; + +class Demo extends React.Component { + state = { + value: ['cat1'], + }; + handleFormSubmit = value => { + this.setState({ + value, + }); + }; + checkAll = () => { + this.setState({ + value: ['cat1', 'cat2', 'cat3', 'cat4', 'cat5', 'cat6'], + }); + }; + render() { + return ( +
    + +
    + + 类目一 + 类目二 + 类目三 + 类目四 + 类目五 + 类目六 + +
    +
    + ); + } +} + +ReactDOM.render(, mountNode); +``` diff --git a/antdsp-admin/src/main/web/src/components/TagSelect/demo/expandable.md b/antdsp-admin/src/main/web/src/components/TagSelect/demo/expandable.md new file mode 100644 index 0000000..c45a30a --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TagSelect/demo/expandable.md @@ -0,0 +1,31 @@ +--- +order: 1 +title: 可展开和收起 +--- + +使用 `expandable` 属性,让标签组可以收起,避免过高。 + +````jsx +import TagSelect from 'ant-design-pro/lib/TagSelect'; + +function handleFormSubmit(checkedValue) { + console.log(checkedValue); +} + +ReactDOM.render( + + 类目一 + 类目二 + 类目三 + 类目四 + 类目五 + 类目六 + 类目七 + 类目八 + 类目九 + 类目十 + 类目十一 + 类目十二 + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/TagSelect/demo/simple.md b/antdsp-admin/src/main/web/src/components/TagSelect/demo/simple.md new file mode 100644 index 0000000..9e7a13a --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TagSelect/demo/simple.md @@ -0,0 +1,25 @@ +--- +order: 0 +title: 基础样例 +--- + +结合 `Tag` 的 `TagSelect` 组件,方便的应用于筛选类目的业务场景中。 + +````jsx +import TagSelect from 'ant-design-pro/lib/TagSelect'; + +function handleFormSubmit(checkedValue) { + console.log(checkedValue); +} + +ReactDOM.render( + + 类目一 + 类目二 + 类目三 + 类目四 + 类目五 + 类目六 + +, mountNode); +```` diff --git a/antdsp-admin/src/main/web/src/components/TagSelect/index.d.ts b/antdsp-admin/src/main/web/src/components/TagSelect/index.d.ts new file mode 100644 index 0000000..c225a86 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TagSelect/index.d.ts @@ -0,0 +1,25 @@ +import React from 'react'; +import TagSelectOption, { TagSelectOptionProps } from './TagSelectOption'; + +export interface TagSelectProps { + onChange?: (value: string[]) => void; + expandable?: boolean; + value?: string[] | number[]; + style?: React.CSSProperties; + hideCheckAll?: boolean; + actionsText?: { + expandText?: React.ReactNode; + collapseText?: React.ReactNode; + selectAllText?: React.ReactNode; + }; + className: string; + Option: TagSelectOptionProps; + children: React.ReactElement | Array>; +} + +export default class TagSelect extends React.Component { + public static Option: typeof TagSelectOption; + private children: + | React.ReactElement + | Array>; +} diff --git a/antdsp-admin/src/main/web/src/components/TagSelect/index.js b/antdsp-admin/src/main/web/src/components/TagSelect/index.js new file mode 100644 index 0000000..6d0394d --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TagSelect/index.js @@ -0,0 +1,143 @@ +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import classNames from 'classnames'; +import { Tag, Icon } from 'antd'; + +import styles from './index.less'; + +const { CheckableTag } = Tag; + +const TagSelectOption = ({ children, checked, onChange, value }) => ( + onChange(value, state)}> + {children} + +); + +TagSelectOption.isTagSelectOption = true; + +class TagSelect extends Component { + static propTypes = { + actionsText: PropTypes.object, + hideCheckAll: PropTypes.bool, + }; + + static defaultProps = { + hideCheckAll: false, + actionsText: { + expandText: 'Expand', + collapseText: 'Collapse', + selectAllText: 'All', + }, + }; + + constructor(props) { + super(props); + this.state = { + expand: false, + value: props.value || props.defaultValue || [], + }; + } + + static getDerivedStateFromProps(nextProps) { + if ('value' in nextProps) { + return { value: nextProps.value || [] }; + } + return null; + } + + onChange = value => { + const { onChange } = this.props; + if (!('value' in this.props)) { + this.setState({ value }); + } + if (onChange) { + onChange(value); + } + }; + + onSelectAll = checked => { + let checkedTags = []; + if (checked) { + checkedTags = this.getAllTags(); + } + this.onChange(checkedTags); + }; + + getAllTags() { + let { children } = this.props; + children = React.Children.toArray(children); + const checkedTags = children + .filter(child => this.isTagSelectOption(child)) + .map(child => child.props.value); + return checkedTags || []; + } + + handleTagChange = (value, checked) => { + const { value: StateValue } = this.state; + const checkedTags = [...StateValue]; + + const index = checkedTags.indexOf(value); + if (checked && index === -1) { + checkedTags.push(value); + } else if (!checked && index > -1) { + checkedTags.splice(index, 1); + } + this.onChange(checkedTags); + }; + + handleExpand = () => { + const { expand } = this.state; + this.setState({ + expand: !expand, + }); + }; + + isTagSelectOption = node => + node && + node.type && + (node.type.isTagSelectOption || node.type.displayName === 'TagSelectOption'); + + render() { + const { value, expand } = this.state; + const { children, hideCheckAll, className, style, expandable, actionsText } = this.props; + const checkedAll = this.getAllTags().length === value.length; + const { expandText = 'Expand', collapseText = 'Collapse', selectAllText = 'All' } = + actionsText === null ? {} : actionsText; + + const cls = classNames(styles.tagSelect, className, { + [styles.hasExpandTag]: expandable, + [styles.expanded]: expand, + }); + + return ( +
    + {hideCheckAll ? null : ( + + {selectAllText} + + )} + {value && + React.Children.map(children, child => { + if (this.isTagSelectOption(child)) { + return React.cloneElement(child, { + key: `tag-select-${child.props.value}`, + value: child.props.value, + checked: value.indexOf(child.props.value) > -1, + onChange: this.handleTagChange, + }); + } + return child; + })} + {expandable && ( + + {expand ? collapseText : expandText} + + )} +
    + ); + } +} + +TagSelect.Option = TagSelectOption; + +export default TagSelect; diff --git a/antdsp-admin/src/main/web/src/components/TagSelect/index.less b/antdsp-admin/src/main/web/src/components/TagSelect/index.less new file mode 100644 index 0000000..9369465 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TagSelect/index.less @@ -0,0 +1,33 @@ +@import '~antd/lib/style/themes/default.less'; + +.tagSelect { + position: relative; + max-height: 32px; + margin-left: -8px; + overflow: hidden; + line-height: 32px; + transition: all 0.3s; + user-select: none; + :global { + .ant-tag { + margin-right: 24px; + padding: 0 8px; + font-size: @font-size-base; + } + } + &.expanded { + max-height: 200px; + transition: all 0.3s; + } + .trigger { + position: absolute; + top: 0; + right: 0; + i { + font-size: 12px; + } + } + &.hasExpandTag { + padding-right: 50px; + } +} diff --git a/antdsp-admin/src/main/web/src/components/TagSelect/index.md b/antdsp-admin/src/main/web/src/components/TagSelect/index.md new file mode 100644 index 0000000..8d21de7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TagSelect/index.md @@ -0,0 +1,27 @@ +--- +title: TagSelect +subtitle: 标签选择器 +cols: 1 +order: 13 +--- + +可进行多选,带折叠收起和展开更多功能,常用于对列表进行筛选。 + +## API + +### TagSelect + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| value |选中的项 |string[] \| number[] | | +| defaultValue |默认选中的项 |string[] \| number[] | | +| onChange | 标签选择的回调函数 | Function(checkedTags) | | +| expandable | 是否展示 `展开/收起` 按钮 | Boolean | false | +| hideCheckAll | 隐藏 `全部` 按钮 | Boolean | false | + +### TagSelectOption + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| value | TagSelect的值 | string\| number | - | +| children | tag的内容 | string \| ReactNode | - | diff --git a/antdsp-admin/src/main/web/src/components/TopNavHeader/index.d.ts b/antdsp-admin/src/main/web/src/components/TopNavHeader/index.d.ts new file mode 100644 index 0000000..2d6631b --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TopNavHeader/index.d.ts @@ -0,0 +1,25 @@ +import React from 'react'; +import { SiderTheme, CollapseType } from 'antd/es/Layout/Sider'; +import { MenuMode } from 'antd/es/menu'; + +export interface TopNavHeaderProps { + theme: SiderTheme; + contentWidth?: string; + menuData?: any[]; + logo?: string; + mode?: MenuMode; + flatMenuKeys?: any[]; + onCollapse?: (collapsed: boolean, type?: CollapseType) => void; + isMobile?: boolean; + openKeys?: any; + className?: string; + collapsed?: boolean; + handleOpenChange?: (openKeys: any[]) => void; + style?: React.CSSProperties; + onOpenChange?: (openKeys: string[]) => void; + onNoticeClear?: (type: string) => void; + onMenuClick?: ({ key: string }) => void; + onNoticeVisibleChange?: (b: boolean) => void; +} + +export default class TopNavHeader extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/TopNavHeader/index.js b/antdsp-admin/src/main/web/src/components/TopNavHeader/index.js new file mode 100644 index 0000000..0b6440e --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TopNavHeader/index.js @@ -0,0 +1,56 @@ +import React, { PureComponent } from 'react'; +import Link from 'umi/link'; +import RightContent from '../GlobalHeader/RightContent'; +import BaseMenu from '../SiderMenu/BaseMenu'; +import { getFlatMenuKeys } from '../SiderMenu/SiderMenuUtils'; +import styles from './index.less'; +import { title } from '../../defaultSettings'; + +export default class TopNavHeader extends PureComponent { + state = { + maxWidth: undefined, + }; + + static getDerivedStateFromProps(props) { + return { + maxWidth: + (props.contentWidth === 'Fixed' && window.innerWidth > 1200 ? 1200 : window.innerWidth) - + 280 - + 120 - + 40, + }; + } + + render() { + const { theme, contentWidth, menuData, logo } = this.props; + const { maxWidth } = this.state; + const flatMenuKeys = getFlatMenuKeys(menuData); + return ( +
    +
    { + this.maim = ref; + }} + className={`${styles.main} ${contentWidth === 'Fixed' ? styles.wide : ''}`} + > +
    + +
    + +
    +
    + +
    +
    + ); + } +} diff --git a/antdsp-admin/src/main/web/src/components/TopNavHeader/index.less b/antdsp-admin/src/main/web/src/components/TopNavHeader/index.less new file mode 100644 index 0000000..aad3d74 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/TopNavHeader/index.less @@ -0,0 +1,72 @@ +@import '~antd/lib/style/themes/default.less'; + +.head { + position: relative; + width: 100%; + height: @layout-header-height; + box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08); + transition: background 0.3s, width 0.2s; + :global { + .ant-menu-submenu.ant-menu-submenu-horizontal { + height: 100%; + line-height: @layout-header-height; + .ant-menu-submenu-title { + height: 100%; + } + } + } + &.light { + background-color: #fff; + } + .main { + display: flex; + height: @layout-header-height; + padding-left: 24px; + &.wide { + max-width: 1200px; + margin: auto; + padding-left: 0; + } + .left { + display: flex; + flex: 1; + } + .right { + width: 324px; + } + } +} + +.logo { + position: relative; + width: 165px; + height: @layout-header-height; + overflow: hidden; + line-height: @layout-header-height; + transition: all 0.3s; + img { + display: inline-block; + height: 32px; + vertical-align: middle; + } + h1 { + display: inline-block; + margin: 0 0 0 12px; + color: #fff; + font-weight: 400; + font-size: 16px; + vertical-align: top; + } +} + +.light { + h1 { + color: #002140; + } +} + +.menu { + height: @layout-header-height; + line-height: @layout-header-height; + border: none; +} diff --git a/antdsp-admin/src/main/web/src/components/Trend/demo/basic.md b/antdsp-admin/src/main/web/src/components/Trend/demo/basic.md new file mode 100644 index 0000000..da771dc --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Trend/demo/basic.md @@ -0,0 +1,17 @@ +--- +order: 0 +title: 演示 +--- + +在数值背后添加一个小图标来标识涨跌情况。 + +```jsx +import Trend from 'ant-design-pro/lib/Trend'; + +ReactDOM.render( +
    + 12% + 11% +
    +, mountNode); +``` diff --git a/antdsp-admin/src/main/web/src/components/Trend/demo/reverse.md b/antdsp-admin/src/main/web/src/components/Trend/demo/reverse.md new file mode 100644 index 0000000..26f7366 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Trend/demo/reverse.md @@ -0,0 +1,17 @@ +--- +order: 0 +title: 颜色反转 +--- + +在数值背后添加一个小图标来标识涨跌情况。 + +```jsx +import Trend from 'ant-design-pro/lib/Trend'; + +ReactDOM.render( +
    + 12% + 11% +
    +, mountNode); +``` diff --git a/antdsp-admin/src/main/web/src/components/Trend/index.d.ts b/antdsp-admin/src/main/web/src/components/Trend/index.d.ts new file mode 100644 index 0000000..a7775ae --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Trend/index.d.ts @@ -0,0 +1,11 @@ +import React from 'react'; + +export interface ITrendProps { + colorful?: boolean; + flag: 'up' | 'down'; + style?: React.CSSProperties; + reverseColor?: boolean; + className?: string; +} + +export default class Trend extends React.Component {} diff --git a/antdsp-admin/src/main/web/src/components/Trend/index.js b/antdsp-admin/src/main/web/src/components/Trend/index.js new file mode 100644 index 0000000..c476ef6 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Trend/index.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { Icon } from 'antd'; +import classNames from 'classnames'; +import styles from './index.less'; + +const Trend = ({ colorful = true, reverseColor = false, flag, children, className, ...rest }) => { + const classString = classNames( + styles.trendItem, + { + [styles.trendItemGrey]: !colorful, + [styles.reverseColor]: reverseColor && colorful, + }, + className + ); + return ( +
    + {children} + {flag && ( + + + + )} +
    + ); +}; + +export default Trend; diff --git a/antdsp-admin/src/main/web/src/components/Trend/index.less b/antdsp-admin/src/main/web/src/components/Trend/index.less new file mode 100644 index 0000000..1361883 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Trend/index.less @@ -0,0 +1,37 @@ +@import '~antd/lib/style/themes/default.less'; + +.trendItem { + display: inline-block; + font-size: @font-size-base; + line-height: 22px; + + .up, + .down { + position: relative; + top: 1px; + margin-left: 4px; + i { + font-size: 12px; + transform: scale(0.83); + } + } + .up { + color: @red-6; + } + .down { + top: -1px; + color: @green-6; + } + + &.trendItemGrey .up, + &.trendItemGrey .down { + color: @text-color; + } + + &.reverseColor .up { + color: @green-6; + } + &.reverseColor .down { + color: @red-6; + } +} diff --git a/antdsp-admin/src/main/web/src/components/Trend/index.md b/antdsp-admin/src/main/web/src/components/Trend/index.md new file mode 100644 index 0000000..96d83b8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/Trend/index.md @@ -0,0 +1,20 @@ +--- +title: Trend +subtitle: 趋势标记 +cols: 1 +order: 14 +--- + +趋势符号,标记上升和下降趋势。通常用绿色代表“好”,红色代表“不好”,股票涨跌场景除外。 + +## API + +```html +50% +``` + +| 参数 | 说明 | 类型 | 默认值 | +|----------|------------------------------------------|-------------|-------| +| colorful | 是否彩色标记 | Boolean | true | +| flag | 上升下降标识:`up|down` | string | - | +| reverseColor | 颜色反转 | Boolean | false | diff --git a/antdsp-admin/src/main/web/src/components/_utils/pathTools.js b/antdsp-admin/src/main/web/src/components/_utils/pathTools.js new file mode 100644 index 0000000..bfb94e7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/_utils/pathTools.js @@ -0,0 +1,6 @@ +// /userinfo/2144/id => ['/userinfo','/useinfo/2144,'/userindo/2144/id'] +// eslint-disable-next-line import/prefer-default-export +export function urlToList(url) { + const urllist = url.split('/').filter(i => i); + return urllist.map((urlItem, index) => `/${urllist.slice(0, index + 1).join('/')}`); +} diff --git a/antdsp-admin/src/main/web/src/components/_utils/pathTools.test.js b/antdsp-admin/src/main/web/src/components/_utils/pathTools.test.js new file mode 100644 index 0000000..a9b9315 --- /dev/null +++ b/antdsp-admin/src/main/web/src/components/_utils/pathTools.test.js @@ -0,0 +1,17 @@ +import { urlToList } from './pathTools'; + +describe('test urlToList', () => { + it('A path', () => { + expect(urlToList('/userinfo')).toEqual(['/userinfo']); + }); + it('Secondary path', () => { + expect(urlToList('/userinfo/2144')).toEqual(['/userinfo', '/userinfo/2144']); + }); + it('Three paths', () => { + expect(urlToList('/userinfo/2144/addr')).toEqual([ + '/userinfo', + '/userinfo/2144', + '/userinfo/2144/addr', + ]); + }); +}); diff --git a/antdsp-admin/src/main/web/src/defaultSettings.js b/antdsp-admin/src/main/web/src/defaultSettings.js new file mode 100644 index 0000000..4e7e801 --- /dev/null +++ b/antdsp-admin/src/main/web/src/defaultSettings.js @@ -0,0 +1,19 @@ +module.exports = { + navTheme: 'dark', // theme for nav menu + primaryColor: '#1890FF', // primary color of ant design + layout: 'sidemenu', // nav menu position: sidemenu or topmenu + contentWidth: 'Fluid', // layout of content: Fluid or Fixed, only works when layout is topmenu + fixedHeader: false, // sticky header + autoHideHeader: false, // auto hide header + fixSiderbar: false, // sticky siderbar + menu: { + disableLocal: false, + }, + title: 'Ant Design Pro', + pwa: true, + // Your custom iconfont Symbol script Url + // eg://at.alicdn.com/t/font_1039637_btcrd5co4w.js + // 注意:如果需要图标多色,Iconfont 图标项目里要进行批量去色处理 + // Usage: https://github.com/ant-design/ant-design-pro/pull/3517 + iconfontUrl: '', +}; diff --git a/antdsp-admin/src/main/web/src/e2e/baseLayout.e2e.js b/antdsp-admin/src/main/web/src/e2e/baseLayout.e2e.js new file mode 100644 index 0000000..70bb984 --- /dev/null +++ b/antdsp-admin/src/main/web/src/e2e/baseLayout.e2e.js @@ -0,0 +1,38 @@ +import RouterConfig from '../../config/router.config'; + +const BASE_URL = `http://localhost:${process.env.PORT || 8000}`; + +function formatter(data) { + return data + .reduce((pre, item) => { + if (item.routes) { + pre.push(item.routes[0].path); + } else { + pre.push(item.path); + } + return pre; + }, []) + .filter(item => item); +} + +describe('Homepage', () => { + const testPage = path => async () => { + await page.goto(`${BASE_URL}${path}`); + await page.waitForSelector('footer', { + timeout: 2000, + }); + const haveFooter = await page.evaluate( + () => document.getElementsByTagName('footer').length > 0 + ); + expect(haveFooter).toBeTruthy(); + }; + + beforeAll(async () => { + jest.setTimeout(1000000); + await page.setCacheEnabled(false); + }); + const routers = formatter(RouterConfig[1].routes); + routers.forEach(route => { + it(`test pages ${route}`, testPage(route)); + }); +}); diff --git a/antdsp-admin/src/main/web/src/e2e/home.e2e.js b/antdsp-admin/src/main/web/src/e2e/home.e2e.js new file mode 100644 index 0000000..0531d5f --- /dev/null +++ b/antdsp-admin/src/main/web/src/e2e/home.e2e.js @@ -0,0 +1,15 @@ +const BASE_URL = `http://localhost:${process.env.PORT || 8000}`; + +describe('Homepage', () => { + beforeAll(async () => { + jest.setTimeout(1000000); + }); + it('it should have logo text', async () => { + await page.goto(BASE_URL); + await page.waitForSelector('h1', { + timeout: 5000, + }); + const text = await page.evaluate(() => document.getElementsByTagName('h1')[0].innerText); + expect(text).toContain('Ant Design Pro'); + }); +}); diff --git a/antdsp-admin/src/main/web/src/e2e/login.e2e.js b/antdsp-admin/src/main/web/src/e2e/login.e2e.js new file mode 100644 index 0000000..b991af4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/e2e/login.e2e.js @@ -0,0 +1,34 @@ +const BASE_URL = `http://localhost:${process.env.PORT || 8000}`; + +describe('Login', () => { + beforeAll(async () => { + jest.setTimeout(1000000); + }); + + beforeEach(async () => { + await page.goto(`${BASE_URL}/user/login`, { waitUntil: 'networkidle2' }); + await page.evaluate(() => window.localStorage.setItem('antd-pro-authority', 'guest')); + }); + + it('should login with failure', async () => { + await page.waitForSelector('#userName', { + timeout: 2000, + }); + await page.type('#userName', 'mockuser'); + await page.type('#password', 'wrong_password'); + await page.click('button[type="submit"]'); + await page.waitForSelector('.ant-alert-error'); // should display error + }); + + it('should login successfully', async () => { + await page.waitForSelector('#userName', { + timeout: 2000, + }); + await page.type('#userName', 'admin'); + await page.type('#password', 'ant.design'); + await page.click('button[type="submit"]'); + await page.waitForSelector('.ant-layout-sider h1'); // should display error + const text = await page.evaluate(() => document.body.innerHTML); + expect(text).toContain('

    Ant Design Pro

    '); + }); +}); diff --git a/antdsp-admin/src/main/web/src/e2e/topMenu.e2e.js b/antdsp-admin/src/main/web/src/e2e/topMenu.e2e.js new file mode 100644 index 0000000..d90983b --- /dev/null +++ b/antdsp-admin/src/main/web/src/e2e/topMenu.e2e.js @@ -0,0 +1,19 @@ +const BASE_URL = `http://localhost:${process.env.PORT || 8000}`; + +describe('Homepage', () => { + beforeAll(async () => { + jest.setTimeout(1000000); + }); + + it('topmenu should have footer', async () => { + const params = '/form/basic-form?navTheme=light&layout=topmenu'; + await page.goto(`${BASE_URL}${params}`); + await page.waitForSelector('footer', { + timeout: 2000, + }); + const haveFooter = await page.evaluate( + () => document.getElementsByTagName('footer').length > 0 + ); + expect(haveFooter).toBeTruthy(); + }); +}); diff --git a/antdsp-admin/src/main/web/src/e2e/userLayout.e2e.js b/antdsp-admin/src/main/web/src/e2e/userLayout.e2e.js new file mode 100644 index 0000000..a2edfc7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/e2e/userLayout.e2e.js @@ -0,0 +1,32 @@ +import RouterConfig from '../../config/router.config'; + +const BASE_URL = `http://localhost:${process.env.PORT || 8000}`; + +function formatter(data) { + return data + .reduce((pre, item) => { + pre.push(item.path); + return pre; + }, []) + .filter(item => item); +} + +describe('Homepage', () => { + const testPage = path => async () => { + await page.goto(`${BASE_URL}${path}`); + await page.waitForSelector('footer', { + timeout: 2000, + }); + const haveFooter = await page.evaluate( + () => document.getElementsByTagName('footer').length > 0 + ); + expect(haveFooter).toBeTruthy(); + }; + + beforeAll(async () => { + jest.setTimeout(1000000); + }); + formatter(RouterConfig[0].routes).forEach(route => { + it(`test pages ${route}`, testPage(route)); + }); +}); diff --git a/antdsp-admin/src/main/web/src/global.js b/antdsp-admin/src/main/web/src/global.js new file mode 100644 index 0000000..a0ecf97 --- /dev/null +++ b/antdsp-admin/src/main/web/src/global.js @@ -0,0 +1,61 @@ +import React from 'react'; +import { notification, Button, message } from 'antd'; +import { formatMessage } from 'umi-plugin-react/locale'; +import defaultSettings from './defaultSettings'; + +window.React = React; + +const { pwa } = defaultSettings; +// if pwa is true +if (pwa) { + // Notify user if offline now + window.addEventListener('sw.offline', () => { + message.warning(formatMessage({ id: 'app.pwa.offline' })); + }); + + // Pop up a prompt on the page asking the user if they want to use the latest version + window.addEventListener('sw.updated', e => { + const reloadSW = async () => { + // Check if there is sw whose state is waiting in ServiceWorkerRegistration + // https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration + const worker = e.detail && e.detail.waiting; + if (!worker) { + return Promise.resolve(); + } + // Send skip-waiting event to waiting SW with MessageChannel + await new Promise((resolve, reject) => { + const channel = new MessageChannel(); + channel.port1.onmessage = event => { + if (event.data.error) { + reject(event.data.error); + } else { + resolve(event.data); + } + }; + worker.postMessage({ type: 'skip-waiting' }, [channel.port2]); + }); + // Refresh current page to use the updated HTML and other assets after SW has skiped waiting + window.location.reload(true); + return true; + }; + const key = `open${Date.now()}`; + const btn = ( + + ); + notification.open({ + message: formatMessage({ id: 'app.pwa.serviceworker.updated' }), + description: formatMessage({ id: 'app.pwa.serviceworker.updated.hint' }), + btn, + key, + onClose: async () => {}, + }); + }); +} diff --git a/antdsp-admin/src/main/web/src/global.less b/antdsp-admin/src/main/web/src/global.less new file mode 100644 index 0000000..1450ba4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/global.less @@ -0,0 +1,52 @@ +@import '~antd/lib/style/themes/default.less'; + +html, +body, +#root { + height: 100%; +} + +.colorWeak { + filter: invert(80%); +} + +.ant-layout { + min-height: 100vh; +} + +canvas { + display: block; +} + +body { + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.globalSpin { + width: 100%; + margin: 40px 0 !important; +} + +ul, +ol { + list-style: none; +} + +@media (max-width: @screen-xs) { + .ant-table { + width: 100%; + overflow-x: auto; + &-thead > tr, + &-tbody > tr { + > th, + > td { + white-space: pre; + > span { + display: block; + } + } + } + } +} diff --git a/antdsp-admin/src/main/web/src/layouts/BasicLayout.js b/antdsp-admin/src/main/web/src/layouts/BasicLayout.js new file mode 100644 index 0000000..686742d --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/BasicLayout.js @@ -0,0 +1,176 @@ +import React, { Suspense } from 'react'; +import { Layout } from 'antd'; +import DocumentTitle from 'react-document-title'; +import { connect } from 'dva'; +import { ContainerQuery } from 'react-container-query'; +import classNames from 'classnames'; +import Media from 'react-media'; +import logo from '../assets/logo.svg'; +import Footer from './Footer'; +import Header from './Header'; +import Context from './MenuContext'; +import SiderMenu from '@/components/SiderMenu'; +import getPageTitle from '@/utils/getPageTitle'; +import styles from './BasicLayout.less'; + +// lazy load SettingDrawer +const SettingDrawer = React.lazy(() => import('@/components/SettingDrawer')); + +const { Content } = Layout; + +const query = { + 'screen-xs': { + maxWidth: 575, + }, + 'screen-sm': { + minWidth: 576, + maxWidth: 767, + }, + 'screen-md': { + minWidth: 768, + maxWidth: 991, + }, + 'screen-lg': { + minWidth: 992, + maxWidth: 1199, + }, + 'screen-xl': { + minWidth: 1200, + maxWidth: 1599, + }, + 'screen-xxl': { + minWidth: 1600, + }, +}; + +class BasicLayout extends React.Component { + componentDidMount() { + const { + dispatch, + route: { routes, path, authority }, + } = this.props; + dispatch({ + type: 'user/fetchCurrent', + }); + dispatch({ + type: 'setting/getSetting', + }); + dispatch({ + type: 'menu/getMenuData', + payload: { routes, path, authority }, + }); + } + + getContext() { + const { location, breadcrumbNameMap } = this.props; + return { + location, + breadcrumbNameMap, + }; + } + + getLayoutStyle = () => { + const { fixSiderbar, isMobile, collapsed, layout } = this.props; + if (fixSiderbar && layout !== 'topmenu' && !isMobile) { + return { + paddingLeft: collapsed ? '80px' : '256px', + }; + } + return null; + }; + + handleMenuCollapse = collapsed => { + const { dispatch } = this.props; + dispatch({ + type: 'global/changeLayoutCollapsed', + payload: collapsed, + }); + }; + + renderSettingDrawer = () => { + // Do not render SettingDrawer in production + // unless it is deployed in preview.pro.ant.design as demo + // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + if ( + process.env.NODE_ENV === 'production' && + ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION !== 'site' + ) { + return null; + } + return ; + }; + + render() { + const { + navTheme, + layout: PropsLayout, + children, + location: { pathname }, + isMobile, + menuData, + breadcrumbNameMap, + fixedHeader, + } = this.props; + + const isTop = PropsLayout === 'topmenu'; + const contentStyle = !fixedHeader ? { paddingTop: 0 } : {}; + const layout = ( + + {isTop && !isMobile ? null : ( + + )} + +
    + + {children} + +
    + + + ); + return ( + + + + {params => ( + +
    {layout}
    +
    + )} +
    +
    + {this.renderSettingDrawer()} +
    + ); + } +} + +export default connect(({ global, setting, menu: menuModel }) => ({ + collapsed: global.collapsed, + layout: setting.layout, + menuData: menuModel.menuData, + breadcrumbNameMap: menuModel.breadcrumbNameMap, + ...setting, +}))(props => ( + + {isMobile => } + +)); diff --git a/antdsp-admin/src/main/web/src/layouts/BasicLayout.less b/antdsp-admin/src/main/web/src/layouts/BasicLayout.less new file mode 100644 index 0000000..60beb60 --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/BasicLayout.less @@ -0,0 +1,6 @@ +@import '~antd/lib/style/themes/default.less'; + +.content { + margin: 24px; + padding-top: @layout-header-height; +} diff --git a/antdsp-admin/src/main/web/src/layouts/BlankLayout.js b/antdsp-admin/src/main/web/src/layouts/BlankLayout.js new file mode 100644 index 0000000..ef39aa4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/BlankLayout.js @@ -0,0 +1,3 @@ +import React from 'react'; + +export default ({ children }) =>
    {children}
    ; diff --git a/antdsp-admin/src/main/web/src/layouts/Footer.js b/antdsp-admin/src/main/web/src/layouts/Footer.js new file mode 100644 index 0000000..693c817 --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/Footer.js @@ -0,0 +1,37 @@ +import React, { Fragment } from 'react'; +import { Layout, Icon } from 'antd'; +import GlobalFooter from '@/components/GlobalFooter'; + +const { Footer } = Layout; +const FooterView = () => ( +
    + , + href: 'https://github.com/ant-design/ant-design-pro', + blankTarget: true, + }, + { + key: 'Ant Design', + title: 'Ant Design', + href: 'https://ant.design', + blankTarget: true, + }, + ]} + copyright={ + + Copyright 2018 蚂蚁金服体验技术部出品 + + } + /> +
    +); +export default FooterView; diff --git a/antdsp-admin/src/main/web/src/layouts/Header.js b/antdsp-admin/src/main/web/src/layouts/Header.js new file mode 100644 index 0000000..e58d37c --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/Header.js @@ -0,0 +1,163 @@ +import React, { Component } from 'react'; +import { formatMessage } from 'umi-plugin-react/locale'; +import { Layout, message } from 'antd'; +import Animate from 'rc-animate'; +import { connect } from 'dva'; +import router from 'umi/router'; +import GlobalHeader from '@/components/GlobalHeader'; +import TopNavHeader from '@/components/TopNavHeader'; +import styles from './Header.less'; + +const { Header } = Layout; + +class HeaderView extends Component { + state = { + visible: true, + }; + + static getDerivedStateFromProps(props, state) { + if (!props.autoHideHeader && !state.visible) { + return { + visible: true, + }; + } + return null; + } + + componentDidMount() { + document.addEventListener('scroll', this.handScroll, { passive: true }); + } + + componentWillUnmount() { + document.removeEventListener('scroll', this.handScroll); + } + + getHeadWidth = () => { + const { isMobile, collapsed, setting } = this.props; + const { fixedHeader, layout } = setting; + if (isMobile || !fixedHeader || layout === 'topmenu') { + return '100%'; + } + return collapsed ? 'calc(100% - 80px)' : 'calc(100% - 256px)'; + }; + + handleNoticeClear = type => { + message.success( + `${formatMessage({ id: 'component.noticeIcon.cleared' })} ${formatMessage({ + id: `component.globalHeader.${type}`, + })}` + ); + const { dispatch } = this.props; + dispatch({ + type: 'global/clearNotices', + payload: type, + }); + }; + + handleMenuClick = ({ key }) => { + const { dispatch } = this.props; + if (key === 'userCenter') { + router.push('/account/center'); + return; + } + if (key === 'triggerError') { + router.push('/exception/trigger'); + return; + } + if (key === 'userinfo') { + router.push('/account/settings/base'); + return; + } + if (key === 'logout') { + dispatch({ + type: 'login/logout', + }); + } + }; + + handleNoticeVisibleChange = visible => { + if (visible) { + const { dispatch } = this.props; + dispatch({ + type: 'global/fetchNotices', + }); + } + }; + + handScroll = () => { + const { autoHideHeader } = this.props; + const { visible } = this.state; + if (!autoHideHeader) { + return; + } + const scrollTop = document.body.scrollTop + document.documentElement.scrollTop; + if (!this.ticking) { + this.ticking = true; + requestAnimationFrame(() => { + if (this.oldScrollTop > scrollTop) { + this.setState({ + visible: true, + }); + } else if (scrollTop > 300 && visible) { + this.setState({ + visible: false, + }); + } else if (scrollTop < 300 && !visible) { + this.setState({ + visible: true, + }); + } + this.oldScrollTop = scrollTop; + this.ticking = false; + }); + } + }; + + render() { + const { isMobile, handleMenuCollapse, setting } = this.props; + const { navTheme, layout, fixedHeader } = setting; + const { visible } = this.state; + const isTop = layout === 'topmenu'; + const width = this.getHeadWidth(); + const HeaderDom = visible ? ( +
    + {isTop && !isMobile ? ( + + ) : ( + + )} +
    + ) : null; + return ( + + {HeaderDom} + + ); + } +} + +export default connect(({ user, global, setting, loading }) => ({ + currentUser: user.currentUser, + collapsed: global.collapsed, + fetchingMoreNotices: loading.effects['global/fetchMoreNotices'], + fetchingNotices: loading.effects['global/fetchNotices'], + notices: global.notices, + setting, +}))(HeaderView); diff --git a/antdsp-admin/src/main/web/src/layouts/Header.less b/antdsp-admin/src/main/web/src/layouts/Header.less new file mode 100644 index 0000000..cc2da96 --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/Header.less @@ -0,0 +1,8 @@ +.fixedHeader { + position: fixed; + top: 0; + right: 0; + z-index: 9; + width: 100%; + transition: width 0.2s; +} diff --git a/antdsp-admin/src/main/web/src/layouts/MenuContext.js b/antdsp-admin/src/main/web/src/layouts/MenuContext.js new file mode 100644 index 0000000..860f106 --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/MenuContext.js @@ -0,0 +1,3 @@ +import { createContext } from 'react'; + +export default createContext(); diff --git a/antdsp-admin/src/main/web/src/layouts/UserLayout.js b/antdsp-admin/src/main/web/src/layouts/UserLayout.js new file mode 100644 index 0000000..93f826b --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/UserLayout.js @@ -0,0 +1,83 @@ +import React, { Component, Fragment } from 'react'; +import { formatMessage } from 'umi-plugin-react/locale'; +import { connect } from 'dva'; +import Link from 'umi/link'; +import { Icon } from 'antd'; +import GlobalFooter from '@/components/GlobalFooter'; +import DocumentTitle from 'react-document-title'; +import SelectLang from '@/components/SelectLang'; +import styles from './UserLayout.less'; +import logo from '../assets/logo.svg'; +import getPageTitle from '@/utils/getPageTitle'; + +const links = [ + { + key: 'help', + title: formatMessage({ id: 'layout.user.link.help' }), + href: '', + }, + { + key: 'privacy', + title: formatMessage({ id: 'layout.user.link.privacy' }), + href: '', + }, + { + key: 'terms', + title: formatMessage({ id: 'layout.user.link.terms' }), + href: '', + }, +]; + +const copyright = ( + + Copyright 2018 蚂蚁金服体验技术部出品 + +); + +class UserLayout extends Component { + componentDidMount() { + const { + dispatch, + route: { routes, authority }, + } = this.props; + dispatch({ + type: 'menu/getMenuData', + payload: { routes, authority }, + }); + } + + render() { + const { + children, + location: { pathname }, + breadcrumbNameMap, + } = this.props; + return ( + +
    +
    + +
    +
    +
    +
    + + logo + Ant Design + +
    +
    Ant Design 是西湖区最具影响力的 Web 设计规范
    +
    + {children} +
    + +
    +
    + ); + } +} + +export default connect(({ menu: menuModel }) => ({ + menuData: menuModel.menuData, + breadcrumbNameMap: menuModel.breadcrumbNameMap, +}))(UserLayout); diff --git a/antdsp-admin/src/main/web/src/layouts/UserLayout.less b/antdsp-admin/src/main/web/src/layouts/UserLayout.less new file mode 100644 index 0000000..ba3d323 --- /dev/null +++ b/antdsp-admin/src/main/web/src/layouts/UserLayout.less @@ -0,0 +1,71 @@ +@import '~antd/lib/style/themes/default.less'; + +.container { + display: flex; + flex-direction: column; + height: 100vh; + overflow: auto; + background: @layout-body-background; +} + +.lang { + width: 100%; + height: 40px; + line-height: 44px; + text-align: right; + :global(.ant-dropdown-trigger) { + margin-right: 24px; + } +} + +.content { + flex: 1; + padding: 32px 0; +} + +@media (min-width: @screen-md-min) { + .container { + background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg'); + background-repeat: no-repeat; + background-position: center 110px; + background-size: 100%; + } + + .content { + padding: 32px 0 24px 0; + } +} + +.top { + text-align: center; +} + +.header { + height: 44px; + line-height: 44px; + a { + text-decoration: none; + } +} + +.logo { + height: 44px; + margin-right: 16px; + vertical-align: top; +} + +.title { + position: relative; + top: 2px; + color: @heading-color; + font-weight: 600; + font-size: 33px; + font-family: Avenir, 'Helvetica Neue', Arial, Helvetica, sans-serif; +} + +.desc { + margin-top: 12px; + margin-bottom: 40px; + color: @text-color-secondary; + font-size: @font-size-base; +} diff --git a/antdsp-admin/src/main/web/src/locales/en-US.js b/antdsp-admin/src/main/web/src/locales/en-US.js new file mode 100644 index 0000000..a10691c --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US.js @@ -0,0 +1,37 @@ +import analysis from './en-US/analysis'; +import exception from './en-US/exception'; +import form from './en-US/form'; +import globalHeader from './en-US/globalHeader'; +import login from './en-US/login'; +import menu from './en-US/menu'; +import monitor from './en-US/monitor'; +import result from './en-US/result'; +import settingDrawer from './en-US/settingDrawer'; +import settings from './en-US/settings'; +import pwa from './en-US/pwa'; +import component from './en-US/component'; +import editor from './en-US/editor'; + +export default { + 'navBar.lang': 'Languages', + 'layout.user.link.help': 'Help', + 'layout.user.link.privacy': 'Privacy', + 'layout.user.link.terms': 'Terms', + 'app.home.introduce': 'introduce', + 'app.forms.basic.title': 'Basic form', + 'app.forms.basic.description': + 'Form pages are used to collect or verify information to users, and basic forms are common in scenarios where there are fewer data items.', + ...analysis, + ...exception, + ...form, + ...globalHeader, + ...login, + ...menu, + ...monitor, + ...result, + ...settingDrawer, + ...settings, + ...pwa, + ...component, + ...editor, +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/analysis.js b/antdsp-admin/src/main/web/src/locales/en-US/analysis.js new file mode 100644 index 0000000..f3005da --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/analysis.js @@ -0,0 +1,34 @@ +export default { + 'app.analysis.test': 'Gongzhuan No.{no} shop', + 'app.analysis.introduce': 'Introduce', + 'app.analysis.total-sales': 'Total Sales', + 'app.analysis.day-sales': 'Daily Sales', + 'app.analysis.visits': 'Visits', + 'app.analysis.visits-trend': 'Visits Trend', + 'app.analysis.visits-ranking': 'Visits Ranking', + 'app.analysis.day-visits': 'Daily Visits', + 'app.analysis.week': 'WoW Change', + 'app.analysis.day': 'DoD Change', + 'app.analysis.payments': 'Payments', + 'app.analysis.conversion-rate': 'Conversion Rate', + 'app.analysis.operational-effect': 'Operational Effect', + 'app.analysis.sales-trend': 'Stores Sales Trend', + 'app.analysis.sales-ranking': 'Sales Ranking', + 'app.analysis.all-year': 'All Year', + 'app.analysis.all-month': 'All Month', + 'app.analysis.all-week': 'All Week', + 'app.analysis.all-day': 'All day', + 'app.analysis.search-users': 'Search Users', + 'app.analysis.per-capita-search': 'Per Capita Search', + 'app.analysis.online-top-search': 'Online Top Search', + 'app.analysis.the-proportion-of-sales': 'The Proportion Of Sales', + 'app.analysis.channel.all': 'ALL', + 'app.analysis.channel.online': 'Online', + 'app.analysis.channel.stores': 'Stores', + 'app.analysis.sales': 'Sales', + 'app.analysis.traffic': 'Traffic', + 'app.analysis.table.rank': 'Rank', + 'app.analysis.table.search-keyword': 'Keyword', + 'app.analysis.table.users': 'Users', + 'app.analysis.table.weekly-range': 'Weekly Range', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/component.js b/antdsp-admin/src/main/web/src/locales/en-US/component.js new file mode 100644 index 0000000..910f30e --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/component.js @@ -0,0 +1,6 @@ +export default { + 'component.tagSelect.expand': 'Expand', + 'component.tagSelect.collapse': 'Collapse', + 'component.tagSelect.all': 'All', + 'component.miniProgress.tooltipDefault': 'Target value', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/editor.js b/antdsp-admin/src/main/web/src/locales/en-US/editor.js new file mode 100644 index 0000000..81bd0f1 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/editor.js @@ -0,0 +1,11 @@ +export default { + 'app.editor.flow.title': 'Flowchart Editor', + 'app.editor.flow.description': + 'The flow chart is an excellent way to represent the idea of the algorithm.', + 'app.editor.koni.title': 'Koni Editor', + 'app.editor.koni.description': + 'The topology diagram refers to the network structure diagram composed of network node devices and communication media.', + 'app.editor.mind.title': 'Mind Map Editor', + 'app.editor.mind.description': + 'The brain map is an effective graphical thinking tool for expressing divergent thinking. It is simple but effective and is a practical thinking tool.', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/exception.js b/antdsp-admin/src/main/web/src/locales/en-US/exception.js new file mode 100644 index 0000000..5035552 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/exception.js @@ -0,0 +1,6 @@ +export default { + 'app.exception.back': 'Back to home', + 'app.exception.description.403': "Sorry, you don't have access to this page", + 'app.exception.description.404': 'Sorry, the page you visited does not exist', + 'app.exception.description.500': 'Sorry, the server is reporting an error', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/form.js b/antdsp-admin/src/main/web/src/locales/en-US/form.js new file mode 100644 index 0000000..36e088d --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/form.js @@ -0,0 +1,38 @@ +export default { + 'form.get-captcha': 'Get Captcha', + 'form.captcha.second': 'sec', + 'form.optional': ' (optional) ', + 'form.submit': 'Submit', + 'form.save': 'Save', + 'form.email.placeholder': 'Email', + 'form.password.placeholder': 'Password', + 'form.confirm-password.placeholder': 'Confirm password', + 'form.phone-number.placeholder': 'Phone number', + 'form.verification-code.placeholder': 'Verification code', + 'form.title.label': 'Title', + 'form.title.placeholder': 'Give the target a name', + 'form.date.label': 'Start and end date', + 'form.date.placeholder.start': 'Start date', + 'form.date.placeholder.end': 'End date', + 'form.goal.label': 'Goal description', + 'form.goal.placeholder': 'Please enter your work goals', + 'form.standard.label': 'Metrics', + 'form.standard.placeholder': 'Please enter a metric', + 'form.client.label': 'Client', + 'form.client.label.tooltip': 'Target service object', + 'form.client.placeholder': + 'Please describe your customer service, internal customers directly @ Name / job number', + 'form.invites.label': 'Inviting critics', + 'form.invites.placeholder': 'Please direct @ Name / job number, you can invite up to 5 people', + 'form.weight.label': 'Weight', + 'form.weight.placeholder': 'Please enter weight', + 'form.public.label': 'Target disclosure', + 'form.public.label.help': 'Customers and invitees are shared by default', + 'form.public.radio.public': 'Public', + 'form.public.radio.partially-public': 'Partially public', + 'form.public.radio.private': 'Private', + 'form.publicUsers.placeholder': 'Open to', + 'form.publicUsers.option.A': 'Colleague A', + 'form.publicUsers.option.B': 'Colleague B', + 'form.publicUsers.option.C': 'Colleague C', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/globalHeader.js b/antdsp-admin/src/main/web/src/locales/en-US/globalHeader.js new file mode 100644 index 0000000..60b6d4e --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/globalHeader.js @@ -0,0 +1,17 @@ +export default { + 'component.globalHeader.search': 'Search', + 'component.globalHeader.search.example1': 'Search example 1', + 'component.globalHeader.search.example2': 'Search example 2', + 'component.globalHeader.search.example3': 'Search example 3', + 'component.globalHeader.help': 'Help', + 'component.globalHeader.notification': 'Notification', + 'component.globalHeader.notification.empty': 'You have viewed all notifications.', + 'component.globalHeader.message': 'Message', + 'component.globalHeader.message.empty': 'You have viewed all messsages.', + 'component.globalHeader.event': 'Event', + 'component.globalHeader.event.empty': 'You have viewed all events.', + 'component.noticeIcon.clear': 'Clear', + 'component.noticeIcon.cleared': 'Cleared', + 'component.noticeIcon.empty': 'No notifications', + 'component.noticeIcon.view-more': 'View more', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/login.js b/antdsp-admin/src/main/web/src/locales/en-US/login.js new file mode 100644 index 0000000..195e59c --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/login.js @@ -0,0 +1,41 @@ +export default { + 'app.login.userName': 'userName', + 'app.login.password': 'password', + 'app.login.message-invalid-credentials': 'Invalid username or password(admin/ant.design)', + 'app.login.message-invalid-verification-code': 'Invalid verification code', + 'app.login.tab-login-credentials': 'Credentials', + 'app.login.tab-login-mobile': 'Mobile number', + 'app.login.remember-me': 'Remember me', + 'app.login.forgot-password': 'Forgot your password?', + 'app.login.sign-in-with': 'Sign in with', + 'app.login.signup': 'Sign up', + 'app.login.login': 'Login', + 'app.register.register': 'Register', + 'app.register.get-verification-code': 'Get code', + 'app.login.verification-code-warning': + 'This project is a demo project and will not actually send you a verification code. Please switch to the account password login interface and log in as prompted.', + 'app.register.sign-in': 'Already have an account?', + 'app.register-result.msg': 'Account:registered at {email}', + 'app.register-result.activation-email': + 'The activation email has been sent to your email address and is valid for 24 hours. Please log in to the email in time and click on the link in the email to activate the account.', + 'app.register-result.back-home': 'Back to home', + 'app.register-result.view-mailbox': 'View mailbox', + 'validation.email.required': 'Please enter your email!', + 'validation.email.wrong-format': 'The email address is in the wrong format!', + 'validation.userName.required': 'Please enter your userName!', + 'validation.password.required': 'Please enter your password!', + 'validation.password.twice': 'The passwords entered twice do not match!', + 'validation.password.strength.msg': + "Please enter at least 6 characters and don't use passwords that are easy to guess.", + 'validation.password.strength.strong': 'Strength: strong', + 'validation.password.strength.medium': 'Strength: medium', + 'validation.password.strength.short': 'Strength: too short', + 'validation.confirm-password.required': 'Please confirm your password!', + 'validation.phone-number.required': 'Please enter your phone number!', + 'validation.phone-number.wrong-format': 'Malformed phone number!', + 'validation.verification-code.required': 'Please enter the verification code!', + 'validation.title.required': 'Please enter a title', + 'validation.date.required': 'Please select the start and end date', + 'validation.goal.required': 'Please enter a description of the goal', + 'validation.standard.required': 'Please enter a metric', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/menu.js b/antdsp-admin/src/main/web/src/locales/en-US/menu.js new file mode 100644 index 0000000..25805ea --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/menu.js @@ -0,0 +1,45 @@ +export default { + 'menu.home': 'Home', + 'menu.login': 'Login', + 'menu.register': 'Register', + 'menu.register.result': 'Register Result', + 'menu.dashboard': 'Dashboard', + 'menu.dashboard.analysis': 'Analysis', + 'menu.dashboard.monitor': 'Monitor', + 'menu.dashboard.workplace': 'Workplace', + 'menu.form': 'Form', + 'menu.form.basicform': 'Basic Form', + 'menu.form.stepform': 'Step Form', + 'menu.form.stepform.info': 'Step Form(write transfer information)', + 'menu.form.stepform.confirm': 'Step Form(confirm transfer information)', + 'menu.form.stepform.result': 'Step Form(finished)', + 'menu.form.advancedform': 'Advanced Form', + 'menu.list': 'List', + 'menu.list.searchtable': 'Search Table', + 'menu.list.basiclist': 'Basic List', + 'menu.list.cardlist': 'Card List', + 'menu.list.searchlist': 'Search List', + 'menu.list.searchlist.articles': 'Search List(articles)', + 'menu.list.searchlist.projects': 'Search List(projects)', + 'menu.list.searchlist.applications': 'Search List(applications)', + 'menu.profile': 'Profile', + 'menu.profile.basic': 'Basic Profile', + 'menu.profile.advanced': 'Advanced Profile', + 'menu.result': 'Result', + 'menu.result.success': 'Success', + 'menu.result.fail': 'Fail', + 'menu.exception': 'Exception', + 'menu.exception.not-permission': '403', + 'menu.exception.not-find': '404', + 'menu.exception.server-error': '500', + 'menu.exception.trigger': 'Trigger', + 'menu.account': 'Account', + 'menu.account.center': 'Account Center', + 'menu.account.settings': 'Account Settings', + 'menu.account.trigger': 'Trigger Error', + 'menu.account.logout': 'Logout', + 'menu.editor': 'Graphic Editor', + 'menu.editor.flow': 'Flow Editor', + 'menu.editor.mind': 'Mind Editor', + 'menu.editor.koni': 'Koni Editor', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/monitor.js b/antdsp-admin/src/main/web/src/locales/en-US/monitor.js new file mode 100644 index 0000000..dcb5705 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/monitor.js @@ -0,0 +1,18 @@ +export default { + 'app.monitor.trading-activity': 'Real-Time Trading Activity', + 'app.monitor.total-transactions': 'Total transactions today', + 'app.monitor.sales-target': 'Sales target completion rate', + 'app.monitor.remaining-time': 'Remaining time of activity', + 'app.monitor.total-transactions-per-second': 'Total transactions per second', + 'app.monitor.activity-forecast': 'Activity forecast', + 'app.monitor.efficiency': 'Efficiency', + 'app.monitor.ratio': 'Ratio', + 'app.monitor.proportion-per-category': 'Proportion Per Category', + 'app.monitor.fast-food': 'Fast food', + 'app.monitor.western-food': 'Western food', + 'app.monitor.hot-pot': 'Hot pot', + 'app.monitor.waiting-for-implementation': 'Waiting for implementation', + 'app.monitor.popular-searches': 'Popular Searches', + 'app.monitor.resource-surplus': 'Resource Surplus', + 'app.monitor.fund-surplus': 'Fund Surplus', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/pwa.js b/antdsp-admin/src/main/web/src/locales/en-US/pwa.js new file mode 100644 index 0000000..ed8d199 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/pwa.js @@ -0,0 +1,6 @@ +export default { + 'app.pwa.offline': 'You are offline now', + 'app.pwa.serviceworker.updated': 'New content is available', + 'app.pwa.serviceworker.updated.hint': 'Please press the "Refresh" button to reload current page', + 'app.pwa.serviceworker.updated.ok': 'Refresh', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/result.js b/antdsp-admin/src/main/web/src/locales/en-US/result.js new file mode 100644 index 0000000..23de8b7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/result.js @@ -0,0 +1,28 @@ +export default { + 'app.result.error.title': 'Submission Failed', + 'app.result.error.description': + 'Please check and modify the following information before resubmitting.', + 'app.result.error.hint-title': 'The content you submitted has the following error:', + 'app.result.error.hint-text1': 'Your account has been frozen', + 'app.result.error.hint-btn1': 'Thaw immediately', + 'app.result.error.hint-text2': 'Your account is not yet eligible to apply', + 'app.result.error.hint-btn2': 'Upgrade immediately', + 'app.result.error.btn-text': 'Return to modify', + 'app.result.success.title': 'Submission Success', + 'app.result.success.description': + 'The submission results page is used to feed back the results of a series of operational tasks. If it is a simple operation, use the Message global prompt feedback. This text area can show a simple supplementary explanation. If there is a similar requirement for displaying “documents”, the following gray area can present more complicated content.', + 'app.result.success.operate-title': 'Project Name', + 'app.result.success.operate-id': 'Project ID:', + 'app.result.success.principal': 'Principal:', + 'app.result.success.operate-time': 'Effective time:', + 'app.result.success.step1-title': 'Create project', + 'app.result.success.step1-operator': 'Qu Lili', + 'app.result.success.step2-title': 'Departmental preliminary review', + 'app.result.success.step2-operator': 'Zhou Maomao', + 'app.result.success.step2-extra': 'Urge', + 'app.result.success.step3-title': 'Financial review', + 'app.result.success.step4-title': 'Finish', + 'app.result.success.btn-return': 'Back to list', + 'app.result.success.btn-project': 'View project', + 'app.result.success.btn-print': 'Print', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/settingDrawer.js b/antdsp-admin/src/main/web/src/locales/en-US/settingDrawer.js new file mode 100644 index 0000000..a644905 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/settingDrawer.js @@ -0,0 +1,31 @@ +export default { + 'app.setting.pagestyle': 'Page style setting', + 'app.setting.pagestyle.dark': 'Dark style', + 'app.setting.pagestyle.light': 'Light style', + 'app.setting.content-width': 'Content Width', + 'app.setting.content-width.fixed': 'Fixed', + 'app.setting.content-width.fluid': 'Fluid', + 'app.setting.themecolor': 'Theme Color', + 'app.setting.themecolor.dust': 'Dust Red', + 'app.setting.themecolor.volcano': 'Volcano', + 'app.setting.themecolor.sunset': 'Sunset Orange', + 'app.setting.themecolor.cyan': 'Cyan', + 'app.setting.themecolor.green': 'Polar Green', + 'app.setting.themecolor.daybreak': 'Daybreak Blue (default)', + 'app.setting.themecolor.geekblue': 'Geek Glue', + 'app.setting.themecolor.purple': 'Golden Purple', + 'app.setting.navigationmode': 'Navigation Mode', + 'app.setting.sidemenu': 'Side Menu Layout', + 'app.setting.topmenu': 'Top Menu Layout', + 'app.setting.fixedheader': 'Fixed Header', + 'app.setting.fixedsidebar': 'Fixed Sidebar', + 'app.setting.fixedsidebar.hint': 'Works on Side Menu Layout', + 'app.setting.hideheader': 'Hidden Header when scrolling', + 'app.setting.hideheader.hint': 'Works when Hidden Header is enabled', + 'app.setting.othersettings': 'Other Settings', + 'app.setting.weakmode': 'Weak Mode', + 'app.setting.copy': 'Copy Setting', + 'app.setting.copyinfo': 'copy success,please replace defaultSettings in src/models/setting.js', + 'app.setting.production.hint': + 'Setting panel shows in development environment only, please manually modify', +}; diff --git a/antdsp-admin/src/main/web/src/locales/en-US/settings.js b/antdsp-admin/src/main/web/src/locales/en-US/settings.js new file mode 100644 index 0000000..822dd00 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/en-US/settings.js @@ -0,0 +1,60 @@ +export default { + 'app.settings.menuMap.basic': 'Basic Settings', + 'app.settings.menuMap.security': 'Security Settings', + 'app.settings.menuMap.binding': 'Account Binding', + 'app.settings.menuMap.notification': 'New Message Notification', + 'app.settings.basic.avatar': 'Avatar', + 'app.settings.basic.change-avatar': 'Change avatar', + 'app.settings.basic.email': 'Email', + 'app.settings.basic.email-message': 'Please input your email!', + 'app.settings.basic.nickname': 'Nickname', + 'app.settings.basic.nickname-message': 'Please input your Nickname!', + 'app.settings.basic.profile': 'Personal profile', + 'app.settings.basic.profile-message': 'Please input your personal profile!', + 'app.settings.basic.profile-placeholder': 'Brief introduction to yourself', + 'app.settings.basic.country': 'Country/Region', + 'app.settings.basic.country-message': 'Please input your country!', + 'app.settings.basic.geographic': 'Province or city', + 'app.settings.basic.geographic-message': 'Please input your geographic info!', + 'app.settings.basic.address': 'Street Address', + 'app.settings.basic.address-message': 'Please input your address!', + 'app.settings.basic.phone': 'Phone Number', + 'app.settings.basic.phone-message': 'Please input your phone!', + 'app.settings.basic.update': 'Update Information', + 'app.settings.security.strong': 'Strong', + 'app.settings.security.medium': 'Medium', + 'app.settings.security.weak': 'Weak', + 'app.settings.security.password': 'Account Password', + 'app.settings.security.password-description': 'Current password strength', + 'app.settings.security.phone': 'Security Phone', + 'app.settings.security.phone-description': 'Bound phone', + 'app.settings.security.question': 'Security Question', + 'app.settings.security.question-description': + 'The security question is not set, and the security policy can effectively protect the account security', + 'app.settings.security.email': 'Backup Email', + 'app.settings.security.email-description': 'Bound Email', + 'app.settings.security.mfa': 'MFA Device', + 'app.settings.security.mfa-description': + 'Unbound MFA device, after binding, can be confirmed twice', + 'app.settings.security.modify': 'Modify', + 'app.settings.security.set': 'Set', + 'app.settings.security.bind': 'Bind', + 'app.settings.binding.taobao': 'Binding Taobao', + 'app.settings.binding.taobao-description': 'Currently unbound Taobao account', + 'app.settings.binding.alipay': 'Binding Alipay', + 'app.settings.binding.alipay-description': 'Currently unbound Alipay account', + 'app.settings.binding.dingding': 'Binding DingTalk', + 'app.settings.binding.dingding-description': 'Currently unbound DingTalk account', + 'app.settings.binding.bind': 'Bind', + 'app.settings.notification.password': 'Account Password', + 'app.settings.notification.password-description': + 'Messages from other users will be notified in the form of a station letter', + 'app.settings.notification.messages': 'System Messages', + 'app.settings.notification.messages-description': + 'System messages will be notified in the form of a station letter', + 'app.settings.notification.todo': 'To-do Notification', + 'app.settings.notification.todo-description': + 'The to-do list will be notified in the form of a letter from the station', + 'app.settings.open': 'Open', + 'app.settings.close': 'Close', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR.js b/antdsp-admin/src/main/web/src/locales/pt-BR.js new file mode 100644 index 0000000..19e8264 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR.js @@ -0,0 +1,37 @@ +import analysis from './pt-BR/analysis'; +import exception from './pt-BR/exception'; +import form from './pt-BR/form'; +import globalHeader from './pt-BR/globalHeader'; +import login from './pt-BR/login'; +import menu from './pt-BR/menu'; +import monitor from './pt-BR/monitor'; +import result from './pt-BR/result'; +import settingDrawer from './pt-BR/settingDrawer'; +import settings from './pt-BR/settings'; +import pwa from './pt-BR/pwa'; +import component from './pt-BR/component'; +import editor from './pt-BR/editor'; + +export default { + 'navBar.lang': 'Idiomas', + 'layout.user.link.help': 'ajuda', + 'layout.user.link.privacy': 'política de privacidade', + 'layout.user.link.terms': 'termos de serviços', + 'app.home.introduce': 'introduzir', + 'app.forms.basic.title': 'Basic form', + 'app.forms.basic.description': + 'Páginas de formulário são usadas para coletar e verificar as informações dos usuários e formulários básicos são comuns nos cenários onde existem alguns formatos de informações.', + ...analysis, + ...exception, + ...form, + ...globalHeader, + ...login, + ...menu, + ...monitor, + ...result, + ...settingDrawer, + ...settings, + ...pwa, + ...component, + ...editor, +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/analysis.js b/antdsp-admin/src/main/web/src/locales/pt-BR/analysis.js new file mode 100644 index 0000000..eb33f10 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/analysis.js @@ -0,0 +1,34 @@ +export default { + 'app.analysis.test': 'Gongzhuan No.{no} shop', + 'app.analysis.introduce': 'Introduzir', + 'app.analysis.total-sales': 'Vendas Totais', + 'app.analysis.day-sales': 'Vendas do Dia', + 'app.analysis.visits': 'Visitas', + 'app.analysis.visits-trend': 'Tendência de Visitas', + 'app.analysis.visits-ranking': 'Ranking de Visitas', + 'app.analysis.day-visits': 'Visitas do Dia', + 'app.analysis.week': 'Taxa Semanal', + 'app.analysis.day': 'Taxa Diária', + 'app.analysis.payments': 'Pagamentos', + 'app.analysis.conversion-rate': 'Taxa de Conversão', + 'app.analysis.operational-effect': 'Efeito Operacional', + 'app.analysis.sales-trend': 'Tendência de Vendas das Lojas', + 'app.analysis.sales-ranking': 'Ranking de Vendas', + 'app.analysis.all-year': 'Todo ano', + 'app.analysis.all-month': 'Todo mês', + 'app.analysis.all-week': 'Toda semana', + 'app.analysis.all-day': 'Todo dia', + 'app.analysis.search-users': 'Pesquisa de Usuários', + 'app.analysis.per-capita-search': 'Busca Per Capta', + 'app.analysis.online-top-search': 'Mais Buscadas Online', + 'app.analysis.the-proportion-of-sales': 'Proporção de Vendas', + 'app.analysis.channel.all': 'Tudo', + 'app.analysis.channel.online': 'Online', + 'app.analysis.channel.stores': 'Lojas', + 'app.analysis.sales': 'Vendas', + 'app.analysis.traffic': 'Tráfego', + 'app.analysis.table.rank': 'Rank', + 'app.analysis.table.search-keyword': 'Palavra chave', + 'app.analysis.table.users': 'Usuários', + 'app.analysis.table.weekly-range': 'Faixa Semanal', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/component.js b/antdsp-admin/src/main/web/src/locales/pt-BR/component.js new file mode 100644 index 0000000..d3a2c1b --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/component.js @@ -0,0 +1,6 @@ +export default { + 'component.tagSelect.expand': 'Expandir', + 'component.tagSelect.collapse': 'Diminuir', + 'component.tagSelect.all': 'Todas', + 'component.miniProgress.tooltipDefault': 'Valor alvo', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/editor.js b/antdsp-admin/src/main/web/src/locales/pt-BR/editor.js new file mode 100644 index 0000000..10237f9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/editor.js @@ -0,0 +1,11 @@ +export default { + 'app.editor.flow.title': 'Editor de diagrama de flujo', + 'app.editor.flow.description': + 'El diagrama de flujo es una excelente manera de representar la idea del algoritmo.', + 'app.editor.koni.title': 'Editor de topologia', + 'app.editor.koni.description': + 'El diagrama de topología se refiere al diagrama de estructura de red compuesto por dispositivos de nodo de red y medios de comunicación.', + 'app.editor.mind.title': 'Editor de mapas cerebrales', + 'app.editor.mind.description': + 'El mapa cerebral es una herramienta de pensamiento gráfico eficaz para expresar el pensamiento divergente. Es simple pero efectivo y es una herramienta de pensamiento práctico.', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/exception.js b/antdsp-admin/src/main/web/src/locales/pt-BR/exception.js new file mode 100644 index 0000000..ff4f1a8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/exception.js @@ -0,0 +1,6 @@ +export default { + 'app.exception.back': 'Voltar para Início', + 'app.exception.description.403': 'Desculpe, você não tem acesso a esta página', + 'app.exception.description.404': 'Desculpe, a página que você visitou não existe', + 'app.exception.description.500': 'Desculpe, o servidor está reportando um erro', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/form.js b/antdsp-admin/src/main/web/src/locales/pt-BR/form.js new file mode 100644 index 0000000..8e5b760 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/form.js @@ -0,0 +1,39 @@ +export default { + 'form.get-captcha': 'Get Captcha', + 'form.captcha.second': 'sec', + 'form.email.placeholder': 'Email', + 'form.password.placeholder': 'Senha', + 'form.confirm-password.placeholder': 'Confirme a senha', + 'form.phone-number.placeholder': 'Telefone', + 'form.verification-code.placeholder': 'Código de verificação', + 'form.optional': ' (opcional) ', + 'form.submit': 'Enviar', + 'form.save': 'Salvar', + 'form.title.label': 'Titulo', + 'form.title.placeholder': 'Dê o nome do input', + 'form.date.label': 'Período', + 'form.date.placeholder.start': 'Data Inicial', + 'form.date.placeholder.end': 'Data Final', + 'form.goal.label': 'Objetivos', + 'form.goal.placeholder': 'Por favor, digite os seus objetivos', + 'form.standard.label': 'Métricas', + 'form.standard.placeholder': 'Por favor, digite suas métricas', + 'form.client.label': 'Cliente', + 'form.client.label.tooltip': 'Target service object', + 'form.client.placeholder': + 'Por favor, descreva seu atendimento ao cliente, clientes internos diretamente @ Nome / número do trabalho', + 'form.invites.label': 'Convidados críticos', + 'form.invites.placeholder': + 'Por favor, dirija @ Nome / número do trabalho, você pode convidar até 5 pessoas', + 'form.weight.label': 'Peso', + 'form.weight.placeholder': 'Por favor, entre com o peso', + 'form.public.label': 'Revelação de objetivo', + 'form.public.label.help': 'Clientes e convidados são compartilhados por padrão', + 'form.public.radio.public': 'Publico', + 'form.public.radio.partially-public': 'Parcialmente publico', + 'form.public.radio.private': 'Privado', + 'form.publicUsers.placeholder': 'Aberto para', + 'form.publicUsers.option.A': 'Colega A', + 'form.publicUsers.option.B': 'Colega B', + 'form.publicUsers.option.C': 'Colega C', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/globalHeader.js b/antdsp-admin/src/main/web/src/locales/pt-BR/globalHeader.js new file mode 100644 index 0000000..c927399 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/globalHeader.js @@ -0,0 +1,18 @@ +export default { + 'component.globalHeader.search': 'Busca', + 'component.globalHeader.search.example1': 'Exemplo de busca 1', + 'component.globalHeader.search.example2': 'Exemplo de busca 2', + 'component.globalHeader.search.example3': 'Exemplo de busca 3', + 'component.globalHeader.help': 'Ajuda', + 'component.globalHeader.notification': 'Notificação', + 'component.globalHeader.notification.empty': 'Você visualizou todas as notificações.', + 'component.globalHeader.message': 'Mensagem', + 'component.globalHeader.message.empty': 'Você visualizou todas as mensagens.', + 'component.globalHeader.event': 'Evento', + 'component.globalHeader.event.empty': 'Você visualizou todos os eventos.', + 'component.noticeIcon.clear': 'Limpar', + 'component.noticeIcon.cleared': 'Limpo', + 'component.noticeIcon.empty': 'Sem notificações', + 'component.noticeIcon.loaded': 'Carregado', + 'component.noticeIcon.view-more': 'Veja mais', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/login.js b/antdsp-admin/src/main/web/src/locales/pt-BR/login.js new file mode 100644 index 0000000..5e2d869 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/login.js @@ -0,0 +1,38 @@ +export default { + 'app.login.userName': 'Nome de usuário', + 'app.login.password': 'Sua senha', + 'app.login.message-invalid-credentials': + 'Nome de usuário ou senha inválidosd(admin/ant.design)', + 'app.login.message-invalid-verification-code': 'Código de verificação inválido', + 'app.login.tab-login-credentials': 'Credenciais', + 'app.login.tab-login-mobile': 'Telefone', + 'app.login.remember-me': 'Lembre-me', + 'app.login.forgot-password': 'Esqueceu sua senha?', + 'app.login.sign-in-with': 'Login com', + 'app.login.signup': 'Cadastre-se', + 'app.login.login': 'Login', + 'app.register.register': 'Cadastro', + 'app.register.get-verification-code': 'Recuperar código', + 'app.login.verification-code-warning': + 'This project is a demo project and will not actually send you a verification code. Please switch to the account password login interface and log in as prompted.', + 'app.register.sign-in': 'Já tem uma conta?', + 'app.register-result.msg': 'Conta:registrada em {email}', + 'app.register-result.activation-email': + 'Um email de ativação foi enviado para o seu email e é válido por 24 horas. Por favor entre no seu email e clique no link de ativação da conta.', + 'app.register-result.back-home': 'Voltar ao Início', + 'app.register-result.view-mailbox': 'Visualizar a caixa de email', + 'validation.email.required': 'Por favor insira seu email!', + 'validation.email.wrong-format': 'O email está errado!', + 'validation.userName.required': 'Por favor insira nome de usuário!', + 'validation.password.required': 'Por favor insira sua senha!', + 'validation.password.twice': 'As senhas não estão iguais!', + 'validation.password.strength.msg': + 'Por favor insira pelo menos 6 caracteres e não use senhas fáceis de adivinhar.', + 'validation.password.strength.strong': 'Força: forte', + 'validation.password.strength.medium': 'Força: média', + 'validation.password.strength.short': 'Força: curta', + 'validation.confirm-password.required': 'Por favor confirme sua senha!', + 'validation.phone-number.required': 'Por favor insira seu telefone!', + 'validation.phone-number.wrong-format': 'Formato de telefone errado!', + 'validation.verification-code.required': 'Por favor insira seu código de verificação!', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/menu.js b/antdsp-admin/src/main/web/src/locales/pt-BR/menu.js new file mode 100644 index 0000000..994f73c --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/menu.js @@ -0,0 +1,45 @@ +export default { + 'menu.home': 'Início', + 'menu.login': 'Login', + 'menu.register': 'Registro', + 'menu.register.result': 'Resultado de registro', + 'menu.dashboard': 'Dashboard', + 'menu.dashboard.analysis': 'Análise', + 'menu.dashboard.monitor': 'Monitor', + 'menu.dashboard.workplace': 'Ambiente de Trabalho', + 'menu.form': 'Formulário', + 'menu.form.basicform': 'Formulário Básico', + 'menu.form.stepform': 'Formulário Assistido', + 'menu.form.stepform.info': 'Formulário Assistido(gravar informações de transferência)', + 'menu.form.stepform.confirm': 'Formulário Assistido(confirmar informações de transferência)', + 'menu.form.stepform.result': 'Formulário Assistido(finalizado)', + 'menu.form.advancedform': 'Formulário Avançado', + 'menu.list': 'Lista', + 'menu.list.searchtable': 'Tabela de Busca', + 'menu.list.basiclist': 'Lista Básica', + 'menu.list.cardlist': 'Lista de Card', + 'menu.list.searchlist': 'Lista de Busca', + 'menu.list.searchlist.articles': 'Lista de Busca(artigos)', + 'menu.list.searchlist.projects': 'Lista de Busca(projetos)', + 'menu.list.searchlist.applications': 'Lista de Busca(aplicações)', + 'menu.profile': 'Perfil', + 'menu.profile.basic': 'Perfil Básico', + 'menu.profile.advanced': 'Perfil Avançado', + 'menu.result': 'Resultado', + 'menu.result.success': 'Sucesso', + 'menu.result.fail': 'Falha', + 'menu.exception': 'Exceção', + 'menu.exception.not-permission': '403', + 'menu.exception.not-find': '404', + 'menu.exception.server-error': '500', + 'menu.exception.trigger': 'Disparar', + 'menu.account': 'Conta', + 'menu.account.center': 'Central da Conta', + 'menu.account.settings': 'Configurar Conta', + 'menu.account.trigger': 'Disparar Erro', + 'menu.account.logout': 'Sair', + 'menu.editor': 'Graphic Editor', + 'menu.editor.flow': 'Flow Editor', + 'menu.editor.mind': 'Mind Editor', + 'menu.editor.koni': 'Koni Editor', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/monitor.js b/antdsp-admin/src/main/web/src/locales/pt-BR/monitor.js new file mode 100644 index 0000000..44a2608 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/monitor.js @@ -0,0 +1,19 @@ +export default { + 'app.monitor.trading-activity': 'Atividade de Trading Real-time', + 'app.monitor.total-transactions': 'Total de transações hoje', + 'app.monitor.sales-target': 'Taxa de conclusão da meta de vendas', + 'app.monitor.remaining-time': 'Tempo restante da atividade', + 'app.monitor.total-transactions-per-second': 'Total de transações por segundo', + 'app.monitor.activity-forecast': 'Previsão atual', + 'app.monitor.efficiency': 'Eficiência', + 'app.monitor.ratio': 'Relação', + 'app.monitor.proportion-per-category': 'Proporção por categoria', + 'app.monitor.fast-food': 'Fast food', + 'app.monitor.western-food': 'Comida Ocidental', + 'app.monitor.hot-pot': 'Hot pot', + 'app.monitor.waiting-for-implementation': 'Aguardando implementação', + 'app.monitor.popular-searches': 'Buscas populares', + 'app.monitor.resource-surplus': 'Excedente de recursos', + 'app.monitor.fund-surplus': 'Excedente do fundo', + 'app.exception.back': 'Voltar a home', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/pwa.js b/antdsp-admin/src/main/web/src/locales/pt-BR/pwa.js new file mode 100644 index 0000000..05cc797 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/pwa.js @@ -0,0 +1,7 @@ +export default { + 'app.pwa.offline': 'Você está offline agora', + 'app.pwa.serviceworker.updated': 'Novo conteúdo está disponível', + 'app.pwa.serviceworker.updated.hint': + 'Por favor, pressione o botão "Atualizar" para recarregar a página atual', + 'app.pwa.serviceworker.updated.ok': 'Atualizar', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/result.js b/antdsp-admin/src/main/web/src/locales/pt-BR/result.js new file mode 100644 index 0000000..2720e07 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/result.js @@ -0,0 +1,28 @@ +export default { + 'app.result.error.title': 'A Submissão Falhou', + 'app.result.error.description': + 'Por favor, verifique e modifique as seguintes informações antes de reenviar.', + 'app.result.error.hint-title': 'O conteúdo que você enviou tem o seguinte erro:', + 'app.result.error.hint-text1': 'Sua conta foi congelada', + 'app.result.error.hint-btn1': 'Descongele imediatamente', + 'app.result.error.hint-text2': 'Sua conta ainda não está qualificada para se candidatar', + 'app.result.error.hint-btn2': 'Atualizar imediatamente', + 'app.result.error.btn-text': 'Retornar para modificar', + 'app.result.success.title': 'A Submissão foi um Sucesso', + 'app.result.success.description': + 'A página de resultados de envio é usada para fornecer os resultados de uma série de tarefas operacionais. Se for uma operação simples, use o prompt de feedback de Mensagem global. Esta área de texto pode mostrar uma explicação suplementar simples. Se houver um requisito semelhante para exibir "documentos", a área cinza a seguir pode apresentar um conteúdo mais complicado.', + 'app.result.success.operate-title': 'Nome do Projeto', + 'app.result.success.operate-id': 'ID do Projeto:', + 'app.result.success.principal': 'Principal:', + 'app.result.success.operate-time': 'Tempo efetivo:', + 'app.result.success.step1-title': 'Criar projeto', + 'app.result.success.step1-operator': 'Qu Lili', + 'app.result.success.step2-title': 'Revisão preliminar do departamento', + 'app.result.success.step2-operator': 'Zhou Maomao', + 'app.result.success.step2-extra': 'Urge', + 'app.result.success.step3-title': 'Revisão financeira', + 'app.result.success.step4-title': 'Terminar', + 'app.result.success.btn-return': 'Voltar a lista', + 'app.result.success.btn-project': 'Ver projeto', + 'app.result.success.btn-print': 'imprimir', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/settingDrawer.js b/antdsp-admin/src/main/web/src/locales/pt-BR/settingDrawer.js new file mode 100644 index 0000000..8a10b57 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/settingDrawer.js @@ -0,0 +1,32 @@ +export default { + 'app.setting.pagestyle': 'Configuração de estilo da página', + 'app.setting.pagestyle.dark': 'Dark style', + 'app.setting.pagestyle.light': 'Light style', + 'app.setting.content-width': 'Largura do conteúdo', + 'app.setting.content-width.fixed': 'Fixo', + 'app.setting.content-width.fluid': 'Fluido', + 'app.setting.themecolor': 'Cor do Tema', + 'app.setting.themecolor.dust': 'Dust Red', + 'app.setting.themecolor.volcano': 'Volcano', + 'app.setting.themecolor.sunset': 'Sunset Orange', + 'app.setting.themecolor.cyan': 'Cyan', + 'app.setting.themecolor.green': 'Polar Green', + 'app.setting.themecolor.daybreak': 'Daybreak Blue (default)', + 'app.setting.themecolor.geekblue': 'Geek Glue', + 'app.setting.themecolor.purple': 'Golden Purple', + 'app.setting.navigationmode': 'Modo de Navegação', + 'app.setting.sidemenu': 'Layout do Menu Lateral', + 'app.setting.topmenu': 'Layout do Menu Superior', + 'app.setting.fixedheader': 'Cabeçalho fixo', + 'app.setting.fixedsidebar': 'Barra lateral fixa', + 'app.setting.fixedsidebar.hint': 'Funciona no layout do menu lateral', + 'app.setting.hideheader': 'Esconder o cabeçalho quando rolar', + 'app.setting.hideheader.hint': 'Funciona quando o esconder cabeçalho está abilitado', + 'app.setting.othersettings': 'Outras configurações', + 'app.setting.weakmode': 'Weak Mode', + 'app.setting.copy': 'Copiar Configuração', + 'app.setting.copyinfo': + 'copiado com sucesso,por favor trocar o defaultSettings em src/models/setting.js', + 'app.setting.production.hint': + 'O painel de configuração apenas é exibido no ambiente de desenvolvimento, por favor modifique manualmente o', +}; diff --git a/antdsp-admin/src/main/web/src/locales/pt-BR/settings.js b/antdsp-admin/src/main/web/src/locales/pt-BR/settings.js new file mode 100644 index 0000000..aad2e38 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/pt-BR/settings.js @@ -0,0 +1,60 @@ +export default { + 'app.settings.menuMap.basic': 'Configurações Básicas', + 'app.settings.menuMap.security': 'Configurações de Segurança', + 'app.settings.menuMap.binding': 'Vinculação de Conta', + 'app.settings.menuMap.notification': 'Mensagens de Notificação', + 'app.settings.basic.avatar': 'Avatar', + 'app.settings.basic.change-avatar': 'Alterar avatar', + 'app.settings.basic.email': 'Email', + 'app.settings.basic.email-message': 'Por favor insira seu email!', + 'app.settings.basic.nickname': 'Nome de usuário', + 'app.settings.basic.nickname-message': 'Por favor insira seu nome de usuário!', + 'app.settings.basic.profile': 'Perfil pessoal', + 'app.settings.basic.profile-message': 'Por favor insira seu perfil pessoal!', + 'app.settings.basic.profile-placeholder': 'Breve introdução sua', + 'app.settings.basic.country': 'País/Região', + 'app.settings.basic.country-message': 'Por favor insira país!', + 'app.settings.basic.geographic': 'Província, estado ou cidade', + 'app.settings.basic.geographic-message': 'Por favor insira suas informações geográficas!', + 'app.settings.basic.address': 'Endereço', + 'app.settings.basic.address-message': 'Por favor insira seu endereço!', + 'app.settings.basic.phone': 'Número de telefone', + 'app.settings.basic.phone-message': 'Por favor insira seu número de telefone!', + 'app.settings.basic.update': 'Atualizar Informações', + 'app.settings.security.strong': 'Forte', + 'app.settings.security.medium': 'Média', + 'app.settings.security.weak': 'Fraca', + 'app.settings.security.password': 'Senha da Conta', + 'app.settings.security.password-description': 'Força da senha', + 'app.settings.security.phone': 'Telefone de Seguraça', + 'app.settings.security.phone-description': 'Telefone vinculado', + 'app.settings.security.question': 'Pergunta de Segurança', + 'app.settings.security.question-description': + 'A pergunta de segurança não está definida e a política de segurança pode proteger efetivamente a segurança da conta', + 'app.settings.security.email': 'Email de Backup', + 'app.settings.security.email-description': 'Email vinculado', + 'app.settings.security.mfa': 'Dispositivo MFA', + 'app.settings.security.mfa-description': + 'O dispositivo MFA não vinculado, após a vinculação, pode ser confirmado duas vezes', + 'app.settings.security.modify': 'Modificar', + 'app.settings.security.set': 'Atribuir', + 'app.settings.security.bind': 'Vincular', + 'app.settings.binding.taobao': 'Vincular Taobao', + 'app.settings.binding.taobao-description': 'Atualmente não vinculado à conta Taobao', + 'app.settings.binding.alipay': 'Vincular Alipay', + 'app.settings.binding.alipay-description': 'Atualmente não vinculado à conta Alipay', + 'app.settings.binding.dingding': 'Vincular DingTalk', + 'app.settings.binding.dingding-description': 'Atualmente não vinculado à conta DingTalk', + 'app.settings.binding.bind': 'Vincular', + 'app.settings.notification.password': 'Senha da Conta', + 'app.settings.notification.password-description': + 'Mensagens de outros usuários serão notificadas na forma de uma estação de letra', + 'app.settings.notification.messages': 'Mensagens de Sistema', + 'app.settings.notification.messages-description': + 'Mensagens de sistema serão notificadas na forma de uma estação de letra', + 'app.settings.notification.todo': 'Notificação de To-do', + 'app.settings.notification.todo-description': + 'A lista de to-do será notificada na forma de uma estação de letra', + 'app.settings.open': 'Aberto', + 'app.settings.close': 'Fechado', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN.js b/antdsp-admin/src/main/web/src/locales/zh-CN.js new file mode 100644 index 0000000..6cc85e4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN.js @@ -0,0 +1,37 @@ +import analysis from './zh-CN/analysis'; +import exception from './zh-CN/exception'; +import form from './zh-CN/form'; +import globalHeader from './zh-CN/globalHeader'; +import login from './zh-CN/login'; +import menu from './zh-CN/menu'; +import monitor from './zh-CN/monitor'; +import result from './zh-CN/result'; +import settingDrawer from './zh-CN/settingDrawer'; +import settings from './zh-CN/settings'; +import pwa from './zh-CN/pwa'; +import component from './zh-CN/component'; +import editor from './zh-CN/editor'; + +export default { + 'navBar.lang': '语言', + 'layout.user.link.help': '帮助', + 'layout.user.link.privacy': '隐私', + 'layout.user.link.terms': '条款', + 'app.home.introduce': '介绍', + 'app.forms.basic.title': '基础表单', + 'app.forms.basic.description': + '表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。', + ...analysis, + ...exception, + ...form, + ...globalHeader, + ...login, + ...menu, + ...monitor, + ...result, + ...settingDrawer, + ...settings, + ...pwa, + ...component, + ...editor, +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/analysis.js b/antdsp-admin/src/main/web/src/locales/zh-CN/analysis.js new file mode 100644 index 0000000..8ed17ed --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/analysis.js @@ -0,0 +1,34 @@ +export default { + 'app.analysis.test': '工专路 {no} 号店', + 'app.analysis.introduce': '指标说明', + 'app.analysis.total-sales': '总销售额', + 'app.analysis.day-sales': '日销售额', + 'app.analysis.visits': '访问量', + 'app.analysis.visits-trend': '访问量趋势', + 'app.analysis.visits-ranking': '门店访问量排名', + 'app.analysis.day-visits': '日访问量', + 'app.analysis.week': '周同比', + 'app.analysis.day': '日同比', + 'app.analysis.payments': '支付笔数', + 'app.analysis.conversion-rate': '转化率', + 'app.analysis.operational-effect': '运营活动效果', + 'app.analysis.sales-trend': '销售趋势', + 'app.analysis.sales-ranking': '门店销售额排名', + 'app.analysis.all-year': '全年', + 'app.analysis.all-month': '本月', + 'app.analysis.all-week': '本周', + 'app.analysis.all-day': '今日', + 'app.analysis.search-users': '搜索用户数', + 'app.analysis.per-capita-search': '人均搜索次数', + 'app.analysis.online-top-search': '线上热门搜索', + 'app.analysis.the-proportion-of-sales': '销售额类别占比', + 'app.analysis.channel.all': '全部渠道', + 'app.analysis.channel.online': '线上', + 'app.analysis.channel.stores': '门店', + 'app.analysis.sales': '销售额', + 'app.analysis.traffic': '客流量', + 'app.analysis.table.rank': '排名', + 'app.analysis.table.search-keyword': '搜索关键词', + 'app.analysis.table.users': '用户数', + 'app.analysis.table.weekly-range': '周涨幅', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/component.js b/antdsp-admin/src/main/web/src/locales/zh-CN/component.js new file mode 100644 index 0000000..8d988ca --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/component.js @@ -0,0 +1,6 @@ +export default { + 'component.tagSelect.expand': '展开', + 'component.tagSelect.collapse': '收起', + 'component.tagSelect.all': '全部', + 'component.miniProgress.tooltipDefault': '目标值', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/editor.js b/antdsp-admin/src/main/web/src/locales/zh-CN/editor.js new file mode 100644 index 0000000..1688644 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/editor.js @@ -0,0 +1,9 @@ +export default { + 'app.editor.flow.title': '流程图编辑器', + 'app.editor.flow.description': '千言万语不如一张图,流程图是表示算法思路的好方法', + 'app.editor.koni.title': '拓扑编辑器', + 'app.editor.koni.description': '拓扑结构图是指由网络节点设备和通信介质构成的网络结构图', + 'app.editor.mind.title': '脑图编辑器', + 'app.editor.mind.description': + '脑图是表达发散性思维的有效图形思维工具 ,它简单却又很有效,是一种实用性的思维工具。', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/exception.js b/antdsp-admin/src/main/web/src/locales/zh-CN/exception.js new file mode 100644 index 0000000..1b89ab7 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/exception.js @@ -0,0 +1,6 @@ +export default { + 'app.exception.back': '返回首页', + 'app.exception.description.403': '抱歉,你无权访问此页面', + 'app.exception.description.404': '抱歉,你访问的页面不存在', + 'app.exception.description.500': '抱歉,服务器出错了', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/form.js b/antdsp-admin/src/main/web/src/locales/zh-CN/form.js new file mode 100644 index 0000000..7f3bd95 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/form.js @@ -0,0 +1,37 @@ +export default { + 'form.get-captcha': '获取验证码', + 'form.captcha.second': '秒', + 'form.optional': '(选填)', + 'form.submit': '提交', + 'form.save': '保存', + 'form.email.placeholder': '邮箱', + 'form.password.placeholder': '至少6位密码,区分大小写', + 'form.confirm-password.placeholder': '确认密码', + 'form.phone-number.placeholder': '手机号', + 'form.verification-code.placeholder': '验证码', + 'form.title.label': '标题', + 'form.title.placeholder': '给目标起个名字', + 'form.date.label': '起止日期', + 'form.date.placeholder.start': '开始日期', + 'form.date.placeholder.end': '结束日期', + 'form.goal.label': '目标描述', + 'form.goal.placeholder': '请输入你的阶段性工作目标', + 'form.standard.label': '衡量标准', + 'form.standard.placeholder': '请输入衡量标准', + 'form.client.label': '客户', + 'form.client.label.tooltip': '目标的服务对象', + 'form.client.placeholder': '请描述你服务的客户,内部客户直接 @姓名/工号', + 'form.invites.label': '邀评人', + 'form.invites.placeholder': '请直接 @姓名/工号,最多可邀请 5 人', + 'form.weight.label': '权重', + 'form.weight.placeholder': '请输入', + 'form.public.label': '目标公开', + 'form.public.label.help': '客户、邀评人默认被分享', + 'form.public.radio.public': '公开', + 'form.public.radio.partially-public': '部分公开', + 'form.public.radio.private': '不公开', + 'form.publicUsers.placeholder': '公开给', + 'form.publicUsers.option.A': '同事甲', + 'form.publicUsers.option.B': '同事乙', + 'form.publicUsers.option.C': '同事丙', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/globalHeader.js b/antdsp-admin/src/main/web/src/locales/zh-CN/globalHeader.js new file mode 100644 index 0000000..9fd66a5 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/globalHeader.js @@ -0,0 +1,17 @@ +export default { + 'component.globalHeader.search': '站内搜索', + 'component.globalHeader.search.example1': '搜索提示一', + 'component.globalHeader.search.example2': '搜索提示二', + 'component.globalHeader.search.example3': '搜索提示三', + 'component.globalHeader.help': '使用文档', + 'component.globalHeader.notification': '通知', + 'component.globalHeader.notification.empty': '你已查看所有通知', + 'component.globalHeader.message': '消息', + 'component.globalHeader.message.empty': '您已读完所有消息', + 'component.globalHeader.event': '待办', + 'component.globalHeader.event.empty': '你已完成所有待办', + 'component.noticeIcon.clear': '清空', + 'component.noticeIcon.cleared': '清空了', + 'component.noticeIcon.empty': '暂无数据', + 'component.noticeIcon.view-more': '查看更多', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/login.js b/antdsp-admin/src/main/web/src/locales/zh-CN/login.js new file mode 100644 index 0000000..e211e2c --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/login.js @@ -0,0 +1,40 @@ +export default { + 'app.login.userName': '用户名', + 'app.login.password': '密码', + 'app.login.message-invalid-credentials': '账户或密码错误(admin/ant.design)', + 'app.login.message-invalid-verification-code': '验证码错误', + 'app.login.tab-login-credentials': '账户密码登录', + 'app.login.tab-login-mobile': '手机号登录', + 'app.login.remember-me': '自动登录', + 'app.login.forgot-password': '忘记密码', + 'app.login.sign-in-with': '其他登录方式', + 'app.login.signup': '注册账户', + 'app.login.login': '登录', + 'app.register.register': '注册', + 'app.register.get-verification-code': '获取验证码', + 'app.login.verification-code-warning': + '此项目为演示项目,并不会真的给您发送验证码。请切换到账户密码登录界面按提示登录。', + 'app.register.sign-in': '使用已有账户登录', + 'app.register-result.msg': '你的账户:{email} 注册成功', + 'app.register-result.activation-email': + '激活邮件已发送到你的邮箱中,邮件有效期为24小时。请及时登录邮箱,点击邮件中的链接激活帐户。', + 'app.register-result.back-home': '返回首页', + 'app.register-result.view-mailbox': '查看邮箱', + 'validation.email.required': '请输入邮箱地址!', + 'validation.email.wrong-format': '邮箱地址格式错误!', + 'validation.userName.required': '请输入用户名!', + 'validation.password.required': '请输入密码!', + 'validation.password.twice': '两次输入的密码不匹配!', + 'validation.password.strength.msg': '请至少输入 6 个字符。请不要使用容易被猜到的密码。', + 'validation.password.strength.strong': '强度:强', + 'validation.password.strength.medium': '强度:中', + 'validation.password.strength.short': '强度:太短', + 'validation.confirm-password.required': '请确认密码!', + 'validation.phone-number.required': '请输入手机号!', + 'validation.phone-number.wrong-format': '手机号格式错误!', + 'validation.verification-code.required': '请输入验证码!', + 'validation.title.required': '请输入标题', + 'validation.date.required': '请选择起止日期', + 'validation.goal.required': '请输入目标描述', + 'validation.standard.required': '请输入衡量标准', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js b/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js new file mode 100644 index 0000000..cba1a2d --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js @@ -0,0 +1,10 @@ +export default { + 'menu.home': '首页', + 'menu.login': '登录', + 'menu.register': '注册', + 'menu.register.result': '注册结果', + 'menu.system': '系统管理', + 'menu.system.role': '角色管理', + 'menu.system.user': '用户管理', + 'menu.system.menu': '菜单管理', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/monitor.js b/antdsp-admin/src/main/web/src/locales/zh-CN/monitor.js new file mode 100644 index 0000000..3a3e3f0 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/monitor.js @@ -0,0 +1,18 @@ +export default { + 'app.monitor.trading-activity': '活动实时交易情况', + 'app.monitor.total-transactions': '今日交易总额', + 'app.monitor.sales-target': '销售目标完成率', + 'app.monitor.remaining-time': '活动剩余时间', + 'app.monitor.total-transactions-per-second': '每秒交易总额', + 'app.monitor.activity-forecast': '活动情况预测', + 'app.monitor.efficiency': '券核效率', + 'app.monitor.ratio': '跳出率', + 'app.monitor.proportion-per-category': '各品类占比', + 'app.monitor.fast-food': '中式快餐', + 'app.monitor.western-food': '西餐', + 'app.monitor.hot-pot': '火锅', + 'app.monitor.waiting-for-implementation': 'Waiting for implementation', + 'app.monitor.popular-searches': '热门搜索', + 'app.monitor.resource-surplus': '资源剩余', + 'app.monitor.fund-surplus': '补贴资金剩余', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/pwa.js b/antdsp-admin/src/main/web/src/locales/zh-CN/pwa.js new file mode 100644 index 0000000..e950484 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/pwa.js @@ -0,0 +1,6 @@ +export default { + 'app.pwa.offline': '当前处于离线状态', + 'app.pwa.serviceworker.updated': '有新内容', + 'app.pwa.serviceworker.updated.hint': '请点击“刷新”按钮或者手动刷新页面', + 'app.pwa.serviceworker.updated.ok': '刷新', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/result.js b/antdsp-admin/src/main/web/src/locales/zh-CN/result.js new file mode 100644 index 0000000..cba0e1c --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/result.js @@ -0,0 +1,27 @@ +export default { + 'app.result.error.title': '提交失败', + 'app.result.error.description': '请核对并修改以下信息后,再重新提交。', + 'app.result.error.hint-title': '您提交的内容有如下错误:', + 'app.result.error.hint-text1': '您的账户已被冻结', + 'app.result.error.hint-btn1': '立即解冻', + 'app.result.error.hint-text2': '您的账户还不具备申请资格', + 'app.result.error.hint-btn2': '立即升级', + 'app.result.error.btn-text': '返回修改', + 'app.result.success.title': '提交成功', + 'app.result.success.description': + '提交结果页用于反馈一系列操作任务的处理结果, 如果仅是简单操作,使用 Message 全局提示反馈即可。 本文字区域可以展示简单的补充说明,如果有类似展示 “单据”的需求,下面这个灰色区域可以呈现比较复杂的内容。', + 'app.result.success.operate-title': '项目名称', + 'app.result.success.operate-id': '项目 ID:', + 'app.result.success.principal': '负责人:', + 'app.result.success.operate-time': '生效时间:', + 'app.result.success.step1-title': '创建项目', + 'app.result.success.step1-operator': '曲丽丽', + 'app.result.success.step2-title': '部门初审', + 'app.result.success.step2-operator': '周毛毛', + 'app.result.success.step2-extra': '催一下', + 'app.result.success.step3-title': '财务复核', + 'app.result.success.step4-title': '完成', + 'app.result.success.btn-return': '返回列表', + 'app.result.success.btn-project': '查看项目', + 'app.result.success.btn-print': '打印', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/settingDrawer.js b/antdsp-admin/src/main/web/src/locales/zh-CN/settingDrawer.js new file mode 100644 index 0000000..15685a4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/settingDrawer.js @@ -0,0 +1,31 @@ +export default { + 'app.setting.pagestyle': '整体风格设置', + 'app.setting.pagestyle.dark': '暗色菜单风格', + 'app.setting.pagestyle.light': '亮色菜单风格', + 'app.setting.content-width': '内容区域宽度', + 'app.setting.content-width.fixed': '定宽', + 'app.setting.content-width.fluid': '流式', + 'app.setting.themecolor': '主题色', + 'app.setting.themecolor.dust': '薄暮', + 'app.setting.themecolor.volcano': '火山', + 'app.setting.themecolor.sunset': '日暮', + 'app.setting.themecolor.cyan': '明青', + 'app.setting.themecolor.green': '极光绿', + 'app.setting.themecolor.daybreak': '拂晓蓝(默认)', + 'app.setting.themecolor.geekblue': '极客蓝', + 'app.setting.themecolor.purple': '酱紫', + 'app.setting.navigationmode': '导航模式', + 'app.setting.sidemenu': '侧边菜单布局', + 'app.setting.topmenu': '顶部菜单布局', + 'app.setting.fixedheader': '固定 Header', + 'app.setting.fixedsidebar': '固定侧边菜单', + 'app.setting.fixedsidebar.hint': '侧边菜单布局时可配置', + 'app.setting.hideheader': '下滑时隐藏 Header', + 'app.setting.hideheader.hint': '固定 Header 时可配置', + 'app.setting.othersettings': '其他设置', + 'app.setting.weakmode': '色弱模式', + 'app.setting.copy': '拷贝设置', + 'app.setting.copyinfo': '拷贝成功,请到 src/defaultSettings.js 中替换默认配置', + 'app.setting.production.hint': + '配置栏只在开发环境用于预览,生产环境不会展现,请拷贝后手动修改配置文件', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/settings.js b/antdsp-admin/src/main/web/src/locales/zh-CN/settings.js new file mode 100644 index 0000000..df8af43 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/settings.js @@ -0,0 +1,55 @@ +export default { + 'app.settings.menuMap.basic': '基本设置', + 'app.settings.menuMap.security': '安全设置', + 'app.settings.menuMap.binding': '账号绑定', + 'app.settings.menuMap.notification': '新消息通知', + 'app.settings.basic.avatar': '头像', + 'app.settings.basic.change-avatar': '更换头像', + 'app.settings.basic.email': '邮箱', + 'app.settings.basic.email-message': '请输入您的邮箱!', + 'app.settings.basic.nickname': '昵称', + 'app.settings.basic.nickname-message': '请输入您的昵称!', + 'app.settings.basic.profile': '个人简介', + 'app.settings.basic.profile-message': '请输入个人简介!', + 'app.settings.basic.profile-placeholder': '个人简介', + 'app.settings.basic.country': '国家/地区', + 'app.settings.basic.country-message': '请输入您的国家或地区!', + 'app.settings.basic.geographic': '所在省市', + 'app.settings.basic.geographic-message': '请输入您的所在省市!', + 'app.settings.basic.address': '街道地址', + 'app.settings.basic.address-message': '请输入您的街道地址!', + 'app.settings.basic.phone': '联系电话', + 'app.settings.basic.phone-message': '请输入您的联系电话!', + 'app.settings.basic.update': '更新基本信息', + 'app.settings.security.strong': '强', + 'app.settings.security.medium': '中', + 'app.settings.security.weak': '弱', + 'app.settings.security.password': '账户密码', + 'app.settings.security.password-description': '当前密码强度', + 'app.settings.security.phone': '密保手机', + 'app.settings.security.phone-description': '已绑定手机', + 'app.settings.security.question': '密保问题', + 'app.settings.security.question-description': '未设置密保问题,密保问题可有效保护账户安全', + 'app.settings.security.email': '备用邮箱', + 'app.settings.security.email-description': '已绑定邮箱', + 'app.settings.security.mfa': 'MFA 设备', + 'app.settings.security.mfa-description': '未绑定 MFA 设备,绑定后,可以进行二次确认', + 'app.settings.security.modify': '修改', + 'app.settings.security.set': '设置', + 'app.settings.security.bind': '绑定', + 'app.settings.binding.taobao': '绑定淘宝', + 'app.settings.binding.taobao-description': '当前未绑定淘宝账号', + 'app.settings.binding.alipay': '绑定支付宝', + 'app.settings.binding.alipay-description': '当前未绑定支付宝账号', + 'app.settings.binding.dingding': '绑定钉钉', + 'app.settings.binding.dingding-description': '当前未绑定钉钉账号', + 'app.settings.binding.bind': '绑定', + 'app.settings.notification.password': '账户密码', + 'app.settings.notification.password-description': '其他用户的消息将以站内信的形式通知', + 'app.settings.notification.messages': '系统消息', + 'app.settings.notification.messages-description': '系统消息将以站内信的形式通知', + 'app.settings.notification.todo': '待办任务', + 'app.settings.notification.todo-description': '待办任务将以站内信的形式通知', + 'app.settings.open': '开', + 'app.settings.close': '关', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW.js b/antdsp-admin/src/main/web/src/locales/zh-TW.js new file mode 100644 index 0000000..3335150 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW.js @@ -0,0 +1,37 @@ +import analysis from './zh-TW/analysis'; +import exception from './zh-TW/exception'; +import form from './zh-TW/form'; +import globalHeader from './zh-TW/globalHeader'; +import login from './zh-TW/login'; +import menu from './zh-TW/menu'; +import monitor from './zh-TW/monitor'; +import result from './zh-TW/result'; +import settingDrawer from './zh-TW/settingDrawer'; +import settings from './zh-TW/settings'; +import pwa from './zh-TW/pwa'; +import component from './zh-TW/component'; +import editor from './zh-TW/editor'; + +export default { + 'navBar.lang': '語言', + 'layout.user.link.help': '幫助', + 'layout.user.link.privacy': '隱私', + 'layout.user.link.terms': '條款', + 'app.home.introduce': '介紹', + 'app.forms.basic.title': '基礎表單', + 'app.forms.basic.description': + '表單頁用於向用戶收集或驗證信息,基礎表單常見於數據項較少的表單場景。', + ...analysis, + ...exception, + ...form, + ...globalHeader, + ...login, + ...menu, + ...monitor, + ...result, + ...settingDrawer, + ...settings, + ...pwa, + ...component, + ...editor, +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/analysis.js b/antdsp-admin/src/main/web/src/locales/zh-TW/analysis.js new file mode 100644 index 0000000..7b2e37c --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/analysis.js @@ -0,0 +1,34 @@ +export default { + 'app.analysis.test': '工專路 {no} 號店', + 'app.analysis.introduce': '指標說明', + 'app.analysis.total-sales': '總銷售額', + 'app.analysis.day-sales': '日銷售額', + 'app.analysis.visits': '訪問量', + 'app.analysis.visits-trend': '訪問量趨勢', + 'app.analysis.visits-ranking': '門店訪問量排名', + 'app.analysis.day-visits': '日訪問量', + 'app.analysis.week': '周同比', + 'app.analysis.day': '日同比', + 'app.analysis.payments': '支付筆數', + 'app.analysis.conversion-rate': '轉化率', + 'app.analysis.operational-effect': '運營活動效果', + 'app.analysis.sales-trend': '銷售趨勢', + 'app.analysis.sales-ranking': '門店銷售額排名', + 'app.analysis.all-year': '全年', + 'app.analysis.all-month': '本月', + 'app.analysis.all-week': '本周', + 'app.analysis.all-day': '今日', + 'app.analysis.search-users': '搜索用戶數', + 'app.analysis.per-capita-search': '人均搜索次數', + 'app.analysis.online-top-search': '線上熱門搜索', + 'app.analysis.the-proportion-of-sales': '銷售額類別占比', + 'app.analysis.channel.all': '全部渠道', + 'app.analysis.channel.online': '線上', + 'app.analysis.channel.stores': '門店', + 'app.analysis.sales': '銷售額', + 'app.analysis.traffic': '客流量', + 'app.analysis.table.rank': '排名', + 'app.analysis.table.search-keyword': '搜索關鍵詞', + 'app.analysis.table.users': '用戶數', + 'app.analysis.table.weekly-range': '周漲幅', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/component.js b/antdsp-admin/src/main/web/src/locales/zh-TW/component.js new file mode 100644 index 0000000..dde9eb5 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/component.js @@ -0,0 +1,6 @@ +export default { + 'component.tagSelect.expand': '展開', + 'component.tagSelect.collapse': '收起', + 'component.tagSelect.all': '全部', + 'component.miniProgress.tooltipDefault': '目标值', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/editor.js b/antdsp-admin/src/main/web/src/locales/zh-TW/editor.js new file mode 100644 index 0000000..d1d1377 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/editor.js @@ -0,0 +1,9 @@ +export default { + 'app.editor.flow.title': '流程圖編輯器', + 'app.editor.flow.description': '千言萬語不如一張圖,流程圖是表示算法思路的好方法', + 'app.editor.koni.title': '拓撲編輯器', + 'app.editor.koni.description': '拓撲結構圖是指由網絡節點設備和通信介質構成的網絡結構圖', + 'app.editor.mind.title': '腦圖編輯器', + 'app.editor.mind.description': + '腦圖是表達發散性思維的有效圖形思維工具 ,它簡單卻又很有效,是一種實用性的思維工具', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/exception.js b/antdsp-admin/src/main/web/src/locales/zh-TW/exception.js new file mode 100644 index 0000000..119140d --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/exception.js @@ -0,0 +1,6 @@ +export default { + 'app.exception.back': '返回首頁', + 'app.exception.description.403': '抱歉,妳無權訪問此頁面', + 'app.exception.description.404': '抱歉,妳訪問的頁面不存在', + 'app.exception.description.500': '抱歉,服務器出錯了', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/form.js b/antdsp-admin/src/main/web/src/locales/zh-TW/form.js new file mode 100644 index 0000000..cf1adf5 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/form.js @@ -0,0 +1,37 @@ +export default { + 'form.get-captcha': '獲取驗證碼', + 'form.captcha.second': '秒', + 'form.optional': '(選填)', + 'form.submit': '提交', + 'form.save': '保存', + 'form.email.placeholder': '郵箱', + 'form.password.placeholder': '至少6位密碼,區分大小寫', + 'form.confirm-password.placeholder': '確認密碼', + 'form.phone-number.placeholder': '手機號', + 'form.verification-code.placeholder': '驗證碼', + 'form.title.label': '標題', + 'form.title.placeholder': '給目標起個名字', + 'form.date.label': '起止日期', + 'form.date.placeholder.start': '開始日期', + 'form.date.placeholder.end': '結束日期', + 'form.goal.label': '目標描述', + 'form.goal.placeholder': '請輸入妳的階段性工作目標', + 'form.standard.label': '衡量標淮', + 'form.standard.placeholder': '請輸入衡量標淮', + 'form.client.label': '客戶', + 'form.client.label.tooltip': '目標的服務對象', + 'form.client.placeholder': '請描述妳服務的客戶,內部客戶直接 @姓名/工號', + 'form.invites.label': '邀評人', + 'form.invites.placeholder': '請直接 @姓名/工號,最多可邀請 5 人', + 'form.weight.label': '權重', + 'form.weight.placeholder': '請輸入', + 'form.public.label': '目標公開', + 'form.public.label.help': '客戶、邀評人默認被分享', + 'form.public.radio.public': '公開', + 'form.public.radio.partially-public': '部分公開', + 'form.public.radio.private': '不公開', + 'form.publicUsers.placeholder': '公開給', + 'form.publicUsers.option.A': '同事甲', + 'form.publicUsers.option.B': '同事乙', + 'form.publicUsers.option.C': '同事丙', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/globalHeader.js b/antdsp-admin/src/main/web/src/locales/zh-TW/globalHeader.js new file mode 100644 index 0000000..ed58451 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/globalHeader.js @@ -0,0 +1,17 @@ +export default { + 'component.globalHeader.search': '站內搜索', + 'component.globalHeader.search.example1': '搜索提示壹', + 'component.globalHeader.search.example2': '搜索提示二', + 'component.globalHeader.search.example3': '搜索提示三', + 'component.globalHeader.help': '使用手冊', + 'component.globalHeader.notification': '通知', + 'component.globalHeader.notification.empty': '妳已查看所有通知', + 'component.globalHeader.message': '消息', + 'component.globalHeader.message.empty': '您已讀完所有消息', + 'component.globalHeader.event': '待辦', + 'component.globalHeader.event.empty': '妳已完成所有待辦', + 'component.noticeIcon.clear': '清空', + 'component.noticeIcon.cleared': '清空了', + 'component.noticeIcon.empty': '暫無資料', + 'component.noticeIcon.view-more': '查看更多', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/login.js b/antdsp-admin/src/main/web/src/locales/zh-TW/login.js new file mode 100644 index 0000000..fb91660 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/login.js @@ -0,0 +1,40 @@ +export default { + 'app.login.userName': '賬戶', + 'app.login.password': '密碼', + 'app.login.message-invalid-credentials': '賬戶或密碼錯誤(admin/ant.design)', + 'app.login.message-invalid-verification-code': '驗證碼錯誤', + 'app.login.tab-login-credentials': '賬戶密碼登錄', + 'app.login.tab-login-mobile': '手機號登錄', + 'app.login.remember-me': '自動登錄', + 'app.login.forgot-password': '忘記密碼', + 'app.login.sign-in-with': '其他登錄方式', + 'app.login.signup': '註冊賬戶', + 'app.login.login': '登錄', + 'app.register.register': '註冊', + 'app.register.get-verification-code': '獲取驗證碼', + 'app.login.verification-code-warning': + '此項目為演示項目,並不會真的給您發送驗證碼。請切換到賬戶密碼登錄界面按提示登錄。', + 'app.register.sign-in': '使用已有賬戶登錄', + 'app.register-result.msg': '妳的賬戶:{email} 註冊成功', + 'app.register-result.activation-email': + '激活郵件已發送到妳的郵箱中,郵件有效期為24小時。請及時登錄郵箱,點擊郵件中的鏈接激活帳戶。', + 'app.register-result.back-home': '返回首頁', + 'app.register-result.view-mailbox': '查看郵箱', + 'validation.email.required': '請輸入郵箱地址!', + 'validation.email.wrong-format': '郵箱地址格式錯誤!', + 'validation.userName.required': '請輸入賬戶!', + 'validation.password.required': '請輸入密碼!', + 'validation.password.twice': '兩次輸入的密碼不匹配!', + 'validation.password.strength.msg': '請至少輸入 6 個字符。請不要使用容易被猜到的密碼。', + 'validation.password.strength.strong': '強度:強', + 'validation.password.strength.medium': '強度:中', + 'validation.password.strength.short': '強度:太短', + 'validation.confirm-password.required': '請確認密碼!', + 'validation.phone-number.required': '請輸入手機號!', + 'validation.phone-number.wrong-format': '手機號格式錯誤!', + 'validation.verification-code.required': '請輸入驗證碼!', + 'validation.title.required': '請輸入標題', + 'validation.date.required': '請選擇起止日期', + 'validation.goal.required': '請輸入目標描述', + 'validation.standard.required': '請輸入衡量標淮', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/menu.js b/antdsp-admin/src/main/web/src/locales/zh-TW/menu.js new file mode 100644 index 0000000..2b1a49e --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/menu.js @@ -0,0 +1,45 @@ +export default { + 'menu.home': '首頁', + 'menu.login': '登錄', + 'menu.register': '註冊', + 'menu.register.resultt': '註冊結果', + 'menu.dashboard': 'Dashboard', + 'menu.dashboard.analysis': '分析頁', + 'menu.dashboard.monitor': '監控頁', + 'menu.dashboard.workplace': '工作臺', + 'menu.form': '表單頁', + 'menu.form.basicform': '基礎表單', + 'menu.form.stepform': '分步表單', + 'menu.form.stepform.info': '分步表單(填寫轉賬信息)', + 'menu.form.stepform.confirm': '分步表單(確認轉賬信息)', + 'menu.form.stepform.result': '分步表單(完成)', + 'menu.form.advancedform': '高級表單', + 'menu.list': '列表頁', + 'menu.list.searchtable': '查詢表格', + 'menu.list.basiclist': '標淮列表', + 'menu.list.cardlist': '卡片列表', + 'menu.list.searchlist': '搜索列表', + 'menu.list.searchlist.articles': '搜索列表(文章)', + 'menu.list.searchlist.projects': '搜索列表(項目)', + 'menu.list.searchlist.applications': '搜索列表(應用)', + 'menu.profile': '詳情頁', + 'menu.profile.basic': '基礎詳情頁', + 'menu.profile.advanced': '高級詳情頁', + 'menu.result': '結果頁', + 'menu.result.success': '成功頁', + 'menu.result.fail': '失敗頁', + 'menu.account': '個人頁', + 'menu.account.center': '個人中心', + 'menu.account.settings': '個人設置', + 'menu.account.trigger': '觸發報錯', + 'menu.account.logout': '退出登錄', + 'menu.exception': '异常页', + 'menu.exception.not-permission': '403', + 'menu.exception.not-find': '404', + 'menu.exception.server-error': '500', + 'menu.exception.trigger': '触发错误', + 'menu.editor': '圖形編輯器', + 'menu.editor.flow': '流程編輯器', + 'menu.editor.mind': '腦圖編輯器', + 'menu.editor.koni': '拓撲編輯器', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/monitor.js b/antdsp-admin/src/main/web/src/locales/zh-TW/monitor.js new file mode 100644 index 0000000..d19ac05 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/monitor.js @@ -0,0 +1,18 @@ +export default { + 'app.monitor.trading-activity': '活動實時交易情況', + 'app.monitor.total-transactions': '今日交易總額', + 'app.monitor.sales-target': '銷售目標完成率', + 'app.monitor.remaining-time': '活動剩余時間', + 'app.monitor.total-transactions-per-second': '每秒交易總額', + 'app.monitor.activity-forecast': '活動情況預測', + 'app.monitor.efficiency': '券核效率', + 'app.monitor.ratio': '跳出率', + 'app.monitor.proportion-per-category': '各品類占比', + 'app.monitor.fast-food': '中式快餐', + 'app.monitor.western-food': '西餐', + 'app.monitor.hot-pot': '火鍋', + 'app.monitor.waiting-for-implementation': 'Waiting for implementation', + 'app.monitor.popular-searches': '熱門搜索', + 'app.monitor.resource-surplus': '資源剩余', + 'app.monitor.fund-surplus': '補貼資金剩余', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/pwa.js b/antdsp-admin/src/main/web/src/locales/zh-TW/pwa.js new file mode 100644 index 0000000..108a6e4 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/pwa.js @@ -0,0 +1,6 @@ +export default { + 'app.pwa.offline': '當前處於離線狀態', + 'app.pwa.serviceworker.updated': '有新內容', + 'app.pwa.serviceworker.updated.hint': '請點擊“刷新”按鈕或者手動刷新頁面', + 'app.pwa.serviceworker.updated.ok': '刷新', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/result.js b/antdsp-admin/src/main/web/src/locales/zh-TW/result.js new file mode 100644 index 0000000..a87b96e --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/result.js @@ -0,0 +1,27 @@ +export default { + 'app.result.error.title': '提交失敗', + 'app.result.error.description': '請核對並修改以下信息後,再重新提交。', + 'app.result.error.hint-title': '您提交的內容有如下錯誤:', + 'app.result.error.hint-text1': '您的賬戶已被凍結', + 'app.result.error.hint-btn1': '立即解凍', + 'app.result.error.hint-text2': '您的賬戶還不具備申請資格', + 'app.result.error.hint-btn2': '立即升級', + 'app.result.error.btn-text': '返回修改', + 'app.result.success.title': '提交成功', + 'app.result.success.description': + '提交結果頁用於反饋壹系列操作任務的處理結果, 如果僅是簡單操作,使用 Message 全局提示反饋即可。 本文字區域可以展示簡單的補充說明,如果有類似展示 “單據”的需求,下面這個灰色區域可以呈現比較復雜的內容。', + 'app.result.success.operate-title': '項目名稱', + 'app.result.success.operate-id': '項目 ID:', + 'app.result.success.principal': '負責人:', + 'app.result.success.operate-time': '生效時間:', + 'app.result.success.step1-title': '創建項目', + 'app.result.success.step1-operator': '曲麗麗', + 'app.result.success.step2-title': '部門初審', + 'app.result.success.step2-operator': '周毛毛', + 'app.result.success.step2-extra': '催壹下', + 'app.result.success.step3-title': '財務復核', + 'app.result.success.step4-title': '完成', + 'app.result.success.btn-return': '返回列表', + 'app.result.success.btn-project': '查看項目', + 'app.result.success.btn-print': '打印', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/settingDrawer.js b/antdsp-admin/src/main/web/src/locales/zh-TW/settingDrawer.js new file mode 100644 index 0000000..24dc281 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/settingDrawer.js @@ -0,0 +1,31 @@ +export default { + 'app.setting.pagestyle': '整體風格設置', + 'app.setting.pagestyle.dark': '暗色菜單風格', + 'app.setting.pagestyle.light': '亮色菜單風格', + 'app.setting.content-width': '內容區域寬度', + 'app.setting.content-width.fixed': '定寬', + 'app.setting.content-width.fluid': '流式', + 'app.setting.themecolor': '主題色', + 'app.setting.themecolor.dust': '薄暮', + 'app.setting.themecolor.volcano': '火山', + 'app.setting.themecolor.sunset': '日暮', + 'app.setting.themecolor.cyan': '明青', + 'app.setting.themecolor.green': '極光綠', + 'app.setting.themecolor.daybreak': '拂曉藍(默認)', + 'app.setting.themecolor.geekblue': '極客藍', + 'app.setting.themecolor.purple': '醬紫', + 'app.setting.navigationmode': '導航模式', + 'app.setting.sidemenu': '側邊菜單布局', + 'app.setting.topmenu': '頂部菜單布局', + 'app.setting.fixedheader': '固定 Header', + 'app.setting.fixedsidebar': '固定側邊菜單', + 'app.setting.fixedsidebar.hint': '側邊菜單布局時可配置', + 'app.setting.hideheader': '下滑時隱藏 Header', + 'app.setting.hideheader.hint': '固定 Header 時可配置', + 'app.setting.othersettings': '其他設置', + 'app.setting.weakmode': '色弱模式', + 'app.setting.copy': '拷貝設置', + 'app.setting.copyinfo': '拷貝成功,請到 src/defaultSettings.js 中替換默認配置', + 'app.setting.production.hint': + '配置欄只在開發環境用於預覽,生產環境不會展現,請拷貝後手動修改配置文件', +}; diff --git a/antdsp-admin/src/main/web/src/locales/zh-TW/settings.js b/antdsp-admin/src/main/web/src/locales/zh-TW/settings.js new file mode 100644 index 0000000..dd45151 --- /dev/null +++ b/antdsp-admin/src/main/web/src/locales/zh-TW/settings.js @@ -0,0 +1,55 @@ +export default { + 'app.settings.menuMap.basic': '基本設置', + 'app.settings.menuMap.security': '安全設置', + 'app.settings.menuMap.binding': '賬號綁定', + 'app.settings.menuMap.notification': '新消息通知', + 'app.settings.basic.avatar': '頭像', + 'app.settings.basic.change-avatar': '更換頭像', + 'app.settings.basic.email': '郵箱', + 'app.settings.basic.email-message': '請輸入您的郵箱!', + 'app.settings.basic.nickname': '昵稱', + 'app.settings.basic.nickname-message': '請輸入您的昵稱!', + 'app.settings.basic.profile': '個人簡介', + 'app.settings.basic.profile-message': '請輸入個人簡介!', + 'app.settings.basic.profile-placeholder': '個人簡介', + 'app.settings.basic.country': '國家/地區', + 'app.settings.basic.country-message': '請輸入您的國家或地區!', + 'app.settings.basic.geographic': '所在省市', + 'app.settings.basic.geographic-message': '請輸入您的所在省市!', + 'app.settings.basic.address': '街道地址', + 'app.settings.basic.address-message': '請輸入您的街道地址!', + 'app.settings.basic.phone': '聯系電話', + 'app.settings.basic.phone-message': '請輸入您的聯系電話!', + 'app.settings.basic.update': '更新基本信息', + 'app.settings.security.strong': '強', + 'app.settings.security.medium': '中', + 'app.settings.security.weak': '弱', + 'app.settings.security.password': '賬戶密碼', + 'app.settings.security.password-description': '當前密碼強度', + 'app.settings.security.phone': '密保手機', + 'app.settings.security.phone-description': '已綁定手機', + 'app.settings.security.question': '密保問題', + 'app.settings.security.question-description': '未設置密保問題,密保問題可有效保護賬戶安全', + 'app.settings.security.email': '備用郵箱', + 'app.settings.security.email-description': '已綁定郵箱', + 'app.settings.security.mfa': 'MFA 設備', + 'app.settings.security.mfa-description': '未綁定 MFA 設備,綁定後,可以進行二次確認', + 'app.settings.security.modify': '修改', + 'app.settings.security.set': '設置', + 'app.settings.security.bind': '綁定', + 'app.settings.binding.taobao': '綁定淘寶', + 'app.settings.binding.taobao-description': '當前未綁定淘寶賬號', + 'app.settings.binding.alipay': '綁定支付寶', + 'app.settings.binding.alipay-description': '當前未綁定支付寶賬號', + 'app.settings.binding.dingding': '綁定釘釘', + 'app.settings.binding.dingding-description': '當前未綁定釘釘賬號', + 'app.settings.binding.bind': '綁定', + 'app.settings.notification.password': '賬戶密碼', + 'app.settings.notification.password-description': '其他用戶的消息將以站內信的形式通知', + 'app.settings.notification.messages': '系統消息', + 'app.settings.notification.messages-description': '系統消息將以站內信的形式通知', + 'app.settings.notification.todo': '待辦任務', + 'app.settings.notification.todo-description': '待辦任務將以站內信的形式通知', + 'app.settings.open': '開', + 'app.settings.close': '關', +}; diff --git a/antdsp-admin/src/main/web/src/manifest.json b/antdsp-admin/src/main/web/src/manifest.json new file mode 100644 index 0000000..839bc5b --- /dev/null +++ b/antdsp-admin/src/main/web/src/manifest.json @@ -0,0 +1,22 @@ +{ + "name": "Ant Design Pro", + "short_name": "Ant Design Pro", + "display": "standalone", + "start_url": "./?utm_source=homescreen", + "theme_color": "#002140", + "background_color": "#001529", + "icons": [ + { + "src": "icons/icon-192x192.png", + "sizes": "192x192" + }, + { + "src": "icons/icon-128x128.png", + "sizes": "128x128" + }, + { + "src": "icons/icon-512x512.png", + "sizes": "512x512" + } + ] +} diff --git a/antdsp-admin/src/main/web/src/models/global.js b/antdsp-admin/src/main/web/src/models/global.js new file mode 100644 index 0000000..34cff59 --- /dev/null +++ b/antdsp-admin/src/main/web/src/models/global.js @@ -0,0 +1,101 @@ +import { queryNotices } from '@/services/api'; + +export default { + namespace: 'global', + + state: { + collapsed: false, + notices: [], + }, + + effects: { + *fetchNotices(_, { call, put, select }) { + const data = yield call(queryNotices); + yield put({ + type: 'saveNotices', + payload: data, + }); + const unreadCount = yield select( + state => state.global.notices.filter(item => !item.read).length + ); + yield put({ + type: 'user/changeNotifyCount', + payload: { + totalCount: data.length, + unreadCount, + }, + }); + }, + *clearNotices({ payload }, { put, select }) { + yield put({ + type: 'saveClearedNotices', + payload, + }); + const count = yield select(state => state.global.notices.length); + const unreadCount = yield select( + state => state.global.notices.filter(item => !item.read).length + ); + yield put({ + type: 'user/changeNotifyCount', + payload: { + totalCount: count, + unreadCount, + }, + }); + }, + *changeNoticeReadState({ payload }, { put, select }) { + const notices = yield select(state => + state.global.notices.map(item => { + const notice = { ...item }; + if (notice.id === payload) { + notice.read = true; + } + return notice; + }) + ); + yield put({ + type: 'saveNotices', + payload: notices, + }); + yield put({ + type: 'user/changeNotifyCount', + payload: { + totalCount: notices.length, + unreadCount: notices.filter(item => !item.read).length, + }, + }); + }, + }, + + reducers: { + changeLayoutCollapsed(state, { payload }) { + return { + ...state, + collapsed: payload, + }; + }, + saveNotices(state, { payload }) { + return { + ...state, + notices: payload, + }; + }, + saveClearedNotices(state, { payload }) { + return { + ...state, + notices: state.notices.filter(item => item.type !== payload), + }; + }, + }, + + subscriptions: { + setup({ history }) { + // Subscribe history(url) change, trigger `load` action if pathname is `/` + return history.listen(({ pathname, search }) => { + if (typeof window.ga !== 'undefined') { + window.ga('send', 'pageview', pathname + search); + } + }); + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/models/list.js b/antdsp-admin/src/main/web/src/models/list.js new file mode 100644 index 0000000..4758eda --- /dev/null +++ b/antdsp-admin/src/main/web/src/models/list.js @@ -0,0 +1,54 @@ +import { queryFakeList, removeFakeList, addFakeList, updateFakeList } from '@/services/api'; + +export default { + namespace: 'list', + + state: { + list: [], + }, + + effects: { + *fetch({ payload }, { call, put }) { + const response = yield call(queryFakeList, payload); + yield put({ + type: 'queryList', + payload: Array.isArray(response) ? response : [], + }); + }, + *appendFetch({ payload }, { call, put }) { + const response = yield call(queryFakeList, payload); + yield put({ + type: 'appendList', + payload: Array.isArray(response) ? response : [], + }); + }, + *submit({ payload }, { call, put }) { + let callback; + if (payload.id) { + callback = Object.keys(payload).length === 1 ? removeFakeList : updateFakeList; + } else { + callback = addFakeList; + } + const response = yield call(callback, payload); // post + yield put({ + type: 'queryList', + payload: response, + }); + }, + }, + + reducers: { + queryList(state, action) { + return { + ...state, + list: action.payload, + }; + }, + appendList(state, action) { + return { + ...state, + list: state.list.concat(action.payload), + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/models/login.js b/antdsp-admin/src/main/web/src/models/login.js new file mode 100644 index 0000000..b5d226a --- /dev/null +++ b/antdsp-admin/src/main/web/src/models/login.js @@ -0,0 +1,80 @@ +import { routerRedux } from 'dva/router'; +import { stringify } from 'qs'; +import { fakeAccountLogin, getFakeCaptcha } from '@/services/api'; +import { setAuthority } from '@/utils/authority'; +import { getPageQuery } from '@/utils/utils'; +import { reloadAuthorized } from '@/utils/Authorized'; + +export default { + namespace: 'login', + + state: { + status: undefined, + }, + + effects: { + *login({ payload }, { call, put }) { + const response = yield call(fakeAccountLogin, payload); + yield put({ + type: 'changeLoginStatus', + payload: response, + }); + // Login successfully + if (response.status === 'ok') { + reloadAuthorized(); + const urlParams = new URL(window.location.href); + const params = getPageQuery(); + let { redirect } = params; + if (redirect) { + const redirectUrlParams = new URL(redirect); + if (redirectUrlParams.origin === urlParams.origin) { + redirect = redirect.substr(urlParams.origin.length); + if (redirect.match(/^\/.*#/)) { + redirect = redirect.substr(redirect.indexOf('#') + 1); + } + } else { + redirect = null; + } + } + yield put(routerRedux.replace(redirect || '/')); + } + }, + + *getCaptcha({ payload }, { call }) { + yield call(getFakeCaptcha, payload); + }, + + *logout(_, { put }) { + yield put({ + type: 'changeLoginStatus', + payload: { + status: false, + currentAuthority: 'guest', + }, + }); + reloadAuthorized(); + // redirect + if (window.location.pathname !== '/user/login') { + yield put( + routerRedux.replace({ + pathname: '/user/login', + search: stringify({ + redirect: window.location.href, + }), + }) + ); + } + }, + }, + + reducers: { + changeLoginStatus(state, { payload }) { + setAuthority(payload.currentAuthority); + return { + ...state, + status: payload.status, + type: payload.type, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/models/menu.js b/antdsp-admin/src/main/web/src/models/menu.js new file mode 100644 index 0000000..3d98f2d --- /dev/null +++ b/antdsp-admin/src/main/web/src/models/menu.js @@ -0,0 +1,131 @@ +import memoizeOne from 'memoize-one'; +import isEqual from 'lodash/isEqual'; +import { formatMessage } from 'umi-plugin-react/locale'; +import Authorized from '@/utils/Authorized'; +import { menu } from '../defaultSettings'; + +const { check } = Authorized; + +// Conversion router to menu. +function formatter(data, parentAuthority, parentName) { + if (!data) { + return undefined; + } + return data + .map(item => { + if (!item.name || !item.path) { + return null; + } + + let locale = 'menu'; + if (parentName && parentName !== '/') { + locale = `${parentName}.${item.name}`; + } else { + locale = `menu.${item.name}`; + } + // if enableMenuLocale use item.name, + // close menu international + const name = menu.disableLocal + ? item.name + : formatMessage({ id: locale, defaultMessage: item.name }); + const result = { + ...item, + name, + locale, + authority: item.authority || parentAuthority, + }; + if (item.routes) { + const children = formatter(item.routes, item.authority, locale); + // Reduce memory usage + result.children = children; + } + delete result.routes; + return result; + }) + .filter(item => item); +} + +const memoizeOneFormatter = memoizeOne(formatter, isEqual); + +/** + * get SubMenu or Item + */ +const getSubMenu = item => { + // doc: add hideChildrenInMenu + if (item.children && !item.hideChildrenInMenu && item.children.some(child => child.name)) { + return { + ...item, + children: filterMenuData(item.children), // eslint-disable-line + }; + } + return item; +}; + +/** + * filter menuData + */ +const filterMenuData = menuData => { + if (!menuData) { + return []; + } + return menuData + .filter(item => item.name && !item.hideInMenu) + .map(item => check(item.authority, getSubMenu(item))) + .filter(item => item); +}; +/** + * 获取面包屑映射 + * @param {Object} menuData 菜单配置 + */ +const getBreadcrumbNameMap = menuData => { + if (!menuData) { + return {}; + } + const routerMap = {}; + + const flattenMenuData = data => { + data.forEach(menuItem => { + if (menuItem.children) { + flattenMenuData(menuItem.children); + } + // Reduce memory usage + routerMap[menuItem.path] = menuItem; + }); + }; + flattenMenuData(menuData); + return routerMap; +}; + +const memoizeOneGetBreadcrumbNameMap = memoizeOne(getBreadcrumbNameMap, isEqual); + +export default { + namespace: 'menu', + + state: { + menuData: [], + routerData: [], + breadcrumbNameMap: {}, + }, + + effects: { + *getMenuData({ payload }, { put }) { + const { routes, authority, path } = payload; + const originalMenuData = memoizeOneFormatter(routes, authority, path); + const menuData = filterMenuData(originalMenuData); + const breadcrumbNameMap = memoizeOneGetBreadcrumbNameMap(originalMenuData); + yield put({ + type: 'save', + payload: { menuData, breadcrumbNameMap, routerData: routes }, + }); + }, + }, + + reducers: { + save(state, action) { + return { + ...state, + ...action.payload, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/models/project.js b/antdsp-admin/src/main/web/src/models/project.js new file mode 100644 index 0000000..cf89412 --- /dev/null +++ b/antdsp-admin/src/main/web/src/models/project.js @@ -0,0 +1,28 @@ +import { queryProjectNotice } from '@/services/api'; + +export default { + namespace: 'project', + + state: { + notice: [], + }, + + effects: { + *fetchNotice(_, { call, put }) { + const response = yield call(queryProjectNotice); + yield put({ + type: 'saveNotice', + payload: Array.isArray(response) ? response : [], + }); + }, + }, + + reducers: { + saveNotice(state, action) { + return { + ...state, + notice: action.payload, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/models/setting.js b/antdsp-admin/src/main/web/src/models/setting.js new file mode 100644 index 0000000..3956ed3 --- /dev/null +++ b/antdsp-admin/src/main/web/src/models/setting.js @@ -0,0 +1,124 @@ +import { message } from 'antd'; +import defaultSettings from '../defaultSettings'; + +let lessNodesAppended; +const updateTheme = primaryColor => { + // Don't compile less in production! + // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION !== 'site') { + return; + } + // Determine if the component is remounted + if (!primaryColor) { + return; + } + const hideMessage = message.loading('正在编译主题!', 0); + function buildIt() { + if (!window.less) { + return; + } + setTimeout(() => { + window.less + .modifyVars({ + '@primary-color': primaryColor, + }) + .then(() => { + hideMessage(); + }) + .catch(() => { + message.error('Failed to update theme'); + hideMessage(); + }); + }, 200); + } + if (!lessNodesAppended) { + // insert less.js and color.less + const lessStyleNode = document.createElement('link'); + const lessConfigNode = document.createElement('script'); + const lessScriptNode = document.createElement('script'); + lessStyleNode.setAttribute('rel', 'stylesheet/less'); + lessStyleNode.setAttribute('href', '/color.less'); + lessConfigNode.innerHTML = ` + window.less = { + async: true, + env: 'production', + javascriptEnabled: true + }; + `; + lessScriptNode.src = 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js'; + lessScriptNode.async = true; + lessScriptNode.onload = () => { + buildIt(); + lessScriptNode.onload = null; + }; + document.body.appendChild(lessStyleNode); + document.body.appendChild(lessConfigNode); + document.body.appendChild(lessScriptNode); + lessNodesAppended = true; + } else { + buildIt(); + } +}; + +const updateColorWeak = colorWeak => { + document.body.className = colorWeak ? 'colorWeak' : ''; +}; + +export default { + namespace: 'setting', + state: defaultSettings, + reducers: { + getSetting(state) { + const setting = {}; + const urlParams = new URL(window.location.href); + Object.keys(state).forEach(key => { + if (urlParams.searchParams.has(key)) { + const value = urlParams.searchParams.get(key); + setting[key] = value === '1' ? true : value; + } + }); + const { primaryColor, colorWeak } = setting; + if (state.primaryColor !== primaryColor) { + updateTheme(primaryColor); + } + updateColorWeak(colorWeak); + return { + ...state, + ...setting, + }; + }, + changeSetting(state, { payload }) { + const urlParams = new URL(window.location.href); + Object.keys(defaultSettings).forEach(key => { + if (urlParams.searchParams.has(key)) { + urlParams.searchParams.delete(key); + } + }); + Object.keys(payload).forEach(key => { + if (key === 'collapse') { + return; + } + let value = payload[key]; + if (value === true) { + value = 1; + } + if (defaultSettings[key] !== value) { + urlParams.searchParams.set(key, value); + } + }); + const { primaryColor, colorWeak, contentWidth } = payload; + if (state.primaryColor !== primaryColor) { + updateTheme(primaryColor); + } + if (state.contentWidth !== contentWidth && window.dispatchEvent) { + window.dispatchEvent(new Event('resize')); + } + updateColorWeak(colorWeak); + window.history.replaceState(null, 'setting', urlParams.href); + return { + ...state, + ...payload, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/models/user.js b/antdsp-admin/src/main/web/src/models/user.js new file mode 100644 index 0000000..c84ebbc --- /dev/null +++ b/antdsp-admin/src/main/web/src/models/user.js @@ -0,0 +1,52 @@ +import { query as queryUsers, queryCurrent } from '@/services/user'; + +export default { + namespace: 'user', + + state: { + list: [], + currentUser: {}, + }, + + effects: { + *fetch(_, { call, put }) { + const response = yield call(queryUsers); + yield put({ + type: 'save', + payload: response, + }); + }, + *fetchCurrent(_, { call, put }) { + const response = yield call(queryCurrent); + yield put({ + type: 'saveCurrentUser', + payload: response, + }); + }, + }, + + reducers: { + save(state, action) { + return { + ...state, + list: action.payload, + }; + }, + saveCurrentUser(state, action) { + return { + ...state, + currentUser: action.payload || {}, + }; + }, + changeNotifyCount(state, action) { + return { + ...state, + currentUser: { + ...state.currentUser, + notifyCount: action.payload.totalCount, + unreadCount: action.payload.unreadCount, + }, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/pages/404.js b/antdsp-admin/src/main/web/src/pages/404.js new file mode 100644 index 0000000..ada3484 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/404.js @@ -0,0 +1,13 @@ +import React from 'react'; +import Link from 'umi/link'; +import { formatMessage } from 'umi-plugin-react/locale'; +import Exception from '@/components/Exception'; + +export default () => ( + +); diff --git a/antdsp-admin/src/main/web/src/pages/Authorized.js b/antdsp-admin/src/main/web/src/pages/Authorized.js new file mode 100644 index 0000000..5889812 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Authorized.js @@ -0,0 +1,38 @@ +import React from 'react'; +import Redirect from 'umi/redirect'; +import pathToRegexp from 'path-to-regexp'; +import { connect } from 'dva'; +import Authorized from '@/utils/Authorized'; +import { getAuthority } from '@/utils/authority'; +import Exception403 from '@/pages/Exception/403'; + +function AuthComponent({ children, location, routerData }) { + const auth = getAuthority(); + const isLogin = auth && auth[0] !== 'guest'; + const getRouteAuthority = (path, routeData) => { + let authorities; + routeData.forEach(route => { + // match prefix + if (pathToRegexp(`${route.path}(.*)`).test(path)) { + authorities = route.authority || authorities; + + // get children authority recursively + if (route.routes) { + authorities = getRouteAuthority(path, route.routes) || authorities; + } + } + }); + return authorities; + }; + return ( + : } + > + {children} + + ); +} +export default connect(({ menu: menuModel }) => ({ + routerData: menuModel.routerData, +}))(AuthComponent); diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.js b/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.js new file mode 100644 index 0000000..0d222cc --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.js @@ -0,0 +1,184 @@ +import React, { Component, Suspense } from 'react'; +import { connect } from 'dva'; +import { Row, Col, Icon, Menu, Dropdown } from 'antd'; +import GridContent from '@/components/PageHeaderWrapper/GridContent'; +import { getTimeDistance } from '@/utils/utils'; +import styles from './Analysis.less'; +import PageLoading from '@/components/PageLoading'; + +const IntroduceRow = React.lazy(() => import('./IntroduceRow')); +const SalesCard = React.lazy(() => import('./SalesCard')); +const TopSearch = React.lazy(() => import('./TopSearch')); +const ProportionSales = React.lazy(() => import('./ProportionSales')); +const OfflineData = React.lazy(() => import('./OfflineData')); + +@connect(({ chart, loading }) => ({ + chart, + loading: loading.effects['chart/fetch'], +})) +class Analysis extends Component { + state = { + salesType: 'all', + currentTabKey: '', + rangePickerValue: getTimeDistance('year'), + }; + + componentDidMount() { + const { dispatch } = this.props; + this.reqRef = requestAnimationFrame(() => { + dispatch({ + type: 'chart/fetch', + }); + }); + } + + componentWillUnmount() { + const { dispatch } = this.props; + dispatch({ + type: 'chart/clear', + }); + cancelAnimationFrame(this.reqRef); + } + + handleChangeSalesType = e => { + this.setState({ + salesType: e.target.value, + }); + }; + + handleTabChange = key => { + this.setState({ + currentTabKey: key, + }); + }; + + handleRangePickerChange = rangePickerValue => { + const { dispatch } = this.props; + this.setState({ + rangePickerValue, + }); + + dispatch({ + type: 'chart/fetchSalesData', + }); + }; + + selectDate = type => { + const { dispatch } = this.props; + this.setState({ + rangePickerValue: getTimeDistance(type), + }); + + dispatch({ + type: 'chart/fetchSalesData', + }); + }; + + isActive = type => { + const { rangePickerValue } = this.state; + const value = getTimeDistance(type); + if (!rangePickerValue[0] || !rangePickerValue[1]) { + return ''; + } + if ( + rangePickerValue[0].isSame(value[0], 'day') && + rangePickerValue[1].isSame(value[1], 'day') + ) { + return styles.currentDate; + } + return ''; + }; + + render() { + const { rangePickerValue, salesType, currentTabKey } = this.state; + const { chart, loading } = this.props; + const { + visitData, + visitData2, + salesData, + searchData, + offlineData, + offlineChartData, + salesTypeData, + salesTypeDataOnline, + salesTypeDataOffline, + } = chart; + let salesPieData; + if (salesType === 'all') { + salesPieData = salesTypeData; + } else { + salesPieData = salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline; + } + const menu = ( + + 操作一 + 操作二 + + ); + + const dropdownGroup = ( + + + + + + ); + + const activeKey = currentTabKey || (offlineData[0] && offlineData[0].name); + + return ( + + }> + + + + + +
    + +
    + + + + + + + + + + + + + + + + ); + } +} + +export default Analysis; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.less b/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.less new file mode 100644 index 0000000..f71bd34 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.less @@ -0,0 +1,198 @@ +@import '~antd/lib/style/themes/default.less'; +@import '~@/utils/utils.less'; + +.iconGroup { + i { + margin-left: 16px; + color: @text-color-secondary; + cursor: pointer; + transition: color 0.32s; + &:hover { + color: @text-color; + } + } +} + +.rankingList { + margin: 25px 0 0; + padding: 0; + list-style: none; + li { + .clearfix(); + + display: flex; + align-items: center; + margin-top: 16px; + span { + color: @text-color; + font-size: 14px; + line-height: 22px; + } + .rankingItemNumber { + display: inline-block; + width: 20px; + height: 20px; + margin-top: 1.5px; + margin-right: 16px; + font-weight: 600; + font-size: 12px; + line-height: 20px; + text-align: center; + background-color: @background-color-base; + border-radius: 20px; + &.active { + color: #fff; + background-color: #314659; + } + } + .rankingItemTitle { + flex: 1; + margin-right: 8px; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + } + } +} + +.salesExtra { + display: inline-block; + margin-right: 24px; + a { + margin-left: 24px; + color: @text-color; + &:hover { + color: @primary-color; + } + &.currentDate { + color: @primary-color; + } + } +} + +.salesCard { + .salesBar { + padding: 0 0 32px 32px; + } + .salesRank { + padding: 0 32px 32px 72px; + } + :global { + .ant-tabs-bar { + padding-left: 16px; + .ant-tabs-nav .ant-tabs-tab { + padding-top: 16px; + padding-bottom: 14px; + line-height: 24px; + } + } + .ant-tabs-extra-content { + padding-right: 24px; + line-height: 55px; + } + .ant-card-head { + position: relative; + } + .ant-card-head-title { + align-items: normal; + } + } +} + +.salesCardExtra { + height: inherit; +} + +.salesTypeRadio { + position: absolute; + right: 54px; + bottom: 12px; +} + +.offlineCard { + :global { + .ant-tabs-ink-bar { + bottom: auto; + } + .ant-tabs-bar { + border-bottom: none; + } + .ant-tabs-nav-container-scrolling { + padding-right: 40px; + padding-left: 40px; + } + .ant-tabs-tab-prev-icon::before { + position: relative; + left: 6px; + } + .ant-tabs-tab-next-icon::before { + position: relative; + right: 6px; + } + .ant-tabs-tab-active h4 { + color: @primary-color; + } + } +} + +.twoColLayout { + .salesCard { + height: calc(100% - 24px); + } + div[class^='ant-col']:last-child { + position: absolute\9; + right: 0\9; + height: 100%\9; + } + :global { + .ant-row { + position: relative\9; + display: flex; + display: block\9; + flex-flow: row wrap; + } + } +} + +.trendText { + margin-left: 8px; + color: @heading-color; +} + +@media screen and (max-width: @screen-lg) { + .salesExtra { + display: none; + } + + .rankingList { + li { + span:first-child { + margin-right: 8px; + } + } + } +} + +@media screen and (max-width: @screen-md) { + .rankingTitle { + margin-top: 16px; + } + + .salesCard .salesBar { + padding: 16px; + } +} + +@media screen and (max-width: @screen-sm) { + .salesExtraWrap { + display: none; + } + + .salesCard { + :global { + .ant-tabs-content { + padding-top: 30px; + } + } + } +} diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/IntroduceRow.js b/antdsp-admin/src/main/web/src/pages/Dashboard/IntroduceRow.js new file mode 100644 index 0000000..f7e67df --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/IntroduceRow.js @@ -0,0 +1,152 @@ +import React, { memo } from 'react'; +import { Row, Col, Icon, Tooltip } from 'antd'; +import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale'; +import styles from './Analysis.less'; +import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from '@/components/Charts'; +import Trend from '@/components/Trend'; +import numeral from 'numeral'; +import Yuan from '@/utils/Yuan'; + +const topColResponsiveProps = { + xs: 24, + sm: 12, + md: 12, + lg: 12, + xl: 6, + style: { marginBottom: 24 }, +}; + +const IntroduceRow = memo(({ loading, visitData }) => ( + + + } + action={ + } + > + + + } + loading={loading} + total={() => 126560} + footer={ + } + value={`¥${numeral(12423).format('0,0')}`} + /> + } + contentHeight={46} + > + + + 12% + + + + 11% + + + + + + } + action={ + } + > + + + } + total={numeral(8846).format('0,0')} + footer={ + } + value={numeral(1234).format('0,0')} + /> + } + contentHeight={46} + > + + + + + } + action={ + } + > + + + } + total={numeral(6560).format('0,0')} + footer={ + + } + value="60%" + /> + } + contentHeight={46} + > + + + + + + } + action={ + } + > + + + } + total="78%" + footer={ +
    + + + 12% + + + + 11% + +
    + } + contentHeight={46} + > + +
    + + +)); + +export default IntroduceRow; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.js b/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.js new file mode 100644 index 0000000..de80353 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.js @@ -0,0 +1,244 @@ +import React, { Component } from 'react'; +import { connect } from 'dva'; +import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; +import { Row, Col, Card, Tooltip } from 'antd'; +import { Pie, WaterWave, Gauge, TagCloud } from '@/components/Charts'; +import NumberInfo from '@/components/NumberInfo'; +import CountDown from '@/components/CountDown'; +import ActiveChart from '@/components/ActiveChart'; +import numeral from 'numeral'; +import GridContent from '@/components/PageHeaderWrapper/GridContent'; +import Authorized from '@/utils/Authorized'; +import styles from './Monitor.less'; + +const { Secured } = Authorized; + +const targetTime = new Date().getTime() + 3900000; + +// use permission as a parameter +const havePermissionAsync = new Promise(resolve => { + // Call resolve on behalf of passed + setTimeout(() => resolve(), 300); +}); + +@Secured(havePermissionAsync) +@connect(({ monitor, loading }) => ({ + monitor, + loading: loading.models.monitor, +})) +class Monitor extends Component { + componentDidMount() { + const { dispatch } = this.props; + dispatch({ + type: 'monitor/fetchTags', + }); + } + + render() { + const { monitor, loading } = this.props; + const { tags } = monitor; + + return ( + + + + + } + bordered={false} + > + + + + } + suffix="元" + total={numeral(124543233).format('0,0')} + /> + + + + } + total="92%" + /> + + + + } + total={} + /> + + + + } + suffix="元" + total={numeral(234).format('0,0')} + /> + + +
    + + } + > + map + +
    + + +
    + + } + style={{ marginBottom: 24 }} + bordered={false} + > + + + } + style={{ marginBottom: 24 }} + bodyStyle={{ textAlign: 'center' }} + bordered={false} + > + + + + + + + + } + bordered={false} + className={styles.pieCard} + > + + + + } + total="28%" + height={128} + lineWidth={2} + /> + + + + } + total="22%" + height={128} + lineWidth={2} + /> + + + + } + total="32%" + height={128} + lineWidth={2} + /> + + + + + + + } + loading={loading} + bordered={false} + bodyStyle={{ overflow: 'hidden' }} + > + + + + + + } + bodyStyle={{ textAlign: 'center', fontSize: 0 }} + bordered={false} + > + + } + percent={34} + /> + + + + + ); + } +} + +export default Monitor; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.less b/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.less new file mode 100644 index 0000000..82d7272 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.less @@ -0,0 +1,23 @@ +@import '~antd/lib/style/themes/default.less'; +@import '~@/utils/utils.less'; + +.mapChart { + height: 452px; + padding-top: 24px; + text-align: center; + img { + display: inline-block; + max-width: 100%; + max-height: 437px; + } +} + +.pieCard :global(.pie-stat) { + font-size: 24px !important; +} + +@media screen and (max-width: @screen-lg) { + .mapChart { + height: auto; + } +} diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/OfflineData.js b/antdsp-admin/src/main/web/src/pages/Dashboard/OfflineData.js new file mode 100644 index 0000000..7179131 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/OfflineData.js @@ -0,0 +1,65 @@ +import React, { memo } from 'react'; +import { Card, Tabs, Row, Col } from 'antd'; +import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; +import styles from './Analysis.less'; +import { TimelineChart, Pie } from '@/components/Charts'; +import NumberInfo from '@/components/NumberInfo'; + +const CustomTab = ({ data, currentTabKey: currentKey }) => ( + + + + } + gap={2} + total={`${data.cvr * 100}%`} + theme={currentKey !== data.name && 'light'} + /> + + + + + +); + +const { TabPane } = Tabs; + +const OfflineData = memo( + ({ activeKey, loading, offlineData, offlineChartData, handleTabChange }) => ( + + + {offlineData.map(shop => ( + } key={shop.name}> +
    + +
    +
    + ))} +
    +
    + ) +); + +export default OfflineData; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/ProportionSales.js b/antdsp-admin/src/main/web/src/pages/Dashboard/ProportionSales.js new file mode 100644 index 0000000..3977130 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/ProportionSales.js @@ -0,0 +1,58 @@ +import React, { memo } from 'react'; +import { Card, Radio } from 'antd'; +import { FormattedMessage } from 'umi-plugin-react/locale'; +import styles from './Analysis.less'; +import { Pie } from '@/components/Charts'; +import Yuan from '@/utils/Yuan'; + +const ProportionSales = memo( + ({ dropdownGroup, salesType, loading, salesPieData, handleChangeSalesType }) => ( + + } + bodyStyle={{ padding: 24 }} + extra={ +
    + {dropdownGroup} +
    + + + + + + + + + + + +
    +
    + } + style={{ marginTop: 24 }} + > +

    + +

    + } + total={() => {salesPieData.reduce((pre, now) => now.y + pre, 0)}} + data={salesPieData} + valueFormat={value => {value}} + height={270} + lineWidth={4} + style={{ padding: '8px 0' }} + /> +
    + ) +); + +export default ProportionSales; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/SalesCard.js b/antdsp-admin/src/main/web/src/pages/Dashboard/SalesCard.js new file mode 100644 index 0000000..ee6adf2 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/SalesCard.js @@ -0,0 +1,150 @@ +import React, { memo } from 'react'; +import { Row, Col, Card, Tabs, DatePicker } from 'antd'; +import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale'; +import numeral from 'numeral'; +import styles from './Analysis.less'; +import { Bar } from '@/components/Charts'; + +const { RangePicker } = DatePicker; +const { TabPane } = Tabs; + +const rankingListData = []; +for (let i = 0; i < 7; i += 1) { + rankingListData.push({ + title: formatMessage({ id: 'app.analysis.test' }, { no: i }), + total: 323234, + }); +} + +const SalesCard = memo( + ({ rangePickerValue, salesData, isActive, handleRangePickerChange, loading, selectDate }) => ( + + + } + size="large" + tabBarStyle={{ marginBottom: 24 }} + > + } + key="sales" + > + +
    +
    + + } + data={salesData} + /> +
    + + +
    +

    + +

    +
      + {rankingListData.map((item, i) => ( +
    • + + {i + 1} + + + {item.title} + + + {numeral(item.total).format('0,0')} + +
    • + ))} +
    +
    + + + + } + key="views" + > + + +
    + + } + data={salesData} + /> +
    + + +
    +

    + +

    +
      + {rankingListData.map((item, i) => ( +
    • + + {i + 1} + + + {item.title} + + {numeral(item.total).format('0,0')} +
    • + ))} +
    +
    + + + + + + + ) +); + +export default SalesCard; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/TopSearch.js b/antdsp-admin/src/main/web/src/pages/Dashboard/TopSearch.js new file mode 100644 index 0000000..bd89395 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/TopSearch.js @@ -0,0 +1,111 @@ +import React, { memo } from 'react'; +import { Row, Col, Table, Tooltip, Card, Icon } from 'antd'; +import { FormattedMessage } from 'umi-plugin-react/locale'; +import Trend from '@/components/Trend'; +import numeral from 'numeral'; +import styles from './Analysis.less'; +import NumberInfo from '@/components/NumberInfo'; +import { MiniArea } from '@/components/Charts'; + +const columns = [ + { + title: , + dataIndex: 'index', + key: 'index', + }, + { + title: ( + + ), + dataIndex: 'keyword', + key: 'keyword', + render: text => {text}, + }, + { + title: , + dataIndex: 'count', + key: 'count', + sorter: (a, b) => a.count - b.count, + className: styles.alignRight, + }, + { + title: , + dataIndex: 'range', + key: 'range', + sorter: (a, b) => a.range - b.range, + render: (text, record) => ( + + {text}% + + ), + align: 'right', + }, +]; + +const TopSearch = memo(({ loading, visitData2, searchData, dropdownGroup }) => ( + + } + extra={dropdownGroup} + style={{ marginTop: 24 }} + > + + + + + } + > + + + + } + gap={8} + total={numeral(12321).format('0,0')} + status="up" + subTotal={17.1} + /> + + + + + + } + > + + + + } + total={2.7} + status="down" + subTotal={26.2} + gap={8} + /> + + + +
    record.index} + size="small" + columns={columns} + dataSource={searchData} + pagination={{ + style: { marginBottom: 0 }, + pageSize: 5, + }} + /> + +)); + +export default TopSearch; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.js b/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.js new file mode 100644 index 0000000..d71b122 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.js @@ -0,0 +1,255 @@ +import React, { PureComponent } from 'react'; +import moment from 'moment'; +import { connect } from 'dva'; +import Link from 'umi/link'; +import { Row, Col, Card, List, Avatar } from 'antd'; +import { Radar } from '@/components/Charts'; +import EditableLinkGroup from '@/components/EditableLinkGroup'; +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; + +import styles from './Workplace.less'; + +const links = [ + { + title: '操作一', + href: '', + }, + { + title: '操作二', + href: '', + }, + { + title: '操作三', + href: '', + }, + { + title: '操作四', + href: '', + }, + { + title: '操作五', + href: '', + }, + { + title: '操作六', + href: '', + }, +]; + +@connect(({ user, project, activities, chart, loading }) => ({ + currentUser: user.currentUser, + project, + activities, + chart, + currentUserLoading: loading.effects['user/fetchCurrent'], + projectLoading: loading.effects['project/fetchNotice'], + activitiesLoading: loading.effects['activities/fetchList'], +})) +class Workplace extends PureComponent { + componentDidMount() { + const { dispatch } = this.props; + dispatch({ + type: 'user/fetchCurrent', + }); + dispatch({ + type: 'project/fetchNotice', + }); + dispatch({ + type: 'activities/fetchList', + }); + dispatch({ + type: 'chart/fetch', + }); + } + + componentWillUnmount() { + const { dispatch } = this.props; + dispatch({ + type: 'chart/clear', + }); + } + + renderActivities() { + const { + activities: { list }, + } = this.props; + return list.map(item => { + const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => { + if (item[key]) { + return ( + + {item[key].name} + + ); + } + return key; + }); + return ( + + } + title={ + + {item.user.name} +   + {events} + + } + description={ + + {moment(item.updatedAt).fromNow()} + + } + /> + + ); + }); + } + + render() { + const { + currentUser, + currentUserLoading, + project: { notice }, + projectLoading, + activitiesLoading, + chart: { radarData }, + } = this.props; + + const pageHeaderContent = + currentUser && Object.keys(currentUser).length ? ( +
    +
    + +
    +
    +
    + 早安, + {currentUser.name} + ,祝你开心每一天! +
    +
    + {currentUser.title} |{currentUser.group} +
    +
    +
    + ) : null; + + const extraContent = ( +
    +
    +

    项目数

    +

    56

    +
    +
    +

    团队内排名

    +

    + 8 / 24 +

    +
    +
    +

    项目访问

    +

    2,223

    +
    +
    + ); + + return ( + + + + 全部项目} + loading={projectLoading} + bodyStyle={{ padding: 0 }} + > + {notice.map(item => ( + + + + + {item.title} + + } + description={item.description} + /> +
    + {item.member || ''} + {item.updatedAt && ( + + {moment(item.updatedAt).fromNow()} + + )} +
    +
    +
    + ))} +
    + + +
    {this.renderActivities()}
    +
    +
    + + + + {}} links={links} linkElement={Link} /> + + +
    + +
    +
    + +
    + + {notice.map(item => ( +
    + + + {item.member} + + + ))} + + + + + + + ); + } +} + +export default Workplace; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.less b/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.less new file mode 100644 index 0000000..b67e0b6 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.less @@ -0,0 +1,228 @@ +@import '~antd/lib/style/themes/default.less'; +@import '~@/utils/utils.less'; + +.activitiesList { + padding: 0 24px 8px 24px; + .username { + color: @text-color; + } + .event { + font-weight: normal; + } +} + +.pageHeaderContent { + display: flex; + .avatar { + flex: 0 1 72px; + margin-bottom: 8px; + & > span { + display: block; + width: 72px; + height: 72px; + border-radius: 72px; + } + } + .content { + position: relative; + top: 4px; + flex: 1 1 auto; + margin-left: 24px; + color: @text-color-secondary; + line-height: 22px; + .contentTitle { + margin-bottom: 12px; + color: @heading-color; + font-weight: 500; + font-size: 20px; + line-height: 28px; + } + } +} + +.extraContent { + .clearfix(); + + float: right; + white-space: nowrap; + .statItem { + position: relative; + display: inline-block; + padding: 0 32px; + > p:first-child { + margin-bottom: 4px; + color: @text-color-secondary; + font-size: @font-size-base; + line-height: 22px; + } + > p { + margin: 0; + color: @heading-color; + font-size: 30px; + line-height: 38px; + > span { + color: @text-color-secondary; + font-size: 20px; + } + } + &::after { + position: absolute; + top: 8px; + right: 0; + width: 1px; + height: 40px; + background-color: @border-color-split; + content: ''; + } + &:last-child { + padding-right: 0; + &::after { + display: none; + } + } + } +} + +.members { + a { + display: block; + height: 24px; + margin: 12px 0; + color: @text-color; + transition: all 0.3s; + .textOverflow(); + .member { + margin-left: 12px; + font-size: @font-size-base; + line-height: 24px; + vertical-align: top; + } + &:hover { + color: @primary-color; + } + } +} + +.projectList { + :global { + .ant-card-meta-description { + height: 44px; + overflow: hidden; + color: @text-color-secondary; + line-height: 22px; + } + } + .cardTitle { + font-size: 0; + a { + display: inline-block; + height: 24px; + margin-left: 12px; + color: @heading-color; + font-size: @font-size-base; + line-height: 24px; + vertical-align: top; + &:hover { + color: @primary-color; + } + } + } + .projectGrid { + width: 33.33%; + } + .projectItemContent { + display: flex; + height: 20px; + margin-top: 8px; + overflow: hidden; + font-size: 12px; + line-height: 20px; + .textOverflow(); + a { + display: inline-block; + flex: 1 1 0; + color: @text-color-secondary; + .textOverflow(); + &:hover { + color: @primary-color; + } + } + .datetime { + flex: 0 0 auto; + float: right; + color: @disabled-color; + } + } +} + +.datetime { + color: @disabled-color; +} + +@media screen and (max-width: @screen-xl) and (min-width: @screen-lg) { + .activeCard { + margin-bottom: 24px; + } + .members { + margin-bottom: 0; + } + .extraContent { + margin-left: -44px; + .statItem { + padding: 0 16px; + } + } +} + +@media screen and (max-width: @screen-lg) { + .activeCard { + margin-bottom: 24px; + } + .members { + margin-bottom: 0; + } + .extraContent { + float: none; + margin-right: 0; + .statItem { + padding: 0 16px; + text-align: left; + &::after { + display: none; + } + } + } +} + +@media screen and (max-width: @screen-md) { + .extraContent { + margin-left: -16px; + } + .projectList { + .projectGrid { + width: 50%; + } + } +} + +@media screen and (max-width: @screen-sm) { + .pageHeaderContent { + display: block; + .content { + margin-left: 0; + } + } + .extraContent { + .statItem { + float: none; + } + } +} + +@media screen and (max-width: @screen-xs) { + .projectList { + .projectGrid { + width: 100%; + } + } +} diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/models/activities.js b/antdsp-admin/src/main/web/src/pages/Dashboard/models/activities.js new file mode 100644 index 0000000..4e0a11e --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/models/activities.js @@ -0,0 +1,28 @@ +import { queryActivities } from '@/services/api'; + +export default { + namespace: 'activities', + + state: { + list: [], + }, + + effects: { + *fetchList(_, { call, put }) { + const response = yield call(queryActivities); + yield put({ + type: 'saveList', + payload: Array.isArray(response) ? response : [], + }); + }, + }, + + reducers: { + saveList(state, action) { + return { + ...state, + list: action.payload, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/models/chart.js b/antdsp-admin/src/main/web/src/pages/Dashboard/models/chart.js new file mode 100644 index 0000000..8dfe4a9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/models/chart.js @@ -0,0 +1,61 @@ +import { fakeChartData } from '@/services/api'; + +export default { + namespace: 'chart', + + state: { + visitData: [], + visitData2: [], + salesData: [], + searchData: [], + offlineData: [], + offlineChartData: [], + salesTypeData: [], + salesTypeDataOnline: [], + salesTypeDataOffline: [], + radarData: [], + loading: false, + }, + + effects: { + *fetch(_, { call, put }) { + const response = yield call(fakeChartData); + yield put({ + type: 'save', + payload: response, + }); + }, + *fetchSalesData(_, { call, put }) { + const response = yield call(fakeChartData); + yield put({ + type: 'save', + payload: { + salesData: response.salesData, + }, + }); + }, + }, + + reducers: { + save(state, { payload }) { + return { + ...state, + ...payload, + }; + }, + clear() { + return { + visitData: [], + visitData2: [], + salesData: [], + searchData: [], + offlineData: [], + offlineChartData: [], + salesTypeData: [], + salesTypeDataOnline: [], + salesTypeDataOffline: [], + radarData: [], + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/models/monitor.js b/antdsp-admin/src/main/web/src/pages/Dashboard/models/monitor.js new file mode 100644 index 0000000..e3e832f --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Dashboard/models/monitor.js @@ -0,0 +1,28 @@ +import { queryTags } from '@/services/api'; + +export default { + namespace: 'monitor', + + state: { + tags: [], + }, + + effects: { + *fetchTags(_, { call, put }) { + const response = yield call(queryTags); + yield put({ + type: 'saveTags', + payload: response.list, + }); + }, + }, + + reducers: { + saveTags(state, action) { + return { + ...state, + tags: action.payload, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/pages/Exception/403.js b/antdsp-admin/src/main/web/src/pages/Exception/403.js new file mode 100644 index 0000000..e91f9c9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Exception/403.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { formatMessage } from 'umi-plugin-react/locale'; +import Link from 'umi/link'; +import Exception from '@/components/Exception'; + +const Exception403 = () => ( + +); + +export default Exception403; diff --git a/antdsp-admin/src/main/web/src/pages/Exception/404.js b/antdsp-admin/src/main/web/src/pages/Exception/404.js new file mode 100644 index 0000000..f21b1f8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Exception/404.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { formatMessage } from 'umi-plugin-react/locale'; +import Link from 'umi/link'; +import Exception from '@/components/Exception'; + +const Exception404 = () => ( + +); + +export default Exception404; diff --git a/antdsp-admin/src/main/web/src/pages/Exception/500.js b/antdsp-admin/src/main/web/src/pages/Exception/500.js new file mode 100644 index 0000000..904844c --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Exception/500.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { formatMessage } from 'umi-plugin-react/locale'; +import Link from 'umi/link'; +import Exception from '@/components/Exception'; + +const Exception500 = () => ( + +); + +export default Exception500; diff --git a/antdsp-admin/src/main/web/src/pages/Exception/TriggerException.js b/antdsp-admin/src/main/web/src/pages/Exception/TriggerException.js new file mode 100644 index 0000000..15ace51 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Exception/TriggerException.js @@ -0,0 +1,50 @@ +import React, { PureComponent } from 'react'; +import { Button, Spin, Card } from 'antd'; +import { connect } from 'dva'; +import styles from './style.less'; + +@connect(state => ({ + isloading: state.error.isloading, +})) +class TriggerException extends PureComponent { + state = { + isloading: false, + }; + + triggerError = code => { + this.setState({ + isloading: true, + }); + const { dispatch } = this.props; + dispatch({ + type: 'error/query', + payload: { + code, + }, + }); + }; + + render() { + const { isloading } = this.state; + return ( + + + + + + + + + ); + } +} + +export default TriggerException; diff --git a/antdsp-admin/src/main/web/src/pages/Exception/models/error.js b/antdsp-admin/src/main/web/src/pages/Exception/models/error.js new file mode 100644 index 0000000..1bfd939 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Exception/models/error.js @@ -0,0 +1,28 @@ +import queryError from '@/services/error'; + +export default { + namespace: 'error', + + state: { + error: '', + isloading: false, + }, + + effects: { + *query({ payload }, { call, put }) { + yield call(queryError, payload.code); + yield put({ + type: 'trigger', + payload: payload.code, + }); + }, + }, + + reducers: { + trigger(state, action) { + return { + error: action.payload, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/pages/Exception/style.less b/antdsp-admin/src/main/web/src/pages/Exception/style.less new file mode 100644 index 0000000..91ec7dc --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Exception/style.less @@ -0,0 +1,7 @@ +.trigger { + background: 'red'; + :global(.ant-btn) { + margin-right: 8px; + margin-bottom: 12px; + } +} diff --git a/antdsp-admin/src/main/web/src/pages/Result/Error.js b/antdsp-admin/src/main/web/src/pages/Result/Error.js new file mode 100644 index 0000000..b8e528d --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Result/Error.js @@ -0,0 +1,66 @@ +import React, { Fragment } from 'react'; +import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; +import { Button, Icon, Card } from 'antd'; +import Result from '@/components/Result'; +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; + +const extra = ( + +
    + +
    +
    + + + + + + +
    +
    + + + + + + +
    +
    +); + +const actions = ( + +); + +export default () => ( + + + + + +); diff --git a/antdsp-admin/src/main/web/src/pages/Result/Success.js b/antdsp-admin/src/main/web/src/pages/Result/Success.js new file mode 100644 index 0000000..0b10080 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/Result/Success.js @@ -0,0 +1,144 @@ +import React, { Fragment } from 'react'; +import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; +import { Button, Row, Col, Icon, Steps, Card } from 'antd'; +import Result from '@/components/Result'; +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; + +const { Step } = Steps; + +const desc1 = ( +
    +
    + + +
    +
    2016-12-12 12:32
    +
    +); + +const desc2 = ( +
    +
    + + +
    +
    + + + +
    +
    +); + +const extra = ( + +
    + +
    + +
    + + + + 23421 + + + + + + + + + + + + 2016-12-12 ~ 2017-12-12 + + + + + + + } + description={desc1} + /> + + + + } + description={desc2} + /> + + + + } + /> + + + + } + /> + + +); + +const actions = ( + + + + + +); + +export default () => ( + + + + + +); diff --git a/antdsp-admin/src/main/web/src/pages/System/menu/Index.js b/antdsp-admin/src/main/web/src/pages/System/menu/Index.js new file mode 100644 index 0000000..8fed501 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/menu/Index.js @@ -0,0 +1,15 @@ +import { PureComponent } from "react"; + +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; + +export default class Index extends PureComponent{ + + render(){ + + return( + + + + ) + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/models/system.js b/antdsp-admin/src/main/web/src/pages/System/models/system.js new file mode 100644 index 0000000..7c68152 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/models/system.js @@ -0,0 +1,17 @@ + +export default { + namespace: "system", + + state: { + + }, + + effects: { + + }, + + reducers: { + + } + +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/role/Index.js b/antdsp-admin/src/main/web/src/pages/System/role/Index.js new file mode 100644 index 0000000..8fed501 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/role/Index.js @@ -0,0 +1,15 @@ +import { PureComponent } from "react"; + +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; + +export default class Index extends PureComponent{ + + render(){ + + return( + + + + ) + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/user/Index.js b/antdsp-admin/src/main/web/src/pages/System/user/Index.js new file mode 100644 index 0000000..8fed501 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/user/Index.js @@ -0,0 +1,15 @@ +import { PureComponent } from "react"; + +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; + +export default class Index extends PureComponent{ + + render(){ + + return( + + + + ) + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/User/Login.js b/antdsp-admin/src/main/web/src/pages/User/Login.js new file mode 100644 index 0000000..29f59c8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/User/Login.js @@ -0,0 +1,172 @@ +import React, { Component } from 'react'; +import { connect } from 'dva'; +import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; +import Link from 'umi/link'; +import { Checkbox, Alert, message, Icon } from 'antd'; +import Login from '@/components/Login'; +import styles from './Login.less'; + +const { Tab, UserName, Password, Mobile, Captcha, Submit } = Login; + +@connect(({ login, loading }) => ({ + login, + submitting: loading.effects['login/login'], +})) +class LoginPage extends Component { + state = { + type: 'account', + autoLogin: true, + }; + + onTabChange = type => { + this.setState({ type }); + }; + + onGetCaptcha = () => + new Promise((resolve, reject) => { + this.loginForm.validateFields(['mobile'], {}, (err, values) => { + if (err) { + reject(err); + } else { + const { dispatch } = this.props; + dispatch({ + type: 'login/getCaptcha', + payload: values.mobile, + }) + .then(resolve) + .catch(reject); + message.warning(formatMessage({ id: 'app.login.verification-code-warning' })); + } + }); + }); + + handleSubmit = (err, values) => { + const { type } = this.state; + if (!err) { + const { dispatch } = this.props; + dispatch({ + type: 'login/login', + payload: { + ...values, + type, + }, + }); + } + }; + + changeAutoLogin = e => { + this.setState({ + autoLogin: e.target.checked, + }); + }; + + renderMessage = content => ( + + ); + + render() { + const { login, submitting } = this.props; + const { type, autoLogin } = this.state; + return ( +
    + { + this.loginForm = form; + }} + > + + {login.status === 'error' && + login.type === 'account' && + !submitting && + this.renderMessage(formatMessage({ id: 'app.login.message-invalid-credentials' }))} + + { + e.preventDefault(); + this.loginForm.validateFields(this.handleSubmit); + }} + /> + + + {login.status === 'error' && + login.type === 'mobile' && + !submitting && + this.renderMessage( + formatMessage({ id: 'app.login.message-invalid-verification-code' }) + )} + + + +
    + + + + + + +
    + + + +
    + + + + + + + +
    +
    +
    + ); + } +} + +export default LoginPage; diff --git a/antdsp-admin/src/main/web/src/pages/User/Login.less b/antdsp-admin/src/main/web/src/pages/User/Login.less new file mode 100644 index 0000000..3419294 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/User/Login.less @@ -0,0 +1,32 @@ +@import '~antd/lib/style/themes/default.less'; + +.main { + width: 388px; + margin: 0 auto; + @media screen and (max-width: @screen-sm) { + width: 95%; + } + + .icon { + margin-left: 16px; + color: rgba(0, 0, 0, 0.2); + font-size: 24px; + vertical-align: middle; + cursor: pointer; + transition: color 0.3s; + + &:hover { + color: @primary-color; + } + } + + .other { + margin-top: 24px; + line-height: 22px; + text-align: left; + + .register { + float: right; + } + } +} diff --git a/antdsp-admin/src/main/web/src/pages/User/Register.js b/antdsp-admin/src/main/web/src/pages/User/Register.js new file mode 100644 index 0000000..6aab8ff --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/User/Register.js @@ -0,0 +1,335 @@ +import React, { Component } from 'react'; +import { connect } from 'dva'; +import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; +import Link from 'umi/link'; +import router from 'umi/router'; +import { Form, Input, Button, message, Select, Row, Col, Popover, Progress } from 'antd'; +import styles from './Register.less'; + +const FormItem = Form.Item; +const { Option } = Select; +const InputGroup = Input.Group; + +const passwordStatusMap = { + ok: ( +
    + +
    + ), + pass: ( +
    + +
    + ), + poor: ( +
    + +
    + ), +}; + +const passwordProgressMap = { + ok: 'success', + pass: 'normal', + poor: 'exception', +}; + +@connect(({ register, loading }) => ({ + register, + submitting: loading.effects['register/submit'], +})) +@Form.create() +class Register extends Component { + state = { + count: 0, + confirmDirty: false, + visible: false, + help: '', + prefix: '86', + }; + + componentDidUpdate() { + const { form, register } = this.props; + const account = form.getFieldValue('mail'); + if (register.status === 'ok') { + router.push({ + pathname: '/user/register-result', + state: { + account, + }, + }); + } + } + + componentWillUnmount() { + clearInterval(this.interval); + } + + onGetCaptcha = () => { + let count = 59; + this.setState({ count }); + this.interval = setInterval(() => { + count -= 1; + this.setState({ count }); + if (count === 0) { + clearInterval(this.interval); + } + }, 1000); + message.warning(formatMessage({ id: 'app.login.verification-code-warning' })); + }; + + getPasswordStatus = () => { + const { form } = this.props; + const value = form.getFieldValue('password'); + if (value && value.length > 9) { + return 'ok'; + } + if (value && value.length > 5) { + return 'pass'; + } + return 'poor'; + }; + + handleSubmit = e => { + e.preventDefault(); + const { form, dispatch } = this.props; + form.validateFields({ force: true }, (err, values) => { + if (!err) { + const { prefix } = this.state; + dispatch({ + type: 'register/submit', + payload: { + ...values, + prefix, + }, + }); + } + }); + }; + + handleConfirmBlur = e => { + const { value } = e.target; + const { confirmDirty } = this.state; + this.setState({ confirmDirty: confirmDirty || !!value }); + }; + + checkConfirm = (rule, value, callback) => { + const { form } = this.props; + if (value && value !== form.getFieldValue('password')) { + callback(formatMessage({ id: 'validation.password.twice' })); + } else { + callback(); + } + }; + + checkPassword = (rule, value, callback) => { + const { visible, confirmDirty } = this.state; + if (!value) { + this.setState({ + help: formatMessage({ id: 'validation.password.required' }), + visible: !!value, + }); + callback('error'); + } else { + this.setState({ + help: '', + }); + if (!visible) { + this.setState({ + visible: !!value, + }); + } + if (value.length < 6) { + callback('error'); + } else { + const { form } = this.props; + if (value && confirmDirty) { + form.validateFields(['confirm'], { force: true }); + } + callback(); + } + } + }; + + changePrefix = value => { + this.setState({ + prefix: value, + }); + }; + + renderPasswordProgress = () => { + const { form } = this.props; + const value = form.getFieldValue('password'); + const passwordStatus = this.getPasswordStatus(); + return value && value.length ? ( +
    + 100 ? 100 : value.length * 10} + showInfo={false} + /> +
    + ) : null; + }; + + render() { + const { form, submitting } = this.props; + const { getFieldDecorator } = form; + const { count, prefix, help, visible } = this.state; + return ( +
    +

    + +

    +
    + + {getFieldDecorator('mail', { + rules: [ + { + required: true, + message: formatMessage({ id: 'validation.email.required' }), + }, + { + type: 'email', + message: formatMessage({ id: 'validation.email.wrong-format' }), + }, + ], + })( + + )} + + + node.parentNode} + content={ +
    + {passwordStatusMap[this.getPasswordStatus()]} + {this.renderPasswordProgress()} +
    + +
    +
    + } + overlayStyle={{ width: 240 }} + placement="right" + visible={visible} + > + {getFieldDecorator('password', { + rules: [ + { + validator: this.checkPassword, + }, + ], + })( + + )} +
    +
    + + {getFieldDecorator('confirm', { + rules: [ + { + required: true, + message: formatMessage({ id: 'validation.confirm-password.required' }), + }, + { + validator: this.checkConfirm, + }, + ], + })( + + )} + + + + + {getFieldDecorator('mobile', { + rules: [ + { + required: true, + message: formatMessage({ id: 'validation.phone-number.required' }), + }, + { + pattern: /^\d{11}$/, + message: formatMessage({ id: 'validation.phone-number.wrong-format' }), + }, + ], + })( + + )} + + + + +
    + {getFieldDecorator('captcha', { + rules: [ + { + required: true, + message: formatMessage({ id: 'validation.verification-code.required' }), + }, + ], + })( + + )} + + + + + + + + + + + + + + + ); + } +} + +export default Register; diff --git a/antdsp-admin/src/main/web/src/pages/User/Register.less b/antdsp-admin/src/main/web/src/pages/User/Register.less new file mode 100644 index 0000000..c7e2252 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/User/Register.less @@ -0,0 +1,57 @@ +@import '~antd/lib/style/themes/default.less'; + +.main { + width: 388px; + margin: 0 auto; + + :global { + .ant-form-item { + margin-bottom: 24px; + } + } + + h3 { + margin-bottom: 20px; + font-size: 16px; + } + + .getCaptcha { + display: block; + width: 100%; + } + + .submit { + width: 50%; + } + + .login { + float: right; + line-height: @btn-height-lg; + } +} + +.success, +.warning, +.error { + transition: color 0.3s; +} + +.success { + color: @success-color; +} + +.warning { + color: @warning-color; +} + +.error { + color: @error-color; +} + +.progress-pass > .progress { + :global { + .ant-progress-bg { + background-color: @warning-color; + } + } +} diff --git a/antdsp-admin/src/main/web/src/pages/User/RegisterResult.js b/antdsp-admin/src/main/web/src/pages/User/RegisterResult.js new file mode 100644 index 0000000..d1bfe59 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/User/RegisterResult.js @@ -0,0 +1,41 @@ +import React from 'react'; +import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; +import { Button } from 'antd'; +import Link from 'umi/link'; +import Result from '@/components/Result'; +import styles from './RegisterResult.less'; + +const actions = ( +
    + + + + + + +
    +); + +const RegisterResult = ({ location }) => ( + + + + } + description={formatMessage({ id: 'app.register-result.activation-email' })} + actions={actions} + style={{ marginTop: 56 }} + /> +); + +export default RegisterResult; diff --git a/antdsp-admin/src/main/web/src/pages/User/RegisterResult.less b/antdsp-admin/src/main/web/src/pages/User/RegisterResult.less new file mode 100644 index 0000000..a969a5e --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/User/RegisterResult.less @@ -0,0 +1,18 @@ +.registerResult { + :global { + .anticon { + font-size: 64px; + } + } + .title { + margin-top: 32px; + font-size: 20px; + line-height: 28px; + } + .actions { + margin-top: 40px; + a + a { + margin-left: 8px; + } + } +} diff --git a/antdsp-admin/src/main/web/src/pages/User/models/register.js b/antdsp-admin/src/main/web/src/pages/User/models/register.js new file mode 100644 index 0000000..a2901bb --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/User/models/register.js @@ -0,0 +1,32 @@ +import { fakeRegister } from '@/services/api'; +import { setAuthority } from '@/utils/authority'; +import { reloadAuthorized } from '@/utils/Authorized'; + +export default { + namespace: 'register', + + state: { + status: undefined, + }, + + effects: { + *submit({ payload }, { call, put }) { + const response = yield call(fakeRegister, payload); + yield put({ + type: 'registerHandle', + payload: response, + }); + }, + }, + + reducers: { + registerHandle(state, { payload }) { + setAuthority('user'); + reloadAuthorized(); + return { + ...state, + status: payload.status, + }; + }, + }, +}; diff --git a/antdsp-admin/src/main/web/src/pages/document.ejs b/antdsp-admin/src/main/web/src/pages/document.ejs new file mode 100644 index 0000000..cf09eff --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/document.ejs @@ -0,0 +1,17 @@ + + + + + + + Ant Design Pro + + + + +
    + + diff --git a/antdsp-admin/src/main/web/src/service-worker.js b/antdsp-admin/src/main/web/src/service-worker.js new file mode 100644 index 0000000..48d43c2 --- /dev/null +++ b/antdsp-admin/src/main/web/src/service-worker.js @@ -0,0 +1,65 @@ +/* globals workbox */ +/* eslint-disable no-restricted-globals */ +workbox.core.setCacheNameDetails({ + prefix: 'antd-pro', + suffix: 'v1', +}); +// Control all opened tabs ASAP +workbox.clientsClaim(); + +/** + * Use precaching list generated by workbox in build process. + * https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.precaching + */ +/* eslint-disable no-underscore-dangle */ +workbox.precaching.precacheAndRoute(self.__precacheManifest || []); + +/** + * Register a navigation route. + * https://developers.google.com/web/tools/workbox/modules/workbox-routing#how_to_register_a_navigation_route + */ +workbox.routing.registerNavigationRoute('/index.html'); + +/** + * Use runtime cache: + * https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.routing#.registerRoute + * + * Workbox provides all common caching strategies including CacheFirst, NetworkFirst etc. + * https://developers.google.com/web/tools/workbox/reference-docs/latest/workbox.strategies + */ + +/** + * Handle API requests + */ +workbox.routing.registerRoute(/\/api\//, workbox.strategies.networkFirst()); + +/** + * Handle third party requests + */ +workbox.routing.registerRoute( + /^https:\/\/gw.alipayobjects.com\//, + workbox.strategies.networkFirst() +); +workbox.routing.registerRoute( + /^https:\/\/cdnjs.cloudflare.com\//, + workbox.strategies.networkFirst() +); +workbox.routing.registerRoute(/\/color.less/, workbox.strategies.networkFirst()); + +/** + * Response to client after skipping waiting with MessageChannel + */ +addEventListener('message', event => { + const replyPort = event.ports[0]; + const message = event.data; + if (replyPort && message && message.type === 'skip-waiting') { + event.waitUntil( + self + .skipWaiting() + .then( + () => replyPort.postMessage({ error: null }), + error => replyPort.postMessage({ error }) + ) + ); + } +}); diff --git a/antdsp-admin/src/main/web/src/services/api.js b/antdsp-admin/src/main/web/src/services/api.js new file mode 100644 index 0000000..5358a8e --- /dev/null +++ b/antdsp-admin/src/main/web/src/services/api.js @@ -0,0 +1,126 @@ +import { stringify } from 'qs'; +import request from '@/utils/request'; + +export async function queryProjectNotice() { + return request('/api/project/notice'); +} + +export async function queryActivities() { + return request('/api/activities'); +} + +export async function queryRule(params) { + return request(`/api/rule?${stringify(params)}`); +} + +export async function removeRule(params) { + return request('/api/rule', { + method: 'POST', + data: { + ...params, + method: 'delete', + }, + }); +} + +export async function addRule(params) { + return request('/api/rule', { + method: 'POST', + data: { + ...params, + method: 'post', + }, + }); +} + +export async function updateRule(params = {}) { + return request(`/api/rule?${stringify(params.query)}`, { + method: 'POST', + data: { + ...params.body, + method: 'update', + }, + }); +} + +export async function fakeSubmitForm(params) { + return request('/api/forms', { + method: 'POST', + data: params, + }); +} + +export async function fakeChartData() { + return request('/api/fake_chart_data'); +} + +export async function queryTags() { + return request('/api/tags'); +} + +export async function queryBasicProfile(id) { + return request(`/api/profile/basic?id=${id}`); +} + +export async function queryAdvancedProfile() { + return request('/api/profile/advanced'); +} + +export async function queryFakeList(params) { + return request(`/api/fake_list?${stringify(params)}`); +} + +export async function removeFakeList(params) { + const { count = 5, ...restParams } = params; + return request(`/api/fake_list?count=${count}`, { + method: 'POST', + data: { + ...restParams, + method: 'delete', + }, + }); +} + +export async function addFakeList(params) { + const { count = 5, ...restParams } = params; + return request(`/api/fake_list?count=${count}`, { + method: 'POST', + data: { + ...restParams, + method: 'post', + }, + }); +} + +export async function updateFakeList(params) { + const { count = 5, ...restParams } = params; + return request(`/api/fake_list?count=${count}`, { + method: 'POST', + data: { + ...restParams, + method: 'update', + }, + }); +} + +export async function fakeAccountLogin(params) { + return request('/api/login/account', { + method: 'POST', + data: params, + }); +} + +export async function fakeRegister(params) { + return request('/api/register', { + method: 'POST', + data: params, + }); +} + +export async function queryNotices(params = {}) { + return request(`/api/notices?${stringify(params)}`); +} + +export async function getFakeCaptcha(mobile) { + return request(`/api/captcha?mobile=${mobile}`); +} diff --git a/antdsp-admin/src/main/web/src/services/error.js b/antdsp-admin/src/main/web/src/services/error.js new file mode 100644 index 0000000..13f2e94 --- /dev/null +++ b/antdsp-admin/src/main/web/src/services/error.js @@ -0,0 +1,5 @@ +import request from '@/utils/request'; + +export default async function queryError(code) { + return request(`/api/${code}`); +} diff --git a/antdsp-admin/src/main/web/src/services/geographic.js b/antdsp-admin/src/main/web/src/services/geographic.js new file mode 100644 index 0000000..a5defd8 --- /dev/null +++ b/antdsp-admin/src/main/web/src/services/geographic.js @@ -0,0 +1,9 @@ +import request from '@/utils/request'; + +export async function queryProvince() { + return request('/api/geographic/province'); +} + +export async function queryCity(province) { + return request(`/api/geographic/city/${province}`); +} diff --git a/antdsp-admin/src/main/web/src/services/user.js b/antdsp-admin/src/main/web/src/services/user.js new file mode 100644 index 0000000..89e03c6 --- /dev/null +++ b/antdsp-admin/src/main/web/src/services/user.js @@ -0,0 +1,9 @@ +import request from '@/utils/request'; + +export async function query() { + return request('/api/users'); +} + +export async function queryCurrent() { + return request('/api/currentUser'); +} diff --git a/antdsp-admin/src/main/web/src/utils/Authorized.js b/antdsp-admin/src/main/web/src/utils/Authorized.js new file mode 100644 index 0000000..8c420cb --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/Authorized.js @@ -0,0 +1,12 @@ +import RenderAuthorized from '@/components/Authorized'; +import { getAuthority } from './authority'; + +let Authorized = RenderAuthorized(getAuthority()); // eslint-disable-line + +// Reload the rights component +const reloadAuthorized = () => { + Authorized = RenderAuthorized(getAuthority()); +}; + +export { reloadAuthorized }; +export default Authorized; diff --git a/antdsp-admin/src/main/web/src/utils/Yuan.js b/antdsp-admin/src/main/web/src/utils/Yuan.js new file mode 100644 index 0000000..434a57f --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/Yuan.js @@ -0,0 +1,31 @@ +import React from 'react'; +import { yuan } from '@/components/Charts'; +/** + * 减少使用 dangerouslySetInnerHTML + */ +export default class Yuan extends React.PureComponent { + componentDidMount() { + this.rendertoHtml(); + } + + componentDidUpdate() { + this.rendertoHtml(); + } + + rendertoHtml = () => { + const { children } = this.props; + if (this.main) { + this.main.innerHTML = yuan(children); + } + }; + + render() { + return ( + { + this.main = ref; + }} + /> + ); + } +} diff --git a/antdsp-admin/src/main/web/src/utils/authority.js b/antdsp-admin/src/main/web/src/utils/authority.js new file mode 100644 index 0000000..bb1aa23 --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/authority.js @@ -0,0 +1,25 @@ +// use localStorage to store the authority info, which might be sent from server in actual project. +export function getAuthority(str) { + // return localStorage.getItem('antd-pro-authority') || ['admin', 'user']; + const authorityString = + typeof str === 'undefined' ? localStorage.getItem('antd-pro-authority') : str; + // authorityString could be admin, "admin", ["admin"] + let authority; + try { + authority = JSON.parse(authorityString); + } catch (e) { + authority = authorityString; + } + if (typeof authority === 'string') { + return [authority]; + } + // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + if (!authority && ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { + return ['admin']; + } + return authority; +} +export function setAuthority(authority) { + const proAuthority = typeof authority === 'string' ? [authority] : authority; + return localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority)); +} diff --git a/antdsp-admin/src/main/web/src/utils/authority.test.js b/antdsp-admin/src/main/web/src/utils/authority.test.js new file mode 100644 index 0000000..15b3cb9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/authority.test.js @@ -0,0 +1,19 @@ +import { getAuthority } from './authority'; + +describe('getAuthority should be strong', () => { + it('empty', () => { + expect(getAuthority(null)).toEqual(null); // default value + }); + it('string', () => { + expect(getAuthority('admin')).toEqual(['admin']); + }); + it('array with double quotes', () => { + expect(getAuthority('"admin"')).toEqual(['admin']); + }); + it('array with single item', () => { + expect(getAuthority('["admin"]')).toEqual(['admin']); + }); + it('array with multiple items', () => { + expect(getAuthority('["admin", "guest"]')).toEqual(['admin', 'guest']); + }); +}); diff --git a/antdsp-admin/src/main/web/src/utils/getPageTitle.js b/antdsp-admin/src/main/web/src/utils/getPageTitle.js new file mode 100644 index 0000000..30e2dce --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/getPageTitle.js @@ -0,0 +1,27 @@ +import { formatMessage } from 'umi-plugin-react/locale'; +import pathToRegexp from 'path-to-regexp'; +import isEqual from 'lodash/isEqual'; +import memoizeOne from 'memoize-one'; +import { menu, title } from '../defaultSettings'; + +export const matchParamsPath = (pathname, breadcrumbNameMap) => { + const pathKey = Object.keys(breadcrumbNameMap).find(key => pathToRegexp(key).test(pathname)); + return breadcrumbNameMap[pathKey]; +}; + +const getPageTitle = (pathname, breadcrumbNameMap) => { + const currRouterData = matchParamsPath(pathname, breadcrumbNameMap); + if (!currRouterData) { + return title; + } + const pageName = menu.disableLocal + ? currRouterData.name + : formatMessage({ + id: currRouterData.locale || currRouterData.name, + defaultMessage: currRouterData.name, + }); + + return `${pageName} - ${title}`; +}; + +export default memoizeOne(getPageTitle, isEqual); diff --git a/antdsp-admin/src/main/web/src/utils/request.js b/antdsp-admin/src/main/web/src/utils/request.js new file mode 100644 index 0000000..0801b1d --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/request.js @@ -0,0 +1,72 @@ +/** + * request 网络请求工具 + * 更详细的api文档: https://bigfish.alipay.com/doc/api#request + */ +import { extend } from 'umi-request'; +import { notification } from 'antd'; +import router from 'umi/router'; + +const codeMessage = { + 200: '服务器成功返回请求的数据。', + 201: '新建或修改数据成功。', + 202: '一个请求已经进入后台排队(异步任务)。', + 204: '删除数据成功。', + 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。', + 401: '用户没有权限(令牌、用户名、密码错误)。', + 403: '用户得到授权,但是访问是被禁止的。', + 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。', + 406: '请求的格式不可得。', + 410: '请求的资源被永久删除,且不会再得到的。', + 422: '当创建一个对象时,发生一个验证错误。', + 500: '服务器发生错误,请检查服务器。', + 502: '网关错误。', + 503: '服务不可用,服务器暂时过载或维护。', + 504: '网关超时。', +}; + +/** + * 异常处理程序 + */ +const errorHandler = error => { + const { response = {} } = error; + const errortext = codeMessage[response.status] || response.statusText; + const { status, url } = response; + + if (status === 401) { + notification.error({ + message: '未登录或登录已过期,请重新登录。', + }); + // @HACK + /* eslint-disable no-underscore-dangle */ + window.g_app._store.dispatch({ + type: 'login/logout', + }); + return; + } + notification.error({ + message: `请求错误 ${status}: ${url}`, + description: errortext, + }); + // environment should not be used + if (status === 403) { + router.push('/exception/403'); + return; + } + if (status <= 504 && status >= 500) { + router.push('/exception/500'); + return; + } + if (status >= 404 && status < 422) { + router.push('/exception/404'); + } +}; + +/** + * 配置request请求时的默认参数 + */ +const request = extend({ + errorHandler, // 默认错误处理 + credentials: 'include', // 默认请求是否带上cookie +}); + +export default request; diff --git a/antdsp-admin/src/main/web/src/utils/utils.js b/antdsp-admin/src/main/web/src/utils/utils.js new file mode 100644 index 0000000..7531af6 --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/utils.js @@ -0,0 +1,194 @@ +import moment from 'moment'; +import React from 'react'; +import nzh from 'nzh/cn'; +import { parse, stringify } from 'qs'; + +export function fixedZero(val) { + return val * 1 < 10 ? `0${val}` : val; +} + +export function getTimeDistance(type) { + const now = new Date(); + const oneDay = 1000 * 60 * 60 * 24; + + if (type === 'today') { + now.setHours(0); + now.setMinutes(0); + now.setSeconds(0); + return [moment(now), moment(now.getTime() + (oneDay - 1000))]; + } + + if (type === 'week') { + let day = now.getDay(); + now.setHours(0); + now.setMinutes(0); + now.setSeconds(0); + + if (day === 0) { + day = 6; + } else { + day -= 1; + } + + const beginTime = now.getTime() - day * oneDay; + + return [moment(beginTime), moment(beginTime + (7 * oneDay - 1000))]; + } + + if (type === 'month') { + const year = now.getFullYear(); + const month = now.getMonth(); + const nextDate = moment(now).add(1, 'months'); + const nextYear = nextDate.year(); + const nextMonth = nextDate.month(); + + return [ + moment(`${year}-${fixedZero(month + 1)}-01 00:00:00`), + moment(moment(`${nextYear}-${fixedZero(nextMonth + 1)}-01 00:00:00`).valueOf() - 1000), + ]; + } + + const year = now.getFullYear(); + return [moment(`${year}-01-01 00:00:00`), moment(`${year}-12-31 23:59:59`)]; +} + +export function getPlainNode(nodeList, parentPath = '') { + const arr = []; + nodeList.forEach(node => { + const item = node; + item.path = `${parentPath}/${item.path || ''}`.replace(/\/+/g, '/'); + item.exact = true; + if (item.children && !item.component) { + arr.push(...getPlainNode(item.children, item.path)); + } else { + if (item.children && item.component) { + item.exact = false; + } + arr.push(item); + } + }); + return arr; +} + +export function digitUppercase(n) { + return nzh.toMoney(n); +} + +function getRelation(str1, str2) { + if (str1 === str2) { + console.warn('Two path are equal!'); // eslint-disable-line + } + const arr1 = str1.split('/'); + const arr2 = str2.split('/'); + if (arr2.every((item, index) => item === arr1[index])) { + return 1; + } + if (arr1.every((item, index) => item === arr2[index])) { + return 2; + } + return 3; +} + +function getRenderArr(routes) { + let renderArr = []; + renderArr.push(routes[0]); + for (let i = 1; i < routes.length; i += 1) { + // 去重 + renderArr = renderArr.filter(item => getRelation(item, routes[i]) !== 1); + // 是否包含 + const isAdd = renderArr.every(item => getRelation(item, routes[i]) === 3); + if (isAdd) { + renderArr.push(routes[i]); + } + } + return renderArr; +} + +/** + * Get router routing configuration + * { path:{name,...param}}=>Array<{name,path ...param}> + * @param {string} path + * @param {routerData} routerData + */ +export function getRoutes(path, routerData) { + let routes = Object.keys(routerData).filter( + routePath => routePath.indexOf(path) === 0 && routePath !== path + ); + // Replace path to '' eg. path='user' /user/name => name + routes = routes.map(item => item.replace(path, '')); + // Get the route to be rendered to remove the deep rendering + const renderArr = getRenderArr(routes); + // Conversion and stitching parameters + const renderRoutes = renderArr.map(item => { + const exact = !routes.some(route => route !== item && getRelation(route, item) === 1); + return { + exact, + ...routerData[`${path}${item}`], + key: `${path}${item}`, + path: `${path}${item}`, + }; + }); + return renderRoutes; +} + +export function getPageQuery() { + return parse(window.location.href.split('?')[1]); +} + +export function getQueryPath(path = '', query = {}) { + const search = stringify(query); + if (search.length) { + return `${path}?${search}`; + } + return path; +} + +/* eslint no-useless-escape:0 */ +const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; + +export function isUrl(path) { + return reg.test(path); +} + +export function formatWan(val) { + const v = val * 1; + if (!v || Number.isNaN(v)) return ''; + + let result = val; + if (val > 10000) { + result = Math.floor(val / 10000); + result = ( + + {result} + + 万 + + + ); + } + return result; +} + +// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 +export function isAntdPro() { + return window.location.hostname === 'preview.pro.ant.design'; +} + +export const importCDN = (url, name) => + new Promise(resolve => { + const dom = document.createElement('script'); + dom.src = url; + dom.type = 'text/javascript'; + dom.onload = () => { + resolve(window[name]); + }; + document.head.appendChild(dom); + }); diff --git a/antdsp-admin/src/main/web/src/utils/utils.less b/antdsp-admin/src/main/web/src/utils/utils.less new file mode 100644 index 0000000..de1aa64 --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/utils.less @@ -0,0 +1,50 @@ +.textOverflow() { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + word-break: break-all; +} + +.textOverflowMulti(@line: 3, @bg: #fff) { + position: relative; + max-height: @line * 1.5em; + margin-right: -1em; + padding-right: 1em; + overflow: hidden; + line-height: 1.5em; + text-align: justify; + &::before { + position: absolute; + right: 14px; + bottom: 0; + padding: 0 1px; + background: @bg; + content: '...'; + } + &::after { + position: absolute; + right: 14px; + width: 1em; + height: 1em; + margin-top: 0.2em; + background: white; + content: ''; + } +} + +// mixins for clearfix +// ------------------------ +.clearfix() { + zoom: 1; + &::before, + &::after { + display: table; + content: ' '; + } + &::after { + clear: both; + height: 0; + font-size: 0; + visibility: hidden; + } +} diff --git a/antdsp-admin/src/main/web/src/utils/utils.test.js b/antdsp-admin/src/main/web/src/utils/utils.test.js new file mode 100644 index 0000000..c97d325 --- /dev/null +++ b/antdsp-admin/src/main/web/src/utils/utils.test.js @@ -0,0 +1,62 @@ +import { fixedZero, isUrl } from './utils'; + +describe('fixedZero tests', () => { + it('should not pad large numbers', () => { + expect(fixedZero(10)).toEqual(10); + expect(fixedZero(11)).toEqual(11); + expect(fixedZero(15)).toEqual(15); + expect(fixedZero(20)).toEqual(20); + expect(fixedZero(100)).toEqual(100); + expect(fixedZero(1000)).toEqual(1000); + }); + + it('should pad single digit numbers and return them as string', () => { + expect(fixedZero(0)).toEqual('00'); + expect(fixedZero(1)).toEqual('01'); + expect(fixedZero(2)).toEqual('02'); + expect(fixedZero(3)).toEqual('03'); + expect(fixedZero(4)).toEqual('04'); + expect(fixedZero(5)).toEqual('05'); + expect(fixedZero(6)).toEqual('06'); + expect(fixedZero(7)).toEqual('07'); + expect(fixedZero(8)).toEqual('08'); + expect(fixedZero(9)).toEqual('09'); + }); +}); + +describe('isUrl tests', () => { + it('should return false for invalid and corner case inputs', () => { + expect(isUrl([])).toBeFalsy(); + expect(isUrl({})).toBeFalsy(); + expect(isUrl(false)).toBeFalsy(); + expect(isUrl(true)).toBeFalsy(); + expect(isUrl(NaN)).toBeFalsy(); + expect(isUrl(null)).toBeFalsy(); + expect(isUrl(undefined)).toBeFalsy(); + expect(isUrl()).toBeFalsy(); + expect(isUrl('')).toBeFalsy(); + }); + + it('should return false for invalid URLs', () => { + expect(isUrl('foo')).toBeFalsy(); + expect(isUrl('bar')).toBeFalsy(); + expect(isUrl('bar/test')).toBeFalsy(); + expect(isUrl('http:/example.com/')).toBeFalsy(); + expect(isUrl('ttp://example.com/')).toBeFalsy(); + }); + + it('should return true for valid URLs', () => { + expect(isUrl('http://example.com/')).toBeTruthy(); + expect(isUrl('https://example.com/')).toBeTruthy(); + expect(isUrl('http://example.com/test/123')).toBeTruthy(); + expect(isUrl('https://example.com/test/123')).toBeTruthy(); + expect(isUrl('http://example.com/test/123?foo=bar')).toBeTruthy(); + expect(isUrl('https://example.com/test/123?foo=bar')).toBeTruthy(); + expect(isUrl('http://www.example.com/')).toBeTruthy(); + expect(isUrl('https://www.example.com/')).toBeTruthy(); + expect(isUrl('http://www.example.com/test/123')).toBeTruthy(); + expect(isUrl('https://www.example.com/test/123')).toBeTruthy(); + expect(isUrl('http://www.example.com/test/123?foo=bar')).toBeTruthy(); + expect(isUrl('https://www.example.com/test/123?foo=bar')).toBeTruthy(); + }); +}); diff --git a/antdsp-admin/src/main/web/tests/run-tests.js b/antdsp-admin/src/main/web/tests/run-tests.js new file mode 100644 index 0000000..5735ada --- /dev/null +++ b/antdsp-admin/src/main/web/tests/run-tests.js @@ -0,0 +1,47 @@ +/* eslint-disable no-console */ +const { spawn } = require('child_process'); +const { kill } = require('cross-port-killer'); + +const env = Object.create(process.env); +env.BROWSER = 'none'; +env.TEST = true; +// flag to prevent multiple test +let once = false; + +const startServer = spawn(/^win/.test(process.platform) ? 'npm.cmd' : 'npm', ['start'], { + env, +}); + +startServer.stderr.on('data', data => { + // eslint-disable-next-line + console.log(data.toString()); +}); + +startServer.on('exit', () => { + kill(process.env.PORT || 8000); +}); + +console.log('Starting development server for e2e tests...'); +startServer.stdout.on('data', data => { + console.log(data.toString()); + // hack code , wait umi + if ( + (!once && data.toString().indexOf('Compiled successfully') >= 0) || + data.toString().indexOf('Theme generated successfully') >= 0 + ) { + // eslint-disable-next-line + once = true; + console.log('Development server is started, ready to run tests.'); + const testCmd = spawn( + /^win/.test(process.platform) ? 'npm.cmd' : 'npm', + ['test', '--', '--maxWorkers=1', '--runInBand'], + { + stdio: 'inherit', + } + ); + testCmd.on('exit', code => { + startServer.kill(); + process.exit(code); + }); + } +}); diff --git a/antdsp-admin/src/main/web/tsconfig.json b/antdsp-admin/src/main/web/tsconfig.json new file mode 100644 index 0000000..5c26101 --- /dev/null +++ b/antdsp-admin/src/main/web/tsconfig.json @@ -0,0 +1,35 @@ +{ + "compilerOptions": { + "outDir": "build/dist", + "module": "esnext", + "target": "es2016", + "lib": ["es6", "dom"], + "sourceMap": true, + "baseUrl": ".", + "jsx": "react", + "allowSyntheticDefaultImports": true, + "moduleResolution": "node", + "rootDirs": ["/src", "/test", "/mock", "./typings"], + "forceConsistentCasingInFileNames": true, + "noImplicitReturns": true, + "suppressImplicitAnyIndexErrors": true, + "noUnusedLocals": true, + "allowJs": true, + "experimentalDecorators": true, + "paths": { + "@/*": ["./src/*"] + } + }, + "include": ["./src"], + "exclude": [ + "node_modules", + "build", + "scripts", + "acceptance-tests", + "webpack", + "jest", + "src/setupTests.ts", + "tslint:latest", + "tslint-config-prettier" + ] +} diff --git a/antdsp-admin/src/main/web/tslint.json b/antdsp-admin/src/main/web/tslint.json new file mode 100644 index 0000000..125e217 --- /dev/null +++ b/antdsp-admin/src/main/web/tslint.json @@ -0,0 +1,11 @@ +{ + "extends": ["tslint:latest", "tslint-react", "tslint-config-prettier"], + "rules": { + "no-var-requires": false, + "no-submodule-imports": false, + "object-literal-sort-keys": false, + "jsx-no-lambda": false, + "no-implicit-dependencies": false, + "no-console": false + } +} diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java new file mode 100644 index 0000000..8816883 --- /dev/null +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java @@ -0,0 +1,14 @@ +package com.antdsp.dao.jpa; + +import java.io.Serializable; +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.NoRepositoryBean; + +@NoRepositoryBean +public interface AntdspBaseRepository extends JpaRepository{ + + List findPageByQuery(int start , int count); + +} diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java new file mode 100644 index 0000000..799ed98 --- /dev/null +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java @@ -0,0 +1,29 @@ +package com.antdsp.dao.jpa; + +import java.io.Serializable; +import java.util.List; + +import javax.persistence.EntityManager; + +import org.springframework.data.jpa.repository.support.SimpleJpaRepository; + +public class AntdspBaseRepositoryImpl extends SimpleJpaRepository implements AntdspBaseRepository{ + + private final EntityManager em; + + private Class clazz; + + public AntdspBaseRepositoryImpl(Class domainClass, EntityManager em) { + super(domainClass, em); + this.em = em; + this.clazz = domainClass; + } + + @Override + public List findPageByQuery(int start, int count) { + return null; + } + + + +} diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/UserJpa.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/UserJpa.java index e7b0db1..03ef064 100644 --- a/antdsp-core/src/main/java/com/antdsp/dao/jpa/UserJpa.java +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/UserJpa.java @@ -1,9 +1,12 @@ package com.antdsp.dao.jpa; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; import com.antdsp.model.entity.User; -public interface UserJpa extends JpaRepository{ +@Repository("userJpa") +public interface UserJpa extends JpaRepository , JpaSpecificationExecutor{ } -- Gitee From d537340d907e250fcbb1a974fa40ded7479d9af8 Mon Sep 17 00:00:00 2001 From: lijiantao Date: Thu, 6 Jun 2019 18:00:16 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/antdsp/common/AntdspResponse.java | 24 ++ .../java/com/antdsp/common/ResponseCode.java | 2 + .../common/exception/AntdspException.java | 2 +- .../java/com/antdsp/web/dto/MenuTree.java | 95 +++++++ .../java/com/antdsp/web/{ => rest}/Login.java | 2 +- .../antdsp/web/rest/sys/SystemMenuApi.java | 58 ++++ .../antdsp/web/rest/sys/SystemRoleApi.java | 68 +++++ .../web/{ => rest}/sys/SystemUserApi.java | 63 ++++- .../com/antdsp/web/sys/SystemMenuApi.java | 10 - .../com/antdsp/web/sys/SystemRoleApi.java | 15 -- .../src/main/resources/application.yml | 2 +- antdsp-admin/src/main/web/config/config.js | 2 +- .../src/main/web/config/router.config.js | 25 +- antdsp-admin/src/main/web/src/custom/Block.js | 15 ++ .../src/main/web/src/custom/style.less | 6 + .../src/main/web/src/locales/zh-CN/menu.js | 6 +- .../main/web/src/pages/Dashboard/Analysis.js | 184 ------------- .../web/src/pages/Dashboard/Analysis.less | 198 -------------- .../web/src/pages/Dashboard/IntroduceRow.js | 152 ----------- .../main/web/src/pages/Dashboard/Monitor.js | 244 ----------------- .../main/web/src/pages/Dashboard/Monitor.less | 23 -- .../web/src/pages/Dashboard/OfflineData.js | 65 ----- .../src/pages/Dashboard/ProportionSales.js | 58 ---- .../main/web/src/pages/Dashboard/SalesCard.js | 150 ----------- .../main/web/src/pages/Dashboard/TopSearch.js | 111 -------- .../main/web/src/pages/Dashboard/Workplace.js | 255 ------------------ .../web/src/pages/Dashboard/Workplace.less | 228 ---------------- .../src/pages/Dashboard/models/activities.js | 28 -- .../web/src/pages/Dashboard/models/chart.js | 61 ----- .../web/src/pages/Dashboard/models/monitor.js | 28 -- .../main/web/src/pages/System/Menu/Index.js | 214 +++++++++++++++ .../web/src/pages/System/Menu/models/menu.js | 32 +++ .../main/web/src/pages/System/User/Index.js | 92 +++++++ .../web/src/pages/System/User/models/user.js | 35 +++ .../main/web/src/pages/System/menu/Index.js | 15 -- .../web/src/pages/System/models/system.js | 17 -- .../main/web/src/pages/System/role/Index.js | 15 -- .../main/web/src/pages/System/user/Index.js | 15 -- .../src/main/web/src/services/system.js | 15 ++ .../main/java/com/antdsp/dao/jpa/UserJpa.java | 7 +- .../com/antdsp/dao/jpa/system/MenuJpa.java | 12 + .../com/antdsp/dao/jpa/system/RoleJpa.java | 12 + .../entity/AbstractEntity.java | 2 +- .../antdsp/{model => data}/entity/User.java | 68 ++++- .../antdsp/data/entity/system/SystemMenu.java | 94 +++++++ .../antdsp/data/entity/system/SystemRole.java | 36 +++ .../com/antdsp/data/entityeenum/MenuType.java | 17 ++ .../entityeenum/UserStatus.java | 2 +- 48 files changed, 973 insertions(+), 1907 deletions(-) create mode 100644 antdsp-admin/src/main/java/com/antdsp/web/dto/MenuTree.java rename antdsp-admin/src/main/java/com/antdsp/web/{ => rest}/Login.java (46%) create mode 100644 antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemMenuApi.java create mode 100644 antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java rename antdsp-admin/src/main/java/com/antdsp/web/{ => rest}/sys/SystemUserApi.java (53%) delete mode 100644 antdsp-admin/src/main/java/com/antdsp/web/sys/SystemMenuApi.java delete mode 100644 antdsp-admin/src/main/java/com/antdsp/web/sys/SystemRoleApi.java create mode 100644 antdsp-admin/src/main/web/src/custom/Block.js create mode 100644 antdsp-admin/src/main/web/src/custom/style.less delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.less delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/IntroduceRow.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.less delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/OfflineData.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/ProportionSales.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/SalesCard.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/TopSearch.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.less delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/models/activities.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/models/chart.js delete mode 100644 antdsp-admin/src/main/web/src/pages/Dashboard/models/monitor.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/Menu/Index.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/Menu/models/menu.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/User/Index.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/User/models/user.js delete mode 100644 antdsp-admin/src/main/web/src/pages/System/menu/Index.js delete mode 100644 antdsp-admin/src/main/web/src/pages/System/models/system.js delete mode 100644 antdsp-admin/src/main/web/src/pages/System/role/Index.js delete mode 100644 antdsp-admin/src/main/web/src/pages/System/user/Index.js create mode 100644 antdsp-admin/src/main/web/src/services/system.js create mode 100644 antdsp-core/src/main/java/com/antdsp/dao/jpa/system/MenuJpa.java create mode 100644 antdsp-core/src/main/java/com/antdsp/dao/jpa/system/RoleJpa.java rename antdsp-core/src/main/java/com/antdsp/{model => data}/entity/AbstractEntity.java (98%) rename antdsp-core/src/main/java/com/antdsp/{model => data}/entity/User.java (39%) create mode 100644 antdsp-core/src/main/java/com/antdsp/data/entity/system/SystemMenu.java create mode 100644 antdsp-core/src/main/java/com/antdsp/data/entity/system/SystemRole.java create mode 100644 antdsp-core/src/main/java/com/antdsp/data/entityeenum/MenuType.java rename antdsp-core/src/main/java/com/antdsp/{model => data}/entityeenum/UserStatus.java (79%) diff --git a/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java b/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java index 2b23c1c..996b052 100644 --- a/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java +++ b/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java @@ -37,5 +37,29 @@ public class AntdspResponse { public void setMessage(String message) { this.message = message; } + + public static AntdspResponse success() { + return success("操作成功"); + } + + public static AntdspResponse success(String msg) { + return success(ResponseCode.OK , msg); + } + + public static AntdspResponse success(ResponseCode code , String msg) { + + return new AntdspResponse(code, msg); + } + + public static AntdspResponse error() { + return error("操作失败"); + } + public static AntdspResponse error(String msg) { + return error(ResponseCode.REJECT , msg); + } + + public static AntdspResponse error(ResponseCode code , String msg) { + return new AntdspResponse(code, msg); + } } diff --git a/antdsp-admin/src/main/java/com/antdsp/common/ResponseCode.java b/antdsp-admin/src/main/java/com/antdsp/common/ResponseCode.java index decb222..91ab81d 100644 --- a/antdsp-admin/src/main/java/com/antdsp/common/ResponseCode.java +++ b/antdsp-admin/src/main/java/com/antdsp/common/ResponseCode.java @@ -2,6 +2,8 @@ package com.antdsp.common; public enum ResponseCode { + OK(1200 , "正常"), + REJECT(1207 , "拒绝"), UNAUTHORIZED(1401 , "未登录"), FORBIDDEN(1403 , "权限不足"); diff --git a/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java b/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java index d44a54e..18f619a 100644 --- a/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java +++ b/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java @@ -14,7 +14,7 @@ import com.antdsp.common.ResponseCode; *

    Description: 自定义异常处理

    *

    Copyright: Copyright (c) 2019

    * - * @author ljt + * @author jt-lee * @date 2019年5月31日 * @email a496401006@qq.com * diff --git a/antdsp-admin/src/main/java/com/antdsp/web/dto/MenuTree.java b/antdsp-admin/src/main/java/com/antdsp/web/dto/MenuTree.java new file mode 100644 index 0000000..1cdf8db --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/web/dto/MenuTree.java @@ -0,0 +1,95 @@ +package com.antdsp.web.dto; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class MenuTree implements Serializable{ + + private Long id; + + private Long parentId; + + private String name; + + private String path; + + private String icon; + + private String permission; + + private String type; + + private List children; + + public Long getId() { + return id; + } + + public Long getParentId() { + return parentId; + } + + public String getName() { + return name; + } + + public String getPath() { + return path; + } + + public String getIcon() { + return icon; + } + + public String getPermission() { + return permission; + } + + public String getType() { + return type; + } + + public List getChildren() { + return children; + } + + public void setId(Long id) { + this.id = id; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public void setName(String name) { + this.name = name; + } + + public void setPath(String path) { + this.path = path; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public void setPermission(String permission) { + this.permission = permission; + } + + public void setType(String type) { + this.type = type; + } + + public void setChildren(List children) { + this.children = children; + } + + public void appendChildren(MenuTree childMen) { + if(children == null) { + children = new ArrayList<>(); + } + children.add(childMen); + } +} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/Login.java b/antdsp-admin/src/main/java/com/antdsp/web/rest/Login.java similarity index 46% rename from antdsp-admin/src/main/java/com/antdsp/web/Login.java rename to antdsp-admin/src/main/java/com/antdsp/web/rest/Login.java index 5903df9..f98e901 100644 --- a/antdsp-admin/src/main/java/com/antdsp/web/Login.java +++ b/antdsp-admin/src/main/java/com/antdsp/web/rest/Login.java @@ -1,4 +1,4 @@ -package com.antdsp.web; +package com.antdsp.web.rest; public class Login { diff --git a/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemMenuApi.java b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemMenuApi.java new file mode 100644 index 0000000..2a48653 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemMenuApi.java @@ -0,0 +1,58 @@ +package com.antdsp.web.rest.sys; + +import java.util.List; +import java.util.stream.Collectors; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.antdsp.dao.jpa.system.MenuJpa; +import com.antdsp.data.entity.system.SystemMenu; +import com.antdsp.web.dto.MenuTree; + +@RestController +@RequestMapping("/system/menu") +public class SystemMenuApi { + + @Autowired + private MenuJpa menuJpa; + + @GetMapping("") + public MenuTree list() { + + MenuTree rootMenu = new MenuTree(); + rootMenu.setId(0L); + rootMenu.setName("antdsp"); + rootMenu.setPath("/"); + + List allMenus = this.menuJpa.findAll(); + + this.child(rootMenu, allMenus); + + return rootMenu; + } + + private void child(MenuTree parentMenu , List allMenus) { + List childMenus = allMenus.stream().filter(item-> + parentMenu.equals(item.getParentId())).collect(Collectors.toList()); + allMenus.removeAll(childMenus); + childMenus.forEach(item->{ + MenuTree menu = new MenuTree(); + menu.setId(item.getId()); + menu.setIcon(item.getIcon()); + menu.setName(item.getMenuName()); + menu.setParentId(item.getParentId()); + menu.setPath(item.getUrl()); + menu.setPermission(item.getPermission()); + menu.setType(item.getMenuType().name()); + + this.child(menu , allMenus); + + parentMenu.appendChildren(menu); + }); + + } + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java new file mode 100644 index 0000000..a0eff17 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java @@ -0,0 +1,68 @@ +package com.antdsp.web.rest.sys; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Predicate; +import javax.persistence.criteria.Root; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Order; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.antdsp.common.pagination.PaginationData; +import com.antdsp.dao.jpa.system.RoleJpa; +import com.antdsp.data.entity.User; +import com.antdsp.data.entity.system.SystemRole; + +/** + * + *

    title:SystemRoleApi.java

    + *

    Description:

    + *

    Copyright: Copyright (c) 2019

    + * + * @author jt-lee + * @date 2019年6月3日 + * @email a496401006@qq.com + * + */ +@RestController +@RequestMapping("/system/role") +public class SystemRoleApi { + + @Autowired + private RoleJpa roleJpa; + + @GetMapping("") + public PaginationData list(int page , int count , String roleName){ + + int start = (page - 1) * count; + Pageable pageable = PageRequest.of(start, count , Sort.by(Order.desc("creator"))); + Specification specification = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder builder) { + + List predicates = new ArrayList<>(); + if(!StringUtils.isEmpty(roleName)) { + predicates.add(builder.like(root.get("roleName"), "%"+roleName+"%")); + } + return builder.and(predicates.toArray(new Predicate[predicates.size()])); + } + }; + + Page userList = roleJpa.findAll(specification , pageable); + + return new PaginationData<>(userList.getContent() , page , userList.getTotalElements()); + } + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemUserApi.java b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemUserApi.java similarity index 53% rename from antdsp-admin/src/main/java/com/antdsp/web/sys/SystemUserApi.java rename to antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemUserApi.java index 13437a9..95054ff 100644 --- a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemUserApi.java +++ b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemUserApi.java @@ -1,4 +1,4 @@ -package com.antdsp.web.sys; +package com.antdsp.web.rest.sys; import java.util.ArrayList; import java.util.HashMap; @@ -17,15 +17,22 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Order; import org.springframework.data.jpa.domain.Specification; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.antdsp.common.AntdspResponse; import com.antdsp.common.pagination.PaginationData; import com.antdsp.dao.jpa.UserJpa; -import com.antdsp.model.entity.User; -import com.antdsp.model.entityeenum.UserStatus; +import com.antdsp.data.entity.User; +import com.antdsp.data.entityeenum.UserStatus; @RestController @RequestMapping("/system/user") @@ -37,12 +44,8 @@ public class SystemUserApi { @GetMapping("") public PaginationData list(int page , int count , String loginname , UserStatus status){ - Map params = new HashMap<>(); - int start = (page -1 ) * count; - params.put("start", start); - params.put("count", count); - - Pageable pageable = PageRequest.of(page, count , Sort.by(Order.desc("creator"))); //Sort.and(Order.desc("creator")) + int start = (page - 1) * count; + Pageable pageable = PageRequest.of(start, count , Sort.by(Order.desc("creator"))); //Sort.and(Order.desc("creator")) Specification specification = new Specification() { @Override @@ -63,4 +66,46 @@ public class SystemUserApi { PaginationData pagination = new PaginationData<>(userList.getContent() , page , userList.getTotalElements()); return pagination; } + + @PostMapping("") + @Transactional + public AntdspResponse add(@RequestBody User user) { + + User olduser = userJpa.queryUserByLoginName(user.getLoginname()); + if(olduser != null) { + return AntdspResponse.error("登录名重复"); + } + + user.setAvatar(""); + user.setCreator(""); + user.setModifier(""); + user.setStatus(UserStatus.NORMAL); + user.onPreInsert(); + this.userJpa.save(user); + + return AntdspResponse.success("保存成功"); + } + + @PutMapping("/{id:\\d+}") + @Transactional + public AntdspResponse update(@RequestBody User user) { + + User oldUser = userJpa.getOne(user.getId()); + + oldUser.setEmail(user.getEmail()); + oldUser.setQq(user.getQq()); + oldUser.setRealname(user.getRealname()); + oldUser.onPreUpdate(); + this.userJpa.save(oldUser); + return AntdspResponse.success("保存成功"); + } + + @DeleteMapping("/{id:\\d+}") + @Transactional + public AntdspResponse delete(@PathVariable("id") Long id) { + + User oldUser = userJpa.getOne(id); + this.userJpa.delete(oldUser); + return AntdspResponse.success(); + } } diff --git a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemMenuApi.java b/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemMenuApi.java deleted file mode 100644 index f083885..0000000 --- a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemMenuApi.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.antdsp.web.sys; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/system/menu") -public class SystemMenuApi { - -} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemRoleApi.java b/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemRoleApi.java deleted file mode 100644 index 8041ad3..0000000 --- a/antdsp-admin/src/main/java/com/antdsp/web/sys/SystemRoleApi.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.antdsp.web.sys; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * - * @author ljt - * - */ -@RestController -@RequestMapping("/system/role") -public class SystemRoleApi { - -} diff --git a/antdsp-admin/src/main/resources/application.yml b/antdsp-admin/src/main/resources/application.yml index b7799d2..572f4e8 100644 --- a/antdsp-admin/src/main/resources/application.yml +++ b/antdsp-admin/src/main/resources/application.yml @@ -4,7 +4,7 @@ antdsp: copyrightYear: 2019 server: servlet: - context-path: /api + context-path: /antdsp-api session: timeout: 30 port: 8088 diff --git a/antdsp-admin/src/main/web/config/config.js b/antdsp-admin/src/main/web/config/config.js index dc34a31..973442b 100644 --- a/antdsp-admin/src/main/web/config/config.js +++ b/antdsp-admin/src/main/web/config/config.js @@ -122,7 +122,7 @@ export default { proxy: { "/antdsp-api": { - "target": "http://localhost:8080/antdsp-api/", + "target": "http://localhost:8088/antdsp-api/", "changeOrigin": true, "pathRewrite": { "^/antdsp-api" : "" } } diff --git a/antdsp-admin/src/main/web/config/router.config.js b/antdsp-admin/src/main/web/config/router.config.js index 2c4c173..33d6fa8 100644 --- a/antdsp-admin/src/main/web/config/router.config.js +++ b/antdsp-admin/src/main/web/config/router.config.js @@ -1,25 +1,32 @@ export default [ - //login - { path: '/login', name: 'login', component: './User/Login' }, // app { path: '/', component: '../layouts/BasicLayout', Routes: ['src/pages/Authorized'], + authority: 'admin', routes: [ - { - path: '/', - redirect:'/system/role', - authority: 'admin', + { + path: '/', redirect: '/system/user', }, + // dashboard { path: '/system', name: 'system', icon: 'setting', routes: [ - { path: '/system/role', name: 'role', component: './System/role' }, - { path: '/system/user', name: 'user', component: './System/user' }, - { path: '/system/menu', name: 'menu', component: './System/menu' }, + { + path: '/system/user', + name: 'user', + icon: 'user', + component: './System/User', + }, + { + path: '/system/menu', + name: 'menu', + icon: 'menu', + component: './System/Menu', + } ], }, { diff --git a/antdsp-admin/src/main/web/src/custom/Block.js b/antdsp-admin/src/main/web/src/custom/Block.js new file mode 100644 index 0000000..390cb9c --- /dev/null +++ b/antdsp-admin/src/main/web/src/custom/Block.js @@ -0,0 +1,15 @@ +import { PureComponent, Children } from "react"; + +import styles from "./style.less" + +export default class Block extends PureComponent{ + + render(){ + + return ( +
    + {this.props.children} +
    + ) + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/custom/style.less b/antdsp-admin/src/main/web/src/custom/style.less new file mode 100644 index 0000000..669b53c --- /dev/null +++ b/antdsp-admin/src/main/web/src/custom/style.less @@ -0,0 +1,6 @@ +@import '~antd/lib/style/themes/default.less'; +@import '~@/utils/utils.less'; + +.block{ + margin-bottom: 20px; +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js b/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js index cba1a2d..df39952 100644 --- a/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js @@ -1,10 +1,6 @@ export default { 'menu.home': '首页', - 'menu.login': '登录', - 'menu.register': '注册', - 'menu.register.result': '注册结果', 'menu.system': '系统管理', - 'menu.system.role': '角色管理', 'menu.system.user': '用户管理', - 'menu.system.menu': '菜单管理', + 'menu.system.menu': '菜单管理' }; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.js b/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.js deleted file mode 100644 index 0d222cc..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.js +++ /dev/null @@ -1,184 +0,0 @@ -import React, { Component, Suspense } from 'react'; -import { connect } from 'dva'; -import { Row, Col, Icon, Menu, Dropdown } from 'antd'; -import GridContent from '@/components/PageHeaderWrapper/GridContent'; -import { getTimeDistance } from '@/utils/utils'; -import styles from './Analysis.less'; -import PageLoading from '@/components/PageLoading'; - -const IntroduceRow = React.lazy(() => import('./IntroduceRow')); -const SalesCard = React.lazy(() => import('./SalesCard')); -const TopSearch = React.lazy(() => import('./TopSearch')); -const ProportionSales = React.lazy(() => import('./ProportionSales')); -const OfflineData = React.lazy(() => import('./OfflineData')); - -@connect(({ chart, loading }) => ({ - chart, - loading: loading.effects['chart/fetch'], -})) -class Analysis extends Component { - state = { - salesType: 'all', - currentTabKey: '', - rangePickerValue: getTimeDistance('year'), - }; - - componentDidMount() { - const { dispatch } = this.props; - this.reqRef = requestAnimationFrame(() => { - dispatch({ - type: 'chart/fetch', - }); - }); - } - - componentWillUnmount() { - const { dispatch } = this.props; - dispatch({ - type: 'chart/clear', - }); - cancelAnimationFrame(this.reqRef); - } - - handleChangeSalesType = e => { - this.setState({ - salesType: e.target.value, - }); - }; - - handleTabChange = key => { - this.setState({ - currentTabKey: key, - }); - }; - - handleRangePickerChange = rangePickerValue => { - const { dispatch } = this.props; - this.setState({ - rangePickerValue, - }); - - dispatch({ - type: 'chart/fetchSalesData', - }); - }; - - selectDate = type => { - const { dispatch } = this.props; - this.setState({ - rangePickerValue: getTimeDistance(type), - }); - - dispatch({ - type: 'chart/fetchSalesData', - }); - }; - - isActive = type => { - const { rangePickerValue } = this.state; - const value = getTimeDistance(type); - if (!rangePickerValue[0] || !rangePickerValue[1]) { - return ''; - } - if ( - rangePickerValue[0].isSame(value[0], 'day') && - rangePickerValue[1].isSame(value[1], 'day') - ) { - return styles.currentDate; - } - return ''; - }; - - render() { - const { rangePickerValue, salesType, currentTabKey } = this.state; - const { chart, loading } = this.props; - const { - visitData, - visitData2, - salesData, - searchData, - offlineData, - offlineChartData, - salesTypeData, - salesTypeDataOnline, - salesTypeDataOffline, - } = chart; - let salesPieData; - if (salesType === 'all') { - salesPieData = salesTypeData; - } else { - salesPieData = salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline; - } - const menu = ( - - 操作一 - 操作二 - - ); - - const dropdownGroup = ( - - - - - - ); - - const activeKey = currentTabKey || (offlineData[0] && offlineData[0].name); - - return ( - - }> - - - - - -
    - -
    - - - - - - - - - - - - - - - - ); - } -} - -export default Analysis; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.less b/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.less deleted file mode 100644 index f71bd34..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/Analysis.less +++ /dev/null @@ -1,198 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; -@import '~@/utils/utils.less'; - -.iconGroup { - i { - margin-left: 16px; - color: @text-color-secondary; - cursor: pointer; - transition: color 0.32s; - &:hover { - color: @text-color; - } - } -} - -.rankingList { - margin: 25px 0 0; - padding: 0; - list-style: none; - li { - .clearfix(); - - display: flex; - align-items: center; - margin-top: 16px; - span { - color: @text-color; - font-size: 14px; - line-height: 22px; - } - .rankingItemNumber { - display: inline-block; - width: 20px; - height: 20px; - margin-top: 1.5px; - margin-right: 16px; - font-weight: 600; - font-size: 12px; - line-height: 20px; - text-align: center; - background-color: @background-color-base; - border-radius: 20px; - &.active { - color: #fff; - background-color: #314659; - } - } - .rankingItemTitle { - flex: 1; - margin-right: 8px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - } - } -} - -.salesExtra { - display: inline-block; - margin-right: 24px; - a { - margin-left: 24px; - color: @text-color; - &:hover { - color: @primary-color; - } - &.currentDate { - color: @primary-color; - } - } -} - -.salesCard { - .salesBar { - padding: 0 0 32px 32px; - } - .salesRank { - padding: 0 32px 32px 72px; - } - :global { - .ant-tabs-bar { - padding-left: 16px; - .ant-tabs-nav .ant-tabs-tab { - padding-top: 16px; - padding-bottom: 14px; - line-height: 24px; - } - } - .ant-tabs-extra-content { - padding-right: 24px; - line-height: 55px; - } - .ant-card-head { - position: relative; - } - .ant-card-head-title { - align-items: normal; - } - } -} - -.salesCardExtra { - height: inherit; -} - -.salesTypeRadio { - position: absolute; - right: 54px; - bottom: 12px; -} - -.offlineCard { - :global { - .ant-tabs-ink-bar { - bottom: auto; - } - .ant-tabs-bar { - border-bottom: none; - } - .ant-tabs-nav-container-scrolling { - padding-right: 40px; - padding-left: 40px; - } - .ant-tabs-tab-prev-icon::before { - position: relative; - left: 6px; - } - .ant-tabs-tab-next-icon::before { - position: relative; - right: 6px; - } - .ant-tabs-tab-active h4 { - color: @primary-color; - } - } -} - -.twoColLayout { - .salesCard { - height: calc(100% - 24px); - } - div[class^='ant-col']:last-child { - position: absolute\9; - right: 0\9; - height: 100%\9; - } - :global { - .ant-row { - position: relative\9; - display: flex; - display: block\9; - flex-flow: row wrap; - } - } -} - -.trendText { - margin-left: 8px; - color: @heading-color; -} - -@media screen and (max-width: @screen-lg) { - .salesExtra { - display: none; - } - - .rankingList { - li { - span:first-child { - margin-right: 8px; - } - } - } -} - -@media screen and (max-width: @screen-md) { - .rankingTitle { - margin-top: 16px; - } - - .salesCard .salesBar { - padding: 16px; - } -} - -@media screen and (max-width: @screen-sm) { - .salesExtraWrap { - display: none; - } - - .salesCard { - :global { - .ant-tabs-content { - padding-top: 30px; - } - } - } -} diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/IntroduceRow.js b/antdsp-admin/src/main/web/src/pages/Dashboard/IntroduceRow.js deleted file mode 100644 index f7e67df..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/IntroduceRow.js +++ /dev/null @@ -1,152 +0,0 @@ -import React, { memo } from 'react'; -import { Row, Col, Icon, Tooltip } from 'antd'; -import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale'; -import styles from './Analysis.less'; -import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from '@/components/Charts'; -import Trend from '@/components/Trend'; -import numeral from 'numeral'; -import Yuan from '@/utils/Yuan'; - -const topColResponsiveProps = { - xs: 24, - sm: 12, - md: 12, - lg: 12, - xl: 6, - style: { marginBottom: 24 }, -}; - -const IntroduceRow = memo(({ loading, visitData }) => ( - - - } - action={ - } - > - - - } - loading={loading} - total={() => 126560} - footer={ - } - value={`¥${numeral(12423).format('0,0')}`} - /> - } - contentHeight={46} - > - - - 12% - - - - 11% - - - - - - } - action={ - } - > - - - } - total={numeral(8846).format('0,0')} - footer={ - } - value={numeral(1234).format('0,0')} - /> - } - contentHeight={46} - > - - - - - } - action={ - } - > - - - } - total={numeral(6560).format('0,0')} - footer={ - - } - value="60%" - /> - } - contentHeight={46} - > - - - - - - } - action={ - } - > - - - } - total="78%" - footer={ -
    - - - 12% - - - - 11% - -
    - } - contentHeight={46} - > - -
    - - -)); - -export default IntroduceRow; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.js b/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.js deleted file mode 100644 index de80353..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.js +++ /dev/null @@ -1,244 +0,0 @@ -import React, { Component } from 'react'; -import { connect } from 'dva'; -import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; -import { Row, Col, Card, Tooltip } from 'antd'; -import { Pie, WaterWave, Gauge, TagCloud } from '@/components/Charts'; -import NumberInfo from '@/components/NumberInfo'; -import CountDown from '@/components/CountDown'; -import ActiveChart from '@/components/ActiveChart'; -import numeral from 'numeral'; -import GridContent from '@/components/PageHeaderWrapper/GridContent'; -import Authorized from '@/utils/Authorized'; -import styles from './Monitor.less'; - -const { Secured } = Authorized; - -const targetTime = new Date().getTime() + 3900000; - -// use permission as a parameter -const havePermissionAsync = new Promise(resolve => { - // Call resolve on behalf of passed - setTimeout(() => resolve(), 300); -}); - -@Secured(havePermissionAsync) -@connect(({ monitor, loading }) => ({ - monitor, - loading: loading.models.monitor, -})) -class Monitor extends Component { - componentDidMount() { - const { dispatch } = this.props; - dispatch({ - type: 'monitor/fetchTags', - }); - } - - render() { - const { monitor, loading } = this.props; - const { tags } = monitor; - - return ( - - - - - } - bordered={false} - > - - - - } - suffix="元" - total={numeral(124543233).format('0,0')} - /> - - - - } - total="92%" - /> - - - - } - total={} - /> - - - - } - suffix="元" - total={numeral(234).format('0,0')} - /> - - -
    - - } - > - map - -
    - - -
    - - } - style={{ marginBottom: 24 }} - bordered={false} - > - - - } - style={{ marginBottom: 24 }} - bodyStyle={{ textAlign: 'center' }} - bordered={false} - > - - - - - - - - } - bordered={false} - className={styles.pieCard} - > - - - - } - total="28%" - height={128} - lineWidth={2} - /> - - - - } - total="22%" - height={128} - lineWidth={2} - /> - - - - } - total="32%" - height={128} - lineWidth={2} - /> - - - - - - - } - loading={loading} - bordered={false} - bodyStyle={{ overflow: 'hidden' }} - > - - - - - - } - bodyStyle={{ textAlign: 'center', fontSize: 0 }} - bordered={false} - > - - } - percent={34} - /> - - - - - ); - } -} - -export default Monitor; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.less b/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.less deleted file mode 100644 index 82d7272..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/Monitor.less +++ /dev/null @@ -1,23 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; -@import '~@/utils/utils.less'; - -.mapChart { - height: 452px; - padding-top: 24px; - text-align: center; - img { - display: inline-block; - max-width: 100%; - max-height: 437px; - } -} - -.pieCard :global(.pie-stat) { - font-size: 24px !important; -} - -@media screen and (max-width: @screen-lg) { - .mapChart { - height: auto; - } -} diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/OfflineData.js b/antdsp-admin/src/main/web/src/pages/Dashboard/OfflineData.js deleted file mode 100644 index 7179131..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/OfflineData.js +++ /dev/null @@ -1,65 +0,0 @@ -import React, { memo } from 'react'; -import { Card, Tabs, Row, Col } from 'antd'; -import { formatMessage, FormattedMessage } from 'umi-plugin-react/locale'; -import styles from './Analysis.less'; -import { TimelineChart, Pie } from '@/components/Charts'; -import NumberInfo from '@/components/NumberInfo'; - -const CustomTab = ({ data, currentTabKey: currentKey }) => ( - - - - } - gap={2} - total={`${data.cvr * 100}%`} - theme={currentKey !== data.name && 'light'} - /> - - - - - -); - -const { TabPane } = Tabs; - -const OfflineData = memo( - ({ activeKey, loading, offlineData, offlineChartData, handleTabChange }) => ( - - - {offlineData.map(shop => ( - } key={shop.name}> -
    - -
    -
    - ))} -
    -
    - ) -); - -export default OfflineData; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/ProportionSales.js b/antdsp-admin/src/main/web/src/pages/Dashboard/ProportionSales.js deleted file mode 100644 index 3977130..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/ProportionSales.js +++ /dev/null @@ -1,58 +0,0 @@ -import React, { memo } from 'react'; -import { Card, Radio } from 'antd'; -import { FormattedMessage } from 'umi-plugin-react/locale'; -import styles from './Analysis.less'; -import { Pie } from '@/components/Charts'; -import Yuan from '@/utils/Yuan'; - -const ProportionSales = memo( - ({ dropdownGroup, salesType, loading, salesPieData, handleChangeSalesType }) => ( - - } - bodyStyle={{ padding: 24 }} - extra={ -
    - {dropdownGroup} -
    - - - - - - - - - - - -
    -
    - } - style={{ marginTop: 24 }} - > -

    - -

    - } - total={() => {salesPieData.reduce((pre, now) => now.y + pre, 0)}} - data={salesPieData} - valueFormat={value => {value}} - height={270} - lineWidth={4} - style={{ padding: '8px 0' }} - /> -
    - ) -); - -export default ProportionSales; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/SalesCard.js b/antdsp-admin/src/main/web/src/pages/Dashboard/SalesCard.js deleted file mode 100644 index ee6adf2..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/SalesCard.js +++ /dev/null @@ -1,150 +0,0 @@ -import React, { memo } from 'react'; -import { Row, Col, Card, Tabs, DatePicker } from 'antd'; -import { FormattedMessage, formatMessage } from 'umi-plugin-react/locale'; -import numeral from 'numeral'; -import styles from './Analysis.less'; -import { Bar } from '@/components/Charts'; - -const { RangePicker } = DatePicker; -const { TabPane } = Tabs; - -const rankingListData = []; -for (let i = 0; i < 7; i += 1) { - rankingListData.push({ - title: formatMessage({ id: 'app.analysis.test' }, { no: i }), - total: 323234, - }); -} - -const SalesCard = memo( - ({ rangePickerValue, salesData, isActive, handleRangePickerChange, loading, selectDate }) => ( - - - } - size="large" - tabBarStyle={{ marginBottom: 24 }} - > - } - key="sales" - > - -
    -
    - - } - data={salesData} - /> -
    - - -
    -

    - -

    -
      - {rankingListData.map((item, i) => ( -
    • - - {i + 1} - - - {item.title} - - - {numeral(item.total).format('0,0')} - -
    • - ))} -
    -
    - - - - } - key="views" - > - - -
    - - } - data={salesData} - /> -
    - - -
    -

    - -

    -
      - {rankingListData.map((item, i) => ( -
    • - - {i + 1} - - - {item.title} - - {numeral(item.total).format('0,0')} -
    • - ))} -
    -
    - - - - - - - ) -); - -export default SalesCard; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/TopSearch.js b/antdsp-admin/src/main/web/src/pages/Dashboard/TopSearch.js deleted file mode 100644 index bd89395..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/TopSearch.js +++ /dev/null @@ -1,111 +0,0 @@ -import React, { memo } from 'react'; -import { Row, Col, Table, Tooltip, Card, Icon } from 'antd'; -import { FormattedMessage } from 'umi-plugin-react/locale'; -import Trend from '@/components/Trend'; -import numeral from 'numeral'; -import styles from './Analysis.less'; -import NumberInfo from '@/components/NumberInfo'; -import { MiniArea } from '@/components/Charts'; - -const columns = [ - { - title: , - dataIndex: 'index', - key: 'index', - }, - { - title: ( - - ), - dataIndex: 'keyword', - key: 'keyword', - render: text => {text}, - }, - { - title: , - dataIndex: 'count', - key: 'count', - sorter: (a, b) => a.count - b.count, - className: styles.alignRight, - }, - { - title: , - dataIndex: 'range', - key: 'range', - sorter: (a, b) => a.range - b.range, - render: (text, record) => ( - - {text}% - - ), - align: 'right', - }, -]; - -const TopSearch = memo(({ loading, visitData2, searchData, dropdownGroup }) => ( - - } - extra={dropdownGroup} - style={{ marginTop: 24 }} - > - - - - - } - > - - - - } - gap={8} - total={numeral(12321).format('0,0')} - status="up" - subTotal={17.1} - /> - - - - - - } - > - - - - } - total={2.7} - status="down" - subTotal={26.2} - gap={8} - /> - - - -
    record.index} - size="small" - columns={columns} - dataSource={searchData} - pagination={{ - style: { marginBottom: 0 }, - pageSize: 5, - }} - /> - -)); - -export default TopSearch; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.js b/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.js deleted file mode 100644 index d71b122..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.js +++ /dev/null @@ -1,255 +0,0 @@ -import React, { PureComponent } from 'react'; -import moment from 'moment'; -import { connect } from 'dva'; -import Link from 'umi/link'; -import { Row, Col, Card, List, Avatar } from 'antd'; -import { Radar } from '@/components/Charts'; -import EditableLinkGroup from '@/components/EditableLinkGroup'; -import PageHeaderWrapper from '@/components/PageHeaderWrapper'; - -import styles from './Workplace.less'; - -const links = [ - { - title: '操作一', - href: '', - }, - { - title: '操作二', - href: '', - }, - { - title: '操作三', - href: '', - }, - { - title: '操作四', - href: '', - }, - { - title: '操作五', - href: '', - }, - { - title: '操作六', - href: '', - }, -]; - -@connect(({ user, project, activities, chart, loading }) => ({ - currentUser: user.currentUser, - project, - activities, - chart, - currentUserLoading: loading.effects['user/fetchCurrent'], - projectLoading: loading.effects['project/fetchNotice'], - activitiesLoading: loading.effects['activities/fetchList'], -})) -class Workplace extends PureComponent { - componentDidMount() { - const { dispatch } = this.props; - dispatch({ - type: 'user/fetchCurrent', - }); - dispatch({ - type: 'project/fetchNotice', - }); - dispatch({ - type: 'activities/fetchList', - }); - dispatch({ - type: 'chart/fetch', - }); - } - - componentWillUnmount() { - const { dispatch } = this.props; - dispatch({ - type: 'chart/clear', - }); - } - - renderActivities() { - const { - activities: { list }, - } = this.props; - return list.map(item => { - const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => { - if (item[key]) { - return ( - - {item[key].name} - - ); - } - return key; - }); - return ( - - } - title={ - - {item.user.name} -   - {events} - - } - description={ - - {moment(item.updatedAt).fromNow()} - - } - /> - - ); - }); - } - - render() { - const { - currentUser, - currentUserLoading, - project: { notice }, - projectLoading, - activitiesLoading, - chart: { radarData }, - } = this.props; - - const pageHeaderContent = - currentUser && Object.keys(currentUser).length ? ( -
    -
    - -
    -
    -
    - 早安, - {currentUser.name} - ,祝你开心每一天! -
    -
    - {currentUser.title} |{currentUser.group} -
    -
    -
    - ) : null; - - const extraContent = ( -
    -
    -

    项目数

    -

    56

    -
    -
    -

    团队内排名

    -

    - 8 / 24 -

    -
    -
    -

    项目访问

    -

    2,223

    -
    -
    - ); - - return ( - - - - 全部项目} - loading={projectLoading} - bodyStyle={{ padding: 0 }} - > - {notice.map(item => ( - - - - - {item.title} - - } - description={item.description} - /> -
    - {item.member || ''} - {item.updatedAt && ( - - {moment(item.updatedAt).fromNow()} - - )} -
    -
    -
    - ))} -
    - - -
    {this.renderActivities()}
    -
    -
    - - - - {}} links={links} linkElement={Link} /> - - -
    - -
    -
    - -
    - - {notice.map(item => ( -
    - - - {item.member} - - - ))} - - - - - - - ); - } -} - -export default Workplace; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.less b/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.less deleted file mode 100644 index b67e0b6..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/Workplace.less +++ /dev/null @@ -1,228 +0,0 @@ -@import '~antd/lib/style/themes/default.less'; -@import '~@/utils/utils.less'; - -.activitiesList { - padding: 0 24px 8px 24px; - .username { - color: @text-color; - } - .event { - font-weight: normal; - } -} - -.pageHeaderContent { - display: flex; - .avatar { - flex: 0 1 72px; - margin-bottom: 8px; - & > span { - display: block; - width: 72px; - height: 72px; - border-radius: 72px; - } - } - .content { - position: relative; - top: 4px; - flex: 1 1 auto; - margin-left: 24px; - color: @text-color-secondary; - line-height: 22px; - .contentTitle { - margin-bottom: 12px; - color: @heading-color; - font-weight: 500; - font-size: 20px; - line-height: 28px; - } - } -} - -.extraContent { - .clearfix(); - - float: right; - white-space: nowrap; - .statItem { - position: relative; - display: inline-block; - padding: 0 32px; - > p:first-child { - margin-bottom: 4px; - color: @text-color-secondary; - font-size: @font-size-base; - line-height: 22px; - } - > p { - margin: 0; - color: @heading-color; - font-size: 30px; - line-height: 38px; - > span { - color: @text-color-secondary; - font-size: 20px; - } - } - &::after { - position: absolute; - top: 8px; - right: 0; - width: 1px; - height: 40px; - background-color: @border-color-split; - content: ''; - } - &:last-child { - padding-right: 0; - &::after { - display: none; - } - } - } -} - -.members { - a { - display: block; - height: 24px; - margin: 12px 0; - color: @text-color; - transition: all 0.3s; - .textOverflow(); - .member { - margin-left: 12px; - font-size: @font-size-base; - line-height: 24px; - vertical-align: top; - } - &:hover { - color: @primary-color; - } - } -} - -.projectList { - :global { - .ant-card-meta-description { - height: 44px; - overflow: hidden; - color: @text-color-secondary; - line-height: 22px; - } - } - .cardTitle { - font-size: 0; - a { - display: inline-block; - height: 24px; - margin-left: 12px; - color: @heading-color; - font-size: @font-size-base; - line-height: 24px; - vertical-align: top; - &:hover { - color: @primary-color; - } - } - } - .projectGrid { - width: 33.33%; - } - .projectItemContent { - display: flex; - height: 20px; - margin-top: 8px; - overflow: hidden; - font-size: 12px; - line-height: 20px; - .textOverflow(); - a { - display: inline-block; - flex: 1 1 0; - color: @text-color-secondary; - .textOverflow(); - &:hover { - color: @primary-color; - } - } - .datetime { - flex: 0 0 auto; - float: right; - color: @disabled-color; - } - } -} - -.datetime { - color: @disabled-color; -} - -@media screen and (max-width: @screen-xl) and (min-width: @screen-lg) { - .activeCard { - margin-bottom: 24px; - } - .members { - margin-bottom: 0; - } - .extraContent { - margin-left: -44px; - .statItem { - padding: 0 16px; - } - } -} - -@media screen and (max-width: @screen-lg) { - .activeCard { - margin-bottom: 24px; - } - .members { - margin-bottom: 0; - } - .extraContent { - float: none; - margin-right: 0; - .statItem { - padding: 0 16px; - text-align: left; - &::after { - display: none; - } - } - } -} - -@media screen and (max-width: @screen-md) { - .extraContent { - margin-left: -16px; - } - .projectList { - .projectGrid { - width: 50%; - } - } -} - -@media screen and (max-width: @screen-sm) { - .pageHeaderContent { - display: block; - .content { - margin-left: 0; - } - } - .extraContent { - .statItem { - float: none; - } - } -} - -@media screen and (max-width: @screen-xs) { - .projectList { - .projectGrid { - width: 100%; - } - } -} diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/models/activities.js b/antdsp-admin/src/main/web/src/pages/Dashboard/models/activities.js deleted file mode 100644 index 4e0a11e..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/models/activities.js +++ /dev/null @@ -1,28 +0,0 @@ -import { queryActivities } from '@/services/api'; - -export default { - namespace: 'activities', - - state: { - list: [], - }, - - effects: { - *fetchList(_, { call, put }) { - const response = yield call(queryActivities); - yield put({ - type: 'saveList', - payload: Array.isArray(response) ? response : [], - }); - }, - }, - - reducers: { - saveList(state, action) { - return { - ...state, - list: action.payload, - }; - }, - }, -}; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/models/chart.js b/antdsp-admin/src/main/web/src/pages/Dashboard/models/chart.js deleted file mode 100644 index 8dfe4a9..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/models/chart.js +++ /dev/null @@ -1,61 +0,0 @@ -import { fakeChartData } from '@/services/api'; - -export default { - namespace: 'chart', - - state: { - visitData: [], - visitData2: [], - salesData: [], - searchData: [], - offlineData: [], - offlineChartData: [], - salesTypeData: [], - salesTypeDataOnline: [], - salesTypeDataOffline: [], - radarData: [], - loading: false, - }, - - effects: { - *fetch(_, { call, put }) { - const response = yield call(fakeChartData); - yield put({ - type: 'save', - payload: response, - }); - }, - *fetchSalesData(_, { call, put }) { - const response = yield call(fakeChartData); - yield put({ - type: 'save', - payload: { - salesData: response.salesData, - }, - }); - }, - }, - - reducers: { - save(state, { payload }) { - return { - ...state, - ...payload, - }; - }, - clear() { - return { - visitData: [], - visitData2: [], - salesData: [], - searchData: [], - offlineData: [], - offlineChartData: [], - salesTypeData: [], - salesTypeDataOnline: [], - salesTypeDataOffline: [], - radarData: [], - }; - }, - }, -}; diff --git a/antdsp-admin/src/main/web/src/pages/Dashboard/models/monitor.js b/antdsp-admin/src/main/web/src/pages/Dashboard/models/monitor.js deleted file mode 100644 index e3e832f..0000000 --- a/antdsp-admin/src/main/web/src/pages/Dashboard/models/monitor.js +++ /dev/null @@ -1,28 +0,0 @@ -import { queryTags } from '@/services/api'; - -export default { - namespace: 'monitor', - - state: { - tags: [], - }, - - effects: { - *fetchTags(_, { call, put }) { - const response = yield call(queryTags); - yield put({ - type: 'saveTags', - payload: response.list, - }); - }, - }, - - reducers: { - saveTags(state, action) { - return { - ...state, - tags: action.payload, - }; - }, - }, -}; diff --git a/antdsp-admin/src/main/web/src/pages/System/Menu/Index.js b/antdsp-admin/src/main/web/src/pages/System/Menu/Index.js new file mode 100644 index 0000000..22e2508 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/Menu/Index.js @@ -0,0 +1,214 @@ +import { PureComponent, Fragment } from "react"; +import { connect } from 'dva'; +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; +import Block from '@/custom/Block'; +import { Card, Form, Button, Table, Divider, Popconfirm, Select, Modal } from "antd"; + + +const FormItem = Form.Item; + +@connect(({ systemmenu , loading })=>({ + systemmenu, + loading: loading.models.systemmenu +})) +@Form.create() +export default class extends PureComponent{ + + state={ + visible: false , + confirmLoading: false, + } + + componentDidMount() { + const { dispatch } = this.props; + dispatch({ + type: 'systemmenu/fetchAll', + }) + } + + render() { + + const columns =[{ + title: "", + dataIndex:'id', + },{ + title: "菜单名称", + dataIndex:'name', + },{ + title: "URL", + dataIndex:'path', + },{ + title: "类型", + dataIndex:'type', + render:(val)=> MenuType[val] + },{ + title: "权限名", + dataIndex:'permission', + },{ + title: "图标", + dataIndex:'icon', + render:(val)=>{ + if(val) + return + } + },{ + title: "操作", + render:(record)=>{ + + return ( + + {this.setState({visible: true , currentObj: record})}}>编辑 + + this.handlerDelOnClick(e , record.recId)}> + 删除 + + + ) + } + }]; + + return( + + + + + + +
    + {this.setState({visible: false})}} + onOk={this.handlerModalOnOk} + confirmLoading={this.state.confirmLoading} + destroyOnClose={true} + > + this.formRef= formRef} /> + {/* currentObj={this.state.currentObj} parentMenu={MenuTree} */} + + + + ) + } +} + +class EditMenu extends PureComponent{ + + assbleMenu(menuTree){ + + let parentMenu={ + title: '根菜单', + value: '0', + key: '0' + } + this.handlerAssbleMenu(parentMenu , menuTree); + return parentMenu; + } + + handlerAssbleMenu(parentMenu , menus){ + + let childMenus=[]; + for(let item of menus){ + let childMenu = { + title: item.name , + value: item.recId , + key: item.recId , + }; + if(item.children && item.children.length > 0){ + this.handlerAssbleMenu(childMenu , item.children); + } + childMenus.push(childMenu); + } + parentMenu.children = childMenus; + } + + render() { + + const { getFieldDecorator } = this.props.form; + + const formItemLayout = { + labelCol:{ + xs: { span : 6}, + sm: { span : 6 }, + }, + wrapperCol:{ + xs: { span : 12}, + sm: { span : 12 }, + } + } + + const { current , parentMenu } = this.props; + + const flag = (Object.keys(current).length == 0); + + return( +
    +
    + + {getFieldDecorator('menuType')( + + )} + + + {getFieldDecorator("parentId",{ + initialValue: current.parentId, + rules:[ + { + required: true, + message: '请选择父级菜单', + } + ] + })( + + )} + + + {getFieldDecorator("menuName",{ + initialValue: current.name, + rules: [ + { + required: true, + message: '请选择父级菜单', + } + ] + })( + + )} + + + {getFieldDecorator("url",{ + initialValue: current.path, + })( + + )} + + + {getFieldDecorator("permission",{ + initialValue: current.permission, + })( + + )} + + + {getFieldDecorator("icon",{ + initialValue: current.icon, + })( + + )} + + +
    + ) + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/Menu/models/menu.js b/antdsp-admin/src/main/web/src/pages/System/Menu/models/menu.js new file mode 100644 index 0000000..791f796 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/Menu/models/menu.js @@ -0,0 +1,32 @@ +import { + fetchAllMenu +} from '@/services/system'; + +export default { + + namespace: 'systemmenu', + + state: { + MenuList:[] + }, + + effects: { + *fetchAll({payload},{call , put}){ + const response = yield call(fetchAllMenu); + + yield put({ + type: 'reducersMenuList', + payload: response + }) + } + }, + + reducers: { + reducersMenuList(state , action){ + return { + ...state, + MenuList: action.payload + } + } + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/User/Index.js b/antdsp-admin/src/main/web/src/pages/System/User/Index.js new file mode 100644 index 0000000..b6dc478 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/User/Index.js @@ -0,0 +1,92 @@ +import { PureComponent, Fragment } from "react"; +import { connect } from 'dva'; +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; +import Block from '@/custom/Block'; +import { Card, Form, Button, Table, Divider } from "antd"; + +const FormItem = Form.Item; + +@connect(({ systemuser , loading })=>({ + systemuser, + loading: loading.models.systemuser +})) +@Form.create() +export default class extends PureComponent{ + + componentDidMount(){ + const { dispatch } = this.props; + dispatch({ + type: 'systemuser/fetchAll', + payload:{ + page: 1, + count: 10, + } + }) + } + + renderQueryForm=()=>{ + + return( + +
    + + +
    + ) + } + + render(){ + + const { systemuser:{UserList} } = this.props; + + const columns = [{ + title: '头像', + dataIndex: 'avatar', + },{ + title: '登录名', + dataIndex: 'loginname', + },{ + title: '真实姓名', + dataIndex: 'realname', + },{ + title: 'Email', + dataIndex: 'email', + },{ + title: 'QQ', + dataIndex: 'qq', + },{ + title: '状态', + dataIndex: 'status', + },{ + title: '操作', + render:(record)=>{ + return ( + + 查看 + + 编辑 + + 删除 + + ) + } + }] + + return ( + + + {/* {this.renderQueryForm} */} + + + +
    + + + ) + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/User/models/user.js b/antdsp-admin/src/main/web/src/pages/System/User/models/user.js new file mode 100644 index 0000000..f9774f9 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/User/models/user.js @@ -0,0 +1,35 @@ +import { + fetchAllUser +} from '@/services/system'; + +export default { + namespace: 'systemuser', + + state: { + UserList:{ + data:[], + pagination:{} + } + }, + + effects: { + *fetchAll({payload} , {call , put}){ + const response = yield call(fetchAllUser , payload); + yield put({ + type:'reducersUserList', + payload: response, + }) + } + }, + + reducers: { + reducersUserList(state , action){ + return { + ...state, + UserList:{ + ...action.payload + } + } + } + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/menu/Index.js b/antdsp-admin/src/main/web/src/pages/System/menu/Index.js deleted file mode 100644 index 8fed501..0000000 --- a/antdsp-admin/src/main/web/src/pages/System/menu/Index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { PureComponent } from "react"; - -import PageHeaderWrapper from '@/components/PageHeaderWrapper'; - -export default class Index extends PureComponent{ - - render(){ - - return( - - - - ) - } -} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/models/system.js b/antdsp-admin/src/main/web/src/pages/System/models/system.js deleted file mode 100644 index 7c68152..0000000 --- a/antdsp-admin/src/main/web/src/pages/System/models/system.js +++ /dev/null @@ -1,17 +0,0 @@ - -export default { - namespace: "system", - - state: { - - }, - - effects: { - - }, - - reducers: { - - } - -} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/role/Index.js b/antdsp-admin/src/main/web/src/pages/System/role/Index.js deleted file mode 100644 index 8fed501..0000000 --- a/antdsp-admin/src/main/web/src/pages/System/role/Index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { PureComponent } from "react"; - -import PageHeaderWrapper from '@/components/PageHeaderWrapper'; - -export default class Index extends PureComponent{ - - render(){ - - return( - - - - ) - } -} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/user/Index.js b/antdsp-admin/src/main/web/src/pages/System/user/Index.js deleted file mode 100644 index 8fed501..0000000 --- a/antdsp-admin/src/main/web/src/pages/System/user/Index.js +++ /dev/null @@ -1,15 +0,0 @@ -import { PureComponent } from "react"; - -import PageHeaderWrapper from '@/components/PageHeaderWrapper'; - -export default class Index extends PureComponent{ - - render(){ - - return( - - - - ) - } -} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/services/system.js b/antdsp-admin/src/main/web/src/services/system.js new file mode 100644 index 0000000..0559b7c --- /dev/null +++ b/antdsp-admin/src/main/web/src/services/system.js @@ -0,0 +1,15 @@ +import { async } from "q"; +import request from '@/utils/request'; +import qs from 'qs'; + +const API_BASE = "/antdsp-api"; +const USER_API = API_BASE + "/system/user"; +const MENU_API = API_BASE + "/system/menu"; + +export async function fetchAllUser(params){ + return request(`${USER_API}?${qs.stringify(params, { indices: false })}`); +} + +export async function fetchAllMenu(){ + return request(`${MENU_API}`) +} \ No newline at end of file diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/UserJpa.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/UserJpa.java index 03ef064..49432db 100644 --- a/antdsp-core/src/main/java/com/antdsp/dao/jpa/UserJpa.java +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/UserJpa.java @@ -2,11 +2,16 @@ package com.antdsp.dao.jpa; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import com.antdsp.model.entity.User; +import com.antdsp.data.entity.User; @Repository("userJpa") public interface UserJpa extends JpaRepository , JpaSpecificationExecutor{ + + @Query("From User WHERE loginname = :loginName AND status = 'NORMAL'") + User queryUserByLoginName(@Param("loginName") String loginName); } diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/MenuJpa.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/MenuJpa.java new file mode 100644 index 0000000..6bb2c54 --- /dev/null +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/MenuJpa.java @@ -0,0 +1,12 @@ +package com.antdsp.dao.jpa.system; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +import com.antdsp.data.entity.system.SystemMenu; + +@Repository("menuJpa") +public interface MenuJpa extends JpaRepository , JpaSpecificationExecutor{ + +} diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/RoleJpa.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/RoleJpa.java new file mode 100644 index 0000000..280e7b0 --- /dev/null +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/RoleJpa.java @@ -0,0 +1,12 @@ +package com.antdsp.dao.jpa.system; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.stereotype.Repository; + +import com.antdsp.data.entity.system.SystemRole; + +@Repository("roleJpa") +public interface RoleJpa extends JpaRepository , JpaSpecificationExecutor{ + +} diff --git a/antdsp-core/src/main/java/com/antdsp/model/entity/AbstractEntity.java b/antdsp-core/src/main/java/com/antdsp/data/entity/AbstractEntity.java similarity index 98% rename from antdsp-core/src/main/java/com/antdsp/model/entity/AbstractEntity.java rename to antdsp-core/src/main/java/com/antdsp/data/entity/AbstractEntity.java index fcefb9a..5c3a47b 100644 --- a/antdsp-core/src/main/java/com/antdsp/model/entity/AbstractEntity.java +++ b/antdsp-core/src/main/java/com/antdsp/data/entity/AbstractEntity.java @@ -1,4 +1,4 @@ -package com.antdsp.model.entity; +package com.antdsp.data.entity; import java.io.Serializable; import java.sql.Timestamp; diff --git a/antdsp-core/src/main/java/com/antdsp/model/entity/User.java b/antdsp-core/src/main/java/com/antdsp/data/entity/User.java similarity index 39% rename from antdsp-core/src/main/java/com/antdsp/model/entity/User.java rename to antdsp-core/src/main/java/com/antdsp/data/entity/User.java index ed37833..572724f 100644 --- a/antdsp-core/src/main/java/com/antdsp/model/entity/User.java +++ b/antdsp-core/src/main/java/com/antdsp/data/entity/User.java @@ -1,4 +1,4 @@ -package com.antdsp.model.entity; +package com.antdsp.data.entity; import javax.persistence.Column; import javax.persistence.Entity; @@ -6,7 +6,7 @@ import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.Table; -import com.antdsp.model.entityeenum.UserStatus; +import com.antdsp.data.entityeenum.UserStatus; @Table(name="tb_user") @Entity @@ -21,16 +21,74 @@ public class User extends AbstractEntity{ @Column(name="password" , nullable=false) private String password; - @Column(name="avatar" , nullable=false) + @Column(name="avatar") private String avatar; - @Column(name="email" , nullable=false) + @Column(name="email" ) private String email; - @Column(name="qq" , nullable=false) + @Column(name="qq") private String qq; @Column(name="status" , nullable=false) @Enumerated(EnumType.STRING) private UserStatus status; + + public String getLoginname() { + return loginname; + } + + public String getRealname() { + return realname; + } + + public String getPassword() { + return password; + } + + public String getAvatar() { + return avatar; + } + + public String getEmail() { + return email; + } + + public String getQq() { + return qq; + } + + public UserStatus getStatus() { + return status; + } + + public void setLoginname(String loginname) { + this.loginname = loginname; + } + + public void setRealname(String realname) { + this.realname = realname; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setQq(String qq) { + this.qq = qq; + } + + public void setStatus(UserStatus status) { + this.status = status; + } + + } diff --git a/antdsp-core/src/main/java/com/antdsp/data/entity/system/SystemMenu.java b/antdsp-core/src/main/java/com/antdsp/data/entity/system/SystemMenu.java new file mode 100644 index 0000000..745e87a --- /dev/null +++ b/antdsp-core/src/main/java/com/antdsp/data/entity/system/SystemMenu.java @@ -0,0 +1,94 @@ +package com.antdsp.data.entity.system; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.Table; + +import com.antdsp.data.entity.AbstractEntity; +import com.antdsp.data.entityeenum.MenuType; + +@Table(name="tb_system_menu") +@Entity +public class SystemMenu extends AbstractEntity { + + @Column(name="menu_name" , nullable=false , length=32) + private String menuName; + + @Column(name="parent_id" , nullable = false ) + private Long parentId; + + @Column(name="url" , length=64) + private String url; + + @Column(name="permission" , length=64) + private String permission; + + @Column(name="icon" , length=64) + private String icon; + + @Column(name="menu_type" , length=12) + @Enumerated(value=EnumType.STRING) + private MenuType menuType; + + @Column(name="reamrk" , length=64) + private String reamrk; + + public String getMenuName() { + return menuName; + } + + public Long getParentId() { + return parentId; + } + + public String getUrl() { + return url; + } + + public String getPermission() { + return permission; + } + + public String getIcon() { + return icon; + } + + public String getReamrk() { + return reamrk; + } + + public void setMenuName(String menuName) { + this.menuName = menuName; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setPermission(String permission) { + this.permission = permission; + } + + public void setIcon(String icon) { + this.icon = icon; + } + + public void setReamrk(String reamrk) { + this.reamrk = reamrk; + } + + public MenuType getMenuType() { + return menuType; + } + + public void setMenuType(MenuType menuType) { + this.menuType = menuType; + } + +} diff --git a/antdsp-core/src/main/java/com/antdsp/data/entity/system/SystemRole.java b/antdsp-core/src/main/java/com/antdsp/data/entity/system/SystemRole.java new file mode 100644 index 0000000..66507f9 --- /dev/null +++ b/antdsp-core/src/main/java/com/antdsp/data/entity/system/SystemRole.java @@ -0,0 +1,36 @@ +package com.antdsp.data.entity.system; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; + +import com.antdsp.data.entity.AbstractEntity; + +@Table(name="tb_system_role") +@Entity +public class SystemRole extends AbstractEntity { + + @Column(name="role_name" , nullable=false , length= 32) + private String roleName; + + @Column(name="description" , length= 32) + private String description; + + public String getRoleName() { + return roleName; + } + + public String getDescription() { + return description; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public void setDescription(String description) { + this.description = description; + } + + +} diff --git a/antdsp-core/src/main/java/com/antdsp/data/entityeenum/MenuType.java b/antdsp-core/src/main/java/com/antdsp/data/entityeenum/MenuType.java new file mode 100644 index 0000000..75416f4 --- /dev/null +++ b/antdsp-core/src/main/java/com/antdsp/data/entityeenum/MenuType.java @@ -0,0 +1,17 @@ +package com.antdsp.data.entityeenum; + +public enum MenuType { + + MENU("菜单"), + BUTTON("按钮"); + + private String value; + + MenuType(String value){ + this.value = value; + } + + public String getValue() { + return this.value; + } +} diff --git a/antdsp-core/src/main/java/com/antdsp/model/entityeenum/UserStatus.java b/antdsp-core/src/main/java/com/antdsp/data/entityeenum/UserStatus.java similarity index 79% rename from antdsp-core/src/main/java/com/antdsp/model/entityeenum/UserStatus.java rename to antdsp-core/src/main/java/com/antdsp/data/entityeenum/UserStatus.java index c441ff5..ab9fab3 100644 --- a/antdsp-core/src/main/java/com/antdsp/model/entityeenum/UserStatus.java +++ b/antdsp-core/src/main/java/com/antdsp/data/entityeenum/UserStatus.java @@ -1,4 +1,4 @@ -package com.antdsp.model.entityeenum; +package com.antdsp.data.entityeenum; public enum UserStatus { NORMAL("正常"), -- Gitee From f38eceea450cadf45dc7481cd6744dfcfd556d80 Mon Sep 17 00:00:00 2001 From: lijiantao Date: Mon, 10 Jun 2019 18:02:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/antdsp/ApplicationStarter.java | 4 + .../com/antdsp/common/AntdspResponse.java | 25 ++- .../common/exception/AntdspException.java | 2 +- .../main/java/com/antdsp/web/dto/RoleDto.java | 45 ++++ .../antdsp/web/rest/sys/SystemMenuApi.java | 59 ++++- .../antdsp/web/rest/sys/SystemRoleApi.java | 82 ++++++- .../src/main/web/config/router.config.js | 10 +- .../src/main/web/src/locales/zh-CN/menu.js | 3 +- .../main/web/src/pages/System/Menu/Index.js | 106 +++++++-- .../web/src/pages/System/Menu/models/menu.js | 24 +- .../main/web/src/pages/System/Role/Index.js | 212 ++++++++++++++++++ .../web/src/pages/System/Role/MenuTree.js | 50 +++++ .../web/src/pages/System/Role/models/role.js | 67 ++++++ .../src/main/web/src/services/system.js | 53 +++++ .../common/AntdspRepositoryFactoryBean.java | 53 +++++ .../antdsp/dao/jpa/AntdspBaseRepository.java | 18 +- .../dao/jpa/AntdspBaseRepositoryImpl.java | 28 ++- .../com/antdsp/dao/jpa/system/RoleJpa.java | 5 +- 18 files changed, 810 insertions(+), 36 deletions(-) create mode 100644 antdsp-admin/src/main/java/com/antdsp/web/dto/RoleDto.java create mode 100644 antdsp-admin/src/main/web/src/pages/System/Role/Index.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/Role/MenuTree.js create mode 100644 antdsp-admin/src/main/web/src/pages/System/Role/models/role.js create mode 100644 antdsp-core/src/main/java/com/antdsp/common/AntdspRepositoryFactoryBean.java diff --git a/antdsp-admin/src/main/java/com/antdsp/ApplicationStarter.java b/antdsp-admin/src/main/java/com/antdsp/ApplicationStarter.java index 9c97db6..ad9cb78 100644 --- a/antdsp-admin/src/main/java/com/antdsp/ApplicationStarter.java +++ b/antdsp-admin/src/main/java/com/antdsp/ApplicationStarter.java @@ -5,10 +5,14 @@ import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.Environment; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.transaction.annotation.EnableTransactionManagement; +import com.antdsp.common.AntdspRepositoryFactoryBean; + @SpringBootApplication @EnableTransactionManagement +@EnableJpaRepositories(repositoryFactoryBeanClass = AntdspRepositoryFactoryBean.class) public class ApplicationStarter { private static final Logger logger = LoggerFactory.getLogger(ApplicationStarter.class); diff --git a/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java b/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java index 996b052..284b337 100644 --- a/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java +++ b/antdsp-admin/src/main/java/com/antdsp/common/AntdspResponse.java @@ -4,22 +4,25 @@ public class AntdspResponse { private int code; + private boolean success; + private String message; public AntdspResponse() { } - public AntdspResponse(ResponseCode code){ - this(code.getValue() , code.getMsg()); + public AntdspResponse(ResponseCode code , boolean success){ + this(code.getValue() , success , code.getMsg()); } - public AntdspResponse(ResponseCode code , String message) { - this(code.getValue() , message); + public AntdspResponse(ResponseCode code , boolean success , String message) { + this(code.getValue() , success, message); } - public AntdspResponse(int code , String message) { + public AntdspResponse(int code , boolean success , String message) { this.code = code; this.message = message; + this.success = success; } public int getCode() { @@ -48,7 +51,7 @@ public class AntdspResponse { public static AntdspResponse success(ResponseCode code , String msg) { - return new AntdspResponse(code, msg); + return new AntdspResponse(code, true , msg); } public static AntdspResponse error() { @@ -60,6 +63,14 @@ public class AntdspResponse { } public static AntdspResponse error(ResponseCode code , String msg) { - return new AntdspResponse(code, msg); + return new AntdspResponse(code, false, msg); + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; } } diff --git a/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java b/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java index 18f619a..722dd94 100644 --- a/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java +++ b/antdsp-admin/src/main/java/com/antdsp/common/exception/AntdspException.java @@ -25,6 +25,6 @@ public class AntdspException extends RuntimeException{ @ExceptionHandler(value= {UnauthorizedException.class}) @ResponseBody public AntdspResponse unauthorizedException() { - return new AntdspResponse( ResponseCode.FORBIDDEN , "权限不足,请联系管理员."); + return new AntdspResponse( ResponseCode.FORBIDDEN , false , "权限不足,请联系管理员."); } } diff --git a/antdsp-admin/src/main/java/com/antdsp/web/dto/RoleDto.java b/antdsp-admin/src/main/java/com/antdsp/web/dto/RoleDto.java new file mode 100644 index 0000000..9319343 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/web/dto/RoleDto.java @@ -0,0 +1,45 @@ +package com.antdsp.web.dto; + +import java.util.List; + +public class RoleDto { + private Long id; + private String roleName; + private String description; + + private List menuIds; + + public Long getId() { + return id; + } + + public String getRoleName() { + return roleName; + } + + public String getDescription() { + return description; + } + + public List getMenuIds() { + return menuIds; + } + + public void setId(Long id) { + this.id = id; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setMenuIds(List menuIds) { + this.menuIds = menuIds; + } + + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemMenuApi.java b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemMenuApi.java index 2a48653..fb45c00 100644 --- a/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemMenuApi.java +++ b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemMenuApi.java @@ -4,12 +4,20 @@ import java.util.List; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.antdsp.common.AntdspResponse; import com.antdsp.dao.jpa.system.MenuJpa; import com.antdsp.data.entity.system.SystemMenu; +import com.antdsp.data.entityeenum.MenuType; import com.antdsp.web.dto.MenuTree; @RestController @@ -34,9 +42,58 @@ public class SystemMenuApi { return rootMenu; } + @PostMapping("") + @Transactional + public AntdspResponse add(@RequestBody MenuTree menu) { + + SystemMenu data = new SystemMenu(); + this.dtoToData(menu, data); + data.setCreator(""); + data.setModifier(""); + data.onPreInsert(); + data.setId(null); + this.menuJpa.save(data); + return AntdspResponse.success(); + } + + @PutMapping("") + @Transactional + public AntdspResponse update(@RequestBody MenuTree menu) { + + SystemMenu oldMenu = this.menuJpa.getOne(menu.getId()); + + this.dtoToData(menu, oldMenu); + oldMenu.onPreUpdate(); + this.menuJpa.save(oldMenu); + return AntdspResponse.success(); + } + + @DeleteMapping("/{id:\\d+}") + public AntdspResponse delete(@PathVariable("id") Long id) { + + SystemMenu oldMenu = this.menuJpa.getOne(id); + if(oldMenu == null) { + return AntdspResponse.error("未找到操作对象"); + } + + this.menuJpa.delete(oldMenu); + return AntdspResponse.success(); + + } + + + private void dtoToData(MenuTree menu , SystemMenu systemenu) { + systemenu.setIcon(menu.getIcon()); + systemenu.setMenuName(menu.getName()); + systemenu.setMenuType(MenuType.valueOf(menu.getType())); + systemenu.setParentId(menu.getParentId()); + systemenu.setPermission(menu.getPermission()); + systemenu.setUrl(menu.getPath()); + } + private void child(MenuTree parentMenu , List allMenus) { List childMenus = allMenus.stream().filter(item-> - parentMenu.equals(item.getParentId())).collect(Collectors.toList()); + parentMenu.getId().equals(item.getParentId())).collect(Collectors.toList()); allMenus.removeAll(childMenus); childMenus.forEach(item->{ MenuTree menu = new MenuTree(); diff --git a/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java index a0eff17..58059aa 100644 --- a/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java +++ b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java @@ -15,15 +15,22 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Order; import org.springframework.data.jpa.domain.Specification; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.antdsp.common.AntdspResponse; import com.antdsp.common.pagination.PaginationData; import com.antdsp.dao.jpa.system.RoleJpa; -import com.antdsp.data.entity.User; import com.antdsp.data.entity.system.SystemRole; +import com.antdsp.web.dto.RoleDto; /** * @@ -64,5 +71,78 @@ public class SystemRoleApi { return new PaginationData<>(userList.getContent() , page , userList.getTotalElements()); } + + @PostMapping("") + @Transactional + public AntdspResponse add(@RequestBody RoleDto role) { + + SystemRole data = new SystemRole(); + + data.setId(null); + this.dtoToData(role, data); + data.setCreator(""); + data.setModifier(""); + data.onPreInsert(); + + data = this.roleJpa.save(data); + + List menuIds = role.getMenuIds(); + + this.saveRoleMenu(menuIds, role.getId()); + + return AntdspResponse.success(); + } + + @PutMapping("") + @Transactional + public AntdspResponse update(@RequestBody RoleDto role) { + + Long roleId = role.getId(); + SystemRole data = this.roleJpa.getOne(roleId); + if(data == null) { + return AntdspResponse.error("未找到角色信息"); + } + + this.dtoToData(role, data); + data.onPreUpdate(); + this.roleJpa.save(data); + + String deleteStr = "DELETE FROM `tb_role_menu` WHERE `role_id` = :roleId"; + + this.roleJpa.executeSQL(deleteStr , roleId); + this.saveRoleMenu(role.getMenuIds(), roleId); + return AntdspResponse.success(); + } + + @DeleteMapping("/{id:\\d+}") + @Transactional + public AntdspResponse delete(@PathVariable("id") Long id) { + + SystemRole role = this.roleJpa.getOne(id); + if(role == null) { + return AntdspResponse.error("未找到角色信息"); + } + this.roleJpa.delete(role); + return AntdspResponse.success(); + } + + private int saveRoleMenu(List menuIds , Long roleId) { + if(menuIds != null &&menuIds.size() > 0) { + StringBuffer sqlStr = new StringBuffer("INSERT INTO `tb_role_menu` (`role_id`,`menu_id`) VALUES "); + sqlStr.append("("+roleId+" , "+ menuIds.get(0)+" ) "); + if(menuIds.size() > 2) { + for(int i = 1 ; i< menuIds.size() ; i++) { + sqlStr.append(",("+roleId+" , "+ menuIds.get(0)+" ) "); + } + } + return this.roleJpa.executeSQL(sqlStr.toString()); + } + return 0; + } + + private void dtoToData(RoleDto role , SystemRole data) { + data.setDescription(role.getDescription()); + data.setRoleName(role.getRoleName()); + } } diff --git a/antdsp-admin/src/main/web/config/router.config.js b/antdsp-admin/src/main/web/config/router.config.js index 33d6fa8..673bdc8 100644 --- a/antdsp-admin/src/main/web/config/router.config.js +++ b/antdsp-admin/src/main/web/config/router.config.js @@ -19,13 +19,19 @@ export default [ path: '/system/user', name: 'user', icon: 'user', - component: './System/User', + component: './System/User/Index', }, { path: '/system/menu', name: 'menu', icon: 'menu', - component: './System/Menu', + component: './System/Menu/Index', + }, + { + path: '/system/role', + name: 'role', + icon: 'team', + component: './System/Role/Index', } ], }, diff --git a/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js b/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js index df39952..3cb2b06 100644 --- a/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js +++ b/antdsp-admin/src/main/web/src/locales/zh-CN/menu.js @@ -2,5 +2,6 @@ export default { 'menu.home': '首页', 'menu.system': '系统管理', 'menu.system.user': '用户管理', - 'menu.system.menu': '菜单管理' + 'menu.system.menu': '菜单管理', + 'menu.system.role': '角色管理' }; diff --git a/antdsp-admin/src/main/web/src/pages/System/Menu/Index.js b/antdsp-admin/src/main/web/src/pages/System/Menu/Index.js index 22e2508..bb7026a 100644 --- a/antdsp-admin/src/main/web/src/pages/System/Menu/Index.js +++ b/antdsp-admin/src/main/web/src/pages/System/Menu/Index.js @@ -2,11 +2,16 @@ import { PureComponent, Fragment } from "react"; import { connect } from 'dva'; import PageHeaderWrapper from '@/components/PageHeaderWrapper'; import Block from '@/custom/Block'; -import { Card, Form, Button, Table, Divider, Popconfirm, Select, Modal } from "antd"; +import { Card, Form, Button, Table, Divider, Popconfirm, Select, Modal, TreeSelect, Input, Icon, message } from "antd"; const FormItem = Form.Item; +const MenuType = { + 'MENU': '菜单', + 'BUTTON': '按钮' +} + @connect(({ systemmenu , loading })=>({ systemmenu, loading: loading.models.systemmenu @@ -17,6 +22,7 @@ export default class extends PureComponent{ state={ visible: false , confirmLoading: false, + current:{} } componentDidMount() { @@ -26,8 +32,71 @@ export default class extends PureComponent{ }) } + /** + * 添加或者更新 + */ + handlerModalOnOk=()=>{ + const { dispatch } = this.props; + const { form } = this.formRef.props; + + this.setState({confirmLoading: true}); + + form.validateFields((err , fieldsValue)=>{ + if(err) return this.setState({confirmLoading: false}); + + let currentObj = this.state.current; + + currentObj = { + ...currentObj, + ...fieldsValue, + }; + + dispatch({ + type: 'systemmenu/save', + payload: { + ...currentObj, + }, + callback: (result)=>{ + if(result.success){ + this.setState({visible: false , confirmLoading: false }); + dispatch({ + type: 'systemmenu/fetchAll', + }); + }else { + message.error(result.message); + this.setState({confirmLoading: false}) + } + } + }) + + }); + } + + handlerDelOnClick=(e , id)=>{ + e.preventDefault(); + + const { dispatch } = this.props; + dispatch({ + type: "systemmenu/delById", + payload: { + id: id + }, + callback: (result)=>{ + if(result.success){ + dispatch({ + type: 'systemmenu/fetchAll', + }); + }else { + message.error(result.message); + } + } + }); + } + render() { + const { systemmenu: {MenuList} , loading } = this.props; + const columns =[{ title: "", dataIndex:'id', @@ -57,9 +126,9 @@ export default class extends PureComponent{ return ( - {this.setState({visible: true , currentObj: record})}}>编辑 + {this.setState({visible: true , current: record, confirmLoading: false})}}>编辑 - this.handlerDelOnClick(e , record.recId)}> + this.handlerDelOnClick(e , record.id)}> 删除 @@ -72,11 +141,13 @@ export default class extends PureComponent{ - +
    - this.formRef= formRef} /> - {/* currentObj={this.state.currentObj} parentMenu={MenuTree} */} + this.formRef= formRef} current={this.state.current} parentMenu={MenuList}/> + {/* parentMenu={MenuTree} */} @@ -97,6 +168,7 @@ export default class extends PureComponent{ } } +@Form.create() class EditMenu extends PureComponent{ assbleMenu(menuTree){ @@ -107,7 +179,7 @@ class EditMenu extends PureComponent{ key: '0' } this.handlerAssbleMenu(parentMenu , menuTree); - return parentMenu; + return [parentMenu]; } handlerAssbleMenu(parentMenu , menus){ @@ -116,8 +188,8 @@ class EditMenu extends PureComponent{ for(let item of menus){ let childMenu = { title: item.name , - value: item.recId , - key: item.recId , + value: item.id , + key: item.id , }; if(item.children && item.children.length > 0){ this.handlerAssbleMenu(childMenu , item.children); @@ -150,7 +222,15 @@ class EditMenu extends PureComponent{
    - {getFieldDecorator('menuType')( + {getFieldDecorator('type',{ + initialValue: current.type, + rules: [ + { + required: true, + message: '请选择父级菜单', + } + ] + })( diff --git a/antdsp-admin/src/main/web/src/pages/System/Menu/models/menu.js b/antdsp-admin/src/main/web/src/pages/System/Menu/models/menu.js index 791f796..b55e60c 100644 --- a/antdsp-admin/src/main/web/src/pages/System/Menu/models/menu.js +++ b/antdsp-admin/src/main/web/src/pages/System/Menu/models/menu.js @@ -1,5 +1,8 @@ import { - fetchAllMenu + fetchAllMenu, + addMenu, + updateMenu, + delMenuById } from '@/services/system'; export default { @@ -18,14 +21,31 @@ export default { type: 'reducersMenuList', payload: response }) + }, + *save({payload , callback},{call , put}){ + + const menuInfo = payload; + let response ; + if(!menuInfo.id){ + response = yield call(addMenu , menuInfo); + }else { + response = yield call(updateMenu , menuInfo); + } + + if(callback) callback(response); + }, + *delById({payload, callback},{call,put}){ + const response = yield call(delMenuById , payload); + if(callback) callback(response); } }, reducers: { reducersMenuList(state , action){ + const menus = action.payload; return { ...state, - MenuList: action.payload + MenuList: menus.children || [] } } } diff --git a/antdsp-admin/src/main/web/src/pages/System/Role/Index.js b/antdsp-admin/src/main/web/src/pages/System/Role/Index.js new file mode 100644 index 0000000..e9b9308 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/Role/Index.js @@ -0,0 +1,212 @@ +import { PureComponent , Fragment } from "react"; +import { connect } from 'dva'; +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; +import Block from '@/custom/Block'; +import { Card, Table, Divider, Form, Button, Modal, Input, Tree, message } from "antd"; + +import MenuTree from './MenuTree' + +const FormItem = Form.Item; + +@Form.create() +@connect(({systemrole , loading})=>({ + systemrole, + loading: loading.models.systemrole +})) +export default class Index extends PureComponent{ + + state={ + visible: false , + confirmLoading: false, + current:{} + } + + componentDidMount(){ + + const { dispatch } = this.props; + dispatch({ + type: 'systemrole/fetchAll', + payload:{ + page: 1, + count: 10 + } + }); + } + + handlerDelOnClick=()=>{ + + } + + handlerModalOnOk=()=>{ + const { dispatch } = this.props; + const { form } = this.formRef.props; + + this.setState({confirmLoading: true}); + + form.validateFields((err , fieldsValue)=>{ + if(err) return this.setState({confirmLoading: false}); + + const {current} = this.state; + let currentObj = { + ...current, + ...fieldsValue + } + + dispatch({ + type: 'systemrole/save', + payload: { + role: currentObj + }, + callback: (result)=>{ + if(result.success){ + this.setState({ + confirmLoading: false, + visible: false, + }) + dispatch({ + type: 'systemrole/fetchAll', + payload:{ + page: 1, + count: 10 + } + }); + }else { + message.error(result.message); + this.setState({confirmLoading: false}); + } + } + }) + + + }); + } + + showModal=(currentObj)=>{ + this.setState({ + confirmLoading: false, + visible: true, + current: currentObj + }); + const { dispatch } = this.props; + dispatch({ + type: 'systemrole/menus', + }); + } + + render(){ + + const { loading, systemrole: {RoleList , Menus} } = this.props + + const columns = [{ + title: '角色名称', + dataIndex: 'roleName' + },{ + title: '描述', + dataIndex: 'description', + },{ + title: '创建者', + dataIndex: 'creator', + },{ + title: '创建时间', + dataIndex: 'created', + },{ + title: '操作', + render:(record)=>{ + + return ( + + {this.showModal(record)}}>修改 + + {this.handlerDelOnClick(e , record.id)}} style={{color:'red'}}>删除 + + ) + } + }]; + + return( + + + + + + +
    + {this.setState({visible: false})}} + onOk={this.handlerModalOnOk} + confirmLoading={this.state.confirmLoading} + destroyOnClose={true} + > + this.formRef= formRef} menus={Menus.children}/> + + + + ) + } + +} + +@Form.create() +export class EditRole extends PureComponent{ + + handlerOnCheck=(checkedKeys)=>{ + const { setFields } = this.props.form; + setFields({ + menuIds: checkedKeys + }) + } + + render(){ + + const { form: {getFieldDecorator} , menus } = this.props; + + const formItemLayout = { + labelCol:{ + xs: { span : 6}, + sm: { span : 6 }, + }, + wrapperCol:{ + xs: { span : 12}, + sm: { span : 12 }, + } + } + + return( +
    + + + {getFieldDecorator("roleName",{ + rules:[{ + required: true, + message: '角色名称不能为空', + }] + })( + + )} + + + {getFieldDecorator("description")( + + )} + + + {getFieldDecorator("menuIds",{ + + })( + + )} + + +
    + ) + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/Role/MenuTree.js b/antdsp-admin/src/main/web/src/pages/System/Role/MenuTree.js new file mode 100644 index 0000000..af20eac --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/Role/MenuTree.js @@ -0,0 +1,50 @@ +import { PureComponent } from "react"; +import { Tree } from "antd"; + +const { TreeNode } = Tree; + +export default class MenuTree extends PureComponent{ + + constructor(props){ + super(props); + this.state= { + checkedKeys: props.checkedKeys + } + } + + renderTreeNodes=treeData=>{ + + return treeData.map(item => { + if (item.children) { + return ( + + {this.renderTreeNodes(item.children)} + + ); + } + return ; + }); + } + + handlerOnCheck=(checkedKeys , { halfCheckedKeys})=>{ + this.setState({ + checkedKeys: checkedKeys + }); + this.props.handlerOnCheck(checkedKeys.concat(halfCheckedKeys)); + } + + render(){ + + const { menus } = this.props; + return( + + {this.renderTreeNodes(menus)} + + ) + } +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/Role/models/role.js b/antdsp-admin/src/main/web/src/pages/System/Role/models/role.js new file mode 100644 index 0000000..e17bf87 --- /dev/null +++ b/antdsp-admin/src/main/web/src/pages/System/Role/models/role.js @@ -0,0 +1,67 @@ +import { + fetchAllRole, + fetchAllMenu, + addRole, + updateRole +} from '@/services/system' + +export default { + + namespace: "systemrole", + + state: { + RoleList:{ + data: [], + pagination:{} + }, + Menus:{ + children: [] + } + }, + + effects: { + *fetchAll({payload},{call, put}){ + const response = yield call(fetchAllRole , payload) + + yield put({ + type: 'reducersRoleList', + payload: response + }) + }, + *menus({_},{call , put}){ + const response = yield call(fetchAllMenu) + + yield put({ + type: 'reducersMenus', + payload: response + }); + }, + *save({payload , callback},{call}){ + const roleInfo = payload.role; + let response ; + if(!roleInfo.id){ + response = yield call(addRole , roleInfo); + }else { + response = yield call(updateRole , roleInfo); + } + + if(callback) callback(response); + } + }, + + reducers: { + reducersRoleList(state, action){ + return { + ...state, + RoleList: action.payload + } + }, + reducersMenus(state, action){ + return { + ...state, + Menus: action.payload + } + } + }, + +} \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/services/system.js b/antdsp-admin/src/main/web/src/services/system.js index 0559b7c..c862060 100644 --- a/antdsp-admin/src/main/web/src/services/system.js +++ b/antdsp-admin/src/main/web/src/services/system.js @@ -5,6 +5,7 @@ import qs from 'qs'; const API_BASE = "/antdsp-api"; const USER_API = API_BASE + "/system/user"; const MENU_API = API_BASE + "/system/menu"; +const ROLE_API = API_BASE + "/system/role"; export async function fetchAllUser(params){ return request(`${USER_API}?${qs.stringify(params, { indices: false })}`); @@ -12,4 +13,56 @@ export async function fetchAllUser(params){ export async function fetchAllMenu(){ return request(`${MENU_API}`) +} + +export async function addMenu(params){ + + return request(`${MENU_API}`,{ + method: 'POST', + data:{ + ...params + } + }); +} +export async function updateMenu(params){ + return request(`${MENU_API}`,{ + method: 'PUT', + data:{ + ...params + } + }); +} + +export async function delMenuById(param){ + return request(`${MENU_API}/${param.id}`,{ + method: 'DELETE', + }) +} + +export async function fetchAllRole(param){ + return request(`${ROLE_API}?${qs.stringify(param, { indices: false })}`) +} + + +export async function addRole(params){ + return request(`${ROLE_API}`,{ + method: 'POST', + data: { + ...params + }, + }) +} +export async function updateRole(params){ + return request(`${ROLE_API}`,{ + method: 'PUT', + data: { + ...params + } + }); +} + +export async function delRoleById(param){ + return request(`${ROLE_API}/${param.id}`,{ + method: 'DELETE' + }) } \ No newline at end of file diff --git a/antdsp-core/src/main/java/com/antdsp/common/AntdspRepositoryFactoryBean.java b/antdsp-core/src/main/java/com/antdsp/common/AntdspRepositoryFactoryBean.java new file mode 100644 index 0000000..8a2d206 --- /dev/null +++ b/antdsp-core/src/main/java/com/antdsp/common/AntdspRepositoryFactoryBean.java @@ -0,0 +1,53 @@ +package com.antdsp.common; + +import java.io.Serializable; + +import javax.persistence.EntityManager; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.support.JpaRepositoryFactory; +import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean; +import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation; +import org.springframework.data.repository.core.RepositoryInformation; +import org.springframework.data.repository.core.RepositoryMetadata; +import org.springframework.data.repository.core.support.RepositoryFactorySupport; + +import com.antdsp.dao.jpa.AntdspBaseRepositoryImpl; + +public class AntdspRepositoryFactoryBean , T , ID extends Serializable> extends JpaRepositoryFactoryBean { + + public AntdspRepositoryFactoryBean(Class repositoryInterface) { + super(repositoryInterface); + } + + @Override + protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) { +// return super.createRepositoryFactory(entityManager); + return new BaseRepositoryFactory<>(entityManager); + + } + + private static class BaseRepositoryFactory extends JpaRepositoryFactory{ + private final EntityManager em; + + public BaseRepositoryFactory(EntityManager em) { + super(em); + this.em = em; + } + + @Override + protected JpaRepositoryImplementation getTargetRepository(RepositoryInformation information, + EntityManager entityManager) { + + return new AntdspBaseRepositoryImpl<>((Class) information.getDomainType(), entityManager); + } + + @Override + protected Class getRepositoryBaseClass(RepositoryMetadata metadata) { + return AntdspBaseRepositoryImpl.class; + } + + } + + +} diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java index 8816883..527a84e 100644 --- a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java @@ -4,11 +4,25 @@ import java.io.Serializable; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.repository.NoRepositoryBean; +/** + * + *

    title:AntdspBaseRepository.java

    + *

    Description: 统一的数据操作父接口

    + *

    Copyright: Copyright (c) 2019

    + * + * @author jt-lee + * @date 2019年6月10日 + * @email a496401006@qq.com + * + * @param + * @param + */ @NoRepositoryBean -public interface AntdspBaseRepository extends JpaRepository{ +public interface AntdspBaseRepository extends JpaRepository , JpaSpecificationExecutor{ - List findPageByQuery(int start , int count); + int executeSQL(String sqlString , Object...params); } diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java index 799ed98..bae7c55 100644 --- a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java @@ -4,9 +4,23 @@ import java.io.Serializable; import java.util.List; import javax.persistence.EntityManager; +import javax.persistence.Query; import org.springframework.data.jpa.repository.support.SimpleJpaRepository; +/** + * + *

    title:AntdspBaseRepositoryImpl.java

    + *

    Description: 统一数据操作接口实现类

    + *

    Copyright: Copyright (c) 2019

    + * + * @author jt-lee + * @date 2019年6月10日 + * @email a496401006@qq.com + * + * @param + * @param + */ public class AntdspBaseRepositoryImpl extends SimpleJpaRepository implements AntdspBaseRepository{ private final EntityManager em; @@ -18,10 +32,18 @@ public class AntdspBaseRepositoryImpl extends Simple this.em = em; this.clazz = domainClass; } - + @Override - public List findPageByQuery(int start, int count) { - return null; + public int executeSQL(String sqlString , Object...params) { + + Query query = em.createNativeQuery(sqlString); + if(params != null && params.length > 0) { + for(int i = 0 ; i< params.length ; i++) { + query.setParameter(i, params); + } + } + + return query.executeUpdate(); } diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/RoleJpa.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/RoleJpa.java index 280e7b0..b7e3ed7 100644 --- a/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/RoleJpa.java +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/system/RoleJpa.java @@ -1,12 +1,11 @@ package com.antdsp.dao.jpa.system; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.stereotype.Repository; +import com.antdsp.dao.jpa.AntdspBaseRepository; import com.antdsp.data.entity.system.SystemRole; @Repository("roleJpa") -public interface RoleJpa extends JpaRepository , JpaSpecificationExecutor{ +public interface RoleJpa extends AntdspBaseRepository{ } -- Gitee From bbc31edf151fdba04b80c9596a10d2cbc17e1d16 Mon Sep 17 00:00:00 2001 From: lijiantao Date: Tue, 11 Jun 2019 17:51:22 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E7=94=A8=E6=88=B7=E3=80=81=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E3=80=81=E8=A7=92=E8=89=B2=E6=A8=A1=E5=9D=97=E5=AE=8C?= =?UTF-8?q?=E6=88=90=EF=BC=8C=E6=B7=BB=E5=8A=A0sql=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/antdsp/web/dto/RoleMenu.java | 44 +++ .../antdsp/web/rest/sys/SystemRoleApi.java | 41 ++- .../main/web/src/pages/System/Role/Index.js | 134 +++++++- .../web/src/pages/System/Role/models/role.js | 12 +- .../main/web/src/pages/System/User/Index.js | 291 +++++++++++++++++- .../web/src/pages/System/User/models/user.js | 19 +- .../src/main/web/src/services/system.js | 28 ++ .../antdsp/dao/jpa/AntdspBaseRepository.java | 6 +- .../dao/jpa/AntdspBaseRepositoryImpl.java | 31 +- sql/antdsp.sql | 140 +++++++++ 10 files changed, 702 insertions(+), 44 deletions(-) create mode 100644 antdsp-admin/src/main/java/com/antdsp/web/dto/RoleMenu.java create mode 100644 sql/antdsp.sql diff --git a/antdsp-admin/src/main/java/com/antdsp/web/dto/RoleMenu.java b/antdsp-admin/src/main/java/com/antdsp/web/dto/RoleMenu.java new file mode 100644 index 0000000..f774181 --- /dev/null +++ b/antdsp-admin/src/main/java/com/antdsp/web/dto/RoleMenu.java @@ -0,0 +1,44 @@ +package com.antdsp.web.dto; + +public class RoleMenu { + private Long id; + private Long roleId; + private Long menuId; + + public RoleMenu() { + super(); + } + + public RoleMenu(Long id, Long roleId, Long menuId) { + super(); + this.id = id; + this.roleId = roleId; + this.menuId = menuId; + } + + public Long getId() { + return id; + } + + public Long getRoleId() { + return roleId; + } + + public Long getMenuId() { + return menuId; + } + + public void setId(Long id) { + this.id = id; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + + public void setMenuId(Long menuId) { + this.menuId = menuId; + } + + +} diff --git a/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java index 58059aa..be389d7 100644 --- a/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java +++ b/antdsp-admin/src/main/java/com/antdsp/web/rest/sys/SystemRoleApi.java @@ -1,7 +1,11 @@ package com.antdsp.web.rest.sys; +import java.math.BigInteger; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Stream; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; @@ -31,6 +35,7 @@ import com.antdsp.common.pagination.PaginationData; import com.antdsp.dao.jpa.system.RoleJpa; import com.antdsp.data.entity.system.SystemRole; import com.antdsp.web.dto.RoleDto; +import com.antdsp.web.dto.RoleMenu; /** * @@ -54,7 +59,7 @@ public class SystemRoleApi { public PaginationData list(int page , int count , String roleName){ int start = (page - 1) * count; - Pageable pageable = PageRequest.of(start, count , Sort.by(Order.desc("creator"))); + Pageable pageable = PageRequest.of(start, count , Sort.by(Order.desc("created"))); Specification specification = new Specification() { @Override public Predicate toPredicate(Root root, CriteriaQuery query, CriteriaBuilder builder) { @@ -72,6 +77,30 @@ public class SystemRoleApi { return new PaginationData<>(userList.getContent() , page , userList.getTotalElements()); } + @GetMapping("/{id:\\d+}") + public RoleDto detail(@PathVariable("id") Long id) { + + SystemRole role = this.roleJpa.getOne(id); + + RoleDto dto = new RoleDto(); + dto.setDescription(role.getDescription()); + dto.setId(role.getId()); + dto.setRoleName(role.getRoleName()); + + String sqlStr = "SELECT r.menu_id FROM tb_role_menu r LEFT JOIN tb_system_menu sr ON r.menu_id = sr.id WHERE r.role_id = :roleId AND sr.menu_type = 'BUTTON' "; + + Map params = new HashMap<>(); + params.put("roleId", id); + + List list = this.roleJpa.queryAllBySQL(sqlStr, params); + List menuIds = new ArrayList<>(); + for(BigInteger item : list) { + menuIds.add(item.longValue()); + } + dto.setMenuIds(menuIds); + return dto; + } + @PostMapping("") @Transactional public AntdspResponse add(@RequestBody RoleDto role) { @@ -88,7 +117,7 @@ public class SystemRoleApi { List menuIds = role.getMenuIds(); - this.saveRoleMenu(menuIds, role.getId()); + this.saveRoleMenu(menuIds, data.getId()); return AntdspResponse.success(); } @@ -108,8 +137,10 @@ public class SystemRoleApi { this.roleJpa.save(data); String deleteStr = "DELETE FROM `tb_role_menu` WHERE `role_id` = :roleId"; + Map params = new HashMap<>(); + params.put("roleId", roleId); - this.roleJpa.executeSQL(deleteStr , roleId); + this.roleJpa.executeSQL(deleteStr , params); this.saveRoleMenu(role.getMenuIds(), roleId); return AntdspResponse.success(); } @@ -132,10 +163,10 @@ public class SystemRoleApi { sqlStr.append("("+roleId+" , "+ menuIds.get(0)+" ) "); if(menuIds.size() > 2) { for(int i = 1 ; i< menuIds.size() ; i++) { - sqlStr.append(",("+roleId+" , "+ menuIds.get(0)+" ) "); + sqlStr.append(",("+roleId+" , "+ menuIds.get(i)+" ) "); } } - return this.roleJpa.executeSQL(sqlStr.toString()); + return this.roleJpa.executeSQL(sqlStr.toString() , null); } return 0; } diff --git a/antdsp-admin/src/main/web/src/pages/System/Role/Index.js b/antdsp-admin/src/main/web/src/pages/System/Role/Index.js index e9b9308..b906f13 100644 --- a/antdsp-admin/src/main/web/src/pages/System/Role/Index.js +++ b/antdsp-admin/src/main/web/src/pages/System/Role/Index.js @@ -2,9 +2,10 @@ import { PureComponent , Fragment } from "react"; import { connect } from 'dva'; import PageHeaderWrapper from '@/components/PageHeaderWrapper'; import Block from '@/custom/Block'; -import { Card, Table, Divider, Form, Button, Modal, Input, Tree, message } from "antd"; +import { Card, Table, Divider, Form, Button, Modal, Input, Tree, message, Popconfirm } from "antd"; import MenuTree from './MenuTree' +import moment from "moment"; const FormItem = Form.Item; @@ -18,7 +19,11 @@ export default class Index extends PureComponent{ state={ visible: false , confirmLoading: false, - current:{} + current:{}, + formValue: { + count: 10, + page: 1 + } } componentDidMount(){ @@ -27,14 +32,31 @@ export default class Index extends PureComponent{ dispatch({ type: 'systemrole/fetchAll', payload:{ - page: 1, - count: 10 + ...this.state.formValue } }); } - handlerDelOnClick=()=>{ - + handlerDelOnClick=(e , id)=>{ + const { dispatch } = this.props; + dispatch({ + type: 'systemrole/del', + payload:{ + id: id + }, + callback:(result)=>{ + if(result.success){ + dispatch({ + type: 'systemrole/fetchAll', + payload:{ + ...this.state.formValue + } + }); + }else { + message.error(result.message); + } + } + }); } handlerModalOnOk=()=>{ @@ -81,6 +103,21 @@ export default class Index extends PureComponent{ }); } + handlerEditOnclick=(e , id)=>{ + + const { dispatch } = this.props; + dispatch({ + type: 'systemrole/fetchById', + payload: { + id: id + }, + callback:(result)=>{ + this.showModal(result); + } + }); + + } + showModal=(currentObj)=>{ this.setState({ confirmLoading: false, @@ -93,9 +130,52 @@ export default class Index extends PureComponent{ }); } + handlerTableOnChange=(pagination , filters , sorter)=>{ + const { dispatch } = this.props; + let { formValue } = this.state; + + formValue = { + ...formValue, + page: pagination.current, + count: pagination.pageSize, + } + + this.setState({ + formValue:{ + ...formValue, + } + }); + + dispatch({ + type: 'systemrole/fetchAll', + payload:{ + ...formValue, + } + }) + } + + handlerQueryOnClick=()=>{ + const { form , dispatch } = this.props; + form.validateFields((err , fieldsValue)=>{ + let formValue = { + ...fieldsValue, + page: 1, + count: 10 + }; + this.setState({formValue}); + + dispatch({ + type: 'systemrole/fetchAll', + payload: { + ...formValue + } + }) + }); + } + render(){ - const { loading, systemrole: {RoleList , Menus} } = this.props + const { loading, systemrole: {RoleList, Menus}, form: {getFieldDecorator}} = this.props const columns = [{ title: '角色名称', @@ -109,15 +189,18 @@ export default class Index extends PureComponent{ },{ title: '创建时间', dataIndex: 'created', + render: (val)=> {moment(val).format('YYYY-MM-DD HH:mm:ss')} },{ title: '操作', render:(record)=>{ return ( - {this.showModal(record)}}>修改 + {this.handlerEditOnclick(e , record.id)}}>修改 - {this.handlerDelOnClick(e , record.id)}} style={{color:'red'}}>删除 + {this.handlerDelOnClick(e ,record.id)}}> + 删除 + ) } @@ -127,14 +210,28 @@ export default class Index extends PureComponent{ + +
    + + {getFieldDecorator("roleName")( + + )} + + + + + +
    - this.formRef= formRef} menus={Menus.children}/> + this.formRef= formRef} current={this.state.current} menus={Menus.children}/> @@ -159,15 +256,15 @@ export default class Index extends PureComponent{ export class EditRole extends PureComponent{ handlerOnCheck=(checkedKeys)=>{ - const { setFields } = this.props.form; - setFields({ + const { setFieldsValue } = this.props.form; + setFieldsValue({ menuIds: checkedKeys - }) + }); } render(){ - const { form: {getFieldDecorator} , menus } = this.props; + const { form: {getFieldDecorator} , menus , current} = this.props; const formItemLayout = { labelCol:{ @@ -185,6 +282,7 @@ export class EditRole extends PureComponent{ {getFieldDecorator("roleName",{ + initialValue: current.roleName, rules:[{ required: true, message: '角色名称不能为空', @@ -194,15 +292,17 @@ export class EditRole extends PureComponent{ )} - {getFieldDecorator("description")( + {getFieldDecorator("description",{ + initialValue: current.description + })( )} {getFieldDecorator("menuIds",{ - + initialValue: current.menuIds })( - + )} diff --git a/antdsp-admin/src/main/web/src/pages/System/Role/models/role.js b/antdsp-admin/src/main/web/src/pages/System/Role/models/role.js index e17bf87..8a6a2ff 100644 --- a/antdsp-admin/src/main/web/src/pages/System/Role/models/role.js +++ b/antdsp-admin/src/main/web/src/pages/System/Role/models/role.js @@ -2,7 +2,9 @@ import { fetchAllRole, fetchAllMenu, addRole, - updateRole + updateRole, + fetchRoleById, + delRoleById } from '@/services/system' export default { @@ -45,6 +47,14 @@ export default { response = yield call(updateRole , roleInfo); } + if(callback) callback(response); + }, + *fetchById({payload , callback},{call}){ + const response = yield call(fetchRoleById , payload); + if(callback) callback(response); + }, + *del({payload , callback}, {call}){ + const response = yield call(delRoleById , payload); if(callback) callback(response); } }, diff --git a/antdsp-admin/src/main/web/src/pages/System/User/Index.js b/antdsp-admin/src/main/web/src/pages/System/User/Index.js index b6dc478..1185b4c 100644 --- a/antdsp-admin/src/main/web/src/pages/System/User/Index.js +++ b/antdsp-admin/src/main/web/src/pages/System/User/Index.js @@ -2,10 +2,15 @@ import { PureComponent, Fragment } from "react"; import { connect } from 'dva'; import PageHeaderWrapper from '@/components/PageHeaderWrapper'; import Block from '@/custom/Block'; -import { Card, Form, Button, Table, Divider } from "antd"; +import { Card, Form, Button, Table, Divider, Input, Select, Modal, message, Popconfirm } from "antd"; const FormItem = Form.Item; +const UserStatus = { + "NORMAL": "正常", + "FORBIDDEN": "异常" +} + @connect(({ systemuser , loading })=>({ systemuser, loading: loading.models.systemuser @@ -13,6 +18,16 @@ const FormItem = Form.Item; @Form.create() export default class extends PureComponent{ + state={ + confirmLoading: false, + visible: false, + current:{}, + formValue: { + page: 1, + count: 10, + } + } + componentDidMount(){ const { dispatch } = this.props; dispatch({ @@ -24,20 +39,155 @@ export default class extends PureComponent{ }) } + handlerQueryOnClick=()=>{ + const { form , dispatch } = this.props; + form.validateFields((err , fieldsValue)=>{ + let { formValue } = this.state.formValue; + formValue = { + ...fieldsValue, + page: 1, + count: 10 + }; + this.setState({formValue}); + + dispatch({ + type: 'systemuser/fetchAll', + payload: { + ...formValue + } + }) + }); + } + renderQueryForm=()=>{ + const{ getFieldDecorator } = this.props.form; + return(
    - + + {getFieldDecorator("loginname")( + + )} + + + {getFieldDecorator("status")( + + )} + + + +
    ) } + handlerTableOnChange=(pagination , filters , sorter)=>{ + const { dispatch } = this.props; + let { formValue } = this.state; + + formValue = { + ...formValue, + page: pagination.current, + count: pagination.pageSize, + } + + this.setState({ + formValue:{ + ...formValue, + } + }); + + dispatch({ + type: 'systemuser/fetchAll', + payload:{ + ...formValue, + } + }) + } + + showModal=(currentObj)=>{ + this.setState({ + current: currentObj, + confirmLoading: false, + visible: true, + }) + } + + handlerModalOnOk=(e)=>{ + + e.preventDefault(); + this.setState({ + confirmLoading : true , + }); + const { form } = this.formRef.props; + const { dispatch } = this.props; + form.validateFields((err , fieldsValue)=>{ + if(err) return this.setState({confirmLoading: false}); + + const {current} = this.state; + let currentObj = { + ...current, + ...fieldsValue + }; + dispatch({ + type: 'systemuser/save', + payload:{ + user: currentObj + }, + callback: (result)=>{ + + if(result.success){ + this.setState({ + confirmLoading: false, + visible: false, + }); + dispatch({ + type: 'systemuser/fetchAll', + payload:{ + page: 1, + count: 10 + } + }); + }else { + message.error(result.message); + this.setState({confirmLoading: false}); + } + } + }); + }); + } + + handlerDelOnClick=(e , id)=>{ + const { dispatch } = this.props; + dispatch({ + type: 'systemuser/del', + payload:{ + id: id + }, + callback:(result)=>{ + if(result.success){ + dispatch({ + type: 'systemuser/fetchAll', + payload:{ + ...this.state.formValue + } + }); + }else { + message.error(result.message); + } + } + }); + } + render(){ - const { systemuser:{UserList} } = this.props; + const { systemuser:{UserList}, loading } = this.props; const columns = [{ title: '头像', @@ -62,11 +212,11 @@ export default class extends PureComponent{ render:(record)=>{ return ( - 查看 + {this.showModal(record)}}>编辑 - 编辑 - - 删除 + {this.handlerDelOnClick(e ,record.id)}}> + 删除 + ) } @@ -75,18 +225,141 @@ export default class extends PureComponent{ return ( - {/* {this.renderQueryForm} */} + {this.renderQueryForm()} + - +
    + {this.setState({visible: false})}} + onOk={this.handlerModalOnOk} + confirmLoading={this.state.confirmLoading} + destroyOnClose={true} + > + + this.formRef= formRef} current={this.state.current} /> + ) } +} + + +@Form.create() +export class EditUser extends PureComponent{ + + compareToPassword=(rule , value , callback)=>{ + const form = this.props.form; + if (value && value !== form.getFieldValue('password')) { + callback('两次密码输入不一致'); + } else { + callback(); + } + } + + render(){ + + const { getFieldDecorator } = this.props.form; + const { current } = this.props; + + const flag = (Object.keys(current).length == 0); + + const formItemLayout = { + labelCol:{ + xs: { span : 4}, + sm: { span : 4 }, + }, + wrapperCol:{ + xs: { span : 12}, + sm: { span : 12 }, + } + } + + return( +
    +
    + + {getFieldDecorator('loginname',{ + initialValue: current.loginname, + rules:[ + { + required: true, + message: '请输入登录名', + } + ] + })( + + )} + + { + flag ? +
    + + {getFieldDecorator("password",{ + rules:[ + { + required: true, + message: '请输入密码', + } + ] + })( + + )} + + + {getFieldDecorator("repassword",{ + rules:[ + { + required: true, + message: '请输入密码', + },{ + validator:this.compareToPassword, + } + ] + })( + + )} + +
    + : + null + } + + {getFieldDecorator("realname",{ + initialValue: current.realname, + })( + + )} + + + {getFieldDecorator("email",{ + initialValue: current.email, + })( + + )} + + + {getFieldDecorator("qq",{ + initialValue: current.qq, + })( + + )} + + +
    + ) + } } \ No newline at end of file diff --git a/antdsp-admin/src/main/web/src/pages/System/User/models/user.js b/antdsp-admin/src/main/web/src/pages/System/User/models/user.js index f9774f9..3460b77 100644 --- a/antdsp-admin/src/main/web/src/pages/System/User/models/user.js +++ b/antdsp-admin/src/main/web/src/pages/System/User/models/user.js @@ -1,5 +1,8 @@ import { - fetchAllUser + fetchAllUser, + addUser, + updateUser, + delUserById } from '@/services/system'; export default { @@ -19,6 +22,20 @@ export default { type:'reducersUserList', payload: response, }) + }, + *save({payload , callback} , {call}){ + const user = payload.user; + let response ; + if(!user.id){ + response = yield call(addUser , user); + }else { + response = yield call(updateUser , user); + } + if(callback) callback(response); + }, + *del({payload , callback},{call}){ + const response = yield call(delUserById , payload); + if(callback) callback(response); } }, diff --git a/antdsp-admin/src/main/web/src/services/system.js b/antdsp-admin/src/main/web/src/services/system.js index c862060..f4f4fee 100644 --- a/antdsp-admin/src/main/web/src/services/system.js +++ b/antdsp-admin/src/main/web/src/services/system.js @@ -11,6 +11,30 @@ export async function fetchAllUser(params){ return request(`${USER_API}?${qs.stringify(params, { indices: false })}`); } +export async function addUser(params){ + return request(`${USER_API}`,{ + method: 'POST', + data:{ + ...params + } + }); +} + +export async function updateUser(params){ + return request(`${USER_API}/${params.id}`,{ + method: 'PUT', + data:{ + ...params + } + }); +} + +export async function delUserById(params){ + return request(`${USER_API}/${params.id}`,{ + method: 'DELETE', + }); +} + export async function fetchAllMenu(){ return request(`${MENU_API}`) } @@ -65,4 +89,8 @@ export async function delRoleById(param){ return request(`${ROLE_API}/${param.id}`,{ method: 'DELETE' }) +} + +export async function fetchRoleById(param){ + return request(`${ROLE_API}/${param.id}`); } \ No newline at end of file diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java index 527a84e..f2d5183 100644 --- a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepository.java @@ -2,6 +2,7 @@ package com.antdsp.dao.jpa; import java.io.Serializable; import java.util.List; +import java.util.Map; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; @@ -23,6 +24,7 @@ import org.springframework.data.repository.NoRepositoryBean; @NoRepositoryBean public interface AntdspBaseRepository extends JpaRepository , JpaSpecificationExecutor{ - int executeSQL(String sqlString , Object...params); - + int executeSQL(String sqlString , Map params); + + List queryAllBySQL(String sqlStr , Map params); } diff --git a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java index bae7c55..57760e4 100644 --- a/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java +++ b/antdsp-core/src/main/java/com/antdsp/dao/jpa/AntdspBaseRepositoryImpl.java @@ -1,7 +1,9 @@ package com.antdsp.dao.jpa; import java.io.Serializable; +import java.util.Iterator; import java.util.List; +import java.util.Map; import javax.persistence.EntityManager; import javax.persistence.Query; @@ -34,18 +36,29 @@ public class AntdspBaseRepositoryImpl extends Simple } @Override - public int executeSQL(String sqlString , Object...params) { - + public int executeSQL(String sqlString , Map params) { Query query = em.createNativeQuery(sqlString); - if(params != null && params.length > 0) { - for(int i = 0 ; i< params.length ; i++) { - query.setParameter(i, params); - } - } - + this.querySetParameter(query, params); return query.executeUpdate(); } - + private void querySetParameter(Query query , Map params) { + if(params == null) { + return ; + } + Iterator keys = params.keySet().iterator(); + while(keys.hasNext()) { + String key = keys.next(); + query.setParameter(key, params.get(key)); + } + } + + @Override + public List queryAllBySQL(String sqlStr, Map params) { + + Query query = em.createNativeQuery(sqlStr); + this.querySetParameter(query, params); + return query.getResultList(); + } } diff --git a/sql/antdsp.sql b/sql/antdsp.sql new file mode 100644 index 0000000..a9c7770 --- /dev/null +++ b/sql/antdsp.sql @@ -0,0 +1,140 @@ +/* + Navicat Premium Data Transfer + + Source Server : localhost_3306 + Source Server Type : MySQL + Source Server Version : 50621 + Source Host : localhost:3306 + Source Schema : antdsp + + Target Server Type : MySQL + Target Server Version : 50621 + File Encoding : 65001 + + Date: 11/06/2019 17:48:16 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for tb_role_menu +-- ---------------------------- +DROP TABLE IF EXISTS `tb_role_menu`; +CREATE TABLE `tb_role_menu` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `role_id` bigint(20) NOT NULL, + `menu_id` bigint(20) NOT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 36 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; + +-- ---------------------------- +-- Records of tb_role_menu +-- ---------------------------- +INSERT INTO `tb_role_menu` VALUES (21, 4, 14); +INSERT INTO `tb_role_menu` VALUES (22, 4, 16); +INSERT INTO `tb_role_menu` VALUES (23, 4, 17); +INSERT INTO `tb_role_menu` VALUES (24, 4, 18); +INSERT INTO `tb_role_menu` VALUES (25, 4, 8); +INSERT INTO `tb_role_menu` VALUES (26, 5, 8); +INSERT INTO `tb_role_menu` VALUES (27, 5, 14); +INSERT INTO `tb_role_menu` VALUES (28, 5, 15); +INSERT INTO `tb_role_menu` VALUES (29, 5, 16); +INSERT INTO `tb_role_menu` VALUES (30, 5, 17); +INSERT INTO `tb_role_menu` VALUES (31, 5, 18); +INSERT INTO `tb_role_menu` VALUES (32, 5, 19); +INSERT INTO `tb_role_menu` VALUES (33, 5, 20); +INSERT INTO `tb_role_menu` VALUES (34, 5, 21); +INSERT INTO `tb_role_menu` VALUES (35, 5, 22); + +-- ---------------------------- +-- Table structure for tb_role_user +-- ---------------------------- +DROP TABLE IF EXISTS `tb_role_user`; +CREATE TABLE `tb_role_user` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `role_id` bigint(20) NOT NULL, + `user_id` bigint(20) NOT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact; + +-- ---------------------------- +-- Table structure for tb_system_menu +-- ---------------------------- +DROP TABLE IF EXISTS `tb_system_menu`; +CREATE TABLE `tb_system_menu` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `created` datetime(0) NOT NULL, + `creator` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `modified` datetime(0) NOT NULL, + `modifier` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `icon` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `menu_name` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `parent_id` bigint(20) NOT NULL, + `permission` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `reamrk` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `url` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `menu_type` varchar(12) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = MyISAM AUTO_INCREMENT = 23 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of tb_system_menu +-- ---------------------------- +INSERT INTO `tb_system_menu` VALUES (22, '2019-06-10 13:46:43', '', '2019-06-10 13:46:55', '', 'team', '角色管理', 8, NULL, NULL, '/system/role', 'MENU'); +INSERT INTO `tb_system_menu` VALUES (21, '2019-06-10 13:44:18', '', '2019-06-10 13:44:18', '', NULL, '删除', 15, 'menu:del', NULL, NULL, 'BUTTON'); +INSERT INTO `tb_system_menu` VALUES (20, '2019-06-10 13:43:58', '', '2019-06-10 13:43:58', '', NULL, '编辑', 15, 'menu:update', NULL, NULL, 'BUTTON'); +INSERT INTO `tb_system_menu` VALUES (19, '2019-06-10 13:43:36', '', '2019-06-10 13:43:36', '', 'plus', '新增', 15, 'menu:add', NULL, NULL, 'BUTTON'); +INSERT INTO `tb_system_menu` VALUES (18, '2019-06-10 13:43:07', '', '2019-06-10 13:43:07', '', NULL, '修改', 14, 'role:update', NULL, NULL, 'BUTTON'); +INSERT INTO `tb_system_menu` VALUES (8, '2019-06-10 12:20:51', '', '2019-06-11 16:08:03', '', 'setting', '系统管理', 0, '', NULL, '/system', 'MENU'); +INSERT INTO `tb_system_menu` VALUES (14, '2019-06-10 13:40:51', '', '2019-06-10 13:40:51', '', 'user', '用户管理', 8, NULL, NULL, '/system/user', 'MENU'); +INSERT INTO `tb_system_menu` VALUES (15, '2019-06-10 13:41:26', '', '2019-06-10 13:41:26', '', 'menu', '菜单管理', 8, NULL, NULL, '/system/menu', 'MENU'); +INSERT INTO `tb_system_menu` VALUES (16, '2019-06-10 13:42:10', '', '2019-06-10 13:42:10', '', 'plus', '新增', 14, 'role:add', NULL, NULL, 'BUTTON'); +INSERT INTO `tb_system_menu` VALUES (17, '2019-06-10 13:42:40', '', '2019-06-10 13:42:40', '', NULL, '删除', 14, 'role:del', NULL, NULL, 'BUTTON'); + +-- ---------------------------- +-- Table structure for tb_system_role +-- ---------------------------- +DROP TABLE IF EXISTS `tb_system_role`; +CREATE TABLE `tb_system_role` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `created` datetime(0) NOT NULL, + `creator` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `modified` datetime(0) NOT NULL, + `modifier` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `role_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = MyISAM AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of tb_system_role +-- ---------------------------- +INSERT INTO `tb_system_role` VALUES (5, '2019-06-11 11:03:40', '', '2019-06-11 15:21:19', '', '网站管理员,拥有所有权限', 'admin'); + +-- ---------------------------- +-- Table structure for tb_user +-- ---------------------------- +DROP TABLE IF EXISTS `tb_user`; +CREATE TABLE `tb_user` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `created` datetime(0) NOT NULL, + `creator` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `modified` datetime(0) NOT NULL, + `modifier` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `login_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `qq` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, + `real_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + `status` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`id`) USING BTREE +) ENGINE = MyISAM AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of tb_user +-- ---------------------------- +INSERT INTO `tb_user` VALUES (2, '2019-06-03 16:09:52', '', '2019-06-03 16:09:52', '', '', 'a496401006@qq.com', 'jt-lee', '123456', '496401006', 'lijiantao', 'NORMAL'); + +SET FOREIGN_KEY_CHECKS = 1; -- Gitee