cfel-base-components 0.0.25 → 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 (53) hide show
  1. package/README.md +1 -1
  2. package/config/webpack.base.js +11 -2
  3. package/demo/src/index.html +0 -26
  4. package/demo/src/index.jsx +11 -27
  5. package/demo/src/index.module.less +3 -0
  6. package/demo/src/index.scss +2 -59
  7. package/package.json +4 -5
  8. package/src/components/base-component/PageContainer/index.module.less +13 -0
  9. package/src/components/base-component/PageContainer/index.tsx +28 -0
  10. package/src/components/base-component/Pagination/index.tsx +22 -0
  11. package/src/components/base-component/ProTable/index.tsx +29 -0
  12. package/src/components/base-component/QueryFilter/index.tsx +24 -0
  13. package/src/components/layout/index.scss +1 -1
  14. package/src/components/universal-pages/account/index.tsx +54 -0
  15. package/src/components/universal-pages/accountInfo/index.tsx +98 -0
  16. package/src/components/universal-pages/role/index.tsx +53 -0
  17. package/src/components/{roleInfo → universal-pages/roleInfo}/EditAccountDrawer/index.tsx +0 -1
  18. package/src/components/universal-pages/roleInfo/index.scss +3 -0
  19. package/src/components/universal-pages/roleInfo/index.tsx +94 -0
  20. package/src/index.d.ts +8 -1
  21. package/src/index.tsx +10 -17
  22. package/.vscode/settings.json +0 -3
  23. package/src/.umi/core/helmet.ts +0 -10
  24. package/src/.umi/core/helmetContext.ts +0 -4
  25. package/src/apiRequest/config.ts +0 -71
  26. package/src/apiRequest/hosts.ts +0 -6
  27. package/src/apiRequest/iotConfig.ts +0 -71
  28. package/src/components/PageContainer/index.scss +0 -13
  29. package/src/components/PageContainer/index.tsx +0 -22
  30. package/src/components/Pagination/index.tsx +0 -20
  31. package/src/components/ProTable/index.tsx +0 -22
  32. package/src/components/QueryFilter/index.tsx +0 -20
  33. package/src/components/account/api.ts +0 -11
  34. package/src/components/account/index.tsx +0 -169
  35. package/src/components/accountInfo/api.ts +0 -26
  36. package/src/components/accountInfo/index.tsx +0 -229
  37. package/src/components/button/index.tsx +0 -16
  38. package/src/components/role/api.ts +0 -9
  39. package/src/components/role/index.scss +0 -0
  40. package/src/components/role/index.tsx +0 -141
  41. package/src/components/roleInfo/api.ts +0 -22
  42. package/src/components/roleInfo/index.scss +0 -3
  43. package/src/components/roleInfo/index.tsx +0 -239
  44. package/src/components/widthAutoLabelProps/index.tsx +0 -54
  45. package/src/hooks/useTableHooks.ts +0 -60
  46. package/src/utils/index.ts +0 -29
  47. /package/src/components/{Pagination/index.scss → base-component/Pagination/index.module.less} +0 -0
  48. /package/src/components/{ProTable/index.scss → base-component/ProTable/index.module.less} +0 -0
  49. /package/src/components/{QueryFilter/index.scss → base-component/QueryFilter/index.module.less} +0 -0
  50. /package/src/components/{account → universal-pages/account}/index.scss +0 -0
  51. /package/src/components/{accountInfo → universal-pages/accountInfo}/EditAccountDrawer/index.tsx +0 -0
  52. /package/src/components/{accountInfo → universal-pages/accountInfo}/index.scss +0 -0
  53. /package/src/components/{button → universal-pages/role}/index.scss +0 -0
@@ -1,54 +0,0 @@
1
- import React, { useEffect, useRef } from 'react';
2
-
3
- interface WidthAutoLabelProps {
4
- children: string; // 要绘制的文本
5
- }
6
-
7
- /**
8
- * 文本宽度自适应标签组件
9
- * @param props
10
- * @constructor
11
- */
12
- const WidthAutoLabel = (props: WidthAutoLabelProps) => {
13
- const { children = '' } = props;
14
- const ref = useRef<any>(null);
15
-
16
- useEffect(() => {
17
- drawText();
18
- }, [children]);
19
-
20
-
21
- const drawText = () => {
22
- let canvas = ref.current;
23
- if (!canvas) {
24
- return;
25
- }
26
- let parentNode = canvas.parentNode;
27
- if (!parentNode) {
28
- return;
29
- }
30
- const { fontSize, fontStyle, fontWeight, fontFamily } = getComputedStyle(parentNode, null);
31
- const { clientWidth, clientHeight } = parentNode;
32
- canvas.width = clientWidth;
33
- canvas.height = clientHeight;
34
- let ctx = canvas.getContext("2d");
35
- // 设置文本样式
36
- ctx.font = `${fontStyle} ${fontWeight} ${fontSize} ${fontFamily}`;
37
- ctx.textBaseline = 'top';
38
- let y = Math.ceil((clientHeight - Number(fontSize.replace('px', ''))) / 2);
39
- let x = 0;
40
- // 居中显示
41
- const { width: textWidth } = ctx.measureText(children);
42
- if (textWidth < clientWidth) {
43
- x = (clientWidth - textWidth) / 2;
44
- }
45
- // 绘制文本
46
- ctx.fillText(children, x, y, clientWidth);
47
- }
48
-
49
- return (
50
- <canvas ref={ref}></canvas>
51
- )
52
- }
53
-
54
- export default WidthAutoLabel;
@@ -1,60 +0,0 @@
1
- import React, { useState } from 'react'
2
- import { get } from "lodash"
3
-
4
- function useTableHooks({
5
- asyncFunction
6
- }: any) {
7
- const [isLoading, setIsLoading] = useState<any>(false)
8
- const [pageNo, setPageNo] = useState(1)
9
- const [pageSize, setPageSize] = useState(10)
10
- const [total, setTotal] = useState(0)
11
- const [dataList, setDataList] = useState([])
12
-
13
- const execute: any = async (options: any) => {
14
- const { innerPageNo = pageNo, innerPageSize = pageSize, ...otherOptions } = options || {}
15
-
16
- setPageNo(innerPageNo);
17
- setPageSize(innerPageSize);
18
- setIsLoading(true);
19
-
20
- try {
21
- const res = await asyncFunction({
22
- innerPageNo,
23
- innerPageSize,
24
- ...otherOptions
25
- })
26
-
27
- setIsLoading(false)
28
-
29
- const list: any = get(res, "dataList", [])
30
- const totalCount: any = get(res, "totalCount", 0)
31
-
32
- setTotal(totalCount)
33
- setDataList(list)
34
-
35
- } catch {
36
- setIsLoading(false)
37
- }
38
- }
39
-
40
- const pagination = {
41
- current: pageNo,
42
- pageSize,
43
- total,
44
- onChange: (innerPageNo: number, innerPageSize: number) => {
45
- execute({
46
- innerPageNo,
47
- innerPageSize
48
- })
49
- }
50
- }
51
-
52
- return {
53
- execute,
54
- pagination,
55
- isLoading,
56
- dataList,
57
- }
58
- }
59
-
60
- export default useTableHooks
@@ -1,29 +0,0 @@
1
- import dayjs from "dayjs"
2
- //获取url上的参数
3
- export const getUrlParams = (id: string) => {
4
- let params = new URLSearchParams(location.search);
5
- return params.get(id) || ""
6
- }
7
-
8
- export const downloadFile = (url: string, name: string, suffix?: string) => {
9
- if (!url || !name) return
10
- const link = document.createElement('a');
11
- link.target = '_blank'
12
- link.style.display = 'none';
13
- fetch(url, {
14
- method: 'post',
15
- }).then(res => res.blob()).then((blob) => {
16
- link.href = URL.createObjectURL(blob);
17
- link.download = name + "." + (suffix || 'xlsx');
18
- document.body.appendChild(link);
19
- link.click();
20
- link.remove();
21
- });
22
- }
23
-
24
- export const timeFormatter = (timestamp: number, format?: string) => {
25
- if (isNaN(Number(timestamp))) {
26
- return "-"
27
- }
28
- return dayjs(timestamp).format(format || "YYYY-MM-DD HH:mm:ss")
29
- }