@cloudbase/weda-ui 2.0.10 → 2.0.26
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 +1 -0
- package/package.json +47 -36
- package/src/configs/components/button.json +60 -13
- package/src/configs/components/calendar.json +3 -3
- package/src/configs/components/carousel.json +57 -47
- package/src/configs/components/chart/bar.json +4 -13
- package/src/configs/components/chart/line.json +4 -13
- package/src/configs/components/chart/pie.json +3 -10
- package/src/configs/components/chart/statisticsCard.json +1 -4
- package/src/configs/components/container.json +1 -3
- package/src/configs/components/dataView.json +7 -15
- package/src/configs/components/drawer.json +24 -6
- package/src/configs/components/form/form.json +19 -0
- package/src/configs/components/form/input.json +20 -5
- package/src/configs/components/form/location.json +51 -48
- package/src/configs/components/form/radio.json +1 -3
- package/src/configs/components/form/richText.json +14 -14
- package/src/configs/components/form/select.json +62 -82
- package/src/configs/components/form/textarea.json +14 -1
- package/src/configs/components/form/uploader.json +64 -64
- package/src/configs/components/form/uploaderFile.json +1 -2
- package/src/configs/components/graphicCard.json +44 -45
- package/src/configs/components/image.json +44 -40
- package/src/configs/components/link.json +5 -10
- package/src/configs/components/listView.json +2 -8
- package/src/configs/components/lottery.json +7 -3
- package/src/configs/components/modal.json +26 -21
- package/src/configs/components/navLayout.json +68 -68
- package/src/configs/components/navigationBar.json +4 -1
- package/src/configs/components/richtextview.json +1 -1
- package/src/configs/components/scrollVeiw.json +14 -42
- package/src/configs/components/swiper.json +9 -9
- package/src/configs/components/wedaVideo.json +89 -0
- package/src/configs/components/wxOpenApi/phone.json +7 -21
- package/src/configs/components/wxOpenApi/phoneCode.json +7 -19
- package/src/configs/components/wxOpenApi/share.json +14 -24
- package/src/configs/components/wxOpenApi/userInfo.json +9 -27
- package/src/configs/index.js +2 -0
- package/src/mp/components/button/index.js +1 -1
- package/src/mp/components/button/index.wxml +19 -19
- package/src/mp/components/calendar/index.js +68 -38
- package/src/mp/components/calendar/index.json +3 -2
- package/src/mp/components/calendar/index.wxml +5 -7
- package/src/mp/components/calendar/index.wxss +17 -16
- package/src/mp/components/carousel/index.json +1 -1
- package/src/mp/components/carousel/index.wxml +2 -2
- package/src/mp/components/chart/bar/index.js +1 -2
- package/src/mp/components/chart/bar/index.wxml +1 -1
- package/src/mp/components/chart/common/config/bar.js +1 -1
- package/src/mp/components/chart/common/core/eChartBar.js +29 -34
- package/src/mp/components/chart/common/core/eChartBase.js +46 -32
- package/src/mp/components/chart/common/core/eChartLine.js +34 -40
- package/src/mp/components/chart/common/core/eChartPie.js +12 -9
- package/src/mp/components/chart/ec-canvas/ec-canvas.json +1 -1
- package/src/mp/components/chart/ec-canvas/wx-canvas.js +24 -22
- package/src/mp/components/chart/line/index.js +2 -2
- package/src/mp/components/chart/line/index.wxml +1 -1
- package/src/mp/components/chart/pie/index.js +1 -1
- package/src/mp/components/chart/pie/index.wxml +1 -2
- package/src/mp/components/chart/statisticsCard/index.wxss +7 -10
- package/src/mp/components/dataView/index.wxml +2 -14
- package/src/mp/components/form/checkbox/index.js +15 -7
- package/src/mp/components/form/checkbox/index.wxml +13 -25
- package/src/mp/components/form/form/index.wxml +3 -3
- package/src/mp/components/form/formcell/index.wxml +9 -9
- package/src/mp/components/form/formcell/index.wxss +6 -1
- package/src/mp/components/form/input/index.js +4 -4
- package/src/mp/components/form/input/index.wxml +24 -31
- package/src/mp/components/form/input/index.wxss +9 -3
- package/src/mp/components/form/location/components/mapChoose/index.json +1 -1
- package/src/mp/components/form/location/components/mapChoose/index.wxml +6 -6
- package/src/mp/components/form/location/index.js +7 -1
- package/src/mp/components/form/location/index.json +1 -1
- package/src/mp/components/form/location/index.wxml +6 -10
- package/src/mp/components/form/radio/index.js +14 -6
- package/src/mp/components/form/radio/index.wxml +12 -24
- package/src/mp/components/form/select/index.js +157 -98
- package/src/mp/components/form/select/index.wxml +11 -39
- package/src/mp/components/form/select/index.wxss +10 -1
- package/src/mp/components/form/select/region/index.js +18 -12
- package/src/mp/components/form/switch/index.wxml +11 -18
- package/src/mp/components/form/textarea/index.js +6 -0
- package/src/mp/components/form/textarea/index.wxml +2 -17
- package/src/mp/components/form/textarea/index.wxss +5 -0
- package/src/mp/components/form/tips/index.wxml +1 -3
- package/src/mp/components/form/uploader/index.js +1 -1
- package/src/mp/components/form/uploader/index.wxml +3 -20
- package/src/mp/components/form/uploader/weui-uploader.js +210 -200
- package/src/mp/components/form/uploader/weui-uploader.json +6 -6
- package/src/mp/components/form/uploader/weui-uploader.wxml +38 -38
- package/src/mp/components/form/uploaderFile/index.js +5 -4
- package/src/mp/components/form/uploaderFile/index.wxml +40 -41
- package/src/mp/components/graphicCard/index.js +35 -35
- package/src/mp/components/graphicCard/index.wxml +2 -6
- package/src/mp/components/graphicCard/index.wxss +6 -6
- package/src/mp/components/image/index.wxml +9 -20
- package/src/mp/components/image/index.wxss +3 -1
- package/src/mp/components/listView/index.wxml +5 -7
- package/src/mp/components/listView/index.wxss +2 -2
- package/src/mp/components/lottery/index.wxml +1 -3
- package/src/mp/components/lottery/index.wxss +31 -25
- package/src/mp/components/navLayout/index.js +9 -12
- package/src/mp/components/navLayout/index.wxml +2 -4
- package/src/mp/components/navLayout/index.wxss +10 -10
- package/src/mp/components/navigationBar/index.json +1 -2
- package/src/mp/components/navigationBar/index.wxml +43 -51
- package/src/mp/components/navigationBar/index.wxss +10 -10
- package/src/mp/components/richText/index.wxml +1 -1
- package/src/mp/components/richText/index.wxss +7 -5
- package/src/mp/components/swiper/index.wxml +1 -9
- package/src/mp/components/tabs/index.js +14 -10
- package/src/mp/components/tabs/index.json +1 -1
- package/src/mp/components/tabs/index.wxml +3 -21
- package/src/mp/components/tabs/index.wxss +1 -2
- package/src/mp/components/text/index.wxml +1 -6
- package/src/mp/components/text/index.wxss +1 -1
- package/src/mp/components/wedaVideo/index.js +86 -0
- package/src/mp/components/wedaVideo/index.json +4 -0
- package/src/mp/components/wedaVideo/index.wxml +4 -0
- package/src/mp/components/wedaVideo/index.wxss +20 -0
- package/src/mp/components/wxOpenApi/phone/index.js +1 -9
- package/src/mp/components/wxOpenApi/phone/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/phoneCode/index.json +1 -1
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/share/index.wxml +3 -14
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +3 -13
- package/src/mp/index.json +1 -0
- package/src/mp/style/weda-ui.wxss +24 -9
- package/src/mp/utils/deepEqual.js +37 -37
- package/src/mp/utils/destr.js +41 -40
- package/src/mp/utils/dr_square_point.js +10 -6
- package/src/setupTests.js +13 -13
- package/src/web/actions/showModal/index.tsx +5 -4
- package/src/web/components/button/index.tsx +44 -40
- package/src/web/components/calendar/index.css +99 -65
- package/src/web/components/carousel/index.tsx +1 -1
- package/src/web/components/chart/common/config/bar.js +1 -1
- package/src/web/components/chart/common/core/eChartBar.js +28 -34
- package/src/web/components/chart/common/core/eChartBase.ts +55 -42
- package/src/web/components/chart/common/core/eChartLine.js +34 -40
- package/src/web/components/chart/common/core/eChartPie.js +12 -9
- package/src/web/components/chart/common/core/type.ts +23 -23
- package/src/web/components/chart/common/echart.css +12 -12
- package/src/web/components/chart/common/echarts.ts +3 -5
- package/src/web/components/chart/common/useChart.tsx +34 -16
- package/src/web/components/chart/statisticsCard/index.css +9 -8
- package/src/web/components/container/index.tsx +3 -4
- package/src/web/components/drawer/index.tsx +15 -4
- package/src/web/components/form/checkbox/index.tsx +32 -31
- package/src/web/components/form/enumSelect/NormalSelect.tsx +0 -2
- package/src/web/components/form/form/index.css +3 -6
- package/src/web/components/form/form/index.tsx +7 -6
- package/src/web/components/form/formcell/index.css +11 -18
- package/src/web/components/form/formcell/index.tsx +3 -7
- package/src/web/components/form/input/index.css +8 -4
- package/src/web/components/form/input/index.tsx +61 -53
- package/src/web/components/form/location/common/mapChoose.css +13 -11
- package/src/web/components/form/location/common/selectModal.jsx +2 -11
- package/src/web/components/form/location/common/useLocationInfo.js +4 -0
- package/src/web/components/form/location/components/LocationH5/index.css +19 -20
- package/src/web/components/form/location/components/LocationH5/location.h5.jsx +11 -1
- package/src/web/components/form/location/components/LocationPC/Header.jsx +0 -13
- package/src/web/components/form/location/components/LocationPC/location.PC.jsx +14 -5
- package/src/web/components/form/radio/index.tsx +32 -26
- package/src/web/components/form/renderDecorator.tsx +23 -26
- package/src/web/components/form/select/h5.tsx +155 -104
- package/src/web/components/form/select/index.css +9 -3
- package/src/web/components/form/select/index.tsx +76 -49
- package/src/web/components/form/select/region/index.ts +101 -80
- package/src/web/components/form/select/year.tsx +2 -0
- package/src/web/components/form/switch/index.tsx +40 -40
- package/src/web/components/form/textarea/index.css +4 -0
- package/src/web/components/form/textarea/index.tsx +39 -26
- package/src/web/components/form/types.d.ts +10 -10
- package/src/web/components/form/uploader/index.css +10 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +29 -26
- package/src/web/components/form/uploader/uploader.pc.tsx +3 -6
- package/src/web/components/form/uploaderFile/index.css +24 -23
- package/src/web/components/form/uploaderFile/index.jsx +0 -5
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +24 -15
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +21 -13
- package/src/web/components/graphicCard/index.css +6 -6
- package/src/web/components/image/image.tsx +2 -2
- package/src/web/components/image/index.css +9 -7
- package/src/web/components/image/index.tsx +29 -12
- package/src/web/components/index.js +1 -0
- package/src/web/components/link/index.tsx +13 -13
- package/src/web/components/listView/index.css +8 -8
- package/src/web/components/lottery/index.css +43 -37
- package/src/web/components/lottery/index.tsx +3 -3
- package/src/web/components/modal/index.tsx +34 -34
- package/src/web/components/navLayout/index.css +25 -25
- package/src/web/components/navLayout/index.tsx +1 -1
- package/src/web/components/navigationBar/index.css +26 -26
- package/src/web/components/navigationBar/index.tsx +2 -2
- package/src/web/components/picker/datePicker.tsx +3 -3
- package/src/web/components/picker/picker.tsx +3 -3
- package/src/web/components/picker/timePicker.tsx +1 -1
- package/src/web/components/richText/index.jsx +41 -46
- package/src/web/components/richTextView/index.css +7 -3
- package/src/web/components/richTextView/index.tsx +4 -6
- package/src/web/components/scrollView/index.tsx +2 -2
- package/src/web/components/slot/index.tsx +3 -4
- package/src/web/components/swiper/index.css +1 -1
- package/src/web/components/swiper/index.tsx +33 -15
- package/src/web/components/tabs/index.css +2 -3
- package/src/web/components/tabs/index.tsx +6 -6
- package/src/web/components/tabs/tabs.h5.tsx +17 -12
- package/src/web/components/tabs/tabs.pc.tsx +45 -34
- package/src/web/components/text/index.css +1 -1
- package/src/web/components/text/index.tsx +13 -14
- package/src/web/components/wedaVideo/index.css +42 -0
- package/src/web/components/wedaVideo/index.tsx +208 -0
- package/src/web/utils/constant.ts +2 -1
- package/src/web/utils/isObjectEqual.js +2 -1
- package/src/web/utils/loading-fallback.tsx +2 -2
- package/src/web/utils/lodash.ts +1 -1
- package/src/web/utils/platform.js +13 -0
- package/src/web/utils/useSetState.ts +6 -2
- package/src/web/weda-ui.css +23 -8
- package/src/docs/common/format.tsx +0 -112
- package/src/docs/common/tableView.css +0 -164
- package/src/docs/common/tableView.tsx +0 -273
- package/src/docs/compsdocs/chart/Bar.mdx +0 -159
- package/src/docs/compsdocs/chart/Line.mdx +0 -100
- package/src/docs/compsdocs/chart/Pie.mdx +0 -83
- package/src/docs/compsdocs/chart/_category_.json +0 -1
- package/src/docs/compsdocs/chart/statisticsCard.mdx +0 -51
- package/src/docs/compsdocs/database/DataView.mdx +0 -33
- package/src/docs/compsdocs/database/ListView.mdx +0 -33
- package/src/docs/compsdocs/database/_category_.json +0 -1
- package/src/docs/compsdocs/form/Form.mdx +0 -35
- package/src/docs/compsdocs/form/FormCheckbox.mdx +0 -35
- package/src/docs/compsdocs/form/FormDate.mdx +0 -30
- package/src/docs/compsdocs/form/FormEmail.mdx +0 -30
- package/src/docs/compsdocs/form/FormImageUploader.mdx +0 -31
- package/src/docs/compsdocs/form/FormInput.mdx +0 -30
- package/src/docs/compsdocs/form/FormLocation.mdx +0 -64
- package/src/docs/compsdocs/form/FormPhone.mdx +0 -30
- package/src/docs/compsdocs/form/FormRadio.mdx +0 -35
- package/src/docs/compsdocs/form/FormRegion.mdx +0 -30
- package/src/docs/compsdocs/form/FormSelect.mdx +0 -36
- package/src/docs/compsdocs/form/FormSwitch.mdx +0 -30
- package/src/docs/compsdocs/form/FormTextarea.mdx +0 -30
- package/src/docs/compsdocs/form/FormTime.mdx +0 -30
- package/src/docs/compsdocs/form/FormUploadFile.mdx +0 -30
- package/src/docs/compsdocs/form/FormUrl.mdx +0 -30
- package/src/docs/compsdocs/form/_category_.json +0 -1
- package/src/docs/compsdocs/grid/Card.mdx +0 -32
- package/src/docs/compsdocs/grid/Container.mdx +0 -42
- package/src/docs/compsdocs/grid/Footer.mdx +0 -31
- package/src/docs/compsdocs/grid/GridLayout.mdx +0 -32
- package/src/docs/compsdocs/grid/Header.mdx +0 -31
- package/src/docs/compsdocs/grid/Layout.mdx +0 -25
- package/src/docs/compsdocs/grid/List.mdx +0 -31
- package/src/docs/compsdocs/grid/ScrollView.mdx +0 -37
- package/src/docs/compsdocs/grid/Swiper.mdx +0 -58
- package/src/docs/compsdocs/grid/_category_.json +0 -1
- package/src/docs/compsdocs/media/Icon.mdx +0 -31
- package/src/docs/compsdocs/media/Image.mdx +0 -55
- package/src/docs/compsdocs/media/_category_.json +0 -1
- package/src/docs/compsdocs/model/ModelCreate.mdx +0 -20
- package/src/docs/compsdocs/model/ModelDetail.mdx +0 -20
- package/src/docs/compsdocs/model/ModelTable.mdx +0 -24
- package/src/docs/compsdocs/model/ModelUpdate.mdx +0 -21
- package/src/docs/compsdocs/model/PageLayout.mdx +0 -21
- package/src/docs/compsdocs/model/_category_.json +0 -1
- package/src/docs/compsdocs/navmenu/Classification.mdx +0 -38
- package/src/docs/compsdocs/navmenu/NavBar.mdx +0 -43
- package/src/docs/compsdocs/navmenu/NavLayout.mdx +0 -30
- package/src/docs/compsdocs/navmenu/TabBar.mdx +0 -43
- package/src/docs/compsdocs/navmenu/TabBarItem.mdx +0 -29
- package/src/docs/compsdocs/navmenu/_category_.json +0 -1
- package/src/docs/compsdocs/senior/Lottery.mdx +0 -48
- package/src/docs/compsdocs/senior/Modal.mdx +0 -58
- package/src/docs/compsdocs/senior/SlotMachine.mdx +0 -52
- package/src/docs/compsdocs/senior/_category_.json +0 -1
- package/src/docs/compsdocs/show/Calendar.mdx +0 -29
- package/src/docs/compsdocs/show/Divider.mdx +0 -31
- package/src/docs/compsdocs/show/GraphicCard.mdx +0 -30
- package/src/docs/compsdocs/show/Item.mdx +0 -32
- package/src/docs/compsdocs/show/ItemList.mdx +0 -47
- package/src/docs/compsdocs/show/Media.mdx +0 -25
- package/src/docs/compsdocs/show/StatusTip.mdx +0 -25
- package/src/docs/compsdocs/show/Swiper.mdx +0 -33
- package/src/docs/compsdocs/show/Tabs.mdx +0 -38
- package/src/docs/compsdocs/show/_category_.json +0 -1
- package/src/docs/compsdocs/show/button.mdx +0 -25
- package/src/docs/compsdocs/text/Link.mdx +0 -43
- package/src/docs/compsdocs/text/RichTextView.mdx +0 -36
- package/src/docs/compsdocs/text/Text.mdx +0 -31
- package/src/docs/compsdocs/text/Title.mdx +0 -32
- package/src/docs/compsdocs/text/_category_.json +0 -1
- package/src/docs/compsdocs/wxOpen/Phone.mdx +0 -60
- package/src/docs/compsdocs/wxOpen/Share.mdx +0 -46
- package/src/docs/compsdocs/wxOpen/UserInfo.mdx +0 -60
- package/src/docs/compsdocs/wxOpen/_category_.json +0 -4
|
@@ -6,7 +6,7 @@ import { ConfigProvider, Input } from 'tea-component';
|
|
|
6
6
|
import { usePlatform } from '../../../utils/platform';
|
|
7
7
|
import { renderDecorator } from '../renderDecorator';
|
|
8
8
|
import { useSyncValue } from '../../../utils/useSyncValue';
|
|
9
|
-
import { CommonFormPropsType } from '../types';
|
|
9
|
+
import type { CommonFormPropsType } from '../types';
|
|
10
10
|
|
|
11
11
|
export default function Textarea({
|
|
12
12
|
// 系统属性
|
|
@@ -26,7 +26,7 @@ export default function Textarea({
|
|
|
26
26
|
requiredFlag = false,
|
|
27
27
|
counterVisible = true,
|
|
28
28
|
size = 'l',
|
|
29
|
-
decorator
|
|
29
|
+
decorator,
|
|
30
30
|
}: PropsType) {
|
|
31
31
|
const platform = usePlatform();
|
|
32
32
|
|
|
@@ -44,7 +44,7 @@ export default function Textarea({
|
|
|
44
44
|
|
|
45
45
|
// 两次默认值不同时, 需要刷新value
|
|
46
46
|
const [value, setValue] = useSyncValue(defaultValue);
|
|
47
|
-
const counter = React.useMemo(() =>
|
|
47
|
+
const counter = React.useMemo(() => value?.length || 0, [value]);
|
|
48
48
|
|
|
49
49
|
const onChange = function (e) {
|
|
50
50
|
const text = typeof e === 'string' ? e : e.target.value;
|
|
@@ -52,8 +52,16 @@ export default function Textarea({
|
|
|
52
52
|
events.change({ value: text });
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
+
const onFocus = function (e) {
|
|
56
|
+
events.focus?.({ value: e.target.value }, { originEvent: e });
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const onBlur = function (e) {
|
|
60
|
+
events.blur?.({ value: e.target.value }, { originEvent: e });
|
|
61
|
+
};
|
|
62
|
+
|
|
55
63
|
let textAreaElement;
|
|
56
|
-
if(platform === 'h5') {
|
|
64
|
+
if (platform === 'h5') {
|
|
57
65
|
textAreaElement = (
|
|
58
66
|
<div className={subCls}>
|
|
59
67
|
<div className="weui-cell__bd">
|
|
@@ -62,6 +70,8 @@ export default function Textarea({
|
|
|
62
70
|
placeholder={placeholder}
|
|
63
71
|
value={value}
|
|
64
72
|
onChange={onChange}
|
|
73
|
+
onFocus={onFocus}
|
|
74
|
+
onBlur={onBlur}
|
|
65
75
|
maxLength={maxLength}
|
|
66
76
|
disabled={disabled}
|
|
67
77
|
autoFocus={autoFocus}
|
|
@@ -77,32 +87,35 @@ export default function Textarea({
|
|
|
77
87
|
} else {
|
|
78
88
|
textAreaElement = (
|
|
79
89
|
<ConfigProvider classPrefix="wedatea2td">
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
<Input.TextArea
|
|
91
|
+
size={size}
|
|
92
|
+
placeholder={placeholder}
|
|
93
|
+
value={value}
|
|
94
|
+
onChange={onChange}
|
|
95
|
+
onFocus={onFocus}
|
|
96
|
+
onBlur={onBlur}
|
|
97
|
+
maxLength={maxLength}
|
|
98
|
+
disabled={disabled}
|
|
99
|
+
autoFocus={autoFocus}
|
|
100
|
+
showCount
|
|
101
|
+
></Input.TextArea>
|
|
90
102
|
</ConfigProvider>
|
|
91
103
|
);
|
|
92
104
|
}
|
|
93
105
|
|
|
94
|
-
return renderDecorator(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
return renderDecorator(
|
|
107
|
+
textAreaElement,
|
|
108
|
+
decorator
|
|
109
|
+
)({
|
|
110
|
+
id,
|
|
111
|
+
className: cls,
|
|
112
|
+
style,
|
|
113
|
+
label: labelVisible ? label : null,
|
|
114
|
+
layout,
|
|
115
|
+
multiCell: false,
|
|
116
|
+
requiredFlag,
|
|
117
|
+
size,
|
|
118
|
+
});
|
|
106
119
|
}
|
|
107
120
|
export interface PropsType extends CommonFormPropsType {
|
|
108
121
|
defaultValue?: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as React from
|
|
2
|
-
import { CommonPropsType } from
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { CommonPropsType } from '../../types';
|
|
3
3
|
|
|
4
4
|
export interface CommonFormPropsType extends CommonPropsType {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
5
|
+
name?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
labelVisible?: boolean;
|
|
8
|
+
layout?: 'horizontal' | 'vertical';
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
requiredFlag?: boolean;
|
|
11
|
+
decorator?: React.FC<any>;
|
|
12
|
+
}
|
|
@@ -106,3 +106,13 @@
|
|
|
106
106
|
.weui-uploader__hd.vertical {
|
|
107
107
|
padding-bottom: 0;
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
.weda-ui .weui-uploader__file {
|
|
111
|
+
width: 6.85714em;
|
|
112
|
+
height: 6.85714em;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.weda-ui .weui-uploader__input-box {
|
|
116
|
+
width: 6.85714em;
|
|
117
|
+
height: 6.85714em;
|
|
118
|
+
}
|
|
@@ -4,10 +4,9 @@ import classNames from '../../../utils/classnames';
|
|
|
4
4
|
import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
|
|
5
5
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
6
6
|
import { useSyncValue } from '../../../utils/useSyncValue';
|
|
7
|
-
import { isCloudFileID } from '../../../utils/platform';
|
|
7
|
+
import { isCloudFileID, randomUuid } from '../../../utils/platform';
|
|
8
8
|
import { IMAGE_TYPES } from './uploader.pc';
|
|
9
|
-
import { CommonFormPropsType } from '../types';
|
|
10
|
-
import { v4 } from 'uuid';
|
|
9
|
+
import type { CommonFormPropsType } from '../types';
|
|
11
10
|
|
|
12
11
|
const uploadPath = 'weda-uploader';
|
|
13
12
|
/**
|
|
@@ -40,7 +39,7 @@ export function ImageUploaderH5({
|
|
|
40
39
|
//上传进度
|
|
41
40
|
const [progress, setProgress] = React.useState(0);
|
|
42
41
|
const [inputValue, setInputValue] = useSyncValue(defaultValue, isObjectEqual);
|
|
43
|
-
|
|
42
|
+
const inputValueRef = React.useRef(inputValue);
|
|
44
43
|
const fileIdList = React.useMemo(() => {
|
|
45
44
|
//兼容h5默认值为空时情况
|
|
46
45
|
if (inputValue === null) {
|
|
@@ -94,9 +93,7 @@ export function ImageUploaderH5({
|
|
|
94
93
|
getCloudInstance().then(async (tcb) => {
|
|
95
94
|
try {
|
|
96
95
|
const fileType = file.type.split('/')?.[1];
|
|
97
|
-
const cloudPath = `${uploadPath}/${
|
|
98
|
-
file?.name
|
|
99
|
-
}`;
|
|
96
|
+
const cloudPath = `${uploadPath}/${randomUuid()}-${file?.name}`;
|
|
100
97
|
const { fileID } = await tcb.uploadFile({
|
|
101
98
|
cloudPath,
|
|
102
99
|
filePath: file,
|
|
@@ -122,7 +119,7 @@ export function ImageUploaderH5({
|
|
|
122
119
|
}, [acceptTypes]);
|
|
123
120
|
|
|
124
121
|
const showAdd = React.useMemo(() => {
|
|
125
|
-
if(single) {
|
|
122
|
+
if (single) {
|
|
126
123
|
// single 模式时,仅当数组为空时显示
|
|
127
124
|
return fileIdList.length < 1;
|
|
128
125
|
}
|
|
@@ -132,7 +129,13 @@ export function ImageUploaderH5({
|
|
|
132
129
|
<div className={cls} id={id} style={style}>
|
|
133
130
|
<div className={classNames('weui-uploader', layout)}>
|
|
134
131
|
<div className={classNames('weui-uploader__hd', layout)}>
|
|
135
|
-
<UploaderLabel
|
|
132
|
+
<UploaderLabel
|
|
133
|
+
layout={layout}
|
|
134
|
+
title={title}
|
|
135
|
+
currentCount={fileIdList.length}
|
|
136
|
+
maxCount={finalMaxImgCount}
|
|
137
|
+
requiredFlag={requiredFlag}
|
|
138
|
+
/>
|
|
136
139
|
</div>
|
|
137
140
|
|
|
138
141
|
<div className="weui-uploader__bd">
|
|
@@ -142,9 +145,7 @@ export function ImageUploaderH5({
|
|
|
142
145
|
))}
|
|
143
146
|
{uploading && (
|
|
144
147
|
<li className="weui-uploader__file weui-uploader__file_status">
|
|
145
|
-
<div className="weui-uploader__file-content">
|
|
146
|
-
{progress}%
|
|
147
|
-
</div>
|
|
148
|
+
<div className="weui-uploader__file-content">{progress}%</div>
|
|
148
149
|
</li>
|
|
149
150
|
)}
|
|
150
151
|
</ul>
|
|
@@ -251,11 +252,17 @@ export interface H5UploaderProps extends CommonFormPropsType {
|
|
|
251
252
|
onChange?: (v: any) => void;
|
|
252
253
|
}
|
|
253
254
|
|
|
254
|
-
const UploaderLabel = ({
|
|
255
|
-
|
|
255
|
+
const UploaderLabel = ({
|
|
256
|
+
layout,
|
|
257
|
+
title,
|
|
258
|
+
currentCount,
|
|
259
|
+
maxCount,
|
|
260
|
+
requiredFlag,
|
|
261
|
+
}) => {
|
|
262
|
+
if (layout === 'horizontal') {
|
|
256
263
|
return (
|
|
257
264
|
<React.Fragment>
|
|
258
|
-
<div className=
|
|
265
|
+
<div className="weda-formcells__label weui-cell">
|
|
259
266
|
<div>
|
|
260
267
|
<p className="weui-uploader__title">{title}</p>
|
|
261
268
|
<div className="weui-uploader__info">
|
|
@@ -263,25 +270,21 @@ const UploaderLabel = ({layout, title, currentCount, maxCount, requiredFlag}) =>
|
|
|
263
270
|
{`/${maxCount}`}
|
|
264
271
|
</div>
|
|
265
272
|
</div>
|
|
266
|
-
{requiredFlag &&
|
|
267
|
-
<label className="weda-formcells__flag">*</label>
|
|
268
|
-
)}
|
|
273
|
+
{requiredFlag && <label className="weda-formcells__flag">*</label>}
|
|
269
274
|
</div>
|
|
270
275
|
</React.Fragment>
|
|
271
|
-
)
|
|
276
|
+
);
|
|
272
277
|
}
|
|
273
278
|
return (
|
|
274
|
-
<div className=
|
|
275
|
-
<div className=
|
|
279
|
+
<div className="weda-formcells__label weui-cell">
|
|
280
|
+
<div className="weui-uploader__label">
|
|
276
281
|
<p className="weui-uploader__title">{title}</p>
|
|
277
|
-
{requiredFlag &&
|
|
278
|
-
<label className="weda-formcells__flag">*</label>
|
|
279
|
-
)}
|
|
282
|
+
{requiredFlag && <label className="weda-formcells__flag">*</label>}
|
|
280
283
|
</div>
|
|
281
284
|
<div className="weui-uploader__info">
|
|
282
285
|
<span id="uploadCount">{currentCount}</span>
|
|
283
286
|
{`/${maxCount}`}
|
|
284
287
|
</div>
|
|
285
288
|
</div>
|
|
286
|
-
)
|
|
287
|
-
}
|
|
289
|
+
);
|
|
290
|
+
};
|
|
@@ -8,10 +8,9 @@ import {
|
|
|
8
8
|
ImagePreview,
|
|
9
9
|
ConfigProvider,
|
|
10
10
|
} from 'tea-component';
|
|
11
|
-
import { v4 } from 'uuid';
|
|
12
11
|
import classNames from '../../../utils/classnames';
|
|
13
12
|
import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
|
|
14
|
-
import { isCloudFileID } from '../../../utils/platform';
|
|
13
|
+
import { isCloudFileID, randomUuid } from '../../../utils/platform';
|
|
15
14
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
16
15
|
import { H5UploaderProps } from './uploader.h5';
|
|
17
16
|
// 默认组件类前缀
|
|
@@ -79,7 +78,7 @@ export function UploaderPCInner(props) {
|
|
|
79
78
|
const [progress, setProgress] = React.useState(0);
|
|
80
79
|
// 文件列表
|
|
81
80
|
const [fileIDList, setfileIDList] = React.useState([]);
|
|
82
|
-
const fileRef = React.useRef(
|
|
81
|
+
const fileRef = React.useRef(['']);
|
|
83
82
|
React.useEffect(() => {
|
|
84
83
|
let initialValue = []
|
|
85
84
|
.concat(defaultValue)
|
|
@@ -130,9 +129,7 @@ export function UploaderPCInner(props) {
|
|
|
130
129
|
getCloudInstance().then(async (tcb) => {
|
|
131
130
|
try {
|
|
132
131
|
const fileType = file.type.split('/')?.[1];
|
|
133
|
-
const cloudPath = `${uploadPath}/${
|
|
134
|
-
file?.name
|
|
135
|
-
}`;
|
|
132
|
+
const cloudPath = `${uploadPath}/${randomUuid()}-${file?.name}`;
|
|
136
133
|
const { fileID } = await tcb.uploadFile({
|
|
137
134
|
cloudPath,
|
|
138
135
|
filePath: file,
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
|
|
88
88
|
.weda-upload-file-pc .weda-upload-file-pc__btn-descripe {
|
|
89
89
|
margin-left: 16px;
|
|
90
|
-
font-size:
|
|
90
|
+
font-size: 0.75em;
|
|
91
91
|
line-height: 20px;
|
|
92
92
|
color: rgba(0, 0, 0, 0.4);
|
|
93
93
|
}
|
|
@@ -103,13 +103,13 @@
|
|
|
103
103
|
|
|
104
104
|
.weda-upload-file-pc .weda-upload-file-pc--item {
|
|
105
105
|
display: flex;
|
|
106
|
-
font-size:
|
|
106
|
+
font-size: 0.875em;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
.weda-upload-file-pc .weda-upload-file-pc--item-header {
|
|
110
110
|
border: 1px solid #e7e7e7;
|
|
111
|
-
font-size:
|
|
112
|
-
line-height:
|
|
111
|
+
font-size: 0.875em;
|
|
112
|
+
line-height: 1.375em;
|
|
113
113
|
color: rgba(0, 0, 0, 0.4);
|
|
114
114
|
margin-top: 16px;
|
|
115
115
|
}
|
|
@@ -117,8 +117,8 @@
|
|
|
117
117
|
.weda-upload-file-pc .weda-upload-file-pc--item-body {
|
|
118
118
|
border-left: 1px dashed #e7e7e7;
|
|
119
119
|
border-right: 1px dashed #e7e7e7;
|
|
120
|
-
font-size:
|
|
121
|
-
line-height:
|
|
120
|
+
font-size: 0.875em;
|
|
121
|
+
line-height: 1.375em;
|
|
122
122
|
color: rgba(0, 0, 0, 0.9);
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
border-color: #dcdcdc;
|
|
167
167
|
color: rgba(0, 0, 0, 0.9);
|
|
168
168
|
width: 88px;
|
|
169
|
-
font-size:
|
|
169
|
+
font-size: 0.875em;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
.weda-upload-file-pc
|
|
@@ -187,8 +187,8 @@
|
|
|
187
187
|
.weda-upload-file-pc--item
|
|
188
188
|
.weda-upload-file-pc--item-action
|
|
189
189
|
.wedatea2td-btn {
|
|
190
|
-
font-size:
|
|
191
|
-
line-height:
|
|
190
|
+
font-size: 0.875em;
|
|
191
|
+
line-height: 1.375em;
|
|
192
192
|
color: #0052d9;
|
|
193
193
|
margin-right: 12px;
|
|
194
194
|
}
|
|
@@ -214,9 +214,9 @@
|
|
|
214
214
|
.weda-upload-file-pc
|
|
215
215
|
.weda-upload-file-pc--item-empty
|
|
216
216
|
.weda-upload-file-pc--item {
|
|
217
|
-
font-size:
|
|
217
|
+
font-size: 0.875em;
|
|
218
218
|
color: rgba(0, 0, 0, 0.4);
|
|
219
|
-
line-height:
|
|
219
|
+
line-height: 1.375em;
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
/* ----上传文件---- h5 */
|
|
@@ -236,8 +236,8 @@
|
|
|
236
236
|
padding: 0 20px 8px 20px;
|
|
237
237
|
}
|
|
238
238
|
.weda-upload-file-mobile .weda-upload-file-mobile__title {
|
|
239
|
-
font-size:
|
|
240
|
-
line-height:
|
|
239
|
+
font-size: 0.875em;
|
|
240
|
+
line-height: 1.25em;
|
|
241
241
|
color: #000;
|
|
242
242
|
margin-right: 20px;
|
|
243
243
|
padding-top: 6px;
|
|
@@ -246,18 +246,18 @@
|
|
|
246
246
|
.weda-upload-file-mobile .weda-upload-file-mobile__btn--weak {
|
|
247
247
|
width: 88px;
|
|
248
248
|
padding: 0 16px;
|
|
249
|
-
font-size:
|
|
249
|
+
font-size: 0.875em;
|
|
250
250
|
color: rgba(0, 0, 0, 0.9);
|
|
251
251
|
border: 1px solid #dcdcdc;
|
|
252
252
|
border-radius: 3px;
|
|
253
|
-
line-height:
|
|
253
|
+
line-height: 1.375em;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
.weda-upload-file-mobile .weda-upload-file-mobile__tips {
|
|
257
257
|
display: block;
|
|
258
258
|
margin-top: 8px;
|
|
259
|
-
font-size:
|
|
260
|
-
line-height:
|
|
259
|
+
font-size: 0.75em;
|
|
260
|
+
line-height: 1.25em;
|
|
261
261
|
color: rgba(0, 0, 0, 0.4);
|
|
262
262
|
}
|
|
263
263
|
|
|
@@ -331,8 +331,8 @@
|
|
|
331
331
|
.weda-upload-file-mobile
|
|
332
332
|
.weda-upload-file-mobile__item
|
|
333
333
|
.weda-upload-file-mobile__file-name {
|
|
334
|
-
font-size:
|
|
335
|
-
line-height:
|
|
334
|
+
font-size: 0.875em;
|
|
335
|
+
line-height: 1.375em;
|
|
336
336
|
color: rgba(0, 0, 0, 0.9);
|
|
337
337
|
max-width: 6.5rem;
|
|
338
338
|
overflow: hidden;
|
|
@@ -373,16 +373,16 @@
|
|
|
373
373
|
.weda-upload-file-mobile__file-status--msg {
|
|
374
374
|
width: 4.2rem;
|
|
375
375
|
margin-left: 4px;
|
|
376
|
-
font-size:
|
|
377
|
-
line-height:
|
|
376
|
+
font-size: 0.75em;
|
|
377
|
+
line-height: 1.25em;
|
|
378
378
|
color: rgba(0, 0, 0, 0.9);
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
.weda-upload-file-mobile
|
|
382
382
|
.weda-upload-file-mobile__item
|
|
383
383
|
.weda-upload-file-mobile__file-foot {
|
|
384
|
-
font-size:
|
|
385
|
-
line-height:
|
|
384
|
+
font-size: 0.75em;
|
|
385
|
+
line-height: 1.25em;
|
|
386
386
|
color: rgba(0, 0, 0, 0.4);
|
|
387
387
|
margin-top: 8px;
|
|
388
388
|
display: flex;
|
|
@@ -415,6 +415,7 @@
|
|
|
415
415
|
}
|
|
416
416
|
.weda-upload-file-mobile .weui-uploader-mobile__input {
|
|
417
417
|
position: absolute;
|
|
418
|
+
font-size: 1em;
|
|
418
419
|
opacity: 0;
|
|
419
420
|
width: 92px;
|
|
420
421
|
height: 32px;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import * as PropTypes from 'prop-types';
|
|
4
3
|
import { usePlatform } from '../../../utils/platform';
|
|
5
4
|
import { UploadFileH5 as UploaderH5 } from './uploadFile.h5';
|
|
6
5
|
import { UploadFilePc } from './uploadFile.pc';
|
|
@@ -24,7 +23,3 @@ export default function UploaderFile(props) {
|
|
|
24
23
|
<UploadFilePc {...props} />
|
|
25
24
|
);
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
UploaderFile.propTypes = {
|
|
29
|
-
showType: PropTypes.string, // 强制展示某个平台 pc | h5
|
|
30
|
-
};
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import * as PropTypes from 'prop-types';
|
|
3
2
|
import weui from '../../../utils/weui';
|
|
4
|
-
import { CommonFormPropsType } from '../types';
|
|
3
|
+
import type { CommonFormPropsType } from '../types';
|
|
5
4
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
6
5
|
import {
|
|
7
|
-
Upload,
|
|
8
6
|
ConfigProvider,
|
|
9
7
|
Button,
|
|
10
|
-
message,
|
|
11
8
|
Icon,
|
|
12
9
|
Text,
|
|
13
10
|
List,
|
|
14
11
|
Progress,
|
|
15
12
|
Tooltip,
|
|
16
13
|
} from 'tea-component';
|
|
17
|
-
import { v4 } from 'uuid';
|
|
18
14
|
import {
|
|
19
15
|
filterStrList,
|
|
20
16
|
isCloudFileID,
|
|
@@ -22,6 +18,7 @@ import {
|
|
|
22
18
|
transSize,
|
|
23
19
|
downloadFile,
|
|
24
20
|
transFileCloudidToName,
|
|
21
|
+
randomUuid,
|
|
25
22
|
} from '../../../utils/platform';
|
|
26
23
|
import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
|
|
27
24
|
import classNames from '../../../utils/classnames';
|
|
@@ -74,18 +71,26 @@ export function UploadFileH5({
|
|
|
74
71
|
onChange = null,
|
|
75
72
|
isEdit = true,
|
|
76
73
|
}: IUploadFileH5) {
|
|
77
|
-
const [fileIDList, setfileIDList] = React.useState(
|
|
74
|
+
const [fileIDList, setfileIDList] = React.useState(
|
|
75
|
+
filterStrList([].concat(defaultValue, value))
|
|
76
|
+
); // 上传成功文件ID列表,fileID[]
|
|
78
77
|
const [fileList, setFileList] = React.useState([]); // 上传中的文件列表,file[],file为原始文件 + uuid属性
|
|
79
78
|
const [fileSizeObj, setFileSizeObj] = React.useState({}); // 管理上传文件大小 {uuid:size}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
// 两次默认值不同, 需要刷新
|
|
80
|
+
const prevDefaultRef = React.useRef<any>([]);
|
|
81
|
+
const fileRef = React.useRef(fileIDList);
|
|
82
|
+
React.useMemo(() => {
|
|
83
83
|
//有有效默认值时不刷新,解决初次渲染默认值不显示问题
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
if (
|
|
85
|
+
defaultValue &&
|
|
86
|
+
!isObjectEqual(prevDefaultRef.current, defaultValue) &&
|
|
87
|
+
(JSON.stringify(prevDefaultRef.current) == '[]' ||
|
|
88
|
+
!prevDefaultRef.current)
|
|
89
|
+
) {
|
|
90
|
+
prevDefaultRef.current = defaultValue;
|
|
86
91
|
setfileIDList(filterStrList([].concat(defaultValue)));
|
|
87
92
|
}
|
|
88
|
-
|
|
93
|
+
}, [defaultValue]);
|
|
89
94
|
React.useEffect(() => {
|
|
90
95
|
// 外部 onChange 事件
|
|
91
96
|
const pureFileIDList = fileIDList.filter(
|
|
@@ -99,7 +104,10 @@ export function UploadFileH5({
|
|
|
99
104
|
onChange && onChange(pureFileIDList);
|
|
100
105
|
events?.change?.({ value: pureFileIDList });
|
|
101
106
|
}
|
|
102
|
-
|
|
107
|
+
if (!isObjectEqual(fileRef.current, fileIDList)) {
|
|
108
|
+
events?.success?.({ value: pureFileIDList });
|
|
109
|
+
fileRef.current = fileIDList;
|
|
110
|
+
}
|
|
103
111
|
}, [fileIDList]);
|
|
104
112
|
|
|
105
113
|
// 外层组件类
|
|
@@ -202,13 +210,14 @@ export function UploadFileH5({
|
|
|
202
210
|
weui.alert(`请上传不超过1024M的文件`);
|
|
203
211
|
return false;
|
|
204
212
|
}
|
|
205
|
-
fileList.forEach((f) => (f['_uuid'] =
|
|
213
|
+
fileList.forEach((f) => (f['_uuid'] = randomUuid()));
|
|
206
214
|
setFileList((list) => [...list, ...fileList]);
|
|
207
215
|
}}
|
|
208
216
|
/>
|
|
209
217
|
<a
|
|
210
218
|
type="weak"
|
|
211
219
|
className="wedatea2td-btn wedatea2td-btn--weak"
|
|
220
|
+
style={{ fontSize: '1em' }}
|
|
212
221
|
>
|
|
213
222
|
点击上传
|
|
214
223
|
</a>
|
|
@@ -377,7 +386,7 @@ const TcbFileUpload = ({
|
|
|
377
386
|
try {
|
|
378
387
|
setStatus('UPLOAD_STATUS_PENDING');
|
|
379
388
|
const { fileID } = await tcb.uploadFile({
|
|
380
|
-
cloudPath: `${uploadPath}/${
|
|
389
|
+
cloudPath: `${uploadPath}/${randomUuid()}-${file?.name}`,
|
|
381
390
|
filePath: file,
|
|
382
391
|
onUploadProgress: (progressEvent) => {
|
|
383
392
|
let percent = 0;
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
Text,
|
|
9
9
|
List,
|
|
10
10
|
} from 'tea-component';
|
|
11
|
-
import { v4 } from 'uuid';
|
|
12
11
|
import {
|
|
13
12
|
filterStrList,
|
|
14
13
|
isCloudFileID,
|
|
@@ -17,11 +16,12 @@ import {
|
|
|
17
16
|
downloadFile,
|
|
18
17
|
cutFileTitle,
|
|
19
18
|
transFileCloudidToName,
|
|
19
|
+
randomUuid,
|
|
20
20
|
} from '../../../utils/platform';
|
|
21
21
|
import { getCloudInstance, getTempFileURL } from '../../../utils/tcb';
|
|
22
22
|
import classNames from '../../../utils/classnames';
|
|
23
23
|
import { renderDecorator } from '../renderDecorator';
|
|
24
|
-
import { CommonFormPropsType } from '../types';
|
|
24
|
+
import type { CommonFormPropsType } from '../types';
|
|
25
25
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
26
26
|
|
|
27
27
|
// 默认组件类前缀
|
|
@@ -68,20 +68,26 @@ export function UploadFilePc({
|
|
|
68
68
|
onChange = null,
|
|
69
69
|
isEdit = true,
|
|
70
70
|
}: IUploaderFilePc) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const [fileIDList, setfileIDList] = React.useState(
|
|
72
|
+
filterStrList([].concat(defaultValue, value))
|
|
73
|
+
); // 上传成功文件ID列表,fileID[]
|
|
74
74
|
const [fileList, setFileList] = React.useState([]); // 上传中的文件列表,file[],file为原始文件 + uuid属性
|
|
75
75
|
const [fileSizeObj, setFileSizeObj] = React.useState({}); // 管理上传文件大小 {uuid:size}
|
|
76
|
-
|
|
76
|
+
// 两次默认值不同, 需要刷新
|
|
77
77
|
const prevDefaultRef = React.useRef<any>([]);
|
|
78
|
-
React.
|
|
78
|
+
const fileRef = React.useRef(fileIDList);
|
|
79
|
+
React.useMemo(() => {
|
|
79
80
|
//有有效默认值时不刷新,解决初次渲染默认值不显示问题
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
if (
|
|
82
|
+
defaultValue &&
|
|
83
|
+
!isObjectEqual(prevDefaultRef.current, defaultValue) &&
|
|
84
|
+
(JSON.stringify(prevDefaultRef.current) == '[]' ||
|
|
85
|
+
!prevDefaultRef.current)
|
|
86
|
+
) {
|
|
87
|
+
prevDefaultRef.current = defaultValue;
|
|
82
88
|
setfileIDList(filterStrList([].concat(defaultValue)));
|
|
83
89
|
}
|
|
84
|
-
|
|
90
|
+
}, [defaultValue]);
|
|
85
91
|
React.useEffect(() => {
|
|
86
92
|
// 外部 onChange 事件
|
|
87
93
|
const pureFileIDList = fileIDList.filter(
|
|
@@ -91,11 +97,13 @@ export function UploadFilePc({
|
|
|
91
97
|
const file = pureFileIDList[0] || '';
|
|
92
98
|
onChange?.(file);
|
|
93
99
|
events?.change?.({ value: file });
|
|
94
|
-
events?.success?.({ value: file });
|
|
95
100
|
} else {
|
|
96
101
|
onChange?.(pureFileIDList);
|
|
97
102
|
events?.change?.({ value: pureFileIDList });
|
|
103
|
+
}
|
|
104
|
+
if (!isObjectEqual(fileRef.current, fileIDList)) {
|
|
98
105
|
events?.success?.({ value: pureFileIDList });
|
|
106
|
+
fileRef.current = fileIDList;
|
|
99
107
|
}
|
|
100
108
|
}, [fileIDList]);
|
|
101
109
|
// 外层组件类
|
|
@@ -123,7 +131,7 @@ export function UploadFilePc({
|
|
|
123
131
|
} catch (e) {}
|
|
124
132
|
return false;
|
|
125
133
|
}
|
|
126
|
-
file['_uuid'] =
|
|
134
|
+
file['_uuid'] = randomUuid();
|
|
127
135
|
setFileList((list) => [...list, file]);
|
|
128
136
|
return false;
|
|
129
137
|
};
|
|
@@ -347,7 +355,7 @@ const TcbFileUpload = ({ file }: ITcbFileUpload) => {
|
|
|
347
355
|
try {
|
|
348
356
|
setStatus('0');
|
|
349
357
|
const { fileID } = await tcb.uploadFile({
|
|
350
|
-
cloudPath: `${uploadPath}/${
|
|
358
|
+
cloudPath: `${uploadPath}/${randomUuid()}-${file?.name}`,
|
|
351
359
|
filePath: file,
|
|
352
360
|
onUploadProgress: (progressEvent) => {
|
|
353
361
|
let percent = 0;
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
.weda-graphic-card .weda-graphic-card__col .weda-graphic-card__title {
|
|
84
|
-
font-size:
|
|
85
|
-
line-height:
|
|
84
|
+
font-size: 1.1428em;
|
|
85
|
+
line-height: 1.71428em;
|
|
86
86
|
text-align: center;
|
|
87
87
|
color: rgba(0, 0, 0, 0.9);
|
|
88
88
|
display: -webkit-box;
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
.weda-graphic-card .weda-graphic-card__col .weda-graphic-card__desc {
|
|
96
|
-
font-size:
|
|
97
|
-
line-height:
|
|
96
|
+
font-size: 1em;
|
|
97
|
+
line-height: 1.5714em;
|
|
98
98
|
color: rgba(0, 0, 0, 0.4);
|
|
99
99
|
text-align: center;
|
|
100
100
|
display: -webkit-box;
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
.weda-graphic-card .weda-graphic-card__col .weda-graphic-card__btn--text {
|
|
108
|
-
font-size:
|
|
109
|
-
line-height:
|
|
108
|
+
font-size: 1em;
|
|
109
|
+
line-height: 1.5714em;
|
|
110
110
|
color: #0052d9;
|
|
111
111
|
margin-right: 8px;
|
|
112
112
|
}
|