From 8969e0569f6d5343e207cd60803254767573af84 Mon Sep 17 00:00:00 2001 From: CY Date: Tue, 26 Mar 2024 09:08:14 +0000 Subject: [PATCH] - --- packages/index/src/pages/index/index.tsx | 20 ++- packages/index/src/pages/player/info.tsx | 1 + packages/shared/components/player/OPlayer.tsx | 153 +++++++++--------- 3 files changed, 88 insertions(+), 86 deletions(-) diff --git a/packages/index/src/pages/index/index.tsx b/packages/index/src/pages/index/index.tsx index e619203..a9b468f 100644 --- a/packages/index/src/pages/index/index.tsx +++ b/packages/index/src/pages/index/index.tsx @@ -3,7 +3,7 @@ import { Helmet } from 'react-helmet' import RankList from '../../components/rank-list' import ListSection from '../../components/list-section' -import recommends from '../../mock/recommends.json' +// import recommends from '../../mock/recommends.json' import { cliclisAdapter } from '../../enime.adp' import { corsAxios } from '@web/shared/constants' @@ -13,11 +13,11 @@ const indexConfig = [ // query: 'type=recommends&title=recommends', // icon: require('../../assets/live.svg').default, // }, - { - title: 'Recommends', - query: 'type=recommends&title=recommends', - icon: require('../../assets/recommend.svg').default, - }, + // { + // title: 'Recommends', + // query: 'type=recommends&title=recommends', + // icon: require('../../assets/recommend.svg').default, + // }, { title: `What We're Watching Right Now`, query: `type=popular&title=What We're Watching Right Now`, @@ -36,10 +36,8 @@ export default function IndexPage() { useEffect(() => { Promise.allSettled([ // corsAxios.get(`https://www.clicli.cc/users?level=4&page=1&pageSize=9`), - recommends, - corsAxios.get( - 'https://www.clicli.cc/posts?status=public&sort=&tag=%E6%8E%A8%E8%8D%90&uid=&page=1&pageSize=12' - ), + // recommends, + corsAxios.get('https://www.clicli.cc/posts?status=public&sort=&tag=%E6%8E%A8%E8%8D%90&uid=&page=1&pageSize=12'), corsAxios.get('https://www.clicli.cc/posts?status=public&sort=&tag=&uid=&page=1&pageSize=24'), corsAxios.get('https://www.clicli.cc/rank?day=60'), ] as any).then((_resp) => { @@ -66,7 +64,7 @@ export default function IndexPage() { key={index} videos={state[index]} isLive={index == -1} - icon={indexConfig[index].icon} + // icon={indexConfig[index].icon} title={indexConfig[index].title} moreUrl={`/pv/tag?${indexConfig[index].query}`} aside={index == 0 && } diff --git a/packages/index/src/pages/player/info.tsx b/packages/index/src/pages/player/info.tsx index 2c759bd..03f0d8b 100644 --- a/packages/index/src/pages/player/info.tsx +++ b/packages/index/src/pages/player/info.tsx @@ -76,6 +76,7 @@ export default function PlayerInfo({ .replace(/播放出错.+\n/, '') .replace(/播放失效.+\n/, '') .replace(/有问题.+\n/, '') + .replace(/clicli.+\n/, '') .replace(/CliCli官方.+\d+/, '') || '#### 暂无详情' } /> diff --git a/packages/shared/components/player/OPlayer.tsx b/packages/shared/components/player/OPlayer.tsx index 43d45c9..cb7e4bb 100644 --- a/packages/shared/components/player/OPlayer.tsx +++ b/packages/shared/components/player/OPlayer.tsx @@ -3,7 +3,7 @@ import { isIOS, isMobile } from '@oplayer/core' import hls from '@oplayer/hls' import ReactPlayer from '@oplayer/react' import ui from '@oplayer/ui' -import React, { useImperativeHandle, useRef } from 'react' +import React, { useImperativeHandle, useMemo, useRef } from 'react' import { PlaylistPlugin, Chromecast } from '@oplayer/plugins' // import Anime4kPlugin from './ainme4k' @@ -14,86 +14,89 @@ interface OPlayerProps extends PlayerOptions { onEvent?: (event: PlayerEvent) => void } -const plugins = [ - ui({ - speeds: [], - pictureInPicture: true, - keyboard: { global: true }, - forceLandscapeOnFullscreen: true, - subtitle: { background: true, shadow: 'none' }, +const OPlayer = React.forwardRef(({ playerIsPlaying, duration, onEvent, autoplay, ...rest }: OPlayerProps, ref) => { + const _ref = useRef(null) - theme: { - controller: { - header: {}, - slideToSeek: 'always', - displayBehavior: 'delay', - }, - progress: { position: isIOS ? 'top' : 'auto' }, - }, + useImperativeHandle(ref, () => _ref.current) - settings: [ - { - icon: ``, - name: 'Power By OPlayer', - type: 'switcher', - onChange() { - window.open('https://github.com/shiyiya/oplayer') - }, - }, - ], + const plugins = useMemo( + () => [ + ui({ + speeds: [], + pictureInPicture: true, + keyboard: { global: true }, + forceLandscapeOnFullscreen: true, + subtitle: { background: true, shadow: 'none' }, - icons: { - loadingIndicator: ` - - - `, - next: ``, - play: ` `, - // play: ``, - // pause: ``, - volume: [ - ``, - ``, - ], - fullscreen: [ - ``, - ``, - ], - pip: [ - ``, - ``, - ], - setting: ``, - screenshot: ``, - playbackRate: ``, - loop: ``, - }, - menu: [ - { - name: localStorage.getItem('speed') ? localStorage.getItem('speed')! + 'x' : '倍速', - children: ['2.0', '1.5', '1.25', '1.0', '0.75', '0.5'].map((speed) => ({ - name: speed + 'x', - value: speed, - default: (localStorage.getItem('speed') || '1.0') == speed, - })), - onChange({ name, value }, elm, player) { - elm.innerText = name - player.setPlaybackRate(+value) - localStorage.setItem('speed', value) + theme: { + controller: { + header: {}, + slideToSeek: 'always', + displayBehavior: 'delay', + }, + progress: { position: isIOS ? 'top' : 'auto' }, }, - }, - ], - }), - hls({ forceHLS: true }), - new PlaylistPlugin({ sources: [] }), - new Chromecast(), - // new Anime4kPlugin(), -] -const OPlayer = React.forwardRef(({ playerIsPlaying, duration, onEvent, autoplay, ...rest }: OPlayerProps, ref) => { - const _ref = useRef(null) + settings: [ + { + icon: ``, + name: 'Power By OPlayer', + type: 'switcher', + onChange() { + window.open('https://github.com/shiyiya/oplayer') + }, + }, + ], - useImperativeHandle(ref, () => _ref.current) + icons: { + loadingIndicator: ` + + + `, + next: ``, + play: ` `, + // play: ``, + // pause: ``, + volume: [ + ``, + ``, + ], + fullscreen: [ + ``, + ``, + ], + pip: [ + ``, + ``, + ], + setting: ``, + screenshot: ``, + playbackRate: ``, + loop: ``, + }, + menu: [ + { + name: localStorage.getItem('speed') ? localStorage.getItem('speed')! + 'x' : '倍速', + children: ['2.0', '1.5', '1.25', '1.0', '0.75', '0.5'].map((speed) => ({ + name: speed + 'x', + value: speed, + default: (localStorage.getItem('speed') || '1.0') == speed, + })), + onChange({ name, value }, elm, player) { + elm.innerText = name + player.setPlaybackRate(+value) + localStorage.setItem('speed', value) + }, + }, + ], + }), + hls({ forceHLS: true }), + new PlaylistPlugin({ sources: [] }), + new Chromecast(), + // new Anime4kPlugin(), + ], + [] + ) return (