@@ -924,7 +924,7 @@ const selectEpisode = async (index) => {
924924
925925
926926
927- const playVideo = () => {
927+ const playVideo = async () => {
928928 // 检查是否有历史记录
929929 const videoId = originalVideoInfo .value .id
930930 const apiUrl = currentSiteInfo .value .api
@@ -944,42 +944,28 @@ const playVideo = () => {
944944 currentRoute .value = routeIndex
945945
946946 // 等待currentRouteEpisodes更新后查找选集
947- nextTick (() => {
948- const episodes = currentRouteEpisodes .value
949- const targetEpisode = episodes .find (ep => ep .name === historyItem .current_episode_name )
950-
951- if (targetEpisode) {
952- const episodeIndex = episodes .indexOf (targetEpisode)
953- currentEpisode .value = episodeIndex
954-
955- // 等待currentEpisodeUrl更新后播放
956- nextTick (() => {
957- if (currentEpisodeUrl .value ) {
958- console .log (' 播放历史记录位置:' , historyItem .current_episode_name )
959- Message .info (` 继续播放: ${ historyItem .current_episode_name } ` )
960-
961- // 启动内置播放器
962- showVideoPlayer .value = true
963-
964- // 更新历史记录的播放时间
965- updateHistoryRecord ()
966- }
967- })
968- } else {
969- console .warn (' 未找到历史选集,播放第一个选集' )
970- playFirstEpisode ()
971- }
972- })
947+ await nextTick ()
948+ const episodes = currentRouteEpisodes .value
949+ const targetEpisode = episodes .find (ep => ep .name === historyItem .current_episode_name )
950+
951+ if (targetEpisode) {
952+ const episodeIndex = episodes .indexOf (targetEpisode)
953+ // 调用selectEpisode进行T4解析
954+ await selectEpisode (episodeIndex)
955+ } else {
956+ console .warn (' 未找到历史选集,播放第一个选集' )
957+ await playFirstEpisode ()
958+ }
973959 } else {
974960 console .warn (' 未找到历史线路,播放第一个选集' )
975- playFirstEpisode ()
961+ await playFirstEpisode ()
976962 }
977963 } else {
978964 console .log (' 无历史记录,播放第一个选集' )
979- playFirstEpisode ()
965+ await playFirstEpisode ()
980966 }
981967 } else {
982- playFirstEpisode ()
968+ await playFirstEpisode ()
983969 }
984970}
985971
@@ -1014,7 +1000,7 @@ const findFirstM3u8Episode = () => {
10141000 return null
10151001}
10161002
1017- const playFirstEpisode = () => {
1003+ const playFirstEpisode = async () => {
10181004 // 首先尝试智能查找第一个m3u8选集
10191005 const m3u8Episode = findFirstM3u8Episode ()
10201006
@@ -1023,45 +1009,19 @@ const playFirstEpisode = () => {
10231009 console .log (` 智能播放m3u8选集: ${ m3u8Episode .route } - ${ m3u8Episode .episode } ` )
10241010 currentRoute .value = m3u8Episode .routeIndex
10251011
1026- nextTick (() => {
1027- currentEpisode .value = m3u8Episode .episodeIndex
1028-
1029- nextTick (() => {
1030- if (currentEpisodeUrl .value ) {
1031- console .log (' 播放m3u8选集:' , m3u8Episode .episode )
1032- Message .info (` 智能播放: ${ m3u8Episode .episode } ` )
1033-
1034- // 启动内置播放器
1035- showVideoPlayer .value = true
1036-
1037- // 添加到历史记录
1038- updateHistoryRecord ()
1039- }
1040- })
1041- })
1012+ await nextTick ()
1013+ // 调用selectEpisode进行T4解析
1014+ await selectEpisode (m3u8Episode .episodeIndex )
10421015 } else {
10431016 // 未找到m3u8选集,播放第一个线路的第一个选集(默认行为)
10441017 if (playRoutes .value .length > 0 ) {
10451018 currentRoute .value = 0
10461019
1047- nextTick (() => {
1048- if (currentRouteEpisodes .value .length > 0 ) {
1049- currentEpisode .value = 0
1050-
1051- nextTick (() => {
1052- if (currentEpisodeUrl .value ) {
1053- console .log (' 播放默认选集:' , currentRouteEpisodes .value [0 ].name )
1054- Message .info (` 开始播放: ${ currentRouteEpisodes .value [0 ].name } ` )
1055-
1056- // 启动内置播放器
1057- showVideoPlayer .value = true
1058-
1059- // 添加到历史记录
1060- updateHistoryRecord ()
1061- }
1062- })
1063- }
1064- })
1020+ await nextTick ()
1021+ if (currentRouteEpisodes .value .length > 0 ) {
1022+ // 调用selectEpisode进行T4解析
1023+ await selectEpisode (0 )
1024+ }
10651025 }
10661026 }
10671027}
0 commit comments