@tbox.cn/app-card-assets 0.1.0 → 1.0.0-alpha.10
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 +3 -1
- package/SOURCE.md +1 -1
- package/assets.json +3 -22
- package/components/Banner/index.tsx +2 -3
- package/components/BlockAnimal/LottiePlayer/index.tsx +2 -3
- package/components/BlockAnimal/index.tsx +13 -14
- package/components/BlockBarrage/index.tsx +10 -11
- package/components/BlockFanSwiper/index.tsx +6 -7
- package/components/BlockIntro/index.tsx +4 -5
- package/components/BlockIntroCenter/index.tsx +3 -4
- package/components/BlockNowList/index.tsx +10 -8
- package/components/BlockQuestionList/index.tsx +12 -13
- package/components/BlockServiceIconList/index.tsx +20 -18
- package/components/BlockServiceList/index.tsx +10 -11
- package/components/BlockTravelCarousel/index.tsx +142 -33
- package/components/BlockTravelCarousel/tags/Tags.tsx +2 -3
- package/components/OneCol/index.tsx +18 -19
- package/components/TwoCol/index.tsx +16 -17
- package/docs/Banner.md +1 -1
- package/docs/BlockAnimal.md +1 -1
- package/docs/BlockBarrage.md +1 -1
- package/docs/BlockFanSwiper.md +1 -1
- package/docs/BlockIntro.md +1 -1
- package/docs/BlockIntroCenter.md +1 -1
- package/docs/BlockNowList.md +1 -1
- package/docs/BlockQuestionList.md +1 -1
- package/docs/BlockServiceIconList.md +1 -1
- package/docs/BlockServiceList.md +1 -1
- package/docs/BlockTravelCarousel.md +3 -1
- package/docs/OneCol.md +1 -1
- package/docs/TwoCol.md +1 -1
- package/package.json +1 -3
- package/shared/home-integration.md +18 -16
- package/components/Banner/index.module.less +0 -11
- package/components/BlockAnimal/LottiePlayer/index.module.less +0 -11
- package/components/BlockAnimal/index.module.less +0 -78
- package/components/BlockBarrage/index.module.less +0 -101
- package/components/BlockFanSwiper/index.module.less +0 -89
- package/components/BlockIntro/index.module.less +0 -31
- package/components/BlockIntroCenter/index.module.less +0 -30
- package/components/BlockNowList/index.module.less +0 -72
- package/components/BlockQuestionList/index.module.less +0 -113
- package/components/BlockServiceIconList/index.module.less +0 -62
- package/components/BlockServiceList/index.module.less +0 -89
- package/components/BlockTravelCarousel/index.module.less +0 -125
- package/components/BlockTravelCarousel/tags/Tags.module.less +0 -20
- package/components/OneCol/index.module.less +0 -158
- package/components/TwoCol/index.module.less +0 -191
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { runCardClick } from '../../shared/actions';
|
|
2
2
|
import type { CardAssetProps as ICardProps } from '../../shared/types';
|
|
3
|
-
import React, { useState } from 'react';
|
|
4
|
-
import { Swiper } from 'antd-mobile';
|
|
5
|
-
import styles from './index.module.less';
|
|
3
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
6
4
|
import Tags from './tags/Tags';
|
|
7
5
|
|
|
8
6
|
interface BlockTravelCarouselProps extends ICardProps {
|
|
@@ -20,6 +18,10 @@ interface BlockTravelCarouselProps extends ICardProps {
|
|
|
20
18
|
query?: string;
|
|
21
19
|
}>;
|
|
22
20
|
} & ICardProps['cardData'];
|
|
21
|
+
/** 自动播放间隔(毫秒),默认 3000。 */
|
|
22
|
+
autoplayInterval?: number;
|
|
23
|
+
/** 当前页变化回调(0 基),用于外部联动。 */
|
|
24
|
+
onIndexChange?: (index: number) => void;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
interface CarouselItemProps {
|
|
@@ -32,65 +34,172 @@ interface CarouselItemProps {
|
|
|
32
34
|
const CarouselItem: React.FC<CarouselItemProps> = ({ item, hotTitle, hasDesc, onClick }) => {
|
|
33
35
|
return (
|
|
34
36
|
<div
|
|
35
|
-
className=
|
|
37
|
+
className="relative h-[448px] w-full bg-cover bg-center bg-no-repeat box-border"
|
|
36
38
|
style={{
|
|
37
39
|
backgroundImage: `url(${item.imageUrl})`,
|
|
38
40
|
}}
|
|
39
41
|
onClick={onClick}
|
|
40
42
|
>
|
|
41
|
-
<div className=
|
|
42
|
-
<span className=
|
|
43
|
-
<div className=
|
|
44
|
-
<div className=
|
|
45
|
-
<span className=
|
|
43
|
+
<div className="absolute top-[224px] left-0 h-[224px] w-full rounded-b-[24px] bg-[linear-gradient(to_bottom,rgba(0,0,0,0),rgba(0,0,0,0.5))]" />
|
|
44
|
+
<span className="absolute top-6 left-6 rounded-[8px] bg-[linear-gradient(90deg,#fe5500_0%,#ff8e00_100%)] px-[10px] text-center text-[length:22px] font-medium text-white box-border">{hotTitle}</span>
|
|
45
|
+
<div className="absolute bottom-8 w-full px-6">
|
|
46
|
+
<div className="flex items-center box-border">
|
|
47
|
+
<span className="mb-3 whitespace-nowrap text-[length:40px] font-medium leading-[48px] text-white box-border">{item.title}</span>
|
|
46
48
|
{hasDesc && item.tags && (
|
|
47
|
-
<div className=
|
|
49
|
+
<div className="ml-4">
|
|
48
50
|
<Tags tags={item.tags} />
|
|
49
51
|
</div>
|
|
50
52
|
)}
|
|
51
53
|
</div>
|
|
52
54
|
{!hasDesc && item.tags && (
|
|
53
|
-
<div className=
|
|
55
|
+
<div className="mt-3">
|
|
54
56
|
<Tags tags={item.tags} />
|
|
55
57
|
</div>
|
|
56
58
|
)}
|
|
57
|
-
{hasDesc && item.desc && <span className=
|
|
59
|
+
{hasDesc && item.desc && <span className="mt-4 text-ellipsis text-2xl font-medium leading-[32px] tracking-[1px] text-white opacity-70">{item.desc}</span>}
|
|
58
60
|
</div>
|
|
59
61
|
</div>
|
|
60
62
|
);
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
/** 滑动判定阈值(px):小于它视为误触,回弹到当前页。 */
|
|
66
|
+
const SWIPE_THRESHOLD = 40;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 旅行轮播(首页 banner 位)。
|
|
70
|
+
*
|
|
71
|
+
* 自实现而不是引组件库:只用到「按页平移 + 自动播放 + 触摸切换」三件事——
|
|
72
|
+
* 轨道 = 首尾各复制一张的无缝循环(`pos` 在 [1, count],越界后无动画回跳),
|
|
73
|
+
* 拖动时轨道跟手(`dragX` 像素偏移),松手过阈值换页。触摸期间暂停自动播放。
|
|
74
|
+
*/
|
|
75
|
+
const BlockTravelCarousel: React.FC<BlockTravelCarouselProps> = ({
|
|
76
|
+
cardData = {},
|
|
77
|
+
bridgeAPI,
|
|
78
|
+
autoplayInterval = 3000,
|
|
79
|
+
onIndexChange,
|
|
80
|
+
}) => {
|
|
64
81
|
const { hotTitle, list = [] } = cardData;
|
|
65
|
-
const
|
|
82
|
+
const count = list.length;
|
|
83
|
+
const loop = count > 1;
|
|
84
|
+
const [pos, setPos] = useState(1);
|
|
85
|
+
const [dragX, setDragX] = useState(0);
|
|
86
|
+
const [noTransition, setNoTransition] = useState(false);
|
|
87
|
+
const [paused, setPaused] = useState(false);
|
|
88
|
+
const trackRef = useRef<HTMLDivElement>(null);
|
|
89
|
+
const startXRef = useRef<number | null>(null);
|
|
66
90
|
const hasDesc = !!list[0]?.desc;
|
|
91
|
+
const currentIndex = count > 0 ? (pos - 1 + count) % count : 0;
|
|
67
92
|
|
|
68
93
|
const handleClick = (item: any) => runCardClick(bridgeAPI, item);
|
|
69
94
|
|
|
70
|
-
|
|
95
|
+
// 数据变化(换一批 banner)时回到第一张。
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
setPos(1);
|
|
98
|
+
}, [count]);
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!count) return;
|
|
102
|
+
onIndexChange?.(currentIndex);
|
|
103
|
+
}, [currentIndex, count, onIndexChange]);
|
|
104
|
+
|
|
105
|
+
const step = useCallback((direction: 1 | -1) => {
|
|
106
|
+
setNoTransition(false);
|
|
107
|
+
setPos((value) => value + direction);
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
// 走到复制张后无动画回跳真实张:先关过渡改位置,下一帧恢复过渡。
|
|
111
|
+
const snapTo = useCallback((target: number) => {
|
|
112
|
+
const track = trackRef.current;
|
|
113
|
+
if (track) track.style.transition = 'none';
|
|
114
|
+
setPos(target);
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
requestAnimationFrame(() => {
|
|
117
|
+
if (trackRef.current) trackRef.current.style.transition = '';
|
|
118
|
+
setNoTransition(false);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
}, []);
|
|
122
|
+
|
|
123
|
+
// 回跳时机:动画自然结束(transitionend)是主路径;减少动效/无过渡时用超时兜底,
|
|
124
|
+
// 避免停在复制张上让「下一张」多滑一格。
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!loop || (pos >= 1 && pos <= count)) return undefined;
|
|
127
|
+
const timer = setTimeout(() => snapTo(pos < 1 ? count : 1), 400);
|
|
128
|
+
return () => clearTimeout(timer);
|
|
129
|
+
}, [pos, count, loop, snapTo]);
|
|
130
|
+
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (!loop || paused) return undefined;
|
|
133
|
+
const timer = setInterval(() => {
|
|
134
|
+
setNoTransition(false);
|
|
135
|
+
setPos((value) => value + 1);
|
|
136
|
+
}, autoplayInterval);
|
|
137
|
+
return () => clearInterval(timer);
|
|
138
|
+
}, [loop, paused, autoplayInterval]);
|
|
71
139
|
|
|
72
|
-
|
|
140
|
+
if (!count) return null;
|
|
141
|
+
|
|
142
|
+
const dotsBoxClass = hasDesc
|
|
143
|
+
? 'absolute bottom-3 left-0 flex w-full items-center justify-center'
|
|
144
|
+
: 'absolute right-6 bottom-8';
|
|
145
|
+
|
|
146
|
+
const slides = loop ? [list[count - 1], ...list, list[0]] : list;
|
|
147
|
+
const offset = loop ? pos : currentIndex;
|
|
148
|
+
const dragOffset = startXRef.current === null ? 0 : dragX;
|
|
73
149
|
|
|
74
150
|
return (
|
|
75
|
-
<div className=
|
|
76
|
-
<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
151
|
+
<div className="relative mb-7 h-[448px] w-full min-w-0 rounded-[24px] leading-normal box-border">
|
|
152
|
+
<div className="h-[448px] w-full overflow-hidden rounded-[24px]" data-tbox-travel-carousel="">
|
|
153
|
+
<div
|
|
154
|
+
ref={trackRef}
|
|
155
|
+
className={`flex h-full touch-pan-y ${noTransition || dragOffset !== 0 ? '' : 'transition-transform duration-300 ease-out'} motion-reduce:transition-none`}
|
|
156
|
+
style={{ transform: `translateX(calc(${-offset * 100}% + ${dragOffset}px))` }}
|
|
157
|
+
onTransitionEnd={() => {
|
|
158
|
+
setNoTransition(false);
|
|
159
|
+
if (pos > count) snapTo(1);
|
|
160
|
+
else if (pos < 1) snapTo(count);
|
|
161
|
+
}}
|
|
162
|
+
onTouchStart={(event) => {
|
|
163
|
+
if (!loop) return;
|
|
164
|
+
startXRef.current = event.touches[0].clientX;
|
|
165
|
+
setPaused(true);
|
|
166
|
+
setNoTransition(true);
|
|
167
|
+
}}
|
|
168
|
+
onTouchMove={(event) => {
|
|
169
|
+
if (startXRef.current === null) return;
|
|
170
|
+
setDragX(event.touches[0].clientX - startXRef.current);
|
|
171
|
+
}}
|
|
172
|
+
onTouchEnd={(event) => {
|
|
173
|
+
const start = startXRef.current;
|
|
174
|
+
if (start === null) return;
|
|
175
|
+
const delta = event.changedTouches[0].clientX - start;
|
|
176
|
+
startXRef.current = null;
|
|
177
|
+
setDragX(0);
|
|
178
|
+
setPaused(false);
|
|
179
|
+
if (Math.abs(delta) > SWIPE_THRESHOLD) {
|
|
180
|
+
step(delta > 0 ? -1 : 1);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
setNoTransition(false);
|
|
184
|
+
}}
|
|
185
|
+
onTouchCancel={() => {
|
|
186
|
+
startXRef.current = null;
|
|
187
|
+
setDragX(0);
|
|
188
|
+
setPaused(false);
|
|
189
|
+
setNoTransition(false);
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
{slides.map((item, index) => (
|
|
193
|
+
<div key={index} className="h-full w-full min-w-0 shrink-0 grow-0 basis-full">
|
|
194
|
+
<CarouselItem item={item} hotTitle={hotTitle} hasDesc={hasDesc} onClick={() => handleClick(item)} />
|
|
195
|
+
</div>
|
|
196
|
+
))}
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
90
199
|
<div className={dotsBoxClass}>
|
|
91
|
-
<div className=
|
|
200
|
+
<div className="flex justify-center">
|
|
92
201
|
{list.map((_, index) => (
|
|
93
|
-
<div key={index} className={
|
|
202
|
+
<div key={index} className={`mx-1 h-2 rounded-[4px] ${currentIndex === index ? 'w-[23px] bg-white' : 'w-2 bg-[rgba(255,255,255,0.4)]'}`} />
|
|
94
203
|
))}
|
|
95
204
|
</div>
|
|
96
205
|
</div>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import styles from './Tags.module.less';
|
|
3
2
|
|
|
4
3
|
interface TagsProps {
|
|
5
4
|
tags?: string[];
|
|
@@ -7,9 +6,9 @@ interface TagsProps {
|
|
|
7
6
|
|
|
8
7
|
const Tags: React.FC<TagsProps> = ({ tags = [] }) => {
|
|
9
8
|
return (
|
|
10
|
-
<div className=
|
|
9
|
+
<div className="flex box-border">
|
|
11
10
|
{tags.map((tag, index) => (
|
|
12
|
-
<span key={index} className=
|
|
11
|
+
<span key={index} className="mr-3 flex h-[38px] items-center justify-center rounded-[19px] border-[1.5px] border-solid border-[#6c6e7e] bg-[rgba(255,255,255,0.14)] px-3 text-2xl leading-[inherit] text-white box-border">
|
|
13
12
|
{tag}
|
|
14
13
|
</span>
|
|
15
14
|
))}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { runCardClick } from '../../shared/actions';
|
|
2
2
|
import type { CardAssetProps as ICardProps } from '../../shared/types';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import styles from './index.module.less';
|
|
5
4
|
|
|
6
5
|
interface OneColProps extends ICardProps {
|
|
7
6
|
cardData?: {
|
|
@@ -24,49 +23,49 @@ const OneCol: React.FC<OneColProps> = ({ cardData: { button = [], logo, welcome,
|
|
|
24
23
|
const handleClick = (item: any) => runCardClick(bridgeAPI, item);
|
|
25
24
|
|
|
26
25
|
return (
|
|
27
|
-
<div className=
|
|
28
|
-
<div className=
|
|
29
|
-
<div className=
|
|
26
|
+
<div className="mb-7 box-border w-full min-w-0 px-6 pt-[100px] leading-normal">
|
|
27
|
+
<div className="relative flex items-center rounded-[48px] bg-[rgba(255,255,255,0.5)] pt-[118px] pb-[15px] shadow-[0_2px_38px_#0f2a3138]">
|
|
28
|
+
<div className="w-full">
|
|
30
29
|
{logo && (
|
|
31
|
-
<div className=
|
|
32
|
-
<div className=
|
|
33
|
-
<img src={logo} className=
|
|
30
|
+
<div className="absolute -top-20 flex w-full items-center justify-center">
|
|
31
|
+
<div className="rounded-full bg-[linear-gradient(143deg,#8f64ff_0%,#92b2ff_35%,#bbd5ff_54%,#8dc4ff_73%,#33e4ff_100%)] p-1 leading-[0]">
|
|
32
|
+
<img src={logo} className="h-[148px] w-[148px] rounded-full" alt="logo" />
|
|
34
33
|
</div>
|
|
35
34
|
</div>
|
|
36
35
|
)}
|
|
37
|
-
{welcome && <div className=
|
|
36
|
+
{welcome && <div className="mb-1 shrink overflow-hidden px-6 pb-6 text-center text-3xl font-semibold leading-[42px] text-[#1f3b63] text-ellipsis break-all line-clamp-2">{welcome}</div>}
|
|
38
37
|
{desc && (
|
|
39
|
-
<div className=
|
|
40
|
-
<div className=
|
|
38
|
+
<div className="mx-8">
|
|
39
|
+
<div className="text-3xl leading-[48px] text-[#1f3b63]">{desc}</div>
|
|
41
40
|
</div>
|
|
42
41
|
)}
|
|
43
|
-
<div className=
|
|
42
|
+
<div className="px-6 pt-6">
|
|
44
43
|
{button.map((item, index) => (
|
|
45
44
|
<div
|
|
46
45
|
key={index}
|
|
47
|
-
className=
|
|
46
|
+
className="mb-4"
|
|
48
47
|
>
|
|
49
48
|
<div
|
|
50
|
-
className={
|
|
49
|
+
className={`flex items-center justify-between rounded-[48px] bg-white ${item.clickAction === 'link' ? 'bg-[url(https://mdn.alipayobjects.com/huamei_utmyzw/afts/img/wZNXQpLLo_kAAAAAAAAAAAAADrkDAQFr/original)] bg-[length:100%_100%] bg-left-top' : ''}`}
|
|
51
50
|
style={{
|
|
52
51
|
padding: (item.description ?? item.desc) ? '0.08rem 0.16rem' : '0.24rem 0.28rem',
|
|
53
52
|
}}
|
|
54
53
|
onClick={() => handleClick(item)}
|
|
55
54
|
>
|
|
56
|
-
<div className=
|
|
57
|
-
<div className=
|
|
58
|
-
{item.icon && <img src={item.icon} className=
|
|
55
|
+
<div className="mr-2 shrink">
|
|
56
|
+
<div className="flex items-center">
|
|
57
|
+
{item.icon && <img src={item.icon} className="mr-2 h-8 w-8 shrink-0" alt="icon" />}
|
|
59
58
|
<div
|
|
60
|
-
className={(item.description ?? item.desc) ?
|
|
59
|
+
className={(item.description ?? item.desc) ? 'mb-1 shrink overflow-hidden px-6 pb-6 text-center text-3xl font-semibold leading-[42px] text-[#1f3b63] text-ellipsis break-all line-clamp-2' : 'shrink overflow-hidden text-ellipsis break-all line-clamp-2 text-3xl font-normal leading-[42px]'}
|
|
61
60
|
style={{ color: item.clickAction === 'link' ? '#367EEB' : '#1f3b63' }}
|
|
62
61
|
>
|
|
63
62
|
{item.title}
|
|
64
63
|
</div>
|
|
65
64
|
</div>
|
|
66
|
-
{(item.description ?? item.desc) && <div className=
|
|
65
|
+
{(item.description ?? item.desc) && <div className="text-2xl leading-[42px] text-[#8090a6]">{(item.description ?? item.desc)}</div>}
|
|
67
66
|
</div>
|
|
68
67
|
<img
|
|
69
|
-
className=
|
|
68
|
+
className="w-8"
|
|
70
69
|
src="https://mdn.alipayobjects.com/huamei_dlpkmn/afts/img/A*-uhCQ6Ttuj0AAAAAAAAAAAAADty4AQ/original"
|
|
71
70
|
alt="arrow"
|
|
72
71
|
/>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { runCardClick } from '../../shared/actions';
|
|
2
2
|
import type { CardAssetProps as ICardProps } from '../../shared/types';
|
|
3
3
|
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import styles from './index.module.less';
|
|
5
4
|
|
|
6
5
|
interface TwoColProps extends ICardProps {
|
|
7
6
|
cardData?: {
|
|
@@ -42,35 +41,35 @@ const TwoCol: React.FC<TwoColProps> = ({ cardData = {}, bridgeAPI }) => {
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
return (
|
|
45
|
-
<div className=
|
|
46
|
-
<div className=
|
|
47
|
-
<div className=
|
|
44
|
+
<div className="mb-7 w-full min-w-0 box-border px-6 pt-[100px]">
|
|
45
|
+
<div className="relative flex items-center rounded-[48px] bg-[rgba(255,255,255,0.5)] pt-[118px] pb-8 shadow-[0_2px_38px_#0f2a3138]">
|
|
46
|
+
<div className="w-full min-w-0">
|
|
48
47
|
{(logo || welcome || desc) && (
|
|
49
|
-
<div className=
|
|
50
|
-
<div className=
|
|
51
|
-
<img src={logo} className=
|
|
48
|
+
<div className="absolute -top-20 flex w-full items-center justify-center">
|
|
49
|
+
<div className="rounded-full bg-[linear-gradient(143deg,#8f64ff_0%,#92b2ff_35%,#bbd5ff_54%,#8dc4ff_73%,#33e4ff_100%)] p-1 leading-[0]">
|
|
50
|
+
<img src={logo} className="h-[148px] w-[148px] rounded-full" alt="logo" />
|
|
52
51
|
</div>
|
|
53
52
|
</div>
|
|
54
53
|
)}
|
|
55
|
-
{welcome && <div className=
|
|
54
|
+
{welcome && <div className="px-6 pb-6 text-center text-3xl font-semibold leading-[48px] text-[#1f3b63]">{welcome}</div>}
|
|
56
55
|
{desc && (
|
|
57
|
-
<div className=
|
|
58
|
-
<div className=
|
|
56
|
+
<div className="mx-8">
|
|
57
|
+
<div className="text-3xl leading-[48px] text-[#1f3b63]">{desc}</div>
|
|
59
58
|
</div>
|
|
60
59
|
)}
|
|
61
|
-
<div className=
|
|
60
|
+
<div className="grid grid-cols-2 gap-3 whitespace-normal px-6 pt-6 box-border">
|
|
62
61
|
{listData.map((item, index) => (
|
|
63
|
-
<div key={index} className={
|
|
64
|
-
{item.class && <div className=
|
|
65
|
-
<div className=
|
|
66
|
-
<div className=
|
|
62
|
+
<div key={index} className={`relative mt-3 w-full min-w-0 rounded-[24px] border border-solid border-[rgba(141,159,184,0.4)] bg-white px-6 py-5 box-border${index === listData.length - 1 && listData.length % 2 === 1 ? ' col-span-2' : ''}`} onClick={() => handleClick(item)}>
|
|
63
|
+
{item.class && <div className="absolute -top-[9px] left-0 rounded-[16px] bg-[#60aaf9] px-3 py-1 text-xl leading-[18px] text-white">{item.class}</div>}
|
|
64
|
+
<div className="flex items-center justify-between">
|
|
65
|
+
<div className="min-w-0 flex-1 truncate text-3xl font-medium leading-[38px] text-[#1f3b63]">{item.title}</div>
|
|
67
66
|
<img
|
|
68
|
-
className=
|
|
67
|
+
className="ml-[10px] h-6 w-6 shrink-0"
|
|
69
68
|
src="https://mdn.alipayobjects.com/huamei_xdqfqd/afts/img/qFhvRJ4k084AAAAAAAAAAAAADmgHAQFr/original"
|
|
70
69
|
alt="arrow"
|
|
71
70
|
/>
|
|
72
71
|
</div>
|
|
73
|
-
{item.desc && <div className=
|
|
72
|
+
{item.desc && <div className="mt-3 truncate text-[length:22px] leading-[30px] text-[#1f3b63] opacity-[0.45] break-all">{item.desc}</div>}
|
|
74
73
|
</div>
|
|
75
74
|
))}
|
|
76
75
|
</div>
|
package/docs/Banner.md
CHANGED
|
@@ -14,4 +14,4 @@ import Banner from '@/components/home/components/Banner';
|
|
|
14
14
|
<Banner cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/docs/BlockAnimal.md
CHANGED
|
@@ -14,4 +14,4 @@ import BlockAnimal from '@/components/home/components/BlockAnimal';
|
|
|
14
14
|
<BlockAnimal cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/docs/BlockBarrage.md
CHANGED
|
@@ -14,4 +14,4 @@ import BlockBarrage from '@/components/home/components/BlockBarrage';
|
|
|
14
14
|
<BlockBarrage cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/docs/BlockFanSwiper.md
CHANGED
|
@@ -14,4 +14,4 @@ import BlockFanSwiper from '@/components/home/components/BlockFanSwiper';
|
|
|
14
14
|
<BlockFanSwiper cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/docs/BlockIntro.md
CHANGED
|
@@ -14,4 +14,4 @@ import BlockIntro from '@/components/home/components/BlockIntro';
|
|
|
14
14
|
<BlockIntro cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/docs/BlockIntroCenter.md
CHANGED
|
@@ -14,4 +14,4 @@ import BlockIntroCenter from '@/components/home/components/BlockIntroCenter';
|
|
|
14
14
|
<BlockIntroCenter cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/docs/BlockNowList.md
CHANGED
|
@@ -14,4 +14,4 @@ import BlockNowList from '@/components/home/components/BlockNowList';
|
|
|
14
14
|
<BlockNowList cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
|
@@ -14,4 +14,4 @@ import BlockQuestionList from '@/components/home/components/BlockQuestionList';
|
|
|
14
14
|
<BlockQuestionList cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
|
@@ -14,4 +14,4 @@ import BlockServiceIconList from '@/components/home/components/BlockServiceIconL
|
|
|
14
14
|
<BlockServiceIconList cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/docs/BlockServiceList.md
CHANGED
|
@@ -14,4 +14,4 @@ import BlockServiceList from '@/components/home/components/BlockServiceList';
|
|
|
14
14
|
<BlockServiceList cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
|
@@ -14,4 +14,6 @@ import BlockTravelCarousel from '@/components/home/components/BlockTravelCarouse
|
|
|
14
14
|
<BlockTravelCarousel cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
轮播为自实现(无第三方轮播依赖):轨道在首尾各复制一张做无缝循环,拖动跟手、松手过 40px 阈值翻页,触摸期间暂停自动播放。可选 props:`autoplayInterval`(默认 3000ms)、`onIndexChange(index)`(0 基)。
|
|
18
|
+
|
|
19
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准(本组件当前无依赖)。
|
package/docs/OneCol.md
CHANGED
|
@@ -14,4 +14,4 @@ import OneCol from '@/components/home/components/OneCol';
|
|
|
14
14
|
<OneCol cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/docs/TwoCol.md
CHANGED
|
@@ -14,4 +14,4 @@ import TwoCol from '@/components/home/components/TwoCol';
|
|
|
14
14
|
<TwoCol cardData={/* 按示例填写 */} bridgeAPI={bridge} />
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
组件样式是 TSX 内的 Tailwind 工具类,由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 自动生成;不携带独立样式文件。尺寸与字号沿用原值(普通物理 px,1:1,不做折半);组合父容器宽度与布局约定见 [接入本地首页](../shared/home-integration.md#容器宽度),可直接改本地源码、顺序、样式和数据。图片 URL 仅为示例,生产使用部署者素材;没有请求真实业务数据。依赖声明以 assets.json 为准。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbox.cn/app-card-assets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "可复制、可编辑的卡片源码资源",
|
|
6
6
|
"files": [
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
"@types/react": "18.3.31",
|
|
23
23
|
"@types/node": "24.13.3",
|
|
24
24
|
"react": "18.3.1",
|
|
25
|
-
"antd-mobile-icons": "0.3.0",
|
|
26
|
-
"antd-mobile": "5.39.0",
|
|
27
25
|
"lottie-web": "5.13.0",
|
|
28
26
|
"jszip": "3.10.1",
|
|
29
27
|
"vitest": "4.1.10",
|
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
# 接入本地首页
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`home add` 复制源码并声明依赖,运行 `pnpm install` 后,在 `apps/client/src/components/home/Home.tsx` 组合组件。用法和数据示例见复制目录的 `docs/`、`examples/`,本地源码可直接修改。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 注册首页
|
|
6
6
|
|
|
7
|
-
在 apps/client/src/
|
|
8
|
-
|
|
9
|
-
在 apps/client/src/cards/registry.ts 的 registerAll(ctx) 之后,先检查 ctx.slots.has('home')。已有 home(尤其 mall-core)时停止自动接线,确认是否替换及门禁等业务副作用如何保留,不能直接覆盖。无 home 时导入本地 Home 并注册;该文件扩展名为 .ts,使用 createElement:
|
|
7
|
+
在 `apps/client/src/cards/registry.ts` 取得 ctx 之后注册:页面首次 import 该文件发生在模块注册完成之后、ChatPage 渲染之前。先检查 `ctx.slots.has('home')`。已有用户 home 时先确认替换方案和业务副作用。mall-core 通过 conversationOverlay 槽独立挂载会员授权/入会浮层,应用可注册 home 槽组装首页。无 home 时导入本地 Home 并注册;该文件扩展名为 `.ts`,使用 `createElement`:
|
|
10
8
|
|
|
11
9
|
```ts
|
|
12
10
|
import { createElement } from 'react';
|
|
13
|
-
import Home from '
|
|
11
|
+
import Home from '@/components/home/Home';
|
|
14
12
|
|
|
15
|
-
//
|
|
13
|
+
// registry.ts 内 const ctx = getClientContext(); 之后;保持原有 cards/filter/slots 导出。
|
|
16
14
|
if (ctx.slots.has('home')) throw new Error('已有首页,请确认替换方案');
|
|
17
15
|
ctx.slots.register('home', (props) => createElement(Home, props));
|
|
18
16
|
```
|
|
19
17
|
|
|
20
|
-
Home 的 props 使用
|
|
21
|
-
|
|
22
|
-
## 点击与资源
|
|
18
|
+
Home 的 props 使用 `@tbox.cn/app-contracts` 的 `HomeSlotRenderProps`。不要在 slot 回调里直接运行 Hooks;由 Home 组件处理状态。模板 ChatPage 已按 historyMessages、messages、inlineOrphanCards 判断首页显隐,无需再创建一套显隐逻辑。首页收起时子组件卸载,轮播、弹幕等按自身清理函数停止动画。
|
|
23
19
|
|
|
24
|
-
|
|
20
|
+
## 点击接线
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
query 复用 `onSend`,跳转复用 `openLink`,不要另建消息或导航链路。`home` 是本地导航动作的来源标识,不需要创建服务端卡片实例;不要使用 sendMessage 类型的 UI_ACTION 或臆造卡片 ID 发起首页 query。将 bridge 传给卡片的 `bridgeAPI`:
|
|
27
23
|
|
|
28
24
|
```tsx
|
|
29
25
|
import { createCardAssetBridge } from '@/components/home/shared/actions';
|
|
@@ -35,13 +31,19 @@ function Home({ onSend }: HomeSlotRenderProps) {
|
|
|
35
31
|
const bridge = createCardAssetBridge(onSend, (url) => {
|
|
36
32
|
sendUiAction('home', { type: 'openLink', url });
|
|
37
33
|
});
|
|
38
|
-
// 将 bridge 传给本地卡片的 bridgeAPI prop。
|
|
39
34
|
// return <BlockServiceList cardData={data} bridgeAPI={bridge} />;
|
|
40
35
|
}
|
|
41
36
|
```
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
`clickAction=query` 发起对话,`jump/link` 跳转;未指定时优先 jumpUrl,其次 query。适配器过滤空值及不支持的链接。
|
|
39
|
+
|
|
40
|
+
## 容器宽度
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
首页撑满父容器,不设置固定宽度或额外 max-width,左右留白由组合层统一维护:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
// 首页根容器
|
|
46
|
+
<div className="box-border w-full min-w-0">
|
|
47
|
+
```
|
|
46
48
|
|
|
47
|
-
|
|
49
|
+
保留卡片原有列数、滚动和动画。卡片样式为 TSX 内的 Tailwind 工具类:尺寸与字号为普通物理 px(1:1,不折半),复制进应用后由应用的 `apps/client/src/styles/tailwind.css` 扫描 `apps/client/src` 生成。图片与业务数据使用用户材料;更新资源包不会自动覆盖已复制的应用源码。
|