mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-05-06 20:03:36 +08:00
feat: refine ad block button
This commit is contained in:
@@ -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>
|
||||||
{/* 设置按钮 */}
|
<button
|
||||||
<Menu.Root className='vds-menu'>
|
className='vds-button'
|
||||||
<Menu.Button
|
aria-label={blockAdEnabled ? '关闭去广告' : '开启去广告'}
|
||||||
className='vds-menu-button vds-button'
|
onClick={() => {
|
||||||
aria-label='Settings'
|
const newVal = !blockAdEnabled;
|
||||||
>
|
try {
|
||||||
<SettingsIcon className='vds-rotate-icon vds-icon' />
|
saveCurrentPlayProgress();
|
||||||
</Menu.Button>
|
localStorage.setItem('enable_blockad', String(newVal));
|
||||||
<Menu.Content
|
} catch (_) {
|
||||||
className='vds-menu-items'
|
// ignore
|
||||||
placement='top end'
|
}
|
||||||
offset={0}
|
window.location.reload();
|
||||||
>
|
}}
|
||||||
<button
|
>
|
||||||
className='text-white'
|
<AdBlockIcon enabled={blockAdEnabled} />
|
||||||
onClick={() => {
|
</button>
|
||||||
const newVal = !blockAdEnabled;
|
|
||||||
try {
|
|
||||||
saveCurrentPlayProgress();
|
|
||||||
localStorage.setItem(
|
|
||||||
'enable_blockad',
|
|
||||||
String(newVal)
|
|
||||||
);
|
|
||||||
} catch (_) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
window.location.reload();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{blockAdEnabled ? '关闭去广告' : '开启去广告'}
|
|
||||||
</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>
|
||||||
|
|||||||
Reference in New Issue
Block a user