feat: 新增播客详情页及相关功能组件
实现播客详情页功能,包括: 1. 新增 PodcastContent 组件展示播客详情 2. 添加 AudioPlayerControls 和 PodcastTabs 组件 3. 实现分享功能组件 ShareButton 4. 优化音频文件命名规则和缓存机制 5. 完善类型定义和 API 接口 6. 调整 UI 布局和响应式设计 7. 修复积分不足状态码问题
This commit is contained in:
41
web/src/components/ShareButton.tsx
Normal file
41
web/src/components/ShareButton.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
import { Share2 } from 'lucide-react';
|
||||
import { useToast } from './Toast'; // 确保路径正确
|
||||
import { usePathname } from 'next/navigation'; // next/navigation 用于获取当前路径
|
||||
|
||||
interface ShareButtonProps {
|
||||
className?: string; // 允许外部传入样式
|
||||
}
|
||||
|
||||
const ShareButton: React.FC<ShareButtonProps> = ({ className }) => {
|
||||
const { success, error } = useToast();
|
||||
const pathname = usePathname(); // 获取当前路由路径
|
||||
|
||||
const handleShare = async () => {
|
||||
console.log('handleShare clicked'); // 添加点击日志
|
||||
try {
|
||||
const currentUrl = window.location.origin + pathname; // 构建完整的当前页面 URL
|
||||
await navigator.clipboard.writeText(currentUrl);
|
||||
success('复制成功', '页面链接已复制到剪贴板!');
|
||||
console.log('页面链接已复制:', currentUrl); // 添加成功日志
|
||||
} catch (err) {
|
||||
console.error('复制失败:', err); // 保留原有错误日志
|
||||
error('复制失败', '无法复制页面链接到剪贴板。');
|
||||
console.error('无法复制页面链接到剪贴板,错误信息:', err); // 添加详细错误日志
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={handleShare}
|
||||
className={`text-neutral-500 hover:text-black transition-colors text-sm ${className}`}
|
||||
aria-label="分享页面"
|
||||
>
|
||||
<Share2 className="w-5 h-5" />
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
export default ShareButton;
|
||||
Reference in New Issue
Block a user