播放全局事件

main
king 1 year ago
parent da52fe659c
commit f0a06b7fe9
  1. 2
      src/api/request.ts
  2. 10
      src/components/video/video.tsx
  3. 7
      src/pages/business/videoInfo/components/catalogue.tsx
  4. 1
      src/pages/home/components/feature_recommended.tsx
  5. 1
      src/pages/login/login.config.ts
  6. 14
      src/pages/login/login.tsx
  7. 2
      src/pages/meeting/meeting.tsx
  8. 2
      src/pages/preview/videoFull/videoFull.tsx
  9. 2
      src/store/profile.ts

@ -88,7 +88,7 @@ export function request<T = unknown>(
// showCancel: false,
// success() {
Taro.clearStorageSync()
Taro.reLaunch({url: '/pages/login/login'})
Taro.redirectTo({url: '/pages/login/login'})
// }
// })
} else {

@ -1,7 +1,7 @@
import {BaseEventOrig, Video, VideoProps} from "@tarojs/components";
import {HVideoOptions} from "@/components/video/type";
import Taro from "@tarojs/taro";
import {FC, useState} from "react";
import {FC, useEffect, useState} from "react";
import unique_ident from "@/hooks/unique_ident";
import videoEvents from "@/hooks/videoEvents";
@ -12,6 +12,10 @@ const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
try {
video = Taro.createVideoContext('myVideo')
} catch (e) {
}
useEffect(() => {
videoEvents.onSetVideoState(({name}) => {
switch (name) {
case "pause":
@ -22,8 +26,7 @@ const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
break
}
})
} catch (e) {
}
}, [])
function onTimeUpdate(event: BaseEventOrig<VideoProps.onTimeUpdateEventDetail>) {
const time = event.detail.currentTime
@ -66,6 +69,7 @@ const HVideo: FC<HVideoOptions> = (opt: HVideoOptions) => {
function onEnded() {
if (currentTime + 1 > opt.duration) {
opt.onEnded()
videoEvents.videoState('pause')
} else {
video?.seek(currentTime)
unique_ident.remove()

@ -96,7 +96,8 @@ const Catalogue: FC<Props> = ({data, setHors, id, playId}) => {
function learning() {
const flats: Hour[] = Object.values(data?.hours || {}).flat(Infinity) as Hour[]
if ((data?.learn_hour_records?.length || undefined) == data?.learn_record?.hour_count && flats.length) {
if (!flats.length) return;
if (!data?.learn_hour_records?.length || data.learn_hour_records.length === data.learn_record?.hour_count) {
if (flats[0].id === playId) {
videoEvents.setVideoState('play')
} else {
@ -174,8 +175,8 @@ const Catalogue: FC<Props> = ({data, setHors, id, playId}) => {
<View className='Videobutton'>
{
playing ? <MyButton style={{flex: '1'}} onClick={onPause}></MyButton>
: <MyButton style={{flex: '1'}} onClick={learning}></MyButton>
playing ? <MyButton style={{flex: '1'}} onClick={onPause}>{JSON.stringify(playing)}</MyButton>
: <MyButton style={{flex: '1'}} onClick={learning}>{JSON.stringify(playing)}</MyButton>
}
<View className='px-3' onClick={() => setShow(true)}>...</View>

@ -125,7 +125,6 @@ const FeatureRecommended: FC = () => {
oldData[0].data = brand
oldData[1].data = health
oldData[2].data = kill
console.log(illness)
oldData[3].data = illness
setData(oldData)
})

@ -1,4 +1,3 @@
export default definePageConfig({
navigationStyle: 'custom',
navigationBarTitleText: '登录'
})

@ -9,10 +9,6 @@ import {loginApi, LoginParams} from "@/api/login";
import MyButton from "@/components/button/MyButton";
const Login: FC = () => {
// const {statusBarHeight = 0} = Taro.getSystemInfoSync()
// const bbc = getMenuButtonBoundingClientRect();
// const navHeight = bbc.bottom + (bbc.top - statusBarHeight) - statusBarHeight
const [isLoading, setLoading] = useState(false)
const [error, setError] = useState<string | null>(null)
const {setUser, setToken, setCompany} = Profile.useContainer()
@ -78,11 +74,11 @@ const Login: FC = () => {
}
}
async function TESTLOGIN() {
const res = await loginApi.testLogin()
Taro.setStorageSync('profile', JSON.stringify(res))
Taro.reLaunch({url: '/pages/home/home'})
}
// async function TESTLOGIN() {
// const res = await loginApi.testLogin()
// Taro.setStorageSync('profile', JSON.stringify(res))
// Taro.reLaunch({url: '/pages/home/home'})
// }
return (
<View className={styles.container}>

@ -48,7 +48,7 @@ const MeetingLogin: FC = () => {
Taro.showModal({
title: res.type === 0 ? '暂未开始' : '二维码已过期',
success() {
Taro.reLaunch({url: '/pages/login/login'})
Taro.redirectTo({url: '/pages/login/login'})
}
})
return

@ -49,7 +49,7 @@ const VideoFull: FC = () => {
<>
{params.title && <View className={styles.title}>{params.title}</View>}
<Video
posterSize='cover'
posterSize='100%'
id={'myVideo'}
onClick={click}
className={styles.video}

@ -57,7 +57,7 @@ function useProfile() {
setUser(null)
setToken(null)
Taro.removeStorageSync('profile')
Taro.reLaunch({url: '/pages/login/login'})
Taro.redirectTo({url: '/pages/login/login'})
}
useEffect(() => {

Loading…
Cancel
Save