@cloudbase/weda-ui 3.14.2 → 3.15.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.
- package/dist/configs/components/listView.d.ts +11 -0
- package/dist/configs/components/listView.js +53 -0
- package/dist/configs/components/wd-select-multiple.d.ts +72 -28
- package/dist/configs/components/wd-select-multiple.js +233 -19
- package/dist/configs/components/wd-select.d.ts +70 -29
- package/dist/configs/components/wd-select.js +211 -17
- package/dist/configs/index.d.ts +174 -60
- package/dist/configs/type-utils/type-form.js +65 -21
- package/dist/configs/type-utils/x-runtime-default.d.ts +2 -0
- package/dist/configs/type-utils/x-runtime-default.js +4 -0
- package/dist/style/index.css +15 -0
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +3 -3
- package/dist/web/components/form/uploader/uploader.h5.js +9 -10
- package/dist/web/components/form/uploader/uploader.pc.js +7 -7
- package/dist/web/components/form/uploader/util.js +7 -12
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +29 -37
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +15 -22
- package/dist/web/components/listView/index.css +4 -2
- package/dist/web/components/listView/index.js +25 -43
- package/dist/web/components/richText/index.js +13 -15
- package/dist/web/components/statusContent/index.js +1 -1
- package/dist/web/components/wd-input/wd-input.js +16 -20
- package/dist/web/components/wd-select/contexts/selectContext.d.ts +15 -0
- package/dist/web/components/wd-select/contexts/selectContext.js +13 -0
- package/dist/web/components/wd-select/hooks/useChooseList.d.ts +19 -0
- package/dist/web/components/wd-select/hooks/useChooseList.js +94 -0
- package/dist/web/components/wd-select/relationSelect/enumSelect.d.ts +2 -0
- package/dist/web/components/wd-select/relationSelect/enumSelect.js +48 -0
- package/dist/web/components/wd-select/relationSelect/index.d.ts +2 -0
- package/dist/web/components/wd-select/relationSelect/index.js +19 -0
- package/dist/web/components/wd-select/relationSelect/queryParams.d.ts +15 -0
- package/dist/web/components/wd-select/relationSelect/queryParams.js +15 -0
- package/dist/web/components/wd-select/relationSelect/relationSelect.d.ts +0 -2
- package/dist/web/components/wd-select/relationSelect/relationSelect.js +39 -83
- package/dist/web/components/wd-select/select/index.js +1 -1
- package/dist/web/components/wd-select/wd-select.css +8 -0
- package/dist/web/components/wd-select/wd-select.js +11 -8
- package/dist/web/components/wd-select-multiple/wd-select-multiple.js +11 -8
- package/dist/web/components/wd-table/components/FieldRender/index.js +3 -3
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +8 -13
- package/dist/web/components/wd-table/components/deleteModal.d.ts +1 -1
- package/dist/web/components/wd-table/components/deleteModal.js +47 -30
- package/dist/web/utils/getModelParams.d.ts +6 -1
- package/dist/web/utils/getModelParams.js +16 -13
- package/dist/web/utils/platform.js +9 -13
- package/dist/web/utils/tcb.d.ts +4 -0
- package/dist/web/utils/tcb.js +11 -9
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo, useImperativeHandle } from 'react';
|
|
4
4
|
import { useDebouncedCallback } from '@react-hookz/web';
|
|
5
5
|
import { LoadingTip } from 'tea-component';
|
|
6
6
|
import { SelectUI as Select } from '../select/selectUI';
|
|
@@ -9,12 +9,11 @@ import { getTableColumns } from '../../wd-table/components/FieldRender';
|
|
|
9
9
|
import { useAuthFields } from '../../wd-table/hooks/useAuthFields';
|
|
10
10
|
import { usePlatform } from '../../../utils/platform';
|
|
11
11
|
import { DataSource } from '../../../utils/datasource';
|
|
12
|
-
import { EnumHoc } from '../../../utils/hooks/EnumHoc';
|
|
13
12
|
import { useSyncValue } from '../../../utils/hooks/useSyncValue';
|
|
14
13
|
import isObjectEqual from '../../../utils/isObjectEqual';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { deepClone } from '../../../utils/tool';
|
|
15
|
+
import { useChooseList } from '../hooks/useChooseList';
|
|
16
|
+
import { getDefaultQuery } from './queryParams';
|
|
18
17
|
const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelationOptionJump, enableRelationOptionJump, }) => {
|
|
19
18
|
const platform = usePlatform();
|
|
20
19
|
const columns = useMemo(() => {
|
|
@@ -46,18 +45,18 @@ const OptionText = ({ mode, option, selectFields, authFields, onChange, onRelati
|
|
|
46
45
|
}
|
|
47
46
|
}, children: [_jsxs("div", { className: "wd-relation-select-header", children: [_jsx("p", { className: "wd-relation-select-header-text", title: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value), children: (option === null || option === void 0 ? void 0 : option.label) || (option === null || option === void 0 ? void 0 : option.value) }), enableRelationOptionJump && (_jsx("span", { onClick: () => {
|
|
48
47
|
onRelationOptionJump({ item: option });
|
|
49
|
-
}, children: _jsx(WdIcon, { name: "td:jump", size: "s", type: "inner" }) }))] }), _jsxs("div", { className: "wd-relation-select-option-group", children: [_jsx("div", { className: "wd-relation-select-option-header", children: columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.header }, i.key))) }), _jsx("div", { className: "wd-relation-select-option-content", children: columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.render(option === null || option === void 0 ? void 0 : option.extra) }, i.key))) })] })] }));
|
|
48
|
+
}, children: _jsx(WdIcon, { name: "td:jump", size: "s", type: "inner" }) }))] }), _jsxs("div", { className: "wd-relation-select-option-group", children: [_jsx("div", { className: "wd-relation-select-option-header", children: columns === null || columns === void 0 ? void 0 : columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.header }, i.key))) }), _jsx("div", { className: "wd-relation-select-option-content", children: columns === null || columns === void 0 ? void 0 : columns.map((i) => (_jsx("div", { className: "wd-relation-select-option-text", style: { width: columns.length > 1 ? i.width : 'auto' }, children: i.render(option === null || option === void 0 ? void 0 : option.extra) }, i.key))) })] })] }));
|
|
50
49
|
};
|
|
51
50
|
// 每次请求数据个数
|
|
52
51
|
const defaultSize = 50;
|
|
53
52
|
const defaultPage = 1;
|
|
54
53
|
export function RelationSelect(props) {
|
|
55
54
|
var _a, _b;
|
|
56
|
-
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, listWidth = 700, } = props;
|
|
55
|
+
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, selectFields, selectFieldType, primaryField, setRefreshStatus, mode, onRelationOptionJump, enableRelationOptionJump, listWidth = 700, ignoreCase = true, where, queryCondition, supportManyRelated, sorter, } = props;
|
|
57
56
|
const selectFieldsLength = selectFieldType === 'custom' ? selectFields === null || selectFields === void 0 ? void 0 : selectFields.length : 0;
|
|
58
57
|
// 设置下拉列表与下拉按钮同宽
|
|
59
58
|
// 以传入为准,未传入,在自定义展示字段少于2个时设置为 true,否则设置为false,宽度设置为700,
|
|
60
|
-
const _matchButtonWidth = (_a = props === null || props === void 0 ? void 0 : props.matchButtonWidth) !== null && _a !== void 0 ? _a : selectFieldsLength <
|
|
59
|
+
const _matchButtonWidth = (_a = props === null || props === void 0 ? void 0 : props.matchButtonWidth) !== null && _a !== void 0 ? _a : selectFieldsLength < 3;
|
|
61
60
|
// 以传入为准,未传入,在不与按钮同宽度的情况下,listHeight 会被设置为 400
|
|
62
61
|
const _listHeight = (_b = props === null || props === void 0 ? void 0 : props.listHeight) !== null && _b !== void 0 ? _b : (_matchButtonWidth ? undefined : 400);
|
|
63
62
|
const { authFields } = useAuthFields({
|
|
@@ -74,11 +73,18 @@ export function RelationSelect(props) {
|
|
|
74
73
|
// 是否具备展示自定义字段的条件
|
|
75
74
|
const isRelationSelectOption = selectFieldType === 'custom' && (selectFields === null || selectFields === void 0 ? void 0 : selectFields.length) && (authFields === null || authFields === void 0 ? void 0 : authFields.length);
|
|
76
75
|
const dataSourceAPI = useMemo(() => new DataSource(dataSourceName), [dataSourceName]); // datasource 方法-模型
|
|
77
|
-
const
|
|
76
|
+
const defaultQuery = useMemo(() => getDefaultQuery({
|
|
77
|
+
queryCondition,
|
|
78
|
+
where,
|
|
79
|
+
selectFieldType,
|
|
80
|
+
selectFields,
|
|
81
|
+
supportManyRelated,
|
|
82
|
+
sorter,
|
|
83
|
+
}), [queryCondition, selectFieldType, selectFields, where, supportManyRelated, sorter]);
|
|
78
84
|
const [query, setQuery] = useSyncValue({
|
|
85
|
+
...defaultQuery,
|
|
79
86
|
pageNo: defaultPage,
|
|
80
87
|
pageSize: defaultSize,
|
|
81
|
-
where: whereList,
|
|
82
88
|
}, isObjectEqual);
|
|
83
89
|
const { result: options, total, isValidating, empty, getRelationOptions, } = useChooseList({
|
|
84
90
|
dataSourceAPI,
|
|
@@ -86,7 +92,6 @@ export function RelationSelect(props) {
|
|
|
86
92
|
queryParams: query,
|
|
87
93
|
primaryColumn: primaryField,
|
|
88
94
|
value,
|
|
89
|
-
isInsertSelectedValue: true,
|
|
90
95
|
});
|
|
91
96
|
const [isLoading, setIsLoading] = useSyncValue(isValidating, isObjectEqual);
|
|
92
97
|
// 下拉选项数据
|
|
@@ -107,10 +112,10 @@ export function RelationSelect(props) {
|
|
|
107
112
|
options,
|
|
108
113
|
selectFields,
|
|
109
114
|
]);
|
|
110
|
-
const searchOptionListWithWhere = useDebouncedCallback((
|
|
115
|
+
const searchOptionListWithWhere = useDebouncedCallback((filter = defaultQuery === null || defaultQuery === void 0 ? void 0 : defaultQuery.filter) => {
|
|
111
116
|
empty();
|
|
112
|
-
setQuery({ ...query, pageNo: defaultPage,
|
|
113
|
-
}, [
|
|
117
|
+
setQuery({ ...query, pageNo: defaultPage, filter });
|
|
118
|
+
}, [query, defaultQuery === null || defaultQuery === void 0 ? void 0 : defaultQuery.filter, empty, setQuery], 300);
|
|
114
119
|
useImperativeHandle(childRef, () => {
|
|
115
120
|
return {
|
|
116
121
|
refresh: async () => {
|
|
@@ -132,78 +137,29 @@ export function RelationSelect(props) {
|
|
|
132
137
|
const searchHandle = (keyword) => {
|
|
133
138
|
empty();
|
|
134
139
|
setIsLoading(true);
|
|
135
|
-
let
|
|
136
|
-
if (keyword
|
|
140
|
+
let filter = deepClone(defaultQuery === null || defaultQuery === void 0 ? void 0 : defaultQuery.filter);
|
|
141
|
+
if (keyword) {
|
|
142
|
+
const search = ignoreCase ? '$search_ci' : '$search';
|
|
137
143
|
// 筛选面板的查询条件与数据过滤的查询条件是且的关系
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
filter = {
|
|
145
|
+
...filter,
|
|
146
|
+
where: {
|
|
147
|
+
$and: [filter.where, { $and: [{ [primaryField]: { [`${search}`]: keyword } }] }],
|
|
148
|
+
},
|
|
140
149
|
};
|
|
141
150
|
}
|
|
142
|
-
searchOptionListWithWhere(
|
|
143
|
-
onSearch(keyword);
|
|
144
|
-
};
|
|
145
|
-
return (_jsx(EnumHoc, { fields: authFields, children: _jsx(Select, { ...props, overlayClassName: isRelationSelectOption ? 'wd-relation-select-overlay' : '', searchable: true, listWidth: listWidth, listHeight: _listHeight, matchButtonWidth: _matchButtonWidth, placeholder: placeholder, appearance: 'button', filter: () => true, size: size, disabled: disabled, autoClearSearchValue: true, options: customOptions, value: value, onChange: onChange, onSearch: searchHandle, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined, onScrollBottom: () => {
|
|
146
|
-
if (!isLoading && customOptions.length < total) {
|
|
147
|
-
setQuery((query) => ({
|
|
148
|
-
...query,
|
|
149
|
-
pageNo: query.pageNo + defaultPage,
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
}, onOpen: () => {
|
|
153
|
-
setIsLoading(true);
|
|
154
|
-
searchOptionListWithWhere();
|
|
155
|
-
}, footer: addRelationButton, mode: mode }) }));
|
|
156
|
-
}
|
|
157
|
-
export function EnumSelect(props) {
|
|
158
|
-
const { placeholder, size, disabled, onChange, value, onSearch, addRelationButton, childRef, dataSourceName, enumName, primaryField, format, viewId, where, setRefreshStatus, mode, } = props;
|
|
159
|
-
const [enumOption, setEnumOption] = useState([]);
|
|
160
|
-
const [isLoading, setLoading] = useState(false);
|
|
161
|
-
// 获取枚举字段类型的下拉选项
|
|
162
|
-
const getEnumOption = useCallback(async () => {
|
|
163
|
-
const params = {
|
|
164
|
-
format,
|
|
165
|
-
dataSourceName,
|
|
166
|
-
viewId,
|
|
167
|
-
where,
|
|
168
|
-
primaryField,
|
|
169
|
-
enumName,
|
|
170
|
-
};
|
|
171
|
-
setLoading(true);
|
|
172
|
-
const options = await requestEnumOption(params);
|
|
173
|
-
setEnumOption(options);
|
|
174
|
-
setLoading(false);
|
|
175
|
-
}, [dataSourceName, enumName, format, primaryField, viewId, where]);
|
|
176
|
-
useEffect(() => {
|
|
177
|
-
getEnumOption();
|
|
178
|
-
}, [getEnumOption]);
|
|
179
|
-
useImperativeHandle(childRef, () => {
|
|
180
|
-
return {
|
|
181
|
-
refresh: async () => {
|
|
182
|
-
setRefreshStatus(true);
|
|
183
|
-
await getEnumOption();
|
|
184
|
-
// eslint-disable-next-line rulesdir/no-timer
|
|
185
|
-
const timer = setTimeout(() => {
|
|
186
|
-
setRefreshStatus(false);
|
|
187
|
-
clearTimeout(timer);
|
|
188
|
-
}, 500);
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
}, [getEnumOption, setRefreshStatus]);
|
|
192
|
-
const searchHandle = (keyword) => {
|
|
151
|
+
searchOptionListWithWhere(filter);
|
|
193
152
|
onSearch(keyword);
|
|
194
153
|
};
|
|
195
|
-
return (_jsx(Select, { ...props,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
(
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return _jsx(LoadingTip, {});
|
|
207
|
-
}
|
|
208
|
-
return isEnumType ? (_jsx(EnumSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus })) : (_jsx(RelationSelect, { ...props, addRelationButton: addRelationButton, setRefreshStatus: setRefreshStatus }));
|
|
154
|
+
return (_jsx(Select, { ...props, overlayClassName: isRelationSelectOption ? 'wd-relation-select-overlay' : '', searchable: true, listWidth: listWidth, listHeight: _listHeight, matchButtonWidth: _matchButtonWidth, placeholder: placeholder, appearance: 'button', filter: () => true, size: size, disabled: disabled, autoClearSearchValue: true, options: customOptions, value: value, onChange: onChange, onSearch: searchHandle, bottomTips: isLoading ? _jsx(LoadingTip, {}) : undefined, onScrollBottom: () => {
|
|
155
|
+
if (!isLoading && customOptions.length < total) {
|
|
156
|
+
setQuery((query) => ({
|
|
157
|
+
...query,
|
|
158
|
+
pageNo: query.pageNo + defaultPage,
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
}, onOpen: () => {
|
|
162
|
+
setIsLoading(true);
|
|
163
|
+
searchOptionListWithWhere();
|
|
164
|
+
}, footer: addRelationButton, mode: mode }));
|
|
209
165
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConfigProvider } from 'tea-component';
|
|
3
|
-
import { CustomSelect } from '../relationSelect/
|
|
3
|
+
import { CustomSelect } from '../relationSelect/index';
|
|
4
4
|
import { SelectUI as Select } from './selectUI';
|
|
5
5
|
export function SelectCom(props) {
|
|
6
6
|
const { isRelation } = props;
|
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
display: none;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
/* h5 */
|
|
18
|
+
.wd-form-item.wd-h5-select-root .form-select-pc {
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
/* pc */
|
|
18
23
|
.wd-form-item.wd-pc-select-root .form-select-pc {
|
|
19
24
|
width: 100%;
|
|
@@ -165,6 +170,9 @@
|
|
|
165
170
|
.wd-relation-select-overlay .wedatea2td-dropdown-box .wedatea2td-list--option .wedatea2td-list__status {
|
|
166
171
|
padding: 6px 8px;
|
|
167
172
|
}
|
|
173
|
+
.wd-relation-select-overlay .wedatea2td-dropdown-box > div:nth-child(2) {
|
|
174
|
+
min-height: 105px;
|
|
175
|
+
}
|
|
168
176
|
/* h5端关联下拉样式 */
|
|
169
177
|
.weda-ui-custom-picker__cloumns.weda-ui-custom-picker__cloumns--select.wd-relation-select-overlay
|
|
170
178
|
.weda-ui-custom-picker__cloumn-item {
|
|
@@ -9,9 +9,12 @@ import { useSelected } from '../../utils/hooks/use-selected';
|
|
|
9
9
|
import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
|
|
10
10
|
import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
|
|
11
11
|
import { useDelayEvents } from '../../utils/hooks/use-delay-events';
|
|
12
|
+
import { useSyncValue } from '../../utils/hooks/useSyncValue';
|
|
13
|
+
import isObjectEqual from '../../utils/isObjectEqual';
|
|
12
14
|
import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
|
|
13
15
|
import { RelationalSetting } from './relationSelect/relationalSetting';
|
|
14
16
|
import { SelectCom as Select } from './select';
|
|
17
|
+
import { SelectProvider } from './contexts/selectContext';
|
|
15
18
|
/**
|
|
16
19
|
* 下拉单选-标准化
|
|
17
20
|
*/
|
|
@@ -19,7 +22,7 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
|
|
|
19
22
|
const { classRoot = 'select', clearable = X_RUNTIME_DEFAULT.clearable, placeholder, range, format, tipBlock = X_RUNTIME_DEFAULT.tipBlock, where = X_RUNTIME_DEFAULT.where, enumName, primaryField, viewId, dataSourceName, events = emptyObject, ignoreCase = X_RUNTIME_DEFAULT.ignoreCase, staticSearchable = X_RUNTIME_DEFAULT.staticSearchable, enableRelationalSetting = X_RUNTIME_DEFAULT.enableRelationalSetting, enableRelationalRefresh = X_RUNTIME_DEFAULT.enableRelationalRefresh, addRelationButtonText = X_RUNTIME_DEFAULT.addRelationButtonText, enableAddRelationButton = X_RUNTIME_DEFAULT.enableAddRelationButton, enableRelationOptionJump = X_RUNTIME_DEFAULT.enableRelationOptionJump, popupContainer, selectFields: customFields = [], // 自定义展示字段
|
|
20
23
|
selectFieldType = 'primary', searchPlaceholder, } = props;
|
|
21
24
|
const childRef = useRef(null);
|
|
22
|
-
const [options, setOptions] =
|
|
25
|
+
const [options, setOptions] = useSyncValue(range, isObjectEqual);
|
|
23
26
|
const [innerHandle, setInnerHandle] = useState({});
|
|
24
27
|
const traitProps = { ...props, inputRef: ref, setInnerHandle };
|
|
25
28
|
const trait = useFormInputTrait(traitProps);
|
|
@@ -102,11 +105,11 @@ export const WdSelect = forwardRef(function WsSelect(props, ref) {
|
|
|
102
105
|
}, [debouncedTriggerSearchEvent]);
|
|
103
106
|
if (!visible)
|
|
104
107
|
return null;
|
|
105
|
-
return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(Select, { ...props, style: undefined, className: undefined,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
return (_jsx(SelectProvider, { options: options, setOptions: setOptions, children: _jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(Select, { ...props, style: undefined, className: undefined, onRelationTagClick: (item) => {
|
|
109
|
+
var _a;
|
|
110
|
+
(_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationTagClick) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
|
|
111
|
+
}, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
|
|
112
|
+
var _a;
|
|
113
|
+
(_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
|
|
114
|
+
}, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, options: options, size: "full", tipBlock: tipBlock, viewId: viewId, where: where, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "selector", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: true, searchPlaceholder: searchPlaceholder }) }) }), layout === 'horizontal' && LabelAdornment] }) }) }));
|
|
112
115
|
});
|
|
@@ -8,11 +8,14 @@ import { useSelected } from '../../utils/hooks/use-selected';
|
|
|
8
8
|
import { emptyObject } from '../../utils/constant';
|
|
9
9
|
import { useSetWidgetApi } from '../../utils/widget-api/use-set-widget-api';
|
|
10
10
|
import { useDelayEvents } from '../../utils/hooks/use-delay-events';
|
|
11
|
+
import { useSyncValue } from '../../utils/hooks/useSyncValue';
|
|
12
|
+
import isObjectEqual from '../../utils/isObjectEqual';
|
|
11
13
|
import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
|
|
12
14
|
import './style';
|
|
13
15
|
import { useDebouncedCallback, useSyncedRef } from '@react-hookz/web';
|
|
14
16
|
import { isFormatWithRelation } from '../form/select/formats-util';
|
|
15
17
|
import { RelationalSetting } from '../wd-select/relationSelect/relationalSetting';
|
|
18
|
+
import { SelectProvider } from '../wd-select/contexts/selectContext';
|
|
16
19
|
/**
|
|
17
20
|
* 下拉多选-标准化
|
|
18
21
|
*/
|
|
@@ -20,7 +23,7 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
|
|
|
20
23
|
const { classRoot = 'select-multiple', clearable = X_RUNTIME_DEFAULT.clearable, placeholder, range, enumName, format, primaryField, tipBlock = X_RUNTIME_DEFAULT.tipBlock, viewId, dataSourceName, events = emptyObject, ignoreCase = X_RUNTIME_DEFAULT.ignoreCase, staticSearchable = X_RUNTIME_DEFAULT.staticSearchable, where = X_RUNTIME_DEFAULT.where, enableRelationalSetting = X_RUNTIME_DEFAULT.enableRelationalSetting, enableRelationalRefresh = X_RUNTIME_DEFAULT.enableRelationalRefresh, addRelationButtonText = X_RUNTIME_DEFAULT.addRelationButtonText, enableAddRelationButton = X_RUNTIME_DEFAULT.enableAddRelationButton, enableRelationOptionJump = X_RUNTIME_DEFAULT.enableRelationOptionJump, popupContainer, selectFields: customFields = [], // 自定义展示字段
|
|
21
24
|
selectFieldType = 'primary', searchPlaceholder, } = props;
|
|
22
25
|
const childRef = useRef(null);
|
|
23
|
-
const [options, setOptions] =
|
|
26
|
+
const [options, setOptions] = useSyncValue(range, isObjectEqual);
|
|
24
27
|
const [innerHandle, setInnerHandle] = useState({});
|
|
25
28
|
const traitProps = { ...props, inputRef: ref, setInnerHandle };
|
|
26
29
|
const trait = useFormInputTrait(traitProps);
|
|
@@ -98,11 +101,11 @@ export const WdSelectMultiple = forwardRef(function WdSelectMultiple(props, ref)
|
|
|
98
101
|
}, [debouncedTriggerSearchEvent]);
|
|
99
102
|
if (!visible)
|
|
100
103
|
return null;
|
|
101
|
-
return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(SelectMultiple, { ...props, style: undefined, className: undefined,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
return (_jsx(SelectProvider, { options: options, setOptions: setOptions, children: _jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsx(WdInputWrap, { ...inputWrapProps, children: _jsx(SelectMultiple, { ...props, style: undefined, className: undefined, onRelationTagClick: (item) => {
|
|
105
|
+
var _a;
|
|
106
|
+
(_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationTagClick) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
|
|
107
|
+
}, enableRelationOptionJump: enableRelationOptionJump, onRelationOptionJump: (item) => {
|
|
108
|
+
var _a;
|
|
109
|
+
(_a = delayEvents === null || delayEvents === void 0 ? void 0 : delayEvents.onRelationOptionJump) === null || _a === void 0 ? void 0 : _a.call(delayEvents, item);
|
|
110
|
+
}, selectFieldType: selectFieldType, selectFields: customFields, isRelation: isRelation, addRelationButtonText: addRelationButtonText, enableAddRelationButton: enableAddRelationButton, childRef: childRef, events: delayEvents, labelVisible: false, value: value, enumName: enumName, format: format, placeholder: placeholder, primaryField: primaryField, options: options, size: "full", tipBlock: tipBlock, viewId: viewId, dataSourceName: dataSourceName, readOnly: readOnly, disabled: disabled, mode: "multiple", decorator: null, ignoreCase: ignoreCase, staticSearchable: staticSearchable, where: where, onChange: handleChange, onSearch: onSearchValueInput, popupContainer: popupContainer, searchable: true, searchPlaceholder: searchPlaceholder }) }) }), layout === 'horizontal' && LabelAdornment] }) }) }));
|
|
108
111
|
});
|
|
@@ -782,7 +782,7 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
|
|
|
782
782
|
? {
|
|
783
783
|
modelType: 'table-h5',
|
|
784
784
|
showTip: false,
|
|
785
|
-
relation: record[`@${key}`],
|
|
785
|
+
relation: record === null || record === void 0 ? void 0 : record[`@${key}`],
|
|
786
786
|
columnSet: item2,
|
|
787
787
|
rowId: record._id,
|
|
788
788
|
supportManyRelated,
|
|
@@ -791,9 +791,9 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
|
|
|
791
791
|
}
|
|
792
792
|
: {
|
|
793
793
|
modelType: 'table',
|
|
794
|
-
relation: record[`@${key}`],
|
|
794
|
+
relation: record === null || record === void 0 ? void 0 : record[`@${key}`],
|
|
795
795
|
columnSet: item2,
|
|
796
|
-
rowId: record._id,
|
|
796
|
+
rowId: record === null || record === void 0 ? void 0 : record._id,
|
|
797
797
|
supportManyRelated,
|
|
798
798
|
isH5,
|
|
799
799
|
showRelationWithTag,
|
|
@@ -12,7 +12,7 @@ export const fieldCalculations = {
|
|
|
12
12
|
// { text: '不为空', value: '$nempty' },
|
|
13
13
|
],
|
|
14
14
|
string: [
|
|
15
|
-
{ text: '包含', value: '
|
|
15
|
+
{ text: '包含', value: 'search_ci' },
|
|
16
16
|
{ text: '不包含', value: 'exclude' },
|
|
17
17
|
{ text: '等于', value: 'eq' },
|
|
18
18
|
{ text: '不等于', value: 'neq' },
|
|
@@ -70,8 +70,7 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
70
70
|
fieldCalculation,
|
|
71
71
|
options: [],
|
|
72
72
|
};
|
|
73
|
-
if (i.type === 'number' &&
|
|
74
|
-
['time', 'date', 'datetime'].includes(i.format)) {
|
|
73
|
+
if (i.type === 'number' && ['time', 'date', 'datetime'].includes(i.format)) {
|
|
75
74
|
filterFieldItemConfig.filterType = i.format;
|
|
76
75
|
}
|
|
77
76
|
if (i.type === 'boolean') {
|
|
@@ -97,10 +96,8 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
97
96
|
filterFieldItemConfig.filterType = i.format;
|
|
98
97
|
filterFieldItemConfig.xMultiSelect = i['x-multi-select'];
|
|
99
98
|
filterFieldItemConfig.xOptionName = i['x-option-name'];
|
|
100
|
-
filterFieldItemConfig.fieldCalculation.type =
|
|
101
|
-
|
|
102
|
-
filterFieldItemConfig.fieldCalculation.value =
|
|
103
|
-
filterFieldItemConfig.xMultiSelect ? 'in' : 'eq';
|
|
99
|
+
filterFieldItemConfig.fieldCalculation.type = filterFieldItemConfig.xMultiSelect ? 'checkbox' : 'radio';
|
|
100
|
+
filterFieldItemConfig.fieldCalculation.value = filterFieldItemConfig.xMultiSelect ? 'in' : 'eq';
|
|
104
101
|
}
|
|
105
102
|
if (i.format === 'father-son' || i.format === 'related') {
|
|
106
103
|
filterFieldItemConfig.filterType = i.format;
|
|
@@ -115,18 +112,16 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
115
112
|
filterFieldItemConfig.value = ((_c = i.filterConfig) === null || _c === void 0 ? void 0 : _c.value) || '';
|
|
116
113
|
// 默认计算方式
|
|
117
114
|
const customFieldCalculation = fieldCalculationOption === null || fieldCalculationOption === void 0 ? void 0 : fieldCalculationOption.find((option) => { var _a; return option.value === ((_a = i.filterConfig) === null || _a === void 0 ? void 0 : _a.filterType); });
|
|
118
|
-
filterFieldItemConfig.fieldCalculation =
|
|
119
|
-
customFieldCalculation || filterFieldItemConfig.fieldCalculation;
|
|
115
|
+
filterFieldItemConfig.fieldCalculation = customFieldCalculation || filterFieldItemConfig.fieldCalculation;
|
|
120
116
|
// 支持的运算类型
|
|
121
117
|
const customFieldCalculationOptions = fieldCalculationOption === null || fieldCalculationOption === void 0 ? void 0 : fieldCalculationOption.filter((option) => {
|
|
122
118
|
var _a;
|
|
123
119
|
const filterTypeOption = [].concat((_a = i.filterConfig) === null || _a === void 0 ? void 0 : _a.filterTypeOption);
|
|
124
120
|
return filterTypeOption === null || filterTypeOption === void 0 ? void 0 : filterTypeOption.find((j) => (option === null || option === void 0 ? void 0 : option.value) === j);
|
|
125
121
|
});
|
|
126
|
-
filterFieldItemConfig.fieldCalculationOption =
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
: fieldCalculationOption;
|
|
122
|
+
filterFieldItemConfig.fieldCalculationOption = (customFieldCalculationOptions === null || customFieldCalculationOptions === void 0 ? void 0 : customFieldCalculationOptions.length)
|
|
123
|
+
? customFieldCalculationOptions
|
|
124
|
+
: fieldCalculationOption;
|
|
130
125
|
}
|
|
131
126
|
return filterFieldItemConfig;
|
|
132
127
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const deleteRecord: ({ selectedKeys, dataSourceAPI, beforeModalDestroy, supportManyRelated
|
|
1
|
+
export declare const deleteRecord: ({ selectedKeys, dataSourceAPI, beforeModalDestroy, supportManyRelated }: {
|
|
2
2
|
selectedKeys: any;
|
|
3
3
|
dataSourceAPI: any;
|
|
4
4
|
beforeModalDestroy: any;
|
|
@@ -1,7 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Modal } from 'tea-component';
|
|
3
|
+
import { alertErrorMessage } from '../../../utils/platform';
|
|
1
4
|
// 删除数据事件
|
|
2
|
-
export const deleteRecord = ({ selectedKeys, dataSourceAPI, beforeModalDestroy, supportManyRelated
|
|
5
|
+
export const deleteRecord = ({ selectedKeys, dataSourceAPI, beforeModalDestroy, supportManyRelated }) => {
|
|
6
|
+
const deleteAction = async (resolve, reject) => {
|
|
7
|
+
try {
|
|
8
|
+
await dataSourceAPI.batchDeleteRecord(selectedKeys, supportManyRelated);
|
|
9
|
+
beforeModalDestroy();
|
|
10
|
+
alertErrorMessage({
|
|
11
|
+
message: '删除数据成功',
|
|
12
|
+
icon: 'success',
|
|
13
|
+
});
|
|
14
|
+
resolve();
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
const obj = {
|
|
18
|
+
code: error.code,
|
|
19
|
+
message: error.message,
|
|
20
|
+
requestId: error.requestId,
|
|
21
|
+
original: error.original,
|
|
22
|
+
};
|
|
23
|
+
reject(obj);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
3
26
|
return new Promise((resolve, reject) => {
|
|
4
|
-
var _a, _b;
|
|
27
|
+
var _a, _b, _c, _d;
|
|
5
28
|
if (!(selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.length)) {
|
|
6
29
|
reject({
|
|
7
30
|
code: 'WdTable.NoSelectKeys',
|
|
@@ -13,34 +36,28 @@ export const deleteRecord = ({ selectedKeys, dataSourceAPI, beforeModalDestroy,
|
|
|
13
36
|
const msg =
|
|
14
37
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
15
38
|
(selectedKeys === null || selectedKeys === void 0 ? void 0 : selectedKeys.length) > 1 ? '确认删除选定的条目?' : '确认删除此条目?';
|
|
16
|
-
(_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.utils) === null || _b === void 0 ? void 0 : _b.showModal
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// modal.destroy();
|
|
25
|
-
await dataSourceAPI.batchDeleteRecord(selectedKeys, supportManyRelated);
|
|
26
|
-
beforeModalDestroy();
|
|
27
|
-
(_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.utils) === null || _b === void 0 ? void 0 : _b.showToast({
|
|
28
|
-
title: '删除数据成功',
|
|
29
|
-
icon: 'success',
|
|
30
|
-
});
|
|
31
|
-
resolve();
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
const obj = {
|
|
35
|
-
code: error.code,
|
|
36
|
-
message: error.message,
|
|
37
|
-
requestId: error.requestId,
|
|
38
|
-
original: error.original,
|
|
39
|
-
};
|
|
40
|
-
reject(obj);
|
|
39
|
+
if ((_b = (_a = window === null || window === void 0 ? void 0 : window.$w) === null || _a === void 0 ? void 0 : _a.utils) === null || _b === void 0 ? void 0 : _b.showModal) {
|
|
40
|
+
(_d = (_c = window === null || window === void 0 ? void 0 : window.$w) === null || _c === void 0 ? void 0 : _c.utils) === null || _d === void 0 ? void 0 : _d.showModal({
|
|
41
|
+
title: '操作确认',
|
|
42
|
+
content: msg,
|
|
43
|
+
cancelColor: '#000000',
|
|
44
|
+
success: async (res) => {
|
|
45
|
+
if (res.confirm) {
|
|
46
|
+
deleteAction(resolve, reject);
|
|
41
47
|
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const modal = Modal.show({
|
|
53
|
+
className: 'modal-table-delete',
|
|
54
|
+
caption: '操作确认',
|
|
55
|
+
onClose: () => modal.destroy(),
|
|
56
|
+
children: (_jsxs(_Fragment, { children: [_jsx("div", { children: msg }), _jsx(Modal.Footer, { children: _jsx(Button, { type: "primary", onClick: async () => {
|
|
57
|
+
modal.destroy();
|
|
58
|
+
deleteAction(resolve, reject);
|
|
59
|
+
}, children: "\u786E\u8BA4" }) })] })),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
45
62
|
});
|
|
46
63
|
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export function convertWhere(props: any, supportManyRelated: any): any;
|
|
2
|
+
export function getFilter(wList: any): any;
|
|
3
|
+
export function getSelectFields(props: any): any;
|
|
2
4
|
export function getModelParams(props: any): {
|
|
3
5
|
orderBy: any;
|
|
4
6
|
orderType: any;
|
|
5
7
|
filter: any;
|
|
6
|
-
select:
|
|
8
|
+
select: any;
|
|
7
9
|
where: any[];
|
|
8
10
|
};
|
|
11
|
+
export function transformSorter(sorter?: any[]): {
|
|
12
|
+
[x: number]: any;
|
|
13
|
+
}[];
|
|
@@ -24,7 +24,7 @@ export const convertWhere = (props, supportManyRelated) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* 拼接filter参数
|
|
26
26
|
*/
|
|
27
|
-
const getFilter = (wList) => {
|
|
27
|
+
export const getFilter = (wList) => {
|
|
28
28
|
var _a, _b, _c;
|
|
29
29
|
let where = [];
|
|
30
30
|
let filter = { where: {} };
|
|
@@ -62,19 +62,21 @@ const getFilter = (wList) => {
|
|
|
62
62
|
}
|
|
63
63
|
return getParseValue(filter);
|
|
64
64
|
};
|
|
65
|
-
const getSelectFields = (props) => {
|
|
66
|
-
|
|
65
|
+
export const getSelectFields = (props) => {
|
|
66
|
+
const { selectFieldType = 'main', selectFields = [] } = props;
|
|
67
|
+
// 是否具备展示自定义字段的条件
|
|
68
|
+
const isRelationSelectOption = selectFieldType === 'custom' && Array.isArray(selectFields) && (selectFields === null || selectFields === void 0 ? void 0 : selectFields.length);
|
|
67
69
|
// 支持自定义查询字段
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
select
|
|
70
|
+
if (isRelationSelectOption) {
|
|
71
|
+
const select = selectFields.reduce((acc, item) => {
|
|
72
|
+
if (!acc[item]) {
|
|
73
|
+
acc[item] = true;
|
|
74
|
+
}
|
|
75
|
+
return acc;
|
|
76
|
+
}, {});
|
|
77
|
+
return select;
|
|
76
78
|
}
|
|
77
|
-
return
|
|
79
|
+
return { $master: true };
|
|
78
80
|
};
|
|
79
81
|
/**
|
|
80
82
|
* 获取tcb查询条件
|
|
@@ -122,7 +124,8 @@ export const getModelParams = (props) => {
|
|
|
122
124
|
}
|
|
123
125
|
return params;
|
|
124
126
|
};
|
|
125
|
-
|
|
127
|
+
// relationalTableName,后端暂不支持按照关联关系表的字段排序(前端预埋参数)
|
|
128
|
+
export const transformSorter = (sorter = []) => {
|
|
126
129
|
var _a;
|
|
127
130
|
return (_a = sorter === null || sorter === void 0 ? void 0 : sorter.filter((n) => (n.orderBy && n.orderType) || n.relationalTableName)) === null || _a === void 0 ? void 0 : _a.map((i) => {
|
|
128
131
|
var _a, _b;
|
|
@@ -43,8 +43,7 @@ export function usePlatform() {
|
|
|
43
43
|
// 不进行 observer 的目的是不希望出现页面 resize 时切换大小屏
|
|
44
44
|
// 编辑器在大小屏切换时会刷新,所以不需要监听 platforms 变化
|
|
45
45
|
// 由于编辑器中从 mp 和 h5 之间切换不会刷新页面,这里将 mp 也视为小屏幕
|
|
46
|
-
const smallScreen = (_g = (((_c = (_b = (_a = window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.platforms) === null || _c === void 0 ? void 0 : _c.includes(`MOBILEWEB`)) ||
|
|
47
|
-
((_f = (_e = (_d = window.$w) === null || _d === void 0 ? void 0 : _d.wedaContext) === null || _e === void 0 ? void 0 : _e.platforms) === null || _f === void 0 ? void 0 : _f.includes(`MP`)))) !== null && _g !== void 0 ? _g : isH5Platform();
|
|
46
|
+
const smallScreen = (_g = (((_c = (_b = (_a = window.$w) === null || _a === void 0 ? void 0 : _a.wedaContext) === null || _b === void 0 ? void 0 : _b.platforms) === null || _c === void 0 ? void 0 : _c.includes(`MOBILEWEB`)) || ((_f = (_e = (_d = window.$w) === null || _d === void 0 ? void 0 : _d.wedaContext) === null || _e === void 0 ? void 0 : _e.platforms) === null || _f === void 0 ? void 0 : _f.includes(`MP`)))) !== null && _g !== void 0 ? _g : isH5Platform();
|
|
48
47
|
return smallScreen ? 'h5' : 'pc';
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
@@ -239,9 +238,7 @@ export const getWhereList = (where) => {
|
|
|
239
238
|
}
|
|
240
239
|
let [rel, val] = [REL_DICT[item2 === null || item2 === void 0 ? void 0 : item2.rel] || (item2 === null || item2 === void 0 ? void 0 : item2.rel), item2 === null || item2 === void 0 ? void 0 : item2.value];
|
|
241
240
|
// 去掉空字符串、undefined(接口不支持)、对象类型(接口不支持)
|
|
242
|
-
if (val === '' ||
|
|
243
|
-
val === undefined ||
|
|
244
|
-
Object.prototype.toString.call(val) === '[object Object]') {
|
|
241
|
+
if (val === '' || val === undefined || Object.prototype.toString.call(val) === '[object Object]') {
|
|
245
242
|
return;
|
|
246
243
|
}
|
|
247
244
|
if ('_begin_with' === rel) {
|
|
@@ -284,12 +281,12 @@ export const textToString = (text) => {
|
|
|
284
281
|
* 统一错误提示
|
|
285
282
|
*/
|
|
286
283
|
export function alertErrorMessage({ message, duration = 3000, icon = 'none' }) {
|
|
287
|
-
var _a, _b
|
|
288
|
-
const smallScreen =
|
|
289
|
-
const touchDevice =
|
|
290
|
-
const platform = touchDevice || smallScreen ? 'h5' : 'pc';
|
|
291
|
-
if (
|
|
292
|
-
(
|
|
284
|
+
var _a, _b;
|
|
285
|
+
// const smallScreen = window?.matchMedia('(max-width: 768px)')?.matches ?? isH5Platform();
|
|
286
|
+
// const touchDevice = window?.matchMedia('(pointer:coarse)')?.matches ?? smallScreen;
|
|
287
|
+
// const platform = touchDevice || smallScreen ? 'h5' : 'pc';
|
|
288
|
+
if ((_a = window === null || window === void 0 ? void 0 : window.app) === null || _a === void 0 ? void 0 : _a.showToast) {
|
|
289
|
+
(_b = window === null || window === void 0 ? void 0 : window.app) === null || _b === void 0 ? void 0 : _b.showToast({
|
|
293
290
|
title: message,
|
|
294
291
|
icon,
|
|
295
292
|
duration,
|
|
@@ -374,8 +371,7 @@ export const isSupportLoading = () => {
|
|
|
374
371
|
*/
|
|
375
372
|
export const isWebInMiniprogram = () => {
|
|
376
373
|
var ua = navigator.userAgent.toLowerCase();
|
|
377
|
-
return (
|
|
378
|
-
window['__wxjs_environment'] === 'miniprogram');
|
|
374
|
+
return (ua.match(/micromessenger/i) && ua.match(/miniprogram/i)) || window['__wxjs_environment'] === 'miniprogram';
|
|
379
375
|
};
|
|
380
376
|
/**
|
|
381
377
|
* 判断访问终端
|
package/dist/web/utils/tcb.d.ts
CHANGED
|
@@ -42,3 +42,7 @@ export declare const appCloudGetWedaUserId: () => any;
|
|
|
42
42
|
export declare const appCloudIsInWedaIde: () => any;
|
|
43
43
|
export declare const appCloudGetWedaRelatedRoles: () => any;
|
|
44
44
|
export declare function appCloudShowWedaToast(params: any): any;
|
|
45
|
+
/**
|
|
46
|
+
* 设置默认上传路径
|
|
47
|
+
*/
|
|
48
|
+
export declare const getDefaultUploadPath: (uploadPath: any) => any;
|