@tbox.cn/app-template-agent 0.1.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/.gitignore +13 -0
- package/.nvmrc +1 -0
- package/.tbox/app.json +4 -0
- package/AGENTS.md +101 -0
- package/ENV.md +77 -0
- package/LEGAL.md +7 -0
- package/LICENSE +21 -0
- package/README.md +62 -0
- package/apps/client/STYLE_GUIDE.md +81 -0
- package/apps/client/VISUAL_RESTORE.md +90 -0
- package/apps/client/assets/copy@2x.png +0 -0
- package/apps/client/assets/debug.png +0 -0
- package/apps/client/assets/dislike@2x.png +0 -0
- package/apps/client/assets/keyboard-circle.svg +12 -0
- package/apps/client/assets/like@2x.png +0 -0
- package/apps/client/assets/more-circle.svg +3 -0
- package/apps/client/assets/new-chat.svg +3 -0
- package/apps/client/assets/quick-command-star.svg +3 -0
- package/apps/client/assets/send-gradient.svg +14 -0
- package/apps/client/assets/speaker@2x.png +0 -0
- package/apps/client/assets/stop@2x.png +0 -0
- package/apps/client/assets/voice-circle.svg +3 -0
- package/apps/client/babel-plugins/code-inspect.cjs +110 -0
- package/apps/client/index.html +36 -0
- package/apps/client/package.json +34 -0
- package/apps/client/src/app.tsx +5 -0
- package/apps/client/src/business/App.tsx +11 -0
- package/apps/client/src/business/README.md +82 -0
- package/apps/client/src/cards/CardRenderer.tsx +10 -0
- package/apps/client/src/cards/registry.ts +22 -0
- package/apps/client/src/components/ActionBar/DebugButton.tsx +49 -0
- package/apps/client/src/components/ActionBar/index.less +120 -0
- package/apps/client/src/components/ActionBar/index.tsx +157 -0
- package/apps/client/src/components/ChatHeader/index.less +104 -0
- package/apps/client/src/components/ChatHeader/index.tsx +63 -0
- package/apps/client/src/components/ChatInput/index.less +332 -0
- package/apps/client/src/components/ChatInput/index.tsx +251 -0
- package/apps/client/src/components/ChatInput/voice/VoicePressField.tsx +34 -0
- package/apps/client/src/components/ChatInput/voice/VoiceRecordingOverlay.tsx +51 -0
- package/apps/client/src/components/ChatInput/voice/machine.ts +27 -0
- package/apps/client/src/components/ChatInput/voice/useVoicePress.ts +188 -0
- package/apps/client/src/components/ErrorBoundary.tsx +2 -0
- package/apps/client/src/components/MediaList/index.less +241 -0
- package/apps/client/src/components/MediaList/index.tsx +256 -0
- package/apps/client/src/components/MessageBubble/index.less +309 -0
- package/apps/client/src/components/MessageBubble/index.tsx +163 -0
- package/apps/client/src/components/PullDownIndicator/index.less +32 -0
- package/apps/client/src/components/PullDownIndicator/index.tsx +33 -0
- package/apps/client/src/components/QuickCommands/index.less +48 -0
- package/apps/client/src/components/QuickCommands/index.tsx +22 -0
- package/apps/client/src/components/ReasoningBlock/index.less +90 -0
- package/apps/client/src/components/ReasoningBlock/index.tsx +56 -0
- package/apps/client/src/components/ScrollToBottomButton/index.less +32 -0
- package/apps/client/src/components/ScrollToBottomButton/index.tsx +10 -0
- package/apps/client/src/components/ToolCallBlock/index.less +91 -0
- package/apps/client/src/components/ToolCallBlock/index.tsx +63 -0
- package/apps/client/src/examples/tourism/TourismLanding.tsx +96 -0
- package/apps/client/src/examples/tourism/index.less +192 -0
- package/apps/client/src/hooks/useMediaUpload.ts +237 -0
- package/apps/client/src/hooks/usePullDownHistory.ts +97 -0
- package/apps/client/src/hooks/useTTSAutoPlay.ts +80 -0
- package/apps/client/src/main.tsx +17 -0
- package/apps/client/src/modules.ts +30 -0
- package/apps/client/src/pages/index/index.less +43 -0
- package/apps/client/src/pages/index/index.tsx +145 -0
- package/apps/client/src/platform/AgentChatApp.tsx +39 -0
- package/apps/client/src/platform/agent-runtime.ts +15 -0
- package/apps/client/src/platform/state/createPersistedStore.ts +19 -0
- package/apps/client/src/shims/node-stub.ts +14 -0
- package/apps/client/src/store/chat-config.ts +29 -0
- package/apps/client/src/store/chat.ts +201 -0
- package/apps/client/src/styles/global.less +60 -0
- package/apps/client/src/styles/tokens.less +60 -0
- package/apps/client/src/types/chat.ts +29 -0
- package/apps/client/src/utils/copyText.ts +11 -0
- package/apps/client/src/utils/imagePreview.ts +10 -0
- package/apps/client/src/utils/session-error.ts +5 -0
- package/apps/client/src/utils/toast.ts +15 -0
- package/apps/client/src/vite-env.d.ts +3 -0
- package/apps/client/tsconfig.json +11 -0
- package/apps/client/vite.config.ts +40 -0
- package/apps/server/package.json +40 -0
- package/apps/server/src/cli/collect-registry.ts +26 -0
- package/apps/server/src/cli/plugin-doctor.ts +89 -0
- package/apps/server/src/cli/plugin-inspect.ts +49 -0
- package/apps/server/src/index.ts +230 -0
- package/apps/server/src/intent-routes.ts +23 -0
- package/apps/server/src/modules.ts +31 -0
- package/apps/server/src/tools/translate.ts +41 -0
- package/apps/server/tests/cards-registry.test.ts +55 -0
- package/apps/server/tests/tool-runtime.test.ts +49 -0
- package/apps/server/tsconfig.json +5 -0
- package/apps/server/tsup.config.ts +25 -0
- package/apps/server/vitest.config.ts +8 -0
- package/config/chat.json +8 -0
- package/config/llm_provider.json +3 -0
- package/config/plugins.json +3 -0
- package/eslint.config.mjs +41 -0
- package/package.json +51 -0
- package/packages/module-weather/package.json +35 -0
- package/packages/module-weather/src/client/cards/weather/index.less +22 -0
- package/packages/module-weather/src/client/cards/weather/index.tsx +14 -0
- package/packages/module-weather/src/client/index.ts +19 -0
- package/packages/module-weather/src/index.ts +2 -0
- package/packages/module-weather/src/server/cards/weather/meta.ts +28 -0
- package/packages/module-weather/src/server/index.ts +19 -0
- package/packages/module-weather/src/server/tool.ts +29 -0
- package/packages/module-weather/tbox.component.json +27 -0
- package/packages/module-weather/tsconfig.json +14 -0
- package/pnpm-workspace.template.yaml +60 -0
- package/scripts/build.sh +39 -0
- package/scripts/check-inspector.sh +91 -0
- package/scripts/check-workspace.mjs +164 -0
- package/scripts/dev.sh +15 -0
- package/scripts/prepare.sh +11 -0
- package/scripts/start.sh +11 -0
- package/scripts/stop.sh +26 -0
- package/scripts/verify-generated.mjs +142 -0
- package/tsconfig.base.json +20 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import ReactMarkdown from 'react-markdown';
|
|
3
|
+
import remarkGfm from 'remark-gfm';
|
|
4
|
+
import './index.less';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
reasoning: string;
|
|
8
|
+
/** 是否正在思考中(自动展开 + 计时) */
|
|
9
|
+
isActive?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** 思考过程折叠块(思考中自动展开并计时,结束后自动收起)。 */
|
|
13
|
+
export default function ReasoningBlock({ reasoning, isActive }: Props) {
|
|
14
|
+
const [expanded, setExpanded] = useState(!!isActive);
|
|
15
|
+
const startTime = useRef(Date.now());
|
|
16
|
+
const [elapsed, setElapsed] = useState(0);
|
|
17
|
+
const wasActive = useRef(isActive);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (isActive) {
|
|
21
|
+
wasActive.current = true;
|
|
22
|
+
setExpanded(true);
|
|
23
|
+
startTime.current = Date.now();
|
|
24
|
+
const timer = setInterval(() => {
|
|
25
|
+
setElapsed(Math.floor((Date.now() - startTime.current) / 1000));
|
|
26
|
+
}, 1000);
|
|
27
|
+
return () => clearInterval(timer);
|
|
28
|
+
}
|
|
29
|
+
if (wasActive.current) {
|
|
30
|
+
setExpanded(false);
|
|
31
|
+
wasActive.current = false;
|
|
32
|
+
}
|
|
33
|
+
}, [isActive]);
|
|
34
|
+
|
|
35
|
+
const durationLabel = elapsed > 0 ? `${elapsed}s` : '';
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className={`reasoning ${isActive ? 'reasoning--active' : 'reasoning--done'}`}>
|
|
39
|
+
<div className="reasoning__header" onClick={() => setExpanded(!expanded)}>
|
|
40
|
+
<div className="reasoning__left">
|
|
41
|
+
<div className={`reasoning__indicator${isActive ? ' reasoning__indicator--pulse' : ''}`} />
|
|
42
|
+
<span className="reasoning__title">{isActive ? '思考中...' : '思考过程'}</span>
|
|
43
|
+
{durationLabel && <span className="reasoning__duration">({durationLabel})</span>}
|
|
44
|
+
</div>
|
|
45
|
+
<span className={`reasoning__toggle${expanded ? ' reasoning__toggle--up' : ''}`}>
|
|
46
|
+
{expanded ? '收起' : '展开'}
|
|
47
|
+
</span>
|
|
48
|
+
</div>
|
|
49
|
+
{expanded && (
|
|
50
|
+
<div className="reasoning__content">
|
|
51
|
+
<ReactMarkdown remarkPlugins={[remarkGfm]}>{reasoning}</ReactMarkdown>
|
|
52
|
+
</div>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.scroll-to-bottom-btn {
|
|
2
|
+
position: absolute;
|
|
3
|
+
right: 32px;
|
|
4
|
+
bottom: 32px;
|
|
5
|
+
width: 72px;
|
|
6
|
+
height: 72px;
|
|
7
|
+
border-radius: 50%;
|
|
8
|
+
background: #fff;
|
|
9
|
+
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.12);
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
justify-content: center;
|
|
13
|
+
z-index: 10;
|
|
14
|
+
opacity: 0;
|
|
15
|
+
transform: scale(0.8);
|
|
16
|
+
transition: opacity 0.2s ease, transform 0.2s ease;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
|
|
19
|
+
&--visible {
|
|
20
|
+
opacity: 1;
|
|
21
|
+
transform: scale(1);
|
|
22
|
+
pointer-events: auto;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__arrow {
|
|
26
|
+
width: 0;
|
|
27
|
+
height: 0;
|
|
28
|
+
border-left: 12px solid transparent;
|
|
29
|
+
border-right: 12px solid transparent;
|
|
30
|
+
border-top: 14px solid #666;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './index.less';
|
|
2
|
+
|
|
3
|
+
/** 生成时出现的“回到底部”悬浮按钮。 */
|
|
4
|
+
export default function ScrollToBottomButton({ visible, onClick }: { visible: boolean; onClick: () => void }) {
|
|
5
|
+
return (
|
|
6
|
+
<div className={`scroll-to-bottom-btn${visible ? ' scroll-to-bottom-btn--visible' : ''}`} onClick={onClick}>
|
|
7
|
+
<div className="scroll-to-bottom-btn__arrow" />
|
|
8
|
+
</div>
|
|
9
|
+
);
|
|
10
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
.tool-calls {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 8px;
|
|
5
|
+
margin: 0 0 12px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.tool-call {
|
|
9
|
+
border-radius: 12px;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
|
|
12
|
+
&--calling {
|
|
13
|
+
background: rgba(16, 163, 127, 0.08);
|
|
14
|
+
}
|
|
15
|
+
&--done {
|
|
16
|
+
background: rgba(0, 0, 0, 0.03);
|
|
17
|
+
}
|
|
18
|
+
&--error {
|
|
19
|
+
background: rgba(239, 68, 68, 0.08);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&__header {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
padding: 12px 16px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&__left {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: 8px;
|
|
33
|
+
min-width: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
&__spinner {
|
|
37
|
+
width: 14px;
|
|
38
|
+
height: 14px;
|
|
39
|
+
border: 2px solid rgba(16, 163, 127, 0.3);
|
|
40
|
+
border-top-color: #10a37f;
|
|
41
|
+
border-radius: 50%;
|
|
42
|
+
flex-shrink: 0;
|
|
43
|
+
animation: tool-spin 0.8s linear infinite;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&__name {
|
|
47
|
+
font-size: 22px;
|
|
48
|
+
line-height: 1.4;
|
|
49
|
+
color: #4a5568;
|
|
50
|
+
font-weight: 500;
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
white-space: nowrap;
|
|
54
|
+
}
|
|
55
|
+
&--calling &__name {
|
|
56
|
+
color: #10a37f;
|
|
57
|
+
}
|
|
58
|
+
&--error &__name {
|
|
59
|
+
color: #ef4444;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
&__toggle {
|
|
63
|
+
font-size: 20px;
|
|
64
|
+
color: #8b95b0;
|
|
65
|
+
flex-shrink: 0;
|
|
66
|
+
margin-left: 8px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&__result {
|
|
70
|
+
padding: 0 16px 12px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&__result-text {
|
|
74
|
+
font-size: 20px;
|
|
75
|
+
color: #6b7a99;
|
|
76
|
+
line-height: 1.6;
|
|
77
|
+
font-family: Menlo, Monaco, Consolas, monospace;
|
|
78
|
+
white-space: pre-wrap;
|
|
79
|
+
word-break: break-all;
|
|
80
|
+
|
|
81
|
+
&--error {
|
|
82
|
+
color: #dc2626;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@keyframes tool-spin {
|
|
88
|
+
to {
|
|
89
|
+
transform: rotate(360deg);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Check, X } from '@phosphor-icons/react';
|
|
3
|
+
import type { ToolCallInfo } from '@/types/chat';
|
|
4
|
+
import './index.less';
|
|
5
|
+
|
|
6
|
+
/** 工具调用状态卡片(调用中 spinner / 完成 / 失败,可展开详情)。 */
|
|
7
|
+
export default function ToolCallBlock({ toolCalls }: { toolCalls: ToolCallInfo[] }) {
|
|
8
|
+
const [expandedId, setExpandedId] = useState<string | null>(null);
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div className="tool-calls">
|
|
12
|
+
{toolCalls.map((tc) => {
|
|
13
|
+
const isCalling = tc.status === 'calling';
|
|
14
|
+
const isError = tc.status === 'error';
|
|
15
|
+
const isDone = tc.status === 'done';
|
|
16
|
+
const isExpanded = expandedId === tc.id;
|
|
17
|
+
const hasDetail = !!(tc.result || tc.error);
|
|
18
|
+
const stateClass = isError ? 'tool-call--error' : isCalling ? 'tool-call--calling' : 'tool-call--done';
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<div key={tc.id} className={`tool-call ${stateClass}`}>
|
|
22
|
+
<div
|
|
23
|
+
className="tool-call__header"
|
|
24
|
+
onClick={() => hasDetail && setExpandedId(isExpanded ? null : tc.id)}
|
|
25
|
+
>
|
|
26
|
+
<div className="tool-call__left">
|
|
27
|
+
{isCalling && <div className="tool-call__spinner" />}
|
|
28
|
+
{isDone && <Check size={16} color="#10a37f" strokeWidth={2.5} />}
|
|
29
|
+
{isError && <X size={16} color="#ef4444" strokeWidth={2.5} />}
|
|
30
|
+
<span className="tool-call__name">
|
|
31
|
+
{isCalling && `调用 ${tc.name}`}
|
|
32
|
+
{isDone && `${tc.name} 已完成`}
|
|
33
|
+
{isError && `${tc.name} 调用失败`}
|
|
34
|
+
</span>
|
|
35
|
+
</div>
|
|
36
|
+
{hasDetail && (
|
|
37
|
+
<span className={`tool-call__toggle${isExpanded ? ' tool-call__toggle--up' : ''}`}>
|
|
38
|
+
{isExpanded ? '收起' : '详情'}
|
|
39
|
+
</span>
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
{isExpanded && hasDetail && (
|
|
43
|
+
<div className="tool-call__result">
|
|
44
|
+
<span className={`tool-call__result-text${isError ? ' tool-call__result-text--error' : ''}`}>
|
|
45
|
+
{formatResult(isError ? tc.error! : tc.result!)}
|
|
46
|
+
</span>
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
})}
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function formatResult(raw: string): string {
|
|
57
|
+
try {
|
|
58
|
+
const pretty = JSON.stringify(JSON.parse(raw), null, 2);
|
|
59
|
+
return pretty.length > 500 ? pretty.slice(0, 500) + '...' : pretty;
|
|
60
|
+
} catch {
|
|
61
|
+
return raw.length > 500 ? raw.slice(0, 500) + '...' : raw;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { ArrowsClockwise, CaretRight } from '@phosphor-icons/react';
|
|
3
|
+
import type { ChatLandingProps } from '@/pages/index/index';
|
|
4
|
+
import './index.less';
|
|
5
|
+
|
|
6
|
+
const CAROUSEL_ITEMS = [
|
|
7
|
+
{ title: '预约购票', desc: '景区门票多种选择', img: 'https://mdn.alipayobjects.com/tcmarket/afts/img/HmxURLvK52sAAAAARYAAAAgAwxLNAQBr/original', prompt: '我想预约购票' },
|
|
8
|
+
{ title: '智能导游', desc: '随心游无目的漫游', img: 'https://mdn.alipayobjects.com/tcmarket/afts/img/DbHcTK8C-JIAAAAARMAAAAgAwxLNAQBr/original', prompt: '请为我智能导游' },
|
|
9
|
+
{ title: '景点介绍', desc: '智能推荐景点讲解', img: 'https://mdn.alipayobjects.com/tcmarket/afts/img/CKZLRLnGC9sAAAAARVAAAAgAwxLNAQBr/original', prompt: '介绍一下景区的景点' },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const SERVICE_ITEMS = [
|
|
13
|
+
{ img: 'https://mdn.alipayobjects.com/tcmarket/afts/img/pBvTRZ2lWokAAAAAQHAAAAgAwxLNAQBr/original', title: '杭城美食', desc: '千家商户 7 折起', prompt: '推荐一些杭州特色美食' },
|
|
14
|
+
{ img: 'https://mdn.alipayobjects.com/tcmarket/afts/img/OqxGT6_0RCYAAAAAQGAAAAgAwxLNAQBr/original', title: '酒店预定', desc: '万家酒店 5 折起', prompt: '帮我查找附近的酒店' },
|
|
15
|
+
{ img: 'https://mdn.alipayobjects.com/tcmarket/afts/img/HYeNTLrh83AAAAAAQFAAAAgAwxLNAQBr/original', title: '天气查询', desc: '实时天气速览', prompt: '今天天气怎么样?' },
|
|
16
|
+
{ img: 'https://mdn.alipayobjects.com/tcmarket/afts/img/atCHR6ykFnEAAAAAQHAAAAgAwxLNAQBr/original', title: '路线推荐', desc: '智能规划行程', prompt: '推荐一条游览路线' },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const ALL_SUGGESTIONS = [
|
|
20
|
+
{ title: '热门景区推荐', prompt: '有哪些热门景区推荐?' },
|
|
21
|
+
{ title: '门票优惠政策', prompt: '有哪些门票优惠政策?' },
|
|
22
|
+
{ title: '景区开放时间', prompt: '景区的开放时间是什么时候?' },
|
|
23
|
+
{ title: '项目推荐', prompt: '有什么推荐的游玩项目?' },
|
|
24
|
+
{ title: '交通指南', prompt: '怎么到达景区?' },
|
|
25
|
+
{ title: '住宿推荐', prompt: '附近有哪些住宿推荐?' },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const pickRandom = <T,>(items: T[], count: number): T[] =>
|
|
29
|
+
[...items].sort(() => Math.random() - 0.5).slice(0, count);
|
|
30
|
+
|
|
31
|
+
/** @tbox-template-example tourism */
|
|
32
|
+
export default function TourismLanding({ onSend }: ChatLandingProps) {
|
|
33
|
+
const [suggestions, setSuggestions] = useState(() => pickRandom(ALL_SUGGESTIONS, 4));
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="tourism-example">
|
|
37
|
+
<div className="tourism-example__welcome">
|
|
38
|
+
<div className="tourism-example__welcome-title">欢迎来到文旅景区</div>
|
|
39
|
+
<div className="tourism-example__welcome-desc">
|
|
40
|
+
我是您的通用文旅景区 AI 智能体,适用于山水类单景区、城市类多景区的业务场景。
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<section className="tourism-example__section tourism-example__carousel-section">
|
|
45
|
+
<h2 className="tourism-example__section-title">游玩服务</h2>
|
|
46
|
+
<div className="tourism-example__carousel">
|
|
47
|
+
{CAROUSEL_ITEMS.map((item) => (
|
|
48
|
+
<button key={item.title} className="tourism-example__carousel-item" onClick={() => onSend(item.prompt)}>
|
|
49
|
+
<img className="tourism-example__carousel-image" src={item.img} alt={item.title} />
|
|
50
|
+
<span className="tourism-example__carousel-overlay">
|
|
51
|
+
<span className="tourism-example__carousel-title">{item.title}</span>
|
|
52
|
+
<span className="tourism-example__carousel-desc">{item.desc}</span>
|
|
53
|
+
</span>
|
|
54
|
+
</button>
|
|
55
|
+
))}
|
|
56
|
+
</div>
|
|
57
|
+
</section>
|
|
58
|
+
|
|
59
|
+
<section className="tourism-example__section">
|
|
60
|
+
<h2 className="tourism-example__section-title">配套服务</h2>
|
|
61
|
+
<div className="tourism-example__service-grid">
|
|
62
|
+
{SERVICE_ITEMS.map((item) => (
|
|
63
|
+
<button key={item.title} className="tourism-example__service-item" onClick={() => onSend(item.prompt)}>
|
|
64
|
+
<img className="tourism-example__service-icon" src={item.img} alt={item.title} />
|
|
65
|
+
<span className="tourism-example__service-content">
|
|
66
|
+
<span className="tourism-example__service-title-row">
|
|
67
|
+
<span className="tourism-example__service-title">{item.title}</span>
|
|
68
|
+
<CaretRight size={20} color="#c0c4cc" />
|
|
69
|
+
</span>
|
|
70
|
+
<span className="tourism-example__service-desc">{item.desc}</span>
|
|
71
|
+
</span>
|
|
72
|
+
</button>
|
|
73
|
+
))}
|
|
74
|
+
</div>
|
|
75
|
+
</section>
|
|
76
|
+
|
|
77
|
+
<section className="tourism-example__section">
|
|
78
|
+
<div className="tourism-example__suggestion-header">
|
|
79
|
+
<h2 className="tourism-example__section-title">猜你想问</h2>
|
|
80
|
+
<button className="tourism-example__refresh" onClick={() => setSuggestions(pickRandom(ALL_SUGGESTIONS, 4))}>
|
|
81
|
+
<ArrowsClockwise size={12} />
|
|
82
|
+
<span>换一换</span>
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
<div className="tourism-example__suggestion-grid">
|
|
86
|
+
{suggestions.map((item) => (
|
|
87
|
+
<button key={item.prompt} className="tourism-example__suggestion" onClick={() => onSend(item.prompt)}>
|
|
88
|
+
<span>{item.title}</span>
|
|
89
|
+
<CaretRight size={20} color="#c0c4cc" />
|
|
90
|
+
</button>
|
|
91
|
+
))}
|
|
92
|
+
</div>
|
|
93
|
+
</section>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
.tourism-example {
|
|
2
|
+
&__welcome {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: center;
|
|
6
|
+
padding: 44px 48px 32px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&__welcome-title {
|
|
10
|
+
margin-bottom: 24px;
|
|
11
|
+
color: #1f3b63;
|
|
12
|
+
font-size: 40px;
|
|
13
|
+
font-weight: 700;
|
|
14
|
+
line-height: 48px;
|
|
15
|
+
text-align: center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&__welcome-desc {
|
|
19
|
+
color: #1f3b63;
|
|
20
|
+
font-size: 30px;
|
|
21
|
+
line-height: 48px;
|
|
22
|
+
text-align: justify;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&__section {
|
|
26
|
+
margin: 24px;
|
|
27
|
+
padding: 24px;
|
|
28
|
+
background: #fff9;
|
|
29
|
+
border: 1px solid #fff3;
|
|
30
|
+
border-radius: 24px;
|
|
31
|
+
box-shadow: 0 2px 18px 0 #2a31380a;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&__carousel-section {
|
|
35
|
+
padding-right: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&__section-title {
|
|
39
|
+
display: block;
|
|
40
|
+
margin: 0 0 24px;
|
|
41
|
+
color: #1f3b63;
|
|
42
|
+
font-size: 30px;
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&__carousel {
|
|
47
|
+
display: flex;
|
|
48
|
+
gap: 16px;
|
|
49
|
+
overflow-x: auto;
|
|
50
|
+
padding-right: 24px;
|
|
51
|
+
scrollbar-width: none;
|
|
52
|
+
|
|
53
|
+
&::-webkit-scrollbar {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&__carousel-item {
|
|
59
|
+
position: relative;
|
|
60
|
+
width: 280px;
|
|
61
|
+
height: 168px;
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
padding: 0;
|
|
65
|
+
background: transparent;
|
|
66
|
+
border: 0;
|
|
67
|
+
border-radius: 32px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&__carousel-image {
|
|
71
|
+
display: block;
|
|
72
|
+
width: 100%;
|
|
73
|
+
height: 100%;
|
|
74
|
+
object-fit: cover;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&__carousel-overlay {
|
|
78
|
+
position: absolute;
|
|
79
|
+
right: 0;
|
|
80
|
+
bottom: 0;
|
|
81
|
+
left: 0;
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
padding: 16px 20px 14px;
|
|
85
|
+
background: linear-gradient(180deg, transparent 0%, rgb(0 0 0 / 50%) 100%);
|
|
86
|
+
text-align: left;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&__carousel-title {
|
|
90
|
+
margin-bottom: 4px;
|
|
91
|
+
color: #fff;
|
|
92
|
+
font-size: 30px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
&__carousel-desc {
|
|
96
|
+
color: rgb(255 255 255 / 80%);
|
|
97
|
+
font-size: 22px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&__service-grid,
|
|
101
|
+
&__suggestion-grid {
|
|
102
|
+
display: flex;
|
|
103
|
+
flex-wrap: wrap;
|
|
104
|
+
gap: 16px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&__service-item,
|
|
108
|
+
&__suggestion {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
width: calc(50% - 8px);
|
|
112
|
+
box-sizing: border-box;
|
|
113
|
+
background: #fff;
|
|
114
|
+
border: 1px solid #8d9fb866;
|
|
115
|
+
border-radius: 24px;
|
|
116
|
+
box-shadow: 0 0 24px 0 #8d9fb80d;
|
|
117
|
+
color: #1f3b63;
|
|
118
|
+
text-align: left;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&__service-item {
|
|
122
|
+
height: 112px;
|
|
123
|
+
padding: 0 8px 0 20px;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&__service-icon {
|
|
127
|
+
display: block;
|
|
128
|
+
width: 72px;
|
|
129
|
+
height: 72px;
|
|
130
|
+
margin-right: 16px;
|
|
131
|
+
flex-shrink: 0;
|
|
132
|
+
object-fit: contain;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
&__service-content {
|
|
136
|
+
display: flex;
|
|
137
|
+
min-width: 0;
|
|
138
|
+
flex: 1;
|
|
139
|
+
flex-direction: column;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&__service-title-row {
|
|
143
|
+
display: flex;
|
|
144
|
+
align-items: center;
|
|
145
|
+
justify-content: space-between;
|
|
146
|
+
margin-bottom: 4px;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
&__service-title,
|
|
150
|
+
&__service-desc {
|
|
151
|
+
overflow: hidden;
|
|
152
|
+
text-overflow: ellipsis;
|
|
153
|
+
white-space: nowrap;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
&__service-title {
|
|
157
|
+
font-size: 28px;
|
|
158
|
+
font-weight: 500;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
&__service-desc {
|
|
162
|
+
color: #1f3b6373;
|
|
163
|
+
font-size: 22px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&__suggestion-header {
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: space-between;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
&__refresh {
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: center;
|
|
175
|
+
gap: 9px;
|
|
176
|
+
margin-bottom: 24px;
|
|
177
|
+
padding: 0;
|
|
178
|
+
background: transparent;
|
|
179
|
+
border: 0;
|
|
180
|
+
color: #10295399;
|
|
181
|
+
font-size: 26px;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&__suggestion {
|
|
185
|
+
justify-content: space-between;
|
|
186
|
+
height: 78px;
|
|
187
|
+
padding: 0 20px;
|
|
188
|
+
overflow: hidden;
|
|
189
|
+
font-size: 26px;
|
|
190
|
+
font-weight: 500;
|
|
191
|
+
}
|
|
192
|
+
}
|