win-chart 1.0.1 → 1.0.3

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/build/js/index.js +1 -0
  2. package/package.json +5 -2
  3. package/.eslintrc.json +0 -3
  4. package/.prettierrc.json +0 -5
  5. package/localhost-key.pem +0 -28
  6. package/localhost.pem +0 -25
  7. package/rsbuild.config.ts +0 -48
  8. package/src/api/README.md +0 -15
  9. package/src/api/index.js +0 -5
  10. package/src/api/layout/index.js +0 -32
  11. package/src/api/request.ts +0 -87
  12. package/src/api/url-map/index.js +0 -10
  13. package/src/api/user/index.js +0 -12
  14. package/src/components/FilterContext.tsx +0 -6
  15. package/src/components/GlobalStyle.tsx +0 -25
  16. package/src/components/HalfScreenBrowser.tsx +0 -95
  17. package/src/components/ImgBox.tsx +0 -19
  18. package/src/components/JumpBtn.tsx +0 -38
  19. package/src/components/MCardWrapper.tsx +0 -33
  20. package/src/components/NoContent/index.tsx +0 -85
  21. package/src/components/ResponsiveReactGridLayout.tsx +0 -218
  22. package/src/components/SliderDecoration.tsx +0 -27
  23. package/src/components/VisionUserConfigContext.ts +0 -6
  24. package/src/components/WinMenu/README.md +0 -11
  25. package/src/components/WinMenu/WinHeader.tsx +0 -5
  26. package/src/components/WinMenu/components/ExtraBox.tsx +0 -61
  27. package/src/components/WinMenu/components/FullMenuBox.tsx +0 -80
  28. package/src/components/WinMenu/components/FullMenuContainer.tsx +0 -50
  29. package/src/components/WinMenu/components/FullMenuItem.tsx +0 -128
  30. package/src/components/WinMenu/components/LangSwitch.tsx +0 -84
  31. package/src/components/WinMenu/components/LogoBox.tsx +0 -29
  32. package/src/components/WinMenu/components/PinDialog.tsx +0 -72
  33. package/src/components/WinMenu/components/PinnedMenuBox.tsx +0 -183
  34. package/src/components/WinMenu/components/UserBox.tsx +0 -83
  35. package/src/components/WinMenu/hooks/useUserInfo.ts +0 -21
  36. package/src/components/WinMenu/hooks/useUserMenu.ts +0 -35
  37. package/src/components/WinMenu/index.tsx +0 -100
  38. package/src/components/WinMenu/services/WinService.ts +0 -79
  39. package/src/components/WinMenu/services/request.ts +0 -53
  40. package/src/components/WinMenu/utils/const.ts +0 -80
  41. package/src/components/WinMenu/utils/enum.ts +0 -19
  42. package/src/components/WinMenu/utils/interface.ts +0 -61
  43. package/src/components/WinMenu/utils/map.ts +0 -39
  44. package/src/components/WinMenu/utils/tool.ts +0 -142
  45. package/src/components/WinMenu/utils/type.ts +0 -1
  46. package/src/components/hover-view.tsx +0 -48
  47. package/src/components/icon.tsx +0 -44
  48. package/src/components/indicator-remark.tsx +0 -25
  49. package/src/components/none-content.tsx +0 -93
  50. package/src/components/panel-tab.tsx +0 -150
  51. package/src/components/panel-title-tab.tsx +0 -60
  52. package/src/components/win-card/components/ChartContent.tsx +0 -47
  53. package/src/components/win-card/components/Indicator.tsx +0 -42
  54. package/src/components/win-card/components/IndicatorArea.tsx +0 -63
  55. package/src/components/win-card/components/IndicatorInfo.tsx +0 -78
  56. package/src/components/win-card/components/MatterContent.tsx +0 -121
  57. package/src/components/win-card/components/MatterList.tsx +0 -141
  58. package/src/components/win-card/components/NoticeContent.tsx +0 -73
  59. package/src/components/win-card/components/NoticeList.tsx +0 -68
  60. package/src/components/win-card/components/SelectDecoration.tsx +0 -34
  61. package/src/components/win-card/components/WinRankContent.tsx +0 -102
  62. package/src/components/win-card/index.tsx +0 -298
  63. package/src/components/win-card/utils/interface.ts +0 -12
  64. package/src/components/win-card/utils/tool.ts +0 -11
  65. package/src/components/win-card-mobile/components/ChartContent.tsx +0 -47
  66. package/src/components/win-card-mobile/components/DualLineBar.tsx +0 -61
  67. package/src/components/win-card-mobile/components/Indicator.tsx +0 -42
  68. package/src/components/win-card-mobile/components/IndicatorArea.tsx +0 -65
  69. package/src/components/win-card-mobile/components/IndicatorInfo.tsx +0 -83
  70. package/src/components/win-card-mobile/components/SelectDecoration.tsx +0 -28
  71. package/src/components/win-card-mobile/index.tsx +0 -235
  72. package/src/components/win-card-mobile/utils/interface.ts +0 -12
  73. package/src/components/win-card-mobile/utils/tool.ts +0 -9
  74. package/src/components/win-chart/components/chart-wrapper.tsx +0 -5
  75. package/src/components/win-chart/index.tsx +0 -59
  76. package/src/components/win-chart/theme/win-dark.json +0 -372
  77. package/src/components/win-chart/theme/win-light.json +0 -372
  78. package/src/components/win-chart/utils/const.ts +0 -37
  79. package/src/components/win-chart/utils/getAreaSpec.ts +0 -150
  80. package/src/components/win-chart/utils/getBarSpec.ts +0 -60
  81. package/src/components/win-chart/utils/getChartOptions.ts +0 -59
  82. package/src/components/win-chart/utils/getColumnSpec.ts +0 -112
  83. package/src/components/win-chart/utils/getDualSpec.ts +0 -79
  84. package/src/components/win-chart/utils/getFunnelSpec.ts +0 -70
  85. package/src/components/win-chart/utils/getLineSpec.ts +0 -53
  86. package/src/components/win-chart/utils/getPieSpec.ts +0 -124
  87. package/src/components/win-chart/utils/getRadarSpec.ts +0 -87
  88. package/src/components/win-chart/utils/tool.ts +0 -163
  89. package/src/components/win-chart/utils/type.ts +0 -96
  90. package/src/components/win-icon/index.tsx +0 -97
  91. package/src/components/win-v/components/EmptyBox.tsx +0 -9
  92. package/src/components/win-v/components/VDialog.tsx +0 -173
  93. package/src/components/win-v/components/VDialogBtn.tsx +0 -119
  94. package/src/components/win-v/components/VDialogMsg.tsx +0 -325
  95. package/src/components/win-v/components/VInput.tsx +0 -15
  96. package/src/components/win-v/components/VRemindMsgList.tsx +0 -303
  97. package/src/components/win-v/components/VRobot.tsx +0 -97
  98. package/src/components/win-v/hooks/useVDialogCore.ts +0 -102
  99. package/src/components/win-v/hooks/useVDialogOperate.ts +0 -132
  100. package/src/components/win-v/hooks/useVDialogState.ts +0 -52
  101. package/src/components/win-v/hooks/useVRemindMsgShow.ts +0 -15
  102. package/src/components/win-v/index.tsx +0 -205
  103. package/src/components/win-wrappers/card-wrapper.tsx +0 -103
  104. package/src/components/win-wrappers/dot-wrapper.tsx +0 -18
  105. package/src/components/win-wrappers/iframe-wrapper.tsx +0 -7
  106. package/src/components/win-wrappers/request-wrapper.tsx +0 -190
  107. package/src/global.d.ts +0 -53
  108. package/src/hooks/useCardOptionList.ts +0 -23
  109. package/src/hooks/useCostFiltersDicList.ts +0 -22
  110. package/src/hooks/useFbiUrl.ts +0 -22
  111. package/src/hooks/useHalfScreenState.ts +0 -50
  112. package/src/hooks/useHasIntersected.ts +0 -36
  113. package/src/hooks/useIndicatorCardInfo.ts +0 -26
  114. package/src/hooks/useIndicatorCardQueryList.ts +0 -22
  115. package/src/hooks/useIndicatorClassifyList.ts +0 -25
  116. package/src/hooks/useIndicatorDetailsDateList.ts +0 -22
  117. package/src/hooks/useIndicatorDetailsInfo.ts +0 -49
  118. package/src/hooks/useIndicatorDetailsTrend.ts +0 -25
  119. package/src/hooks/useIndicatorDicList.ts +0 -22
  120. package/src/hooks/useIndicatorLabelList.ts +0 -20
  121. package/src/hooks/useIndicatorList.ts +0 -24
  122. package/src/hooks/useIndicatorRangeList.ts +0 -20
  123. package/src/hooks/useIndicatorTypeList.ts +0 -20
  124. package/src/hooks/useIndicatorUnitList.ts +0 -21
  125. package/src/hooks/useListenQuery.ts +0 -29
  126. package/src/hooks/useMobile.ts +0 -58
  127. package/src/hooks/useNotice.ts +0 -42
  128. package/src/hooks/useOrgLevelList.ts +0 -23
  129. package/src/hooks/usePageSelection.ts +0 -121
  130. package/src/hooks/usePageState.ts +0 -22
  131. package/src/hooks/usePendingList.ts +0 -27
  132. package/src/hooks/usePortalPageInfo.ts +0 -43
  133. package/src/hooks/useRefreshByLocationChange.ts +0 -16
  134. package/src/hooks/useReportIndicatorList.ts +0 -21
  135. package/src/hooks/useReportInfo.ts +0 -45
  136. package/src/hooks/useReportPersonList.ts +0 -21
  137. package/src/hooks/useScriptLoader.ts +0 -22
  138. package/src/hooks/useUnreadMsgList.ts +0 -26
  139. package/src/hooks/useUserAvatar.ts +0 -23
  140. package/src/hooks/useVReportInfo.ts +0 -50
  141. package/src/hooks/useVisionUserConfig.ts +0 -25
  142. package/src/hooks/useWorkbenchOptions.ts +0 -63
  143. package/src/index.tsx +0 -20
  144. package/src/services/CardService.ts +0 -91
  145. package/src/services/CommonService.ts +0 -23
  146. package/src/services/CostService.ts +0 -56
  147. package/src/services/DialogService.ts +0 -74
  148. package/src/services/IndicatorService.ts +0 -406
  149. package/src/services/PageService.ts +0 -204
  150. package/src/services/ReportService.ts +0 -335
  151. package/src/services/WorkbenchService.ts +0 -411
  152. package/src/styles/README.md +0 -12
  153. package/src/styles/index.scss +0 -9
  154. package/src/styles/mixins/index.scss +0 -25
  155. package/src/styles/next-cover.scss +0 -4
  156. package/src/styles/normalize.scss +0 -27
  157. package/src/styles/utilities/index.scss +0 -5
  158. package/src/styles/vars/index.scss +0 -17
  159. package/src/types/enum-workbench.ts +0 -29
  160. package/src/types/enum.ts +0 -156
  161. package/src/types/index.ts +0 -19
  162. package/src/types/indicator.ts +0 -299
  163. package/src/types/interface.ts +0 -303
  164. package/src/types/portal.ts +0 -211
  165. package/src/types/report.ts +0 -28
  166. package/src/types/type.ts +0 -11
  167. package/src/types/user.ts +0 -28
  168. package/src/utils/README.md +0 -4
  169. package/src/utils/arms.ts +0 -59
  170. package/src/utils/arr.ts +0 -123
  171. package/src/utils/const-workbench.ts +0 -9
  172. package/src/utils/const.ts +0 -18
  173. package/src/utils/index.ts +0 -18
  174. package/src/utils/init.ts +0 -5
  175. package/src/utils/map-workbench.ts +0 -66
  176. package/src/utils/map.ts +0 -377
  177. package/src/utils/number.ts +0 -101
  178. package/src/utils/page.ts +0 -81
  179. package/src/utils/str.ts +0 -26
  180. package/src/utils/tools.ts +0 -44
  181. package/src/utils/tree.ts +0 -145
  182. package/src/utils/url.ts +0 -40
  183. package/src/utils/util.ts +0 -99
  184. package/src/utils/workbench.ts +0 -25
  185. package/tsconfig.json +0 -33
@@ -1,20 +0,0 @@
1
- import { IndicatorService } from '@/services/IndicatorService';
2
- import { IListItem } from '@/types';
3
- import { CnMessage } from '@cainiaofe/cn-ui';
4
- import { useEffect, useState } from 'react';
5
-
6
- export const useIndicatorTypeList = () => {
7
- const [state, setState] = useState<IListItem[]>([]);
8
-
9
- useEffect(() => {
10
- (async () => {
11
- try {
12
- setState(await IndicatorService.getTypeList());
13
- } catch (error) {
14
- CnMessage.error(error.message);
15
- }
16
- })();
17
- }, []);
18
-
19
- return state;
20
- };
@@ -1,21 +0,0 @@
1
- import { IndicatorService } from 'src/services/IndicatorService';
2
- import { IListItem } from '@/types';
3
- import { CnMessage } from '@cainiaofe/cn-ui';
4
- import { useEffect, useState } from 'react';
5
-
6
- export const useIndicatorUnitList = () => {
7
- const [state, setState] = useState<IListItem[]>([]);
8
-
9
- useEffect(() => {
10
- (async () => {
11
- try {
12
- const data = await IndicatorService.getUnitList();
13
- setState(data);
14
- } catch (error) {
15
- CnMessage(error.message);
16
- }
17
- })();
18
- }, []);
19
-
20
- return state;
21
- };
@@ -1,29 +0,0 @@
1
- import { useEffect } from 'react';
2
-
3
- export const useListenQuery = () => {
4
- useEffect(() => {
5
- // 监听地址参数的变化
6
- const handleParamChange = () => {
7
- // 获取当前页面的参数部分
8
- const currentParams = window.location.search;
9
-
10
- // 根据需要修改参数的值或者添加新的参数
11
- const newParams = `${currentParams}&param=value`;
12
-
13
- // 重定向到修改后的地址并刷新页面
14
- window.location.href =
15
- window.location.origin + window.location.pathname + newParams;
16
- };
17
-
18
- // 在组件挂载时执行一次监听
19
- handleParamChange();
20
-
21
- // 监听地址参数的变化,并执行回调函数
22
- window.addEventListener('popstate', handleParamChange);
23
-
24
- // 在组件卸载时取消监听
25
- return () => {
26
- window.removeEventListener('popstate', handleParamChange);
27
- };
28
- }, []);
29
- };
@@ -1,58 +0,0 @@
1
- import { isMobileDevice } from '@/utils';
2
- import { useEffect } from 'react';
3
- import { atom, useRecoilValue, useSetRecoilState } from 'recoil';
4
-
5
- const mobileState = atom({
6
- key: 'mobile-state',
7
- default: isMobileDevice(),
8
- });
9
-
10
- /**
11
- * 获取 mobileState
12
- * @returns 是否为移动端
13
- */
14
- export const useMobileState = () => useRecoilValue(mobileState);
15
-
16
- /**
17
- * 监听屏幕大小变化,设置 mobileState
18
- */
19
- export const useMobileStateControl = () => {
20
- const setMobileState = useSetRecoilState(mobileState);
21
-
22
- useEffect(() => {
23
- // 定义处理屏幕大小变化的函数
24
- function handleResize() {
25
- setMobileState(isMobileDevice());
26
- }
27
-
28
- // 监听屏幕大小变化的事件
29
- window.addEventListener('resize', handleResize);
30
-
31
- // 返回一个清理函数,以在组件卸载时移除事件监听器
32
- return () => window.removeEventListener('resize', handleResize);
33
- }, [setMobileState]); // 空依赖数组确保事件监听器只被设置和清理一次
34
- };
35
-
36
- /**
37
- * 在移动端设置 <meta> 标签
38
- */
39
- export const useMobileSetting = () => {
40
- useEffect(() => {
41
- // 创建 <meta> 元素
42
- const meta = document.createElement('meta');
43
- meta.setAttribute('name', 'viewport');
44
- meta.setAttribute(
45
- 'content',
46
- 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
47
- );
48
-
49
- // 插入 <meta> 元素到 <head> 中
50
- document.head.appendChild(meta);
51
-
52
- // 清理函数
53
- return () => {
54
- // 在组件卸载时移除 <meta> 元素
55
- document.head.removeChild(meta);
56
- };
57
- }, []);
58
- };
@@ -1,42 +0,0 @@
1
- import { INoticeInfo } from '@/types';
2
- import { CnMessage } from '@cainiaofe/cn-ui-m';
3
- import { useEffect, useState } from 'react';
4
- import { WorkbenchService } from 'src/services/WorkbenchService';
5
-
6
- export const useNoticeInfo = (id?: number | string) => {
7
- const [state, setState] = useState<Partial<INoticeInfo>>({});
8
-
9
- useEffect(() => {
10
- (async () => {
11
- if (id) {
12
- try {
13
- const data = await WorkbenchService.queryNoticeInfo(id);
14
- setState(data);
15
- } catch (error) {
16
- CnMessage(error.message);
17
- }
18
- }
19
- })();
20
- }, [id]);
21
-
22
- return state;
23
- };
24
-
25
- export const useNoticeBannerList = (init = true) => {
26
- const [state, setState] = useState<INoticeInfo[]>([]);
27
-
28
- useEffect(() => {
29
- (async () => {
30
- if (init) {
31
- try {
32
- const data = await WorkbenchService.queryNoticeBannerList();
33
- setState(data);
34
- } catch (error) {
35
- CnMessage(error.message);
36
- }
37
- }
38
- })();
39
- }, [init]);
40
-
41
- return state;
42
- };
@@ -1,23 +0,0 @@
1
- import { IndicatorService } from 'src/services/IndicatorService';
2
- import { IListItem } from '@/types';
3
- import { CnMessage } from '@cainiaofe/cn-ui';
4
- import { useEffect, useState } from 'react';
5
-
6
- export const useOrgLevelList = (orgLevel?: string) => {
7
- const [state, setState] = useState<IListItem[]>([]);
8
-
9
- useEffect(() => {
10
- (async () => {
11
- try {
12
- if (orgLevel) {
13
- const data = await IndicatorService.getOrgLevelList(orgLevel);
14
- setState(data);
15
- }
16
- } catch (error) {
17
- CnMessage(error.message);
18
- }
19
- })();
20
- }, [orgLevel]);
21
-
22
- return state;
23
- };
@@ -1,121 +0,0 @@
1
- import { IListItem, IListItemDataSourceMap } from '@/types';
2
- import { CnMessage } from '@cainiaofe/cn-ui';
3
- import { useEffect, useState } from 'react';
4
- import { PageService } from '@/services/PageService';
5
- import { filterComponentTypeList } from '@/utils';
6
-
7
- export const usePageSelectionTypeList = () => {
8
- const [state, setState] = useState<IListItem[]>(filterComponentTypeList);
9
-
10
- // useEffect(() => {
11
- // (async () => {
12
- // try {
13
- // const data = await PageService.getPageSelectionTypeList();
14
- // setState(data);
15
- // } catch (error) {
16
- // CnMessage(error.message);
17
- // }
18
- // })();
19
- // }, []);
20
-
21
- return state;
22
- };
23
-
24
- export const useStructedPropertyList = (instanceId?: string | number) => {
25
- const [state, setState] = useState<IListItem[]>([]);
26
-
27
- // useEffect(() => {
28
- // (async () => {
29
- // try {
30
- // const data = await PageService.getStructedPropertyList(instanceId);
31
- // setState(data);
32
- // } catch (error) {
33
- // CnMessage(error.message);
34
- // }
35
- // })();
36
- // }, [instanceId]);
37
-
38
- return state;
39
- };
40
-
41
- export const useTimeSelectionTypeList = () => {
42
- const [state, setState] = useState<IListItem[]>([]);
43
-
44
- // useEffect(() => {
45
- // (async () => {
46
- // try {
47
- // const data = await PageService.getTimeSelectionTypeList();
48
- // setState(data);
49
- // } catch (error) {
50
- // CnMessage(error.message);
51
- // }
52
- // })();
53
- // }, []);
54
-
55
- return state;
56
- };
57
-
58
- export const useStructedPropertyDataSource = (
59
- structedPropertyCode?: string,
60
- ) => {
61
- const [state, setState] = useState<IListItem[]>([]);
62
-
63
- // useEffect(() => {
64
- // (async () => {
65
- // if (structedPropertyCode) {
66
- // try {
67
- // const data = await PageService.getStructedPropertyDataSource(structedPropertyCode);
68
- // setState(data);
69
- // } catch (error) {
70
- // CnMessage(error.message);
71
- // }
72
- // }
73
- // })();
74
- // }, [structedPropertyCode]);
75
-
76
- return state;
77
- };
78
-
79
- export const useStructedPropertyDataSourceByCodeList = (
80
- structedPropertyCodeList?: string[],
81
- ) => {
82
- const [state, setState] = useState<IListItemDataSourceMap>({});
83
-
84
- // useEffect(() => {
85
- // (async () => {
86
- // if (Array.isArray(structedPropertyCodeList)) {
87
- // const dataMap: IListItemDataSourceMap = {};
88
- // await Promise.all(
89
- // structedPropertyCodeList.map(async (code) => {
90
- // try {
91
- // const data = await PageService.getStructedPropertyDataSource(code);
92
- // dataMap[code] = data;
93
- // } catch (error) {
94
- // CnMessage(error.message);
95
- // }
96
- // }),
97
- // );
98
- // setState(dataMap);
99
- // }
100
- // })();
101
- // }, [structedPropertyCodeList]);
102
-
103
- return state;
104
- };
105
-
106
- export const useShowPropertyList = () => {
107
- const [state, setState] = useState<IListItem[]>([]);
108
-
109
- // useEffect(() => {
110
- // (async () => {
111
- // try {
112
- // const data = await PageService.getShowPropertyList();
113
- // setState(data);
114
- // } catch (error) {
115
- // CnMessage(error.message);
116
- // }
117
- // })();
118
- // }, []);
119
-
120
- return state;
121
- };
@@ -1,22 +0,0 @@
1
- import {
2
- atom,
3
- useRecoilState,
4
- useRecoilValue,
5
- useSetRecoilState,
6
- } from 'recoil';
7
- import { getSearchParams } from '@/utils';
8
- import { PageType } from '../types';
9
-
10
- const state = atom({
11
- key: 'workbench-page-context-mobile',
12
- default: {
13
- pageType:
14
- getSearchParams().tab === PageType.MY_APPROVAL
15
- ? PageType.MY_APPROVAL
16
- : PageType.WORKBENCH,
17
- },
18
- });
19
-
20
- export const usePageState = () => useRecoilState(state);
21
- export const usePageStateValue = () => useRecoilValue(state);
22
- export const useSetPageState = () => useSetRecoilState(state);
@@ -1,27 +0,0 @@
1
- import { IMatterPendingInfo } from '@/types';
2
- import { CnMessage } from '@cainiaofe/cn-ui-m';
3
- import { useEffect, useState } from 'react';
4
- import { WorkbenchService } from 'src/services/WorkbenchService';
5
-
6
- export const usePendingList = (init = true) => {
7
- const [state, setState] = useState<IMatterPendingInfo[]>([
8
- { desc: '待我审批', count: '0', url: '' },
9
- { desc: '我的V信', count: '0', url: '' },
10
- { desc: '新鲜速递', count: '0', url: '' },
11
- ]);
12
-
13
- useEffect(() => {
14
- (async () => {
15
- if (init) {
16
- try {
17
- const data = await WorkbenchService.queryPendingList();
18
- setState(data);
19
- } catch (error) {
20
- CnMessage(error.message);
21
- }
22
- }
23
- })();
24
- }, [init]);
25
-
26
- return state;
27
- };
@@ -1,43 +0,0 @@
1
- import { CnMessage } from '@cainiaofe/cn-ui';
2
- import { useCallback, useEffect, useState } from 'react';
3
- import { PageService } from 'src/services/PageService';
4
- import { IPortalPageInfo } from 'src/types';
5
-
6
- interface IRequestParams {
7
- code?: string;
8
- pageType?: string;
9
- init?: boolean;
10
- }
11
-
12
- export const usePortalPageInfo = ({
13
- pageType,
14
- code,
15
- init = true,
16
- }: IRequestParams) => {
17
- const [state, setState] = useState<Partial<IPortalPageInfo>>({});
18
-
19
- const handleGetData = useCallback(async () => {
20
- if (code || pageType) {
21
- try {
22
- const data = await PageService.queryIndicatorPageDetail(code, pageType);
23
-
24
- if (data) {
25
- setState(data);
26
- }
27
- } catch (error) {
28
- CnMessage(error.message);
29
- }
30
- }
31
- }, [code, pageType]);
32
-
33
- useEffect(() => {
34
- if (init) {
35
- handleGetData();
36
- }
37
- }, [init, handleGetData]);
38
-
39
- return {
40
- pageInfo: state,
41
- refreshPageInfo: handleGetData,
42
- };
43
- };
@@ -1,16 +0,0 @@
1
- import { useEffect, useState, useRef } from 'react';
2
- import { useLocation } from 'react-router-dom';
3
-
4
- export const useRefreshByLocationChange = () => {
5
- const [, setState] = useState<{}>({});
6
- const location = useLocation();
7
- const refreshRef = useRef(false);
8
-
9
- useEffect(() => {
10
- if (refreshRef.current) {
11
- setState({});
12
- }
13
-
14
- refreshRef.current = true;
15
- }, [location]);
16
- };
@@ -1,21 +0,0 @@
1
- import { ReportService } from '@/services/ReportService';
2
- import { IListItem } from '@/types';
3
- import { CnMessage } from '@cainiaofe/cn-ui';
4
- import { useEffect, useState } from 'react';
5
-
6
- export const useReportIndicatorList = () => {
7
- const [state, setState] = useState<IListItem[]>([]);
8
-
9
- useEffect(() => {
10
- (async () => {
11
- try {
12
- const data = await ReportService.getIndicatorList();
13
- setState(data);
14
- } catch (error) {
15
- CnMessage(error.message);
16
- }
17
- })();
18
- }, []);
19
-
20
- return state;
21
- };
@@ -1,45 +0,0 @@
1
- import { ReportService } from '@/services/ReportService';
2
- import { IReportContentInfo, IReportTplInfo } from '@/types';
3
- import { CnMessage } from '@cainiaofe/cn-ui-m';
4
- import { useEffect, useState } from 'react';
5
-
6
- export const useReportTplInfo = (id?: number | string) => {
7
- const [state, setState] = useState<Partial<IReportTplInfo>>({});
8
-
9
- useEffect(() => {
10
- (async () => {
11
- if (id) {
12
- try {
13
- const data = await ReportService.getTemplateDetails(id);
14
- setState(data);
15
- } catch (error) {
16
- CnMessage(error.message);
17
- }
18
- }
19
- })();
20
- }, [id]);
21
-
22
- return state;
23
- };
24
-
25
- export const useReportContentInfo = (
26
- id?: number | string,
27
- importType?: string,
28
- ) => {
29
- const [state, setState] = useState<Partial<IReportContentInfo>>({});
30
-
31
- useEffect(() => {
32
- (async () => {
33
- if (id) {
34
- try {
35
- const data = await ReportService.getContentDetails(id, importType);
36
- setState(data);
37
- } catch (error) {
38
- CnMessage(error.message);
39
- }
40
- }
41
- })();
42
- }, [id, importType]);
43
-
44
- return state;
45
- };
@@ -1,21 +0,0 @@
1
- import { ReportService } from '@/services/ReportService';
2
- import { IListItem } from '@/types';
3
- import { CnMessage } from '@cainiaofe/cn-ui-m';
4
- import { useEffect, useState } from 'react';
5
-
6
- export const useReportPersonList = () => {
7
- const [state, setState] = useState<IListItem[]>([]);
8
-
9
- useEffect(() => {
10
- (async () => {
11
- try {
12
- const data = await ReportService.getPersonList();
13
- setState(data);
14
- } catch (error) {
15
- CnMessage(error.message);
16
- }
17
- })();
18
- }, []);
19
-
20
- return state;
21
- };
@@ -1,22 +0,0 @@
1
- import { useEffect, useState } from 'react';
2
-
3
- export const useScriptLoader = (scriptUrl: string) => {
4
- const [loaded, setLoaded] = useState(false);
5
-
6
- useEffect(() => {
7
- if (document.querySelector(`script[src="${scriptUrl}"]`)) {
8
- setLoaded(true);
9
- return;
10
- }
11
- const script = document.createElement('script');
12
- script.src = scriptUrl;
13
- script.async = true;
14
- script.onload = () => setLoaded(true);
15
- document.body.appendChild(script);
16
- return () => {
17
- document.body.removeChild(script);
18
- };
19
- }, [scriptUrl]);
20
-
21
- return loaded;
22
- };
@@ -1,26 +0,0 @@
1
- import { IUnreadMsg } from '@/types';
2
- import { CnMessage } from '@cainiaofe/cn-ui';
3
- import { useCallback, useEffect, useState } from 'react';
4
- import { PageService } from 'src/services/PageService';
5
-
6
- export const useUnreadMsgList = () => {
7
- const [state, setState] = useState<IUnreadMsg[]>([]);
8
-
9
- const getData = useCallback(async () => {
10
- try {
11
- const data = await PageService.queryUnreadMsg();
12
- setState(data);
13
- } catch (error) {
14
- CnMessage(error.message);
15
- }
16
- }, []);
17
-
18
- useEffect(() => {
19
- getData();
20
- }, [getData]);
21
-
22
- return {
23
- msgList: state,
24
- handleRefreshMsgList: getData,
25
- };
26
- };
@@ -1,23 +0,0 @@
1
- import { IUserAvatarInfo } from '@/types';
2
- import { CnMessage } from '@cainiaofe/cn-ui-m';
3
- import { useEffect, useState } from 'react';
4
- import { WorkbenchService } from 'src/services/WorkbenchService';
5
-
6
- export const useUserAvatar = (init = true) => {
7
- const [state, setState] = useState<IUserAvatarInfo>({});
8
-
9
- useEffect(() => {
10
- (async () => {
11
- if (init) {
12
- try {
13
- const data = await WorkbenchService.queryUserAvatar();
14
- setState(data);
15
- } catch (error) {
16
- CnMessage(error.message);
17
- }
18
- }
19
- })();
20
- }, [init]);
21
-
22
- return state;
23
- };
@@ -1,50 +0,0 @@
1
- import { IMsgCountInfo, IVReportInfo } from '@/types';
2
- import { CnMessage } from '@cainiaofe/cn-ui-m';
3
- import { useEffect, useState } from 'react';
4
- import { WorkbenchService } from 'src/services/WorkbenchService';
5
-
6
- export const useVReportInfo = () => {
7
- const [state, setState] = useState<Partial<IVReportInfo> & IMsgCountInfo>({});
8
-
9
- useEffect(() => {
10
- (async () => {
11
- try {
12
- const data = await WorkbenchService.queryVReportInfo();
13
- const countData = await WorkbenchService.queryVReportMessageCount();
14
-
15
- if (data && countData) {
16
- setState({
17
- ...data,
18
- ...countData,
19
- });
20
- }
21
- } catch (error) {
22
- CnMessage(error.message);
23
- }
24
- })();
25
- }, []);
26
-
27
- return state;
28
- };
29
-
30
- export const useVReportMessageCount = (init = true) => {
31
- const [state, setState] = useState<IMsgCountInfo>({
32
- unreadCount: 0,
33
- messageCount: 0,
34
- });
35
-
36
- useEffect(() => {
37
- (async () => {
38
- if (init) {
39
- try {
40
- const data = await WorkbenchService.queryVReportMessageCount();
41
- setState(data);
42
- } catch (error) {
43
- CnMessage(error.message);
44
- }
45
- }
46
- })();
47
- }, [init]);
48
-
49
- return state;
50
- };
@@ -1,25 +0,0 @@
1
- import { IVisionUserConfig } from '@/types';
2
- import { CnMessage } from '@cainiaofe/cn-ui';
3
- import { useCallback, useEffect, useState } from 'react';
4
- import { PageService } from 'src/services/PageService';
5
-
6
- export const useVisionUserConfig = () => {
7
- const [state, setState] = useState<IVisionUserConfig>();
8
-
9
- const handleGetData = useCallback(async () => {
10
- try {
11
- setState(await PageService.getVisionUserConfig());
12
- } catch (error) {
13
- CnMessage.error(error.message);
14
- }
15
- }, []);
16
-
17
- useEffect(() => {
18
- handleGetData();
19
- }, [handleGetData]);
20
-
21
- return {
22
- data: state,
23
- refresh: handleGetData,
24
- };
25
- };