mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-27 23:34:48 +08:00
feat: add delete skip config
This commit is contained in:
@@ -465,12 +465,73 @@ function PlayPageClient() {
|
||||
if (!currentSourceRef.current || !currentIdRef.current) return;
|
||||
|
||||
try {
|
||||
await saveSkipConfig(
|
||||
currentSourceRef.current,
|
||||
currentIdRef.current,
|
||||
newConfig
|
||||
);
|
||||
setSkipConfig(newConfig);
|
||||
if (!newConfig.enable && !newConfig.intro_time && !newConfig.outro_time) {
|
||||
await deleteSkipConfig(currentSourceRef.current, currentIdRef.current);
|
||||
artPlayerRef.current.setting.update({
|
||||
name: '跳过片头片尾',
|
||||
html: '跳过片头片尾',
|
||||
switch: skipConfigRef.current.enable,
|
||||
onSwitch: function (item: any) {
|
||||
const newConfig = {
|
||||
...skipConfigRef.current,
|
||||
enable: !item.switch,
|
||||
};
|
||||
handleSkipConfigChange(newConfig);
|
||||
return !item.switch;
|
||||
},
|
||||
});
|
||||
artPlayerRef.current.setting.update({
|
||||
name: '设置片头',
|
||||
html: '设置片头',
|
||||
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="12" r="2" fill="#ffffff"/><path d="M9 12L17 12" stroke="#ffffff" stroke-width="2"/><path d="M17 6L17 18" stroke="#ffffff" stroke-width="2"/></svg>',
|
||||
tooltip:
|
||||
skipConfigRef.current.intro_time === 0
|
||||
? '设置片头时间'
|
||||
: `${formatTime(skipConfigRef.current.intro_time)}`,
|
||||
onClick: function () {
|
||||
const currentTime = artPlayerRef.current?.currentTime || 0;
|
||||
if (currentTime > 0) {
|
||||
const newConfig = {
|
||||
...skipConfigRef.current,
|
||||
intro_time: currentTime,
|
||||
};
|
||||
handleSkipConfigChange(newConfig);
|
||||
return `${formatTime(currentTime)}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
artPlayerRef.current.setting.update({
|
||||
name: '设置片尾',
|
||||
html: '设置片尾',
|
||||
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 6L7 18" stroke="#ffffff" stroke-width="2"/><path d="M7 12L15 12" stroke="#ffffff" stroke-width="2"/><circle cx="19" cy="12" r="2" fill="#ffffff"/></svg>',
|
||||
tooltip:
|
||||
skipConfigRef.current.outro_time >= 0
|
||||
? '设置片尾时间'
|
||||
: `-${formatTime(-skipConfigRef.current.outro_time)}`,
|
||||
onClick: function () {
|
||||
const outroTime =
|
||||
-(
|
||||
artPlayerRef.current?.duration -
|
||||
artPlayerRef.current?.currentTime
|
||||
) || 0;
|
||||
if (outroTime < 0) {
|
||||
const newConfig = {
|
||||
...skipConfigRef.current,
|
||||
outro_time: outroTime,
|
||||
};
|
||||
handleSkipConfigChange(newConfig);
|
||||
return `-${formatTime(-outroTime)}`;
|
||||
}
|
||||
},
|
||||
});
|
||||
} else {
|
||||
await saveSkipConfig(
|
||||
currentSourceRef.current,
|
||||
currentIdRef.current,
|
||||
newConfig
|
||||
);
|
||||
}
|
||||
console.log('跳过片头片尾配置已保存:', newConfig);
|
||||
} catch (err) {
|
||||
console.error('保存跳过片头片尾配置失败:', err);
|
||||
@@ -1284,8 +1345,9 @@ function PlayPageClient() {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '跳过片头片尾',
|
||||
html: '跳过片头片尾',
|
||||
switch: skipConfig.enable,
|
||||
switch: skipConfigRef.current.enable,
|
||||
onSwitch: function (item) {
|
||||
const newConfig = {
|
||||
...skipConfigRef.current,
|
||||
@@ -1296,12 +1358,24 @@ function PlayPageClient() {
|
||||
},
|
||||
},
|
||||
{
|
||||
html: '删除跳过配置',
|
||||
onClick: function () {
|
||||
handleSkipConfigChange({
|
||||
enable: false,
|
||||
intro_time: 0,
|
||||
outro_time: 0,
|
||||
});
|
||||
return '';
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '设置片头',
|
||||
html: '设置片头',
|
||||
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="5" cy="12" r="2" fill="#ffffff"/><path d="M9 12L17 12" stroke="#ffffff" stroke-width="2"/><path d="M17 6L17 18" stroke="#ffffff" stroke-width="2"/></svg>',
|
||||
tooltip:
|
||||
skipConfig.intro_time === 0
|
||||
skipConfigRef.current.intro_time === 0
|
||||
? '设置片头时间'
|
||||
: `${formatTime(skipConfig.intro_time)}`,
|
||||
: `${formatTime(skipConfigRef.current.intro_time)}`,
|
||||
onClick: function () {
|
||||
const currentTime = artPlayerRef.current?.currentTime || 0;
|
||||
if (currentTime > 0) {
|
||||
@@ -1315,12 +1389,13 @@ function PlayPageClient() {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: '设置片尾',
|
||||
html: '设置片尾',
|
||||
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 6L7 18" stroke="#ffffff" stroke-width="2"/><path d="M7 12L15 12" stroke="#ffffff" stroke-width="2"/><circle cx="19" cy="12" r="2" fill="#ffffff"/></svg>',
|
||||
tooltip:
|
||||
skipConfig.outro_time >= 0
|
||||
skipConfigRef.current.outro_time >= 0
|
||||
? '设置片尾时间'
|
||||
: `-${formatTime(-skipConfig.outro_time)}`,
|
||||
: `-${formatTime(-skipConfigRef.current.outro_time)}`,
|
||||
onClick: function () {
|
||||
const outroTime =
|
||||
-(
|
||||
@@ -1329,7 +1404,7 @@ function PlayPageClient() {
|
||||
) || 0;
|
||||
if (outroTime < 0) {
|
||||
const newConfig = {
|
||||
...skipConfig,
|
||||
...skipConfigRef.current,
|
||||
outro_time: outroTime,
|
||||
};
|
||||
handleSkipConfigChange(newConfig);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
'use client';
|
||||
|
||||
const CURRENT_VERSION = '20250731021807';
|
||||
const CURRENT_VERSION = '20250731130730';
|
||||
|
||||
// 版本检查结果枚举
|
||||
export enum UpdateStatus {
|
||||
|
||||
Reference in New Issue
Block a user