@cloudbase/weda-ui 0.2.15 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -169
- package/package.json +28 -15
- package/src/configs/components/calendar.json +78 -0
- package/src/configs/components/carousel.json +273 -0
- package/src/configs/components/chart/bar.json +724 -0
- package/src/configs/components/chart/line.json +679 -0
- package/src/configs/components/chart/pie.json +497 -0
- package/src/configs/components/chart/statisticsCard.json +379 -0
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +154 -0
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/location.json +152 -0
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/form/uploaderFile.json +2 -1
- package/src/configs/components/graphicCard.json +410 -0
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +20 -4
- package/src/configs/components/listView.json +277 -0
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +362 -0
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +4 -1
- package/src/configs/components/scrollVeiw.json +74 -22
- package/src/configs/components/swiper.json +6 -3
- package/src/configs/components/tabs.json +51 -8
- package/src/configs/components/text.json +33 -25
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +34 -0
- package/src/mp/components/button/index.js +12 -13
- package/src/mp/components/button/index.wxml +1 -1
- package/src/mp/components/calendar/arrowright--line.svg +11 -0
- package/src/mp/components/calendar/index.js +238 -0
- package/src/mp/components/calendar/index.json +4 -0
- package/src/mp/components/calendar/index.wxml +37 -0
- package/src/mp/components/calendar/index.wxss +178 -0
- package/src/mp/components/carousel/index.js +88 -0
- package/src/mp/components/carousel/index.json +7 -0
- package/src/mp/components/carousel/index.wxml +6 -0
- package/src/mp/components/chart/bar/index.js +258 -0
- package/src/mp/components/chart/bar/index.json +6 -0
- package/src/mp/components/chart/bar/index.wxml +3 -0
- package/src/mp/components/chart/bar/index.wxss +9 -0
- package/src/mp/components/chart/common/config/bar.js +50 -0
- package/src/mp/components/chart/common/config/global.js +16 -0
- package/src/mp/components/chart/common/config/line.js +48 -0
- package/src/mp/components/chart/common/config/pie.js +36 -0
- package/src/mp/components/chart/common/core/eChartBar.js +263 -0
- package/src/mp/components/chart/common/core/eChartBase.js +375 -0
- package/src/mp/components/chart/common/core/eChartLine.js +229 -0
- package/src/mp/components/chart/common/core/eChartPie.js +166 -0
- package/src/mp/components/chart/common/lib/echarts.min.js +18 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.js +277 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxml +4 -0
- package/src/mp/components/chart/ec-canvas/ec-canvas.wxss +4 -0
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +107 -0
- package/src/mp/components/chart/line/index.js +247 -0
- package/src/mp/components/chart/line/index.json +6 -0
- package/src/mp/components/chart/line/index.wxml +3 -0
- package/src/mp/components/chart/line/index.wxss +9 -0
- package/src/mp/components/chart/pie/index.js +182 -0
- package/src/mp/components/chart/pie/index.json +6 -0
- package/src/mp/components/chart/pie/index.wxml +4 -0
- package/src/mp/components/chart/pie/index.wxss +9 -0
- package/src/mp/components/chart/statisticsCard/index.js +253 -0
- package/src/mp/components/chart/statisticsCard/index.json +4 -0
- package/src/mp/components/chart/statisticsCard/index.wxml +9 -0
- package/src/mp/components/chart/statisticsCard/index.wxss +45 -0
- package/src/mp/components/dataView/index.js +34 -0
- package/src/mp/components/dataView/index.json +7 -0
- package/src/mp/components/dataView/index.wxml +15 -0
- package/src/mp/components/dataView/index.wxss +0 -0
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/location/components/mapChoose/index.js +201 -0
- package/src/mp/components/form/location/components/mapChoose/index.json +4 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxml +42 -0
- package/src/mp/components/form/location/components/mapChoose/index.wxss +188 -0
- package/src/mp/components/form/location/index.js +382 -0
- package/src/mp/components/form/location/index.json +6 -0
- package/src/mp/components/form/location/index.wxml +25 -0
- package/src/mp/components/form/location/index.wxss +91 -0
- package/src/mp/components/form/radio/index.js +38 -0
- package/src/mp/components/form/select/index.js +360 -40
- package/src/mp/components/form/select/index.wxml +21 -6
- package/src/mp/components/form/select/region/index.js +98 -0
- package/src/mp/components/form/textarea/index.wxml +6 -5
- package/src/mp/components/form/uploader/index.js +84 -48
- package/src/mp/components/form/uploader/index.wxml +15 -3
- package/src/mp/components/form/uploaderFile/index.js +106 -27
- package/src/mp/components/graphicCard/chevron-right.svg +3 -0
- package/src/mp/components/graphicCard/index.js +203 -0
- package/src/mp/components/graphicCard/index.json +4 -0
- package/src/mp/components/graphicCard/index.wxml +29 -0
- package/src/mp/components/graphicCard/index.wxss +157 -0
- package/src/mp/components/image/index.js +0 -1
- package/src/mp/components/listView/arrow-right-line.svg +3 -0
- package/src/mp/components/listView/index.js +285 -0
- package/src/mp/components/listView/index.json +4 -0
- package/src/mp/components/listView/index.wxml +40 -0
- package/src/mp/components/listView/index.wxss +155 -0
- package/src/mp/components/listView/more-line.svg +3 -0
- package/src/mp/components/navLayout/index.js +123 -0
- package/src/mp/components/navLayout/index.json +7 -0
- package/src/mp/components/navLayout/index.wxml +25 -0
- package/src/mp/components/navLayout/index.wxss +1193 -0
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/swiper/index.wxml +2 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/wxOpenApi/phone/index.json +4 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +18 -2
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/debounce.js +133 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/dr_square_point.js +25 -0
- package/src/mp/utils/platform.js +25 -0
- package/src/mp/utils/qqmap-wx-jssdk1.2/qqmap-wx-jssdk.js +1336 -0
- package/src/mp/utils/spark-md5.js +776 -0
- package/src/mp/utils/tcb.js +62 -0
- package/src/setupTests.js +2 -1
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- package/src/web/components/calendar/index.css +382 -0
- package/src/web/components/calendar/index.jsx +312 -0
- package/src/web/components/calendar/util.js +90 -0
- package/src/web/components/carousel/index.css +119 -0
- package/src/web/components/carousel/index.tsx +417 -0
- package/src/web/components/chart/bar/index.tsx +140 -0
- package/src/web/components/chart/common/config/bar.js +49 -0
- package/src/web/components/chart/common/config/global.js +16 -0
- package/src/web/components/chart/common/config/line.js +50 -0
- package/src/web/components/chart/common/config/pie.js +37 -0
- package/src/web/components/chart/common/core/eChartBar.js +265 -0
- package/src/web/components/chart/common/core/eChartBase.ts +383 -0
- package/src/web/components/chart/common/core/eChartLine.js +231 -0
- package/src/web/components/chart/common/core/eChartPie.js +170 -0
- package/src/web/components/chart/common/core/type.ts +34 -0
- package/src/web/components/chart/common/echart.css +106 -0
- package/src/web/components/chart/common/echarts.ts +33 -0
- package/src/web/components/chart/common/useChart.tsx +69 -0
- package/src/web/components/chart/line/index.tsx +136 -0
- package/src/web/components/chart/pie/index.tsx +99 -0
- package/src/web/components/chart/statisticsCard/index.css +62 -0
- package/src/web/components/chart/statisticsCard/index.tsx +307 -0
- package/src/web/components/chart/statisticsCard/interface.ts +14 -0
- package/src/web/components/dataView/index.tsx +20 -0
- package/src/web/components/dataView/interface.ts +6 -0
- package/src/web/components/form/checkbox/index.tsx +55 -23
- package/src/web/components/form/location/common/mapChoose.css +178 -0
- package/src/web/components/form/location/common/mapChoose.jsx +343 -0
- package/src/web/components/form/location/common/mapView.jsx +190 -0
- package/src/web/components/form/location/common/propsConfig.js +54 -0
- package/src/web/components/form/location/common/selectModal.css +44 -0
- package/src/web/components/form/location/common/selectModal.jsx +82 -0
- package/src/web/components/form/location/common/useLocationInfo.js +100 -0
- package/src/web/components/form/location/components/LocationH5/index.css +243 -0
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +403 -0
- package/src/web/components/form/location/components/LocationPC/Header.jsx +109 -0
- package/src/web/components/form/location/components/LocationPC/index.css +44 -0
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +323 -0
- package/src/web/components/form/location/constants.js +4 -0
- package/src/web/components/form/location/index.css +0 -0
- package/src/web/components/form/location/index.jsx +25 -0
- package/src/web/components/form/radio/index.tsx +84 -53
- package/src/web/components/form/select/h5.tsx +389 -71
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +404 -144
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +90 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +19 -4
- package/src/web/components/form/uploader/uploader.pc.tsx +8 -7
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +132 -113
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +16 -11
- package/src/web/components/graphicCard/index.css +159 -0
- package/src/web/components/graphicCard/index.tsx +310 -0
- package/src/web/components/image/image.tsx +1 -2
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +24 -2
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/arrow-right-line.svg +3 -0
- package/src/web/components/listView/index.css +143 -0
- package/src/web/components/listView/index.tsx +359 -0
- package/src/web/components/listView/interface.ts +98 -0
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navLayout/index.css +332 -0
- package/src/web/components/navLayout/index.tsx +247 -0
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +231 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/tabs/index.tsx +4 -2
- package/src/web/components/tabs/tabs.h5.tsx +50 -37
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/uploaderFileView/index.css +9 -9
- package/src/web/components/uploaderFileView/index.jsx +32 -23
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/types.d.ts +15 -14
- package/src/web/utils/debounce.js +98 -0
- package/src/web/utils/platform.js +40 -0
- package/src/web/utils/tcb.js +49 -0
- package/src/web/utils/tmap.js +4 -0
- package/src/web/weda-ui.css +2 -0
- package/CHANGELOG.md +0 -240
- package/src/.DS_Store +0 -0
- package/src/configs/.DS_Store +0 -0
- package/src/mp/.gitignore +0 -10
- package/src/web/.DS_Store +0 -0
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
|
@@ -1,30 +1,43 @@
|
|
|
1
|
+
import { useCustomCompareEffect, useMountEffect, useSyncedRef } from '@react-hookz/web';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { Tabs as TeaTabs, TabPanel, ConfigProvider } from 'tea-component';
|
|
3
4
|
import classNames from '../../utils/classnames';
|
|
5
|
+
import isObjectEqual from '../../utils/isObjectEqual';
|
|
4
6
|
import { useSyncValue } from '../../utils/useSyncValue';
|
|
5
7
|
import { PropsType } from './index';
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
export default function TabsPc({
|
|
9
|
-
tabs,
|
|
11
|
+
tabs = [],
|
|
10
12
|
selectedIndex,
|
|
11
13
|
events,
|
|
12
14
|
className,
|
|
13
15
|
style,
|
|
16
|
+
isMultipleSlot = true,
|
|
14
17
|
...restProps
|
|
15
18
|
}: PropsType) {
|
|
16
19
|
|
|
17
20
|
const [activeIndex, setActiveIndex] = useSyncValue(selectedIndex);
|
|
18
|
-
const _tabs =
|
|
19
|
-
return {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const _tabs = React.useMemo(() => {
|
|
22
|
+
return Array.isArray(tabs) && tabs.length && tabs.map((item, index) => {
|
|
23
|
+
return {
|
|
24
|
+
id: index.toString(),
|
|
25
|
+
label: item.title,
|
|
26
|
+
value: item.value
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}, [tabs]);
|
|
24
30
|
|
|
31
|
+
const eventsRef = useSyncedRef(events);
|
|
32
|
+
useCustomCompareEffect(() => {
|
|
33
|
+
eventsRef.current && eventsRef.current.change({
|
|
34
|
+
id: _tabs[activeIndex]?.id,
|
|
35
|
+
label: _tabs[activeIndex]?.label,
|
|
36
|
+
value: _tabs[activeIndex]?.value,
|
|
37
|
+
});
|
|
38
|
+
}, [activeIndex, _tabs], isObjectEqual);
|
|
25
39
|
const onActive = (e) => {
|
|
26
40
|
setActiveIndex(e.id);
|
|
27
|
-
events && events.change(e);
|
|
28
41
|
};
|
|
29
42
|
return (
|
|
30
43
|
<ConfigProvider classPrefix="wedatea2td">
|
|
@@ -40,11 +53,11 @@ export default function TabsPc({
|
|
|
40
53
|
key={item.id}
|
|
41
54
|
id={item.id}
|
|
42
55
|
>
|
|
43
|
-
{restProps[`panel${index + 1}`]}
|
|
56
|
+
{isMultipleSlot ? restProps[`panel${index + 1}`] : restProps['panel1']}
|
|
44
57
|
</TabPanel>
|
|
45
58
|
)
|
|
46
59
|
)}
|
|
47
60
|
</TeaTabs>
|
|
48
61
|
</ConfigProvider>
|
|
49
62
|
);
|
|
50
|
-
}
|
|
63
|
+
}
|
|
@@ -21,8 +21,6 @@ export default function Text({
|
|
|
21
21
|
maxLines = 2,
|
|
22
22
|
space = false,
|
|
23
23
|
userSelect = true,
|
|
24
|
-
textAlign = '',
|
|
25
|
-
textColor = '',
|
|
26
24
|
style = {},
|
|
27
25
|
className,
|
|
28
26
|
events,
|
|
@@ -42,23 +40,17 @@ export default function Text({
|
|
|
42
40
|
}
|
|
43
41
|
const levelName = level === '0' ? '' : `level_${level}`;
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// 添加对齐属性
|
|
52
|
-
if (textAlign !== "") {
|
|
53
|
-
style2 = {...style2, textAlign};
|
|
54
|
-
}
|
|
43
|
+
const inlineStyle = React.useMemo(
|
|
44
|
+
() => ({ ...textStyle, ...style }),
|
|
45
|
+
[textStyle, style]
|
|
46
|
+
);
|
|
55
47
|
return (
|
|
56
48
|
<p
|
|
57
49
|
//@ts-expect-error contentEditable type def sucks
|
|
58
50
|
contentEditable={contenteditable}
|
|
59
51
|
onInput={onInput}
|
|
60
52
|
onBlur={onBlur}
|
|
61
|
-
style={
|
|
53
|
+
style={inlineStyle}
|
|
62
54
|
className={classNames('weda-text', 'weda-ui', className, levelName)}
|
|
63
55
|
id={id}
|
|
64
56
|
onClick={(e) => events.tap({}, { originEvent: e })}
|
|
@@ -66,4 +58,4 @@ export default function Text({
|
|
|
66
58
|
{text}
|
|
67
59
|
</p>
|
|
68
60
|
);
|
|
69
|
-
}
|
|
61
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
a.weda-file-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
a.weda-uploader-file-view__single {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
vertical-align: middle;
|
|
4
|
+
white-space: nowrap;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
text-overflow: ellipsis;
|
|
7
|
+
max-width: 100%;
|
|
8
8
|
}
|
|
9
|
-
a.weda-file-
|
|
10
|
-
|
|
9
|
+
a.weda-uploader-file-view__single:hover {
|
|
10
|
+
text-decoration: underline;
|
|
11
11
|
}
|
|
@@ -1,43 +1,52 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { UploadFilePc } from '../form/uploaderFile/uploadFile.pc';
|
|
3
|
+
import { UploadFileH5 } from '../form/uploaderFile/uploadFile.h5';
|
|
3
4
|
import {
|
|
4
5
|
filterStrList,
|
|
5
6
|
isCloudFileID,
|
|
6
7
|
downloadFile,
|
|
8
|
+
usePlatform,
|
|
9
|
+
transFileCloudidToName,
|
|
7
10
|
} from '../../utils/platform';
|
|
8
11
|
import { getTempFileURL } from '../../utils/tcb';
|
|
9
12
|
import './index.css';
|
|
10
13
|
|
|
11
|
-
const CLASS_PREFIX = 'weda-file-view
|
|
14
|
+
const CLASS_PREFIX = 'weda-uploader-file-view';
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
15
|
-
* single 表示单个文件回显
|
|
17
|
+
* 上传文件回显,传showType强制展示某端样式,否则根据平台自动判断
|
|
16
18
|
*/
|
|
17
19
|
export default function UploaderFileView({
|
|
18
20
|
value,
|
|
19
21
|
className,
|
|
20
|
-
single = true,
|
|
22
|
+
single = true, // 展示为单行 a 标签
|
|
23
|
+
showType, // 展示端为 pc 还是 h5 样式
|
|
21
24
|
...rest
|
|
22
25
|
}) {
|
|
23
26
|
const fileIDList = filterStrList(value);
|
|
24
|
-
if(single){
|
|
25
|
-
return <FileView fileID={fileIDList[0]}/>;
|
|
26
|
-
}else{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
if (single) {
|
|
28
|
+
return <FileView fileID={fileIDList[0]} />;
|
|
29
|
+
} else {
|
|
30
|
+
const platform = usePlatform();
|
|
31
|
+
const showTypeMix = showType ? (showType === 'h5' ? 'h5' : 'pc') : platform;
|
|
32
|
+
const uploadFileProps = {
|
|
33
|
+
...rest,
|
|
34
|
+
className: `${CLASS_PREFIX} ${className}`,
|
|
35
|
+
decorator: null,
|
|
36
|
+
labelVisible: false,
|
|
37
|
+
value: fileIDList,
|
|
38
|
+
isEdit: false,
|
|
39
|
+
};
|
|
40
|
+
return showTypeMix === 'pc' ? (
|
|
41
|
+
<UploadFilePc {...uploadFileProps} />
|
|
42
|
+
) : (
|
|
43
|
+
<UploadFileH5 {...uploadFileProps} />
|
|
35
44
|
);
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
/**
|
|
40
|
-
*
|
|
49
|
+
* 单个文件回显,用在表格里面
|
|
41
50
|
*/
|
|
42
51
|
const FileView = ({ fileID }) => {
|
|
43
52
|
const [src, setSrc] = React.useState('');
|
|
@@ -58,18 +67,18 @@ const FileView = ({ fileID }) => {
|
|
|
58
67
|
|
|
59
68
|
const title = React.useMemo(() => {
|
|
60
69
|
if (isCloudFileID(fileID)) {
|
|
61
|
-
|
|
62
|
-
const lastIndex = `${fileID}`.lastIndexOf('/');
|
|
63
|
-
const name = `${fileID}`.slice(lastIndex + 1);
|
|
64
|
-
const title = name.replace(uuidReg, '');
|
|
65
|
-
return title;
|
|
70
|
+
return transFileCloudidToName(fileID);
|
|
66
71
|
} else {
|
|
67
72
|
return fileID;
|
|
68
73
|
}
|
|
69
74
|
}, [fileID]);
|
|
70
75
|
return (
|
|
71
|
-
|
|
76
|
+
<a
|
|
77
|
+
title={title}
|
|
78
|
+
onClick={() => downloadFile(src)}
|
|
79
|
+
className={`${CLASS_PREFIX}__single`}
|
|
80
|
+
>
|
|
72
81
|
{title}
|
|
73
|
-
|
|
82
|
+
</a>
|
|
74
83
|
);
|
|
75
84
|
};
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import Button from '../../components/button';
|
|
3
|
+
import { CommonPropsType } from '../../types';
|
|
4
|
+
|
|
5
|
+
const UserInfo = (props: PropsType) => <Button {...props} />;
|
|
6
|
+
|
|
7
|
+
export interface PropsType extends CommonPropsType {
|
|
8
|
+
/**
|
|
9
|
+
* 按钮标题
|
|
10
|
+
*/
|
|
11
|
+
text?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 按钮风格
|
|
14
|
+
*/
|
|
15
|
+
type?: 'primary' | 'warn' | 'wechat' | 'default';
|
|
16
|
+
/**
|
|
17
|
+
* 按钮大小
|
|
18
|
+
*/
|
|
19
|
+
size?: 'default' | 'mini' | 'large';
|
|
20
|
+
/**
|
|
21
|
+
* 信息用途
|
|
22
|
+
*/
|
|
23
|
+
usage?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 语言
|
|
26
|
+
*/
|
|
27
|
+
language?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default UserInfo;
|
package/src/web/types.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/// <reference types="resize-observer-browser" />
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import { any } from 'prop-types';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
export type unknownFunction = (...args: unknown[]) => unknown;
|
|
5
6
|
export interface CommonPropsType {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
id?: string;
|
|
9
|
+
events?: Record<string, unknownFunction>;
|
|
10
|
+
className?: string;
|
|
11
|
+
children?: React.ReactNode | undefined;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
14
|
declare global {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
var app: any;
|
|
16
|
+
interface Window {
|
|
17
|
+
app: any;
|
|
18
|
+
qq: any;
|
|
19
|
+
TMap: any;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function isObject(value) {
|
|
2
|
+
const type = typeof value;
|
|
3
|
+
return value != null && (type === 'object' || type === 'function');
|
|
4
|
+
}
|
|
5
|
+
function debounce(func, wait, options) {
|
|
6
|
+
let lastArgs, lastThis, maxWait, result, timerId, lastCallTime;
|
|
7
|
+
let lastInvokeTime = 0;
|
|
8
|
+
let leading = false;
|
|
9
|
+
let maxing = false;
|
|
10
|
+
let trailing = true;
|
|
11
|
+
if (typeof func !== 'function') {
|
|
12
|
+
throw new TypeError('Expected a function');
|
|
13
|
+
}
|
|
14
|
+
wait = +wait || 0;
|
|
15
|
+
if (isObject(options)) {
|
|
16
|
+
leading = !!options.leading;
|
|
17
|
+
maxing = 'maxWait' in options;
|
|
18
|
+
maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait;
|
|
19
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
20
|
+
}
|
|
21
|
+
function invokeFunc(time) {
|
|
22
|
+
const args = lastArgs;
|
|
23
|
+
const thisArg = lastThis;
|
|
24
|
+
|
|
25
|
+
lastArgs = lastThis = undefined;
|
|
26
|
+
lastInvokeTime = time;
|
|
27
|
+
result = func.apply(thisArg, args);
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
function startTimer(pendingFunc, wait) {
|
|
31
|
+
return setTimeout(pendingFunc, wait);
|
|
32
|
+
}
|
|
33
|
+
function leadingEdge(time) {
|
|
34
|
+
lastInvokeTime = time;
|
|
35
|
+
timerId = startTimer(timerExpired, wait);
|
|
36
|
+
return leading ? invokeFunc(time) : result;
|
|
37
|
+
}
|
|
38
|
+
function remainingWait(time) {
|
|
39
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
40
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
41
|
+
const timeWaiting = wait - timeSinceLastCall;
|
|
42
|
+
|
|
43
|
+
return maxing
|
|
44
|
+
? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
45
|
+
: timeWaiting;
|
|
46
|
+
}
|
|
47
|
+
function shouldInvoke(time) {
|
|
48
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
49
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
50
|
+
return (
|
|
51
|
+
lastCallTime === undefined ||
|
|
52
|
+
timeSinceLastCall >= wait ||
|
|
53
|
+
timeSinceLastCall < 0 ||
|
|
54
|
+
(maxing && timeSinceLastInvoke >= maxWait)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function timerExpired() {
|
|
58
|
+
const time = Date.now();
|
|
59
|
+
if (shouldInvoke(time)) {
|
|
60
|
+
return trailingEdge(time);
|
|
61
|
+
}
|
|
62
|
+
timerId = startTimer(timerExpired, remainingWait(time));
|
|
63
|
+
}
|
|
64
|
+
function trailingEdge(time) {
|
|
65
|
+
timerId = undefined;
|
|
66
|
+
if (trailing && lastArgs) {
|
|
67
|
+
return invokeFunc(time);
|
|
68
|
+
}
|
|
69
|
+
lastArgs = lastThis = undefined;
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//debouncedFunc
|
|
74
|
+
function debounced(...args) {
|
|
75
|
+
const time = Date.now();
|
|
76
|
+
const isInvoking = shouldInvoke(time);
|
|
77
|
+
|
|
78
|
+
lastArgs = args;
|
|
79
|
+
lastThis = this;
|
|
80
|
+
lastCallTime = time;
|
|
81
|
+
|
|
82
|
+
if (isInvoking) {
|
|
83
|
+
if (timerId === undefined) {
|
|
84
|
+
return leadingEdge(lastCallTime);
|
|
85
|
+
}
|
|
86
|
+
if (maxing) {
|
|
87
|
+
timerId = startTimer(timerExpired, wait);
|
|
88
|
+
return invokeFunc(lastCallTime);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (timerId === undefined) {
|
|
92
|
+
timerId = startTimer(timerExpired, wait);
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
return debounced;
|
|
97
|
+
}
|
|
98
|
+
export default debounce;
|
|
@@ -38,6 +38,21 @@ export function usePlatform() {
|
|
|
38
38
|
return touchDevice || smallScreen ? 'h5' : 'pc';
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* 在h5下,判断当前是否是移动浏览器
|
|
43
|
+
*/
|
|
44
|
+
export function inH5IsMobile() {
|
|
45
|
+
try {
|
|
46
|
+
// 区分h5是在编辑器还是移动浏览器
|
|
47
|
+
let is_mobile_ua = false;
|
|
48
|
+
const ua = navigator && navigator.userAgent;
|
|
49
|
+
is_mobile_ua = /Android|webOS|BlackBerry|iPhone|iPad|iPod|iOS/i.test(ua);
|
|
50
|
+
return is_mobile_ua;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
console.log('isMobile err', e);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
/**
|
|
42
57
|
* 过滤非字符串,返回字符串数组
|
|
43
58
|
* 用于兼容单个组件和组件数组
|
|
@@ -101,3 +116,28 @@ export const cutFileTitle = (str = '', count = 10) => {
|
|
|
101
116
|
}
|
|
102
117
|
return title;
|
|
103
118
|
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 判断是否在 ide 中
|
|
122
|
+
*/
|
|
123
|
+
export const isInIde = () => !!window?.app?.cloud?.IS_WEDA_IDE;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* cloudid和文件名转换
|
|
127
|
+
*/
|
|
128
|
+
export const transFileCloudidToName = (fileID) => {
|
|
129
|
+
const uuidReg = /(file-)?[0-9a-f]{8}((-)?[0-9a-f]{4}){3}(-)?[0-9a-f]{12}-/;
|
|
130
|
+
const lastIndex = `${fileID}`.lastIndexOf('/');
|
|
131
|
+
const name = `${fileID}`.slice(lastIndex + 1);
|
|
132
|
+
const title = name.replace(uuidReg, '');
|
|
133
|
+
return title;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 判断是否是url
|
|
138
|
+
*/
|
|
139
|
+
const reg =
|
|
140
|
+
// eslint-disable-next-line no-useless-escape
|
|
141
|
+
/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
|
|
142
|
+
|
|
143
|
+
export const isUrl = (path) => reg.test(path);
|
package/src/web/utils/tcb.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isInIde } from './platform';
|
|
1
2
|
/**
|
|
2
3
|
* 云存储/云函数相关
|
|
3
4
|
*/
|
|
@@ -35,3 +36,51 @@ export async function getTempFileURL(data) {
|
|
|
35
36
|
return await window?.app?.cloud?.getTempFileURL(data);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 云函数获取数据
|
|
42
|
+
*/
|
|
43
|
+
export async function callDataSource(param) {
|
|
44
|
+
const { params, dataSourceName, methodName } = param;
|
|
45
|
+
try {
|
|
46
|
+
const res = await window?.app?.cloud?.callDataSource?.({
|
|
47
|
+
params,
|
|
48
|
+
dataSourceName,
|
|
49
|
+
methodName,
|
|
50
|
+
});
|
|
51
|
+
return res;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error('错误', error);
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 云API:获取用户自定义导航内容
|
|
60
|
+
* param
|
|
61
|
+
* WeAppId: string,
|
|
62
|
+
* EnvId: string,
|
|
63
|
+
* PublishType?: string,
|
|
64
|
+
*/
|
|
65
|
+
export async function getAppCustomNav() {
|
|
66
|
+
try {
|
|
67
|
+
const PublishType = isInIde() ? 'preview' : '';
|
|
68
|
+
const WeAppId = window?.app?.id;
|
|
69
|
+
const res = await callWedaApi({
|
|
70
|
+
action: 'DescribeAppCustomNav',
|
|
71
|
+
serviceType: 'lowcode',
|
|
72
|
+
data: {
|
|
73
|
+
WeAppId,
|
|
74
|
+
PublishType,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
return res;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error('错误', error);
|
|
80
|
+
return {};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function callWedaApi(...args) {
|
|
85
|
+
return window.app.cloud.callWedaApi(...args);
|
|
86
|
+
}
|