增加禁用自动匹配弹幕
This commit is contained in:
@@ -607,6 +607,13 @@ function PlayPageClient() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否禁用了自动装填弹幕
|
||||
const disableAutoLoad = localStorage.getItem('disableAutoLoadDanmaku') === 'true';
|
||||
if (disableAutoLoad) {
|
||||
console.log('[弹幕] 已禁用自动装填弹幕,跳过自动加载');
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查集数是否有效且是否已改变
|
||||
if (currentEpisodeIndex < 0 || !videoTitle) {
|
||||
return;
|
||||
@@ -3644,6 +3651,9 @@ function PlayPageClient() {
|
||||
// 预加载下一集弹幕(完全复制 loadDanmakuForCurrentEpisode 的逻辑)
|
||||
const preloadNextEpisodeDanmaku = async () => {
|
||||
try {
|
||||
const disableAutoLoad = localStorage.getItem('disableAutoLoadDanmaku') === 'true';
|
||||
if (disableAutoLoad) return;
|
||||
|
||||
const title = videoTitleRef.current;
|
||||
if (!title) {
|
||||
return;
|
||||
@@ -3970,6 +3980,9 @@ function PlayPageClient() {
|
||||
|
||||
// 自动搜索并加载弹幕
|
||||
const autoSearchDanmaku = async () => {
|
||||
const disableAutoLoad = localStorage.getItem('disableAutoLoadDanmaku') === 'true';
|
||||
if (disableAutoLoad) return;
|
||||
|
||||
const title = videoTitleRef.current;
|
||||
if (!title) {
|
||||
console.warn('视频标题为空,无法自动搜索弹幕');
|
||||
|
||||
@@ -113,6 +113,7 @@ export const UserMenu: React.FC = () => {
|
||||
const [bufferStrategy, setBufferStrategy] = useState('medium');
|
||||
const [nextEpisodePreCache, setNextEpisodePreCache] = useState(true);
|
||||
const [nextEpisodeDanmakuPreload, setNextEpisodeDanmakuPreload] = useState(true);
|
||||
const [disableAutoLoadDanmaku, setDisableAutoLoadDanmaku] = useState(false);
|
||||
const [searchTraditionalToSimplified, setSearchTraditionalToSimplified] = useState(false);
|
||||
|
||||
// 邮件通知设置
|
||||
@@ -402,6 +403,11 @@ export const UserMenu: React.FC = () => {
|
||||
setNextEpisodeDanmakuPreload(savedNextEpisodeDanmakuPreload === 'true');
|
||||
}
|
||||
|
||||
const savedDisableAutoLoadDanmaku = localStorage.getItem('disableAutoLoadDanmaku');
|
||||
if (savedDisableAutoLoadDanmaku !== null) {
|
||||
setDisableAutoLoadDanmaku(savedDisableAutoLoadDanmaku === 'true');
|
||||
}
|
||||
|
||||
// 加载首页模块配置
|
||||
const savedHomeModules = localStorage.getItem('homeModules');
|
||||
if (savedHomeModules !== null) {
|
||||
@@ -758,6 +764,13 @@ export const UserMenu: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleDisableAutoLoadDanmakuToggle = (value: boolean) => {
|
||||
setDisableAutoLoadDanmaku(value);
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.setItem('disableAutoLoadDanmaku', String(value));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSearchTraditionalToSimplifiedToggle = (value: boolean) => {
|
||||
setSearchTraditionalToSimplified(value);
|
||||
if (typeof window !== 'undefined') {
|
||||
@@ -857,6 +870,7 @@ export const UserMenu: React.FC = () => {
|
||||
setBufferStrategy('medium');
|
||||
setNextEpisodePreCache(true);
|
||||
setNextEpisodeDanmakuPreload(true);
|
||||
setDisableAutoLoadDanmaku(false);
|
||||
setHomeModules(defaultHomeModules);
|
||||
setSearchTraditionalToSimplified(false);
|
||||
|
||||
@@ -875,6 +889,7 @@ export const UserMenu: React.FC = () => {
|
||||
localStorage.setItem('bufferStrategy', 'medium');
|
||||
localStorage.setItem('nextEpisodePreCache', 'true');
|
||||
localStorage.setItem('nextEpisodeDanmakuPreload', 'true');
|
||||
localStorage.setItem('disableAutoLoadDanmaku', 'false');
|
||||
localStorage.setItem('homeModules', JSON.stringify(defaultHomeModules));
|
||||
localStorage.setItem('searchTraditionalToSimplified', 'false');
|
||||
window.dispatchEvent(new CustomEvent('homeModulesUpdated'));
|
||||
@@ -1814,6 +1829,30 @@ export const UserMenu: React.FC = () => {
|
||||
</button>
|
||||
{isDanmakuSectionOpen && (
|
||||
<div className='p-3 md:p-4 space-y-4 md:space-y-6'>
|
||||
{/* 禁用自动装填弹幕 */}
|
||||
<div className='flex items-center justify-between'>
|
||||
<div>
|
||||
<h4 className='text-sm font-medium text-gray-700 dark:text-gray-300'>
|
||||
禁用自动装填弹幕
|
||||
</h4>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 mt-1'>
|
||||
开启后,播放页面不会自动匹配弹幕,只能手动匹配
|
||||
</p>
|
||||
</div>
|
||||
<label className='flex items-center cursor-pointer'>
|
||||
<div className='relative'>
|
||||
<input
|
||||
type='checkbox'
|
||||
className='sr-only peer'
|
||||
checked={disableAutoLoadDanmaku}
|
||||
onChange={(e) => handleDisableAutoLoadDanmakuToggle(e.target.checked)}
|
||||
/>
|
||||
<div className='w-11 h-6 bg-gray-300 rounded-full peer-checked:bg-green-500 transition-colors dark:bg-gray-600'></div>
|
||||
<div className='absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform peer-checked:translate-x-5'></div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* 下集弹幕预加载 */}
|
||||
<div className='flex items-center justify-between'>
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user