fix: 优化筛选组件文本情况时加2s延迟,轮播图没有数据时添加提示 close #735 (#738)

Reviewed-on: daoyoucloud/tachycode#738
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-04-16 21:02:13 +08:00 committed by sealday
parent c7c497659d
commit 9d1d490f6e
4 changed files with 67 additions and 28 deletions

View File

@ -0,0 +1,5 @@
---
"@hera/plugin-mobile": patch
---
优化筛选组件在文本框情况时候延迟2s轮播图组件没有数据添加提示

View File

@ -2,38 +2,54 @@ import { BlockItem, css, useDesignable, useRequest, withDynamicSchemaProps } fro
import { useFieldSchema } from '@nocobase/schema';
import { Swiper } from 'antd-mobile';
import React, { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
export const SwiperBlock = withDynamicSchemaProps((props) => {
const { fieldValue, data, changeNav } = props;
if (!data) return;
const items = data['data']
?.map((imgItem, index) => {
return imgItem[fieldValue] ? (
<Swiper.Item key={index}>
const items = data['data'].length
? data['data']
.map((imgItem, index) => {
return imgItem[fieldValue][0]?.url ? (
<Swiper.Item key={index}>
<div
className={swiperStyle}
style={{
backgroundImage: `url(${imgItem[fieldValue][0]?.url})`,
backgroundSize: '100% 100%',
backgroundAttachment: 'fixed',
}}
onClick={() => {
changeNav(imgItem);
}}
></div>
</Swiper.Item>
) : (
<Swiper.Item key={index}>
<div
className={swiperStyle}
style={{
backgroundColor: '#e0e0e0',
}}
>
</div>
</Swiper.Item>
);
})
.filter(Boolean)
: [
<Swiper.Item key={0}>
<div
className={css`
height: 20vh;
color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
font-size: 48px;
user-select: none;
`}
className={swiperStyle}
style={{
backgroundImage: `url(${imgItem[fieldValue][0].url})`,
backgroundSize: '100% 100%',
backgroundAttachment: 'fixed',
backgroundColor: '#e0e0e0',
}}
onClick={() => {
changeNav(imgItem);
}}
></div>
</Swiper.Item>
) : null;
})
.filter(Boolean);
>
</div>
</Swiper.Item>,
];
return (
<BlockItem>
<Swiper loop autoplay>
@ -42,3 +58,13 @@ export const SwiperBlock = withDynamicSchemaProps((props) => {
</BlockItem>
);
});
const swiperStyle = css`
height: 20vh;
color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
font-size: 25px;
user-select: none;
`;

View File

@ -8,6 +8,7 @@ import {
import React from 'react';
import { createGridCardBlockSchema } from '../../schma-block/schema-create/createGridCardBlockSchma';
import { ISchema } from '@nocobase/schema';
import { Toast } from 'antd-mobile';
export const SwiperBlockInitializer = () => {
const { insert } = useSchemaInitializer();
@ -17,7 +18,10 @@ export const SwiperBlockInitializer = () => {
const onCreateBlockSchema = async ({ item }) => {
const collection = cm.getCollection(item.name);
const value = collection.fields.find((field) => field.interface === 'attachment');
if (!value) return;
if (!value) {
Toast.show({ content: '当前数据源暂无可加载数据' });
return;
}
const schema: ISchema = {
type: 'void',
name: item.name,

View File

@ -1,4 +1,4 @@
import { useMemo, useState } from 'react';
import { useMemo, useRef, useState } from 'react';
import { useFieldSchema } from '@nocobase/schema';
import { useCollection, useCollectionManager, useDesignable, useDesigner } from '@nocobase/client';
import {
@ -79,10 +79,14 @@ export const useTabSearchCollapsibleInputItemAction = (props) => {
setCustomLabelKey(label as string);
};
const onInputChange = (v) => {
const timeout = { current: null };
clearTimeout(timeout.current);
const inputValue = v.target?.value || v;
setValue(inputValue);
if (inputValue === '') {
onSelect(inputValue);
timeout.current = setTimeout(() => {
onSelect(inputValue);
}, 2000);
}
};
const onButtonClick = () => {