win-chart 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/.eslintrc.json +3 -0
  2. package/.prettierrc.json +5 -0
  3. package/README.md +0 -0
  4. package/localhost-key.pem +28 -0
  5. package/localhost.pem +25 -0
  6. package/package.json +65 -0
  7. package/rsbuild.config.ts +48 -0
  8. package/src/api/README.md +15 -0
  9. package/src/api/index.js +5 -0
  10. package/src/api/layout/index.js +32 -0
  11. package/src/api/request.ts +87 -0
  12. package/src/api/url-map/index.js +10 -0
  13. package/src/api/user/index.js +12 -0
  14. package/src/components/FilterContext.tsx +6 -0
  15. package/src/components/GlobalStyle.tsx +25 -0
  16. package/src/components/HalfScreenBrowser.tsx +95 -0
  17. package/src/components/ImgBox.tsx +19 -0
  18. package/src/components/JumpBtn.tsx +38 -0
  19. package/src/components/MCardWrapper.tsx +33 -0
  20. package/src/components/NoContent/index.tsx +85 -0
  21. package/src/components/ResponsiveReactGridLayout.tsx +218 -0
  22. package/src/components/SliderDecoration.tsx +27 -0
  23. package/src/components/VisionUserConfigContext.ts +6 -0
  24. package/src/components/WinMenu/README.md +11 -0
  25. package/src/components/WinMenu/WinHeader.tsx +5 -0
  26. package/src/components/WinMenu/components/ExtraBox.tsx +61 -0
  27. package/src/components/WinMenu/components/FullMenuBox.tsx +80 -0
  28. package/src/components/WinMenu/components/FullMenuContainer.tsx +50 -0
  29. package/src/components/WinMenu/components/FullMenuItem.tsx +128 -0
  30. package/src/components/WinMenu/components/LangSwitch.tsx +84 -0
  31. package/src/components/WinMenu/components/LogoBox.tsx +29 -0
  32. package/src/components/WinMenu/components/PinDialog.tsx +72 -0
  33. package/src/components/WinMenu/components/PinnedMenuBox.tsx +183 -0
  34. package/src/components/WinMenu/components/UserBox.tsx +83 -0
  35. package/src/components/WinMenu/hooks/useUserInfo.ts +21 -0
  36. package/src/components/WinMenu/hooks/useUserMenu.ts +35 -0
  37. package/src/components/WinMenu/index.tsx +100 -0
  38. package/src/components/WinMenu/services/WinService.ts +79 -0
  39. package/src/components/WinMenu/services/request.ts +53 -0
  40. package/src/components/WinMenu/utils/const.ts +80 -0
  41. package/src/components/WinMenu/utils/enum.ts +19 -0
  42. package/src/components/WinMenu/utils/interface.ts +61 -0
  43. package/src/components/WinMenu/utils/map.ts +39 -0
  44. package/src/components/WinMenu/utils/tool.ts +142 -0
  45. package/src/components/WinMenu/utils/type.ts +1 -0
  46. package/src/components/hover-view.tsx +48 -0
  47. package/src/components/icon.tsx +44 -0
  48. package/src/components/indicator-remark.tsx +25 -0
  49. package/src/components/none-content.tsx +93 -0
  50. package/src/components/panel-tab.tsx +150 -0
  51. package/src/components/panel-title-tab.tsx +60 -0
  52. package/src/components/win-card/components/ChartContent.tsx +47 -0
  53. package/src/components/win-card/components/Indicator.tsx +42 -0
  54. package/src/components/win-card/components/IndicatorArea.tsx +63 -0
  55. package/src/components/win-card/components/IndicatorInfo.tsx +78 -0
  56. package/src/components/win-card/components/MatterContent.tsx +121 -0
  57. package/src/components/win-card/components/MatterList.tsx +141 -0
  58. package/src/components/win-card/components/NoticeContent.tsx +73 -0
  59. package/src/components/win-card/components/NoticeList.tsx +68 -0
  60. package/src/components/win-card/components/SelectDecoration.tsx +34 -0
  61. package/src/components/win-card/components/WinRankContent.tsx +102 -0
  62. package/src/components/win-card/index.tsx +298 -0
  63. package/src/components/win-card/utils/interface.ts +12 -0
  64. package/src/components/win-card/utils/tool.ts +11 -0
  65. package/src/components/win-card-mobile/components/ChartContent.tsx +47 -0
  66. package/src/components/win-card-mobile/components/DualLineBar.tsx +61 -0
  67. package/src/components/win-card-mobile/components/Indicator.tsx +42 -0
  68. package/src/components/win-card-mobile/components/IndicatorArea.tsx +65 -0
  69. package/src/components/win-card-mobile/components/IndicatorInfo.tsx +83 -0
  70. package/src/components/win-card-mobile/components/SelectDecoration.tsx +28 -0
  71. package/src/components/win-card-mobile/index.tsx +235 -0
  72. package/src/components/win-card-mobile/utils/interface.ts +12 -0
  73. package/src/components/win-card-mobile/utils/tool.ts +9 -0
  74. package/src/components/win-chart/components/chart-wrapper.tsx +5 -0
  75. package/src/components/win-chart/index.tsx +59 -0
  76. package/src/components/win-chart/theme/win-dark.json +372 -0
  77. package/src/components/win-chart/theme/win-light.json +372 -0
  78. package/src/components/win-chart/utils/const.ts +37 -0
  79. package/src/components/win-chart/utils/getAreaSpec.ts +150 -0
  80. package/src/components/win-chart/utils/getBarSpec.ts +60 -0
  81. package/src/components/win-chart/utils/getChartOptions.ts +59 -0
  82. package/src/components/win-chart/utils/getColumnSpec.ts +112 -0
  83. package/src/components/win-chart/utils/getDualSpec.ts +79 -0
  84. package/src/components/win-chart/utils/getFunnelSpec.ts +70 -0
  85. package/src/components/win-chart/utils/getLineSpec.ts +53 -0
  86. package/src/components/win-chart/utils/getPieSpec.ts +124 -0
  87. package/src/components/win-chart/utils/getRadarSpec.ts +87 -0
  88. package/src/components/win-chart/utils/tool.ts +163 -0
  89. package/src/components/win-chart/utils/type.ts +96 -0
  90. package/src/components/win-icon/index.tsx +97 -0
  91. package/src/components/win-v/components/EmptyBox.tsx +9 -0
  92. package/src/components/win-v/components/VDialog.tsx +173 -0
  93. package/src/components/win-v/components/VDialogBtn.tsx +119 -0
  94. package/src/components/win-v/components/VDialogMsg.tsx +325 -0
  95. package/src/components/win-v/components/VInput.tsx +15 -0
  96. package/src/components/win-v/components/VRemindMsgList.tsx +303 -0
  97. package/src/components/win-v/components/VRobot.tsx +97 -0
  98. package/src/components/win-v/hooks/useVDialogCore.ts +102 -0
  99. package/src/components/win-v/hooks/useVDialogOperate.ts +132 -0
  100. package/src/components/win-v/hooks/useVDialogState.ts +52 -0
  101. package/src/components/win-v/hooks/useVRemindMsgShow.ts +15 -0
  102. package/src/components/win-v/index.tsx +205 -0
  103. package/src/components/win-wrappers/card-wrapper.tsx +103 -0
  104. package/src/components/win-wrappers/dot-wrapper.tsx +18 -0
  105. package/src/components/win-wrappers/iframe-wrapper.tsx +7 -0
  106. package/src/components/win-wrappers/request-wrapper.tsx +190 -0
  107. package/src/global.d.ts +53 -0
  108. package/src/hooks/useCardOptionList.ts +23 -0
  109. package/src/hooks/useCostFiltersDicList.ts +22 -0
  110. package/src/hooks/useFbiUrl.ts +22 -0
  111. package/src/hooks/useHalfScreenState.ts +50 -0
  112. package/src/hooks/useHasIntersected.ts +36 -0
  113. package/src/hooks/useIndicatorCardInfo.ts +26 -0
  114. package/src/hooks/useIndicatorCardQueryList.ts +22 -0
  115. package/src/hooks/useIndicatorClassifyList.ts +25 -0
  116. package/src/hooks/useIndicatorDetailsDateList.ts +22 -0
  117. package/src/hooks/useIndicatorDetailsInfo.ts +49 -0
  118. package/src/hooks/useIndicatorDetailsTrend.ts +25 -0
  119. package/src/hooks/useIndicatorDicList.ts +22 -0
  120. package/src/hooks/useIndicatorLabelList.ts +20 -0
  121. package/src/hooks/useIndicatorList.ts +24 -0
  122. package/src/hooks/useIndicatorRangeList.ts +20 -0
  123. package/src/hooks/useIndicatorTypeList.ts +20 -0
  124. package/src/hooks/useIndicatorUnitList.ts +21 -0
  125. package/src/hooks/useListenQuery.ts +29 -0
  126. package/src/hooks/useMobile.ts +58 -0
  127. package/src/hooks/useNotice.ts +42 -0
  128. package/src/hooks/useOrgLevelList.ts +23 -0
  129. package/src/hooks/usePageSelection.ts +121 -0
  130. package/src/hooks/usePageState.ts +22 -0
  131. package/src/hooks/usePendingList.ts +27 -0
  132. package/src/hooks/usePortalPageInfo.ts +43 -0
  133. package/src/hooks/useRefreshByLocationChange.ts +16 -0
  134. package/src/hooks/useReportIndicatorList.ts +21 -0
  135. package/src/hooks/useReportInfo.ts +45 -0
  136. package/src/hooks/useReportPersonList.ts +21 -0
  137. package/src/hooks/useScriptLoader.ts +22 -0
  138. package/src/hooks/useUnreadMsgList.ts +26 -0
  139. package/src/hooks/useUserAvatar.ts +23 -0
  140. package/src/hooks/useVReportInfo.ts +50 -0
  141. package/src/hooks/useVisionUserConfig.ts +25 -0
  142. package/src/hooks/useWorkbenchOptions.ts +63 -0
  143. package/src/index.tsx +20 -0
  144. package/src/services/CardService.ts +91 -0
  145. package/src/services/CommonService.ts +23 -0
  146. package/src/services/CostService.ts +56 -0
  147. package/src/services/DialogService.ts +74 -0
  148. package/src/services/IndicatorService.ts +406 -0
  149. package/src/services/PageService.ts +204 -0
  150. package/src/services/ReportService.ts +335 -0
  151. package/src/services/WorkbenchService.ts +411 -0
  152. package/src/styles/README.md +12 -0
  153. package/src/styles/index.scss +9 -0
  154. package/src/styles/mixins/index.scss +25 -0
  155. package/src/styles/next-cover.scss +4 -0
  156. package/src/styles/normalize.scss +27 -0
  157. package/src/styles/utilities/index.scss +5 -0
  158. package/src/styles/vars/index.scss +17 -0
  159. package/src/types/enum-workbench.ts +29 -0
  160. package/src/types/enum.ts +156 -0
  161. package/src/types/index.ts +19 -0
  162. package/src/types/indicator.ts +299 -0
  163. package/src/types/interface.ts +303 -0
  164. package/src/types/portal.ts +211 -0
  165. package/src/types/report.ts +28 -0
  166. package/src/types/type.ts +11 -0
  167. package/src/types/user.ts +28 -0
  168. package/src/utils/README.md +4 -0
  169. package/src/utils/arms.ts +59 -0
  170. package/src/utils/arr.ts +123 -0
  171. package/src/utils/const-workbench.ts +9 -0
  172. package/src/utils/const.ts +18 -0
  173. package/src/utils/index.ts +18 -0
  174. package/src/utils/init.ts +5 -0
  175. package/src/utils/map-workbench.ts +66 -0
  176. package/src/utils/map.ts +377 -0
  177. package/src/utils/number.ts +101 -0
  178. package/src/utils/page.ts +81 -0
  179. package/src/utils/str.ts +26 -0
  180. package/src/utils/tools.ts +44 -0
  181. package/src/utils/tree.ts +145 -0
  182. package/src/utils/url.ts +40 -0
  183. package/src/utils/util.ts +99 -0
  184. package/src/utils/workbench.ts +25 -0
  185. package/tsconfig.json +33 -0
package/.eslintrc.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["react-app", "prettier"]
3
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "jsxSingleQuote": false
5
+ }
package/README.md ADDED
File without changes
@@ -0,0 +1,28 @@
1
+ -----BEGIN PRIVATE KEY-----
2
+ MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDTXG4k7dnUXg1y
3
+ YgYfCu2A1e1YVgcsD9+Ex9s1snkqyHY7GJVc2//nTV35hlJAhpZt0bq3vqDgbkaK
4
+ BbHWZgdF7719lgGVmntwNWsAiyyoaOmNuIq2u+UDMKWSxQbChAXId+PfhHUjH/Vo
5
+ 0QZ5CM22jj3tPyor4K1ls04Lz5ZVzLYRz1+fCaNeBLRBrmZNYjdDKZCVOUwUYBpl
6
+ o0dsxb16izPJ9Yw/Bnret0qvRaM/BBt7cT2xabXUTQ3Xr2d1i64+K5GEblYI07A5
7
+ 2kbCHZ6O10/9Nyzaob6pTO1dMnZsim8M2FY3GIad29A+JamEd0br5kFJEp/UJFgQ
8
+ yKf0tHd7AgMBAAECggEACc+GhUxNCiB7e021fwdg0tQbOjh0CMWL2Hv2Xt2z5hp7
9
+ 8m5HsJG9pRzgOc7UTo5wuRQ9GH5OtVwpBgsRoCQIPmTMZOHrnOgYxrKUDuhm4EJO
10
+ ZPel6Kl8DdPaO5/NmoXKRu3Zs+xQC5tWJtFc/Y09DzY3BaYi7Pp20fuqqb2u+rh6
11
+ JyAM2fu7UWSDWXBcIgZFQFpAZarooPQ5aHTtGvVga/Ul2yipFexWFUWcq2CCPFlH
12
+ x5el/AkaheFEPWTND7aw+fmkWVCco21mAH0T1nv0QHXn7sDV+rmAH0ejj+wgqOoq
13
+ GU75BwnoygmDfCbh38hsi9u9dITMPNAtrHQI1IdZgQKBgQD9G7fCHlirN+oYqGJp
14
+ wNC+1XFmg6cN8ZnLZk8CXS060I7BHNF7IyuxtfYKLURhtmVscVdwG1qx9ZeH8m4L
15
+ ni5A5CdTTeENzMjgu+HkH4BPDMBk3PfUCc+ljNPEA6j14c6oZb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c
20
+ 47tAPLtPo2KuuKbQ4FMdRk/DJ8YzbkBrmpOuIAnyIVfmdq/FeFU4yy8s0u0wJ3dg
21
+ EShdbkcMl7RITKU0L5mVXZPDla04RfciUGuR3oFabnPCcWTYOD+BZFrQHvqJPVNR
22
+ hVLYHbOr/w+rTVpcbz3Tyisdmu/GZUwiUUgcG3t20AHSJjXnt2uCQ0tbfFMfdS/l
23
+ jHq09DfDyedApLXLxrqLugay99SsN47qW1Va4yn8dthU95kyi4RM35gul+6hohGR
24
+ WH8pxV8bi6U=
25
+ -----END CERTIFICATE-----
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "win-chart",
3
+ "version": "1.0.0",
4
+ "author": "Samuel Ouyang",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://gitlab.alibaba-inc.com/ground-net-front/win-chart.git"
8
+ },
9
+ "scripts": {
10
+ "dev": "rsbuild dev",
11
+ "build": "rsbuild build",
12
+ "preview": "rsbuild preview"
13
+ },
14
+ "browserslist": {
15
+ "production": [
16
+ ">0.2%",
17
+ "not dead",
18
+ "not op_mini all"
19
+ ],
20
+ "development": [
21
+ "last 1 chrome version",
22
+ "last 1 firefox version",
23
+ "last 1 safari version"
24
+ ]
25
+ },
26
+ "dependencies": {
27
+ "@cainiaofe/cn-ui": "^0.11.16",
28
+ "@ice/stark": "^2.7.3",
29
+ "@rematch/core": "^2.1.0",
30
+ "@rematch/loading": "^2.1.0",
31
+ "@rematch/select": "^3.1.0",
32
+ "ahooks": "^3.7.8",
33
+ "axios": "^1.6.7",
34
+ "classnames": "^2.3.1",
35
+ "core-js": "^3.35.1",
36
+ "d3": "^7.8.5",
37
+ "dayjs": "^1.11.10",
38
+ "deepmerge": "^4.3.1",
39
+ "echarts": "^5.4.3",
40
+ "normalize.css": "^8.0.1",
41
+ "panda-i18n": "^0.2.74",
42
+ "polished": "^4.2.2",
43
+ "qs": "^6.11.2",
44
+ "react": "^18.2.0",
45
+ "react-dom": "^18.2.0",
46
+ "react-grid-layout": "^1.4.4",
47
+ "react-redux": "^7.1.0",
48
+ "react-router-dom": "^6.21.1",
49
+ "recoil": "^0.7.7",
50
+ "styled-components": "^6.1.8"
51
+ },
52
+ "devDependencies": {
53
+ "@rsbuild/core": "^0.4.3",
54
+ "@rsbuild/plugin-react": "^0.4.3",
55
+ "@types/d3": "^7.4.0",
56
+ "@types/node": "^20.11.25",
57
+ "@types/react": "^18.2.64",
58
+ "@types/react-dom": "^18.2.18",
59
+ "eslint": "^8.56.0",
60
+ "eslint-config-prettier": "^9.1.0",
61
+ "eslint-config-react-app": "^7.0.1",
62
+ "prettier": "^3.2.5",
63
+ "typescript": "^5.1.6"
64
+ }
65
+ }
@@ -0,0 +1,48 @@
1
+ import { defineConfig } from '@rsbuild/core';
2
+ import { pluginReact } from '@rsbuild/plugin-react';
3
+ import fs from 'fs';
4
+
5
+ export default defineConfig({
6
+ plugins: [pluginReact()],
7
+ dev: {
8
+ progressBar: true,
9
+ },
10
+ performance: {
11
+ chunkSplit: {
12
+ strategy: 'all-in-one',
13
+ },
14
+ bundleAnalyze: {},
15
+ },
16
+ output: {
17
+ distPath: {
18
+ root: 'build',
19
+ js: 'js',
20
+ css: 'css',
21
+ svg: 'svg',
22
+ font: 'font',
23
+ wasm: 'wasm',
24
+ image: 'image',
25
+ media: 'media',
26
+ server: 'bundles',
27
+ worker: 'worker',
28
+ },
29
+ sourceMap: {
30
+ js: false,
31
+ },
32
+ legalComments: 'none',
33
+ filenameHash: false,
34
+ overrideBrowserslist: [
35
+ 'iOS >= 9',
36
+ 'Android >= 4.4',
37
+ 'last 2 versions',
38
+ '> 0.2%',
39
+ 'not dead',
40
+ ],
41
+ },
42
+ server: {
43
+ https: {
44
+ key: fs.readFileSync('./localhost-key.pem'),
45
+ cert: fs.readFileSync('./localhost.pem'),
46
+ },
47
+ },
48
+ });
@@ -0,0 +1,15 @@
1
+ # 项目 api
2
+
3
+ - 此文件夹用于放置项目级别的数据请求 api.
4
+ - 使用的时候直接 `import { xxx } from 'src/api';` 即可
5
+
6
+ # 新增 api
7
+
8
+ - 在 `./url-map` 里面增加相应的 url, 随着项目的不断迭代, 如果 url 越来越多, 可以逐步按文件来拆分 url-map.
9
+ - 选择或者创建一个文件夹来合理的管理 api, 比如说 `./user` 里面放置的是用户相关的请求, `./layout` 里面放置的是导航相关的请求.
10
+ - 如果创建了新的文件夹, 请在 `./index` 里面导出它.
11
+ - 参照现有的 api 来编写新的 api.
12
+
13
+ # 页面 api
14
+
15
+ - 页面级别的数据请求 api, 可以放在页面里面, 参考 `src/pages/**/api`.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 导出所有的请求, 这样外界使用的时候直接 `import { xxx } from 'src/api';` 即可
3
+ */
4
+ export * from './layout';
5
+ export * from './user';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 此文件用于管理侧边栏相关的请求
3
+ */
4
+ import $i18n from 'panda-i18n';
5
+
6
+ import request from '../request';
7
+ import urlMap from '../url-map';
8
+
9
+ function formatMenu(menu) {
10
+ const { titleKey } = menu;
11
+ if (titleKey) {
12
+ menu.text = $i18n.get({ id: titleKey });
13
+ } else {
14
+ menu.text = menu.title || '';
15
+ }
16
+ menu.key = menu.path || '';
17
+ }
18
+
19
+ // 获取侧边栏菜单栏列表
20
+ export async function getMenuList() {
21
+ const { data } = await request.get(urlMap.getMenuList);
22
+
23
+ const { dataList } = data;
24
+ dataList.forEach((menu) => {
25
+ const { children } = menu;
26
+ formatMenu(menu);
27
+ if (children) {
28
+ children.forEach(formatMenu);
29
+ }
30
+ });
31
+ return dataList;
32
+ }
@@ -0,0 +1,87 @@
1
+ import axios, { AxiosRequestConfig } from 'axios';
2
+ import { IResponse } from 'src/types/interface';
3
+
4
+ /**
5
+ * boss内部未登入错误码
6
+ */
7
+ export const bossBUCWithoutLoginErrorCodeList = ['CN10201812011'];
8
+
9
+ /**
10
+ * boss外部未登入错误码(菜鸟登陆需要两次encodeURIComponent)
11
+ */
12
+ export const bossCaiNiaoWithoutLoginErrorCodeList = ['CN10201912011'];
13
+
14
+ /**
15
+ * boss内外部无权限错误码
16
+ */
17
+ export const bossWithoutAccessErrCodeList = [
18
+ 'CN10201812021',
19
+ 'CN10201812022',
20
+ 'CN10201912021',
21
+ 'CN10201912022',
22
+ ];
23
+
24
+ /**
25
+ * 未登入错误码
26
+ */
27
+ export const withoutLoginErrorCodeList = [
28
+ 'CN10829902001',
29
+ '2000',
30
+ '1000',
31
+ ...bossBUCWithoutLoginErrorCodeList,
32
+ ];
33
+
34
+ /**
35
+ * 无权限错误码
36
+ */
37
+ export const withoutAccessErrorCodeList = [
38
+ 'CN10829902004',
39
+ ...bossWithoutAccessErrCodeList,
40
+ ];
41
+
42
+ // axios 实例
43
+ const request = axios.create({
44
+ withCredentials: true,
45
+ });
46
+
47
+ // 做一些基于业务场景的定制
48
+ request.interceptors.response.use(
49
+ (response) => {
50
+ const obj = response.data;
51
+ const { success, errorMsg, errorCode } = obj;
52
+
53
+ if (withoutLoginErrorCodeList.includes(errorCode)) {
54
+ const curHref = encodeURIComponent(window.parent.location.href);
55
+ window.location.href = errorMsg + curHref;
56
+ }
57
+
58
+ if (bossCaiNiaoWithoutLoginErrorCodeList.includes(errorCode)) {
59
+ const curHref = encodeURIComponent(
60
+ encodeURIComponent(window.parent.location.href),
61
+ );
62
+ window.location.href = errorMsg + curHref;
63
+ }
64
+
65
+ if (!success) {
66
+ // eslint-disable-next-line prefer-promise-reject-errors
67
+ return Promise.reject({
68
+ ...obj,
69
+ message: errorMsg,
70
+ });
71
+ }
72
+
73
+ return obj;
74
+ },
75
+ (err) => {
76
+ console.error('network error', err);
77
+ return Promise.reject(err);
78
+ },
79
+ );
80
+
81
+ export default request;
82
+
83
+ export const newRequest = async <T>(config: AxiosRequestConfig<any>) => {
84
+ const resp: IResponse<T> = (await request<IResponse<T>>(config)) as any;
85
+
86
+ return Promise.resolve(resp);
87
+ };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 统一管理请求的 url, 随着项目的不断迭代, 如果 url 越来越多, 可以逐步按文件来拆分 url-map.
3
+ */
4
+ export default {
5
+ getUserInfo:
6
+ 'https://mocks.alibaba-inc.com/mock/cnxt-web-app-sample/getUserInfo',
7
+ getMenuList:
8
+ 'https://mocks.alibaba-inc.com/mock/kp2dkcok/getDemoSidebarMenuList',
9
+ helloCnxt: 'https://mocks.alibaba-inc.com/mock/cnxt-web-app-sample/helloCnxt',
10
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 此文件用于管理用户相关的请求
3
+ */
4
+
5
+ import request from '../request';
6
+ import urlMap from '../url-map';
7
+
8
+ // 获取用户信息
9
+ export async function getUserInfo() {
10
+ const { data } = await request.get(urlMap.getUserInfo);
11
+ return data;
12
+ }
@@ -0,0 +1,6 @@
1
+ import { IKeyValueItem } from '@/types';
2
+ import { createContext, useContext } from 'react';
3
+
4
+ export const FilterContext = createContext<IKeyValueItem>({});
5
+
6
+ export const useFilterContext = () => useContext(FilterContext);
@@ -0,0 +1,25 @@
1
+ import { RESPONSIVE_BREAKPOINT } from '@/utils';
2
+ import { createGlobalStyle } from 'styled-components';
3
+
4
+ export const GlobalStyle = createGlobalStyle`
5
+ html {
6
+ font-size: 16px;
7
+ @media (max-width: ${RESPONSIVE_BREAKPOINT}) {
8
+ font-size: calc(100vw / 750 * 100);
9
+ * {
10
+ -webkit-tap-highlight-color: transparent;
11
+ }
12
+ }
13
+
14
+ body {
15
+ padding-bottom: env(safe-area-inset-bottom);
16
+ }
17
+ }
18
+ `;
19
+
20
+ export const CommonMobileGlobalStyle = createGlobalStyle`
21
+ body {
22
+ padding: 0.24rem;
23
+ background: no-repeat url('https://img.alicdn.com/imgextra/i4/O1CN01RWfZ7n1xDNHWlwHxT_!!6000000006409-2-tps-1502-3252.png') left 0 top 0 / 100% 100%;
24
+ }
25
+ `;
@@ -0,0 +1,95 @@
1
+ import { CnDrawer } from '@cainiaofe/cn-ui-m';
2
+ import {
3
+ useAutoCloseHalfScreen,
4
+ useHalfScreenDispatch,
5
+ useHalfScreenStateValue,
6
+ } from '../hooks/useHalfScreenState';
7
+ import { styled } from 'styled-components';
8
+ import { getHandleOpenLink } from 'src/utils';
9
+ import { CustomIcon } from 'src/components/icon';
10
+ import { useEffect, useState } from 'react';
11
+
12
+ export const HalfScreenBrowser = () => {
13
+ useAutoCloseHalfScreen();
14
+ const state = useHalfScreenStateValue();
15
+ const dispatch = useHalfScreenDispatch();
16
+ const [iframeSrc, setIframeSrc] = useState('');
17
+
18
+ const handleClose = () => {
19
+ dispatch.close();
20
+ setIframeSrc('');
21
+ };
22
+
23
+ const handleFullScreen = () => {
24
+ getHandleOpenLink(state.src)();
25
+ handleClose();
26
+ };
27
+
28
+ useEffect(() => {
29
+ if (state.src) {
30
+ setTimeout(() => {
31
+ setIframeSrc(state.src!);
32
+ }, 500);
33
+ }
34
+ }, [state.src]);
35
+
36
+ return (
37
+ <CnDrawerDecoration
38
+ visible={state.show}
39
+ title={handleTitle(state.title)}
40
+ onClose={handleClose}
41
+ noCard
42
+ >
43
+ <FullScreenBtn onClick={handleFullScreen} />
44
+ <CloseBtn onClick={handleClose} />
45
+ <iframe
46
+ title="browser"
47
+ src={iframeSrc}
48
+ style={{
49
+ width: '100%',
50
+ height: '80vh',
51
+ border: 'none',
52
+ }}
53
+ />
54
+ </CnDrawerDecoration>
55
+ );
56
+ };
57
+
58
+ const handleTitle = (title?: string) =>
59
+ title && title.length > 16 ? `${title.slice(0, 16)}...` : title;
60
+
61
+ const CnDrawerDecoration = styled(CnDrawer).attrs({
62
+ titleAlign: 'center',
63
+ })`
64
+ border-radius: 0.32rem 0.32rem 0 0;
65
+
66
+ .cn-ui-m-drawer-body::-webkit-scrollbar {
67
+ display: none;
68
+ }
69
+
70
+ .cn-ui-m-drawer-title {
71
+ border: none;
72
+ }
73
+
74
+ .cn-ui-m-drawer-close {
75
+ display: none;
76
+ }
77
+ `;
78
+
79
+ const FullScreenBtn = styled(CustomIcon).attrs({
80
+ type: 'icon-kuozhan',
81
+ })`
82
+ cursor: pointer;
83
+ position: absolute;
84
+ left: 16px;
85
+ top: 16px;
86
+ `;
87
+
88
+ const CloseBtn = styled(CustomIcon).attrs({
89
+ type: 'icon-guanbi',
90
+ })`
91
+ cursor: pointer;
92
+ position: absolute;
93
+ top: 16px;
94
+ right: 16px;
95
+ `;
@@ -0,0 +1,19 @@
1
+ import { CSSProperties } from 'react';
2
+
3
+ interface IProps {
4
+ src: string;
5
+ width: number;
6
+ style: CSSProperties;
7
+ }
8
+
9
+ export const ImgBox = ({ src = '', width = 200, style }: Partial<IProps>) => (
10
+ <img
11
+ alt=''
12
+ src={src}
13
+ style={{
14
+ objectFit: 'contain',
15
+ width,
16
+ ...style,
17
+ }}
18
+ />
19
+ );
@@ -0,0 +1,38 @@
1
+ import { IStyleProps } from '@/types';
2
+ import { CnButton } from '@cainiaofe/cn-ui';
3
+ import { PropsWithChildren } from 'react';
4
+ import { styled } from 'styled-components';
5
+
6
+ interface IProps extends IStyleProps {
7
+ url: string;
8
+ openNewPage?: boolean;
9
+ }
10
+
11
+ export const JumpBtn = ({
12
+ url = '',
13
+ openNewPage = true,
14
+ children,
15
+ ...args
16
+ }: PropsWithChildren<IProps>) => {
17
+ return (
18
+ <CnButton
19
+ text
20
+ type="primary"
21
+ onClick={(e) => {
22
+ e.stopPropagation();
23
+ if (openNewPage) {
24
+ globalThis.open(url);
25
+ } else {
26
+ globalThis.location.href = url;
27
+ }
28
+ }}
29
+ {...args}
30
+ >
31
+ {children}
32
+ </CnButton>
33
+ );
34
+ };
35
+
36
+ export const JumpBtnMobile = styled(JumpBtn)`
37
+ font-size: 0.26rem !important;
38
+ `;
@@ -0,0 +1,33 @@
1
+ import { rgba } from 'polished';
2
+ import { styled } from 'styled-components';
3
+
4
+ export const MCardWrapper = styled.div`
5
+ background-color: rgba(255, 255, 255, 0.8);
6
+ box-shadow: 0 0.02rem 0.04rem 0 rgba(39, 46, 58, 0.12);
7
+ border-radius: 0.24rem;
8
+ padding: 0.32rem;
9
+ margin-bottom: 0.2rem;
10
+ `;
11
+
12
+ export const MCardTitleWrapper = styled.div`
13
+ font-weight: 600;
14
+ font-size: 0.32rem;
15
+ color: #272f3d;
16
+ line-height: 1;
17
+ margin-bottom: 0.2rem;
18
+ `;
19
+
20
+ export const MarkWrapper = styled.div`
21
+ color: #272e3a;
22
+ background-color: ${rgba('#3379ff', 0.12)};
23
+ border-radius: 0.16rem;
24
+ padding: 0.24rem;
25
+ display: flex;
26
+ align-items: flex-start;
27
+ font-size: 0.24rem;
28
+ line-height: 0.36rem;
29
+
30
+ div {
31
+ margin-left: 0.12rem;
32
+ }
33
+ `;
@@ -0,0 +1,85 @@
1
+ import { Box } from '@cainiaofe/cn-ui';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+
4
+ interface IProps {
5
+ direction?: 'row' | 'column' | 'row-reverse';
6
+ style: CSSProperties;
7
+ message: ReactNode;
8
+ className: string;
9
+ }
10
+
11
+ const NoContent = ({
12
+ direction = 'row',
13
+ message = '无内容',
14
+ style,
15
+ className,
16
+ }: Partial<IProps>) => {
17
+ return (
18
+ <Box
19
+ direction={direction}
20
+ justify='center'
21
+ align='center'
22
+ spacing={20}
23
+ className={className}
24
+ style={{
25
+ transform: 'translateY(20px)',
26
+ ...style,
27
+ }}
28
+ >
29
+ <img
30
+ alt=''
31
+ src='https://img.alicdn.com/imgextra/i4/O1CN01bkhh1m21HH4wlsyY9_!!6000000006959-55-tps-96-64.svg'
32
+ style={{
33
+ width: 120,
34
+ height: 120,
35
+ objectFit: 'contain',
36
+ }}
37
+ />
38
+ <span
39
+ style={{
40
+ fontSize: 14,
41
+ fontWeight: 700,
42
+ color: '#afb6c3',
43
+ }}
44
+ >
45
+ {message}
46
+ </span>
47
+ </Box>
48
+ );
49
+ };
50
+
51
+ export const NoAssess = ({
52
+ direction = 'row',
53
+ message = '暂无权限',
54
+ style,
55
+ className,
56
+ }: Partial<IProps>) => {
57
+ return (
58
+ <Box
59
+ direction={direction}
60
+ justify='center'
61
+ align='center'
62
+ spacing={20}
63
+ className={className}
64
+ style={{
65
+ ...style,
66
+ }}
67
+ >
68
+ <img
69
+ alt=''
70
+ src='https://img.alicdn.com/imgextra/i4/O1CN01oQNWzR1rY5L7fdHcH_!!6000000005642-55-tps-160-160.svg'
71
+ style={{ width: 120, height: 120, objectFit: 'contain' }}
72
+ />
73
+ <span
74
+ style={{
75
+ fontSize: 14,
76
+ fontWeight: 700,
77
+ color: '#6D7A90',
78
+ }}
79
+ >
80
+ {message}
81
+ </span>
82
+ </Box>
83
+ );
84
+ };
85
+ export default NoContent;