PositionAbilityArea.tsx
6.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import { useState } from 'react';
import type { PositionTab, Agent, MediaType } from '../types/home';
import { QrcodeModal } from './QrcodeModal';
export interface PositionAbilityAreaProps {
tab: PositionTab;
currentAgent: Agent | undefined;
currentAgentIndex: number;
onAgentSelect: (index: number) => void;
onOpenQrcodeModal: () => void;
qrcodeModalOpen: boolean;
onCloseQrcodeModal: () => void;
}
export function PositionAbilityArea({
tab,
currentAgent,
currentAgentIndex,
onAgentSelect,
onOpenQrcodeModal,
qrcodeModalOpen,
onCloseQrcodeModal,
}: PositionAbilityAreaProps) {
const [mediaError, setMediaError] = useState(false);
const handleMediaError = () => {
setMediaError(true);
};
const renderMedia = (mediaUrl: string | null, mediaType: MediaType | null) => {
if (!mediaUrl || !mediaType || mediaError) {
return (
<div className="w-full h-full bg-surface-container flex items-center justify-center">
<span className="text-on-surface-variant">素材不可用</span>
</div>
);
}
if (mediaType === 'mp4') {
return (
<video
src={mediaUrl}
data-testid="agent-video"
className="w-full h-full object-cover"
autoPlay
loop
muted
playsInline
onError={handleMediaError}
/>
);
}
return (
<img
src={mediaUrl}
data-testid="agent-image"
alt="Agent 素材"
className="w-full h-full object-contain group-hover:scale-110 transition-transform duration-500"
onError={handleMediaError}
/>
);
};
return (
<section className="py-20 bg-surface" data-testid="position-ability-area">
<div className="max-w-container-max mx-auto px-margin-mobile tablet:px-margin-desktop">
<div className="grid grid-cols-1 tablet:grid-cols-2 gap-16 items-center">
{/* Left: Mockup UI */}
<div className="rounded-[32px] p-8 tablet:p-12 border border-outline-variant/30 bg-white/80 backdrop-blur-xl flex flex-col items-center text-center relative shadow-sm">
<div className="absolute top-6 left-8 flex gap-2">
<div className="w-3 h-3 rounded-full bg-red-400/50" />
<div className="w-3 h-3 rounded-full bg-yellow-400/50" />
<div className="w-3 h-3 rounded-full bg-green-400/50" />
</div>
<div className="absolute top-6 right-8">
<div className="px-3 py-1 bg-primary text-[10px] text-white font-bold rounded-md">GL-DIGITECH</div>
</div>
<div className="mb-10 mt-8 w-48 h-48 bg-primary/5 rounded-full flex items-center justify-center p-8 group overflow-hidden" data-testid="agent-media-container">
{currentAgent ? (
renderMedia(currentAgent.media_url, currentAgent.media_type)
) : (
<div className="w-full h-full bg-surface-container flex items-center justify-center">
<span className="text-on-surface-variant">暂无 Agent 素材</span>
</div>
)}
</div>
<h3 className="text-headline-sm mb-2">
{currentAgent?.speech_title ?? '岗位智能体'}
<span className="text-on-surface-variant text-label-md font-normal ml-2">/ Position Agent</span>
</h3>
<p className="text-body-md text-on-surface-variant max-w-sm mb-8">
{currentAgent?.speech_content ?? '为每个岗位配置专属 AI 助手,辅助决策,提升效率'}
</p>
<button
onClick={onOpenQrcodeModal}
className="flex items-center gap-2 px-8 py-3 bg-primary-container text-white rounded-xl text-label-md transition-transform active:scale-95"
>
立即体验 <span className="text-[18px]">↗</span>
</button>
</div>
{/* Right: Content */}
<div className="space-y-8">
<div className="inline-block border-l-4 border-primary pl-4 py-1">
<p className="text-label-sm text-primary uppercase tracking-widest mb-1">核心能力</p>
<h2 className="text-headline-md">
{tab.main_title.split(' ').map((word, index) => (
index === 1 ? <span key={index} className="text-primary">{word}</span> : word + ' '
))}
</h2>
</div>
<p className="text-body-md text-on-surface-variant leading-relaxed">
{tab.sub_title}
</p>
{tab.agents.length > 0 && (
<div className="space-y-4">
{tab.agents.map((agent, index) => (
<div
key={agent.agent_id}
onClick={() => onAgentSelect(index)}
className={`p-5 rounded-2xl border transition-all group cursor-default ${
index === currentAgentIndex
? 'border-primary/40 bg-primary/5 shadow-md'
: 'border-outline-variant/30 bg-surface-container-lowest hover:border-primary/40 hover:shadow-md'
}`}
>
<div className="flex items-start gap-4">
<div className={`w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 transition-colors ${
index === currentAgentIndex
? 'bg-primary text-white'
: 'bg-primary/10 text-primary group-hover:bg-primary group-hover:text-white'
}`}>
<span className="text-[20px]">★</span>
</div>
<div>
<p className="text-label-md font-bold mb-1">{agent.speech_title ?? agent.agent_name ?? 'Agent'}</p>
<p className="text-body-md text-on-surface-variant text-sm">{agent.speech_content ?? ''}</p>
</div>
</div>
</div>
))}
</div>
)}
</div>
</div>
</div>
<QrcodeModal
isOpen={qrcodeModalOpen}
onClose={onCloseQrcodeModal}
positionName={tab.position_name}
qrcodeUrl={tab.qrcode_url}
qrcodeStatus={tab.qrcode_status}
/>
</section>
);
}