MCPcopy
hub / github.com/TanShilongMario/PromptFill / renderSourceAssets

Function renderSourceAssets

src/components/TemplateEditor.jsx:276–356  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

274
275 // 辅助组件:渲染参考素材区域
276 const renderSourceAssets = () => (
277 <div className="flex flex-col gap-1">
278 <label className={`text-[10px] font-black uppercase tracking-widest opacity-40 ${isDarkMode ? 'text-gray-500' : 'text-gray-400'}`}>
279 {language === 'cn' ? '参考素材' : 'Sources'}
280 </label>
281 <HScrollArea isDarkMode={isDarkMode}>
282 {(activeTemplate.source || []).map((src, sIdx) => (
283 <div key={sIdx}
284 className={`flex-shrink-0 relative group/source rounded-lg border-2 transition-all cursor-zoom-in hover:scale-[1.03] ${isDarkMode ? 'border-white/5 bg-white/5' : 'border-gray-100 bg-gray-50'}`}
285 onClick={() => {
286 if (src.templateId) {
287 // 关联模式:跳转到模版
288 if (templates && templates.some(t => t.id === src.templateId)) {
289 setActiveTemplateId(src.templateId);
290 } else {
291 alert(language === 'cn' ? `关联的模版「${src.templateName || '未知'}」已不存在` : `Linked template "${src.templateName || 'Unknown'}" no longer exists`);
292 }
293 } else {
294 setSourceZoomedItem(src);
295 }
296 }}>
297 <div className={`${isMobileDevice ? 'w-[140px] h-[140px]' : 'w-[210px] h-[210px]'} overflow-hidden rounded-lg flex items-center justify-center`}>
298 {src.type === 'video' ? (
299 getVideoEmbedInfo(src.url)?.platform === 'video' || isFolderMediaPath(src.url) ? (
300 <EditorSourceThumbVideo
301 src={src.url}
302 className="w-full h-full object-cover"
303 playIconSize={isMobileDevice ? 18 : 24}
304 onMouseEnter={(e) => e.target.play()}
305 onMouseLeave={(e) => {
306 e.target.pause();
307 e.target.currentTime = 0;
308 }}
309 />
310 ) : (
311 <div className="w-full h-full flex items-center justify-center bg-black/20">
312 <Play size={isMobileDevice ? 18 : 24} className="text-white/60" fill="currentColor" />
313 </div>
314 )
315 ) : (
316 <OptimizedImage
317 src={src.url}
318 alt={`Source ${src.id || sIdx + 1}`}
319 className="w-full h-full object-cover"
320 isDarkMode={isDarkMode}
321 priority={10}
322 />
323 )}
324 </div>
325
326 {/* 关联角标 */}
327 {src.templateId && (
328 <div className="absolute top-1.5 left-1.5 z-10 bg-orange-500 text-white rounded-md px-1 py-0.5 flex items-center gap-1 shadow-lg">
329 <Link size={10} />
330 <span className="text-[9px] font-black">{language === 'cn' ? '关联' : 'LINK'}</span>
331 </div>
332 )}
333

Callers 1

TemplateEditor.jsxFile · 0.85

Calls 3

getVideoEmbedInfoFunction · 0.90
isFolderMediaPathFunction · 0.90
updateTemplatePropertyFunction · 0.85

Tested by

no test coverage detected