feat: refine ad block button

This commit is contained in:
shinya
2025-06-28 21:23:53 +08:00
parent b562f29a5f
commit 2fc86c61b7

View File

@@ -8,9 +8,8 @@ import {
isHLSProvider, isHLSProvider,
MediaPlayer, MediaPlayer,
MediaProvider, MediaProvider,
Menu,
} from '@vidstack/react'; } from '@vidstack/react';
import { AirPlayIcon, SettingsIcon } from '@vidstack/react/icons'; import { AirPlayIcon } from '@vidstack/react/icons';
import { import {
defaultLayoutIcons, defaultLayoutIcons,
DefaultVideoLayout, DefaultVideoLayout,
@@ -1393,39 +1392,22 @@ function PlayPageClient() {
<AirPlayButton className='vds-button'> <AirPlayButton className='vds-button'>
<AirPlayIcon className='vds-icon' /> <AirPlayIcon className='vds-icon' />
</AirPlayButton> </AirPlayButton>
{/* 设置按钮 */}
<Menu.Root className='vds-menu'>
<Menu.Button
className='vds-menu-button vds-button'
aria-label='Settings'
>
<SettingsIcon className='vds-rotate-icon vds-icon' />
</Menu.Button>
<Menu.Content
className='vds-menu-items'
placement='top end'
offset={0}
>
<button <button
className='text-white' className='vds-button'
aria-label={blockAdEnabled ? '关闭去广告' : '开启去广告'}
onClick={() => { onClick={() => {
const newVal = !blockAdEnabled; const newVal = !blockAdEnabled;
try { try {
saveCurrentPlayProgress(); saveCurrentPlayProgress();
localStorage.setItem( localStorage.setItem('enable_blockad', String(newVal));
'enable_blockad',
String(newVal)
);
} catch (_) { } catch (_) {
// ignore // ignore
} }
window.location.reload(); window.location.reload();
}} }}
> >
{blockAdEnabled ? '关闭去广告' : '开启去广告'} <AdBlockIcon enabled={blockAdEnabled} />
</button> </button>
</Menu.Content>
</Menu.Root>
</> </>
), ),
}} }}
@@ -1788,6 +1770,41 @@ const FavoriteIcon = ({ filled }: { filled: boolean }) => {
return <Heart className='h-5 w-5 stroke-[2] text-gray-300' />; return <Heart className='h-5 w-5 stroke-[2] text-gray-300' />;
}; };
// 新增:去广告图标组件
const AdBlockIcon = ({ enabled }: { enabled: boolean }) => {
const color = enabled ? '#22c55e' : '#ffffff'; // Tailwind green-500 or white
return (
<svg
className='h-6 w-6 vds-icon' // 略微放大尺寸
viewBox='0 0 32 32'
xmlns='http://www.w3.org/2000/svg'
>
{/* "AD" 文字,居中显示 */}
<text
x='50%'
y='50%'
fontSize='20'
fontWeight='bold'
textAnchor='middle'
dominantBaseline='middle'
fill={color}
>
AD
</text>
{/* 斜线 */}
<line
x1='4'
y1='4'
x2='28'
y2='28'
stroke={color}
strokeWidth='4'
strokeLinecap='round'
/>
</svg>
);
};
export default function PlayPage() { export default function PlayPage() {
return ( return (
<Suspense> <Suspense>