@x-edu/live-player 0.0.24 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@x-edu/live-player",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "main": "dist/XEduLivePlayer.common.js",
5
5
  "scripts": {
6
6
  "start": "cross-env SDP_ENV=local gms dev",
@@ -12,7 +12,7 @@ export default function Pagination(props) {
12
12
  return (
13
13
  <div className={classNames(style.pagination, className, 'custom-pagination')}>
14
14
  <span className={style['pagination-text']}>
15
- {/*`当前第 ${current} 页/共 ${pageCount} 页,共有 ${total} 条记录`*/}
15
+ {/* `当前第 ${current} 页/共 ${pageCount} 页,共有 ${total} 条记录` */}
16
16
  {`共 ${total} 条`}
17
17
  </span>
18
18
  <FishPagination
package/src/demo/List.jsx CHANGED
@@ -24,9 +24,10 @@ const uc = new UC({
24
24
  export default function List() {
25
25
  const [ucInstance] = useState(uc)
26
26
  const [userInfo, setUserInfo] = useState(null)
27
+ const [refreshPage] = useState('0')
27
28
 
28
29
  const handleSubscribe = (data) => {
29
- console.log(data)
30
+ console.log(data, 444444)
30
31
  }
31
32
 
32
33
  useEffect(() => {
@@ -59,8 +60,9 @@ export default function List() {
59
60
  userInfo
60
61
  }}
61
62
  onSubscribe={handleSubscribe}
62
- scopeType={'e_teacher_studio'}
63
- scopeId={'165fee8b-56b8-48a3-a5e0-f2bf82525ff1'}
63
+ scopeType="e_teacher_studio"
64
+ scopeId="a9a32d1a-b0bd-4482-ab9d-80ce38515280"
65
+ refreshPage={refreshPage}
64
66
  />
65
67
  )
66
68
  }
@@ -6,7 +6,7 @@ import { openLiveSubscribe } from '@/service/live'
6
6
  import style from './index.module.less'
7
7
 
8
8
  const Actions = {
9
- 1: '直播回放', // 直播中 或者开播前15min
9
+ 1: '进入直播', // 直播中 或者开播前15min
10
10
  2: '观看回放', // 回放
11
11
  3: '预约', // 预告 且开播时间大于 15min
12
12
  4: '已预约'
@@ -19,9 +19,10 @@ export default function Action({
19
19
  handleLogin,
20
20
  isLogin,
21
21
  onSubscribe,
22
- setIsSubscribe
22
+ setIsSubscribe,
23
+ status
23
24
  }) {
24
- const { status, live_id: liveId, begin_time: beginTime } = data
25
+ const { live_id: liveId, begin_time: beginTime } = data
25
26
  const [curAction, setCurAction] = useState(() => {
26
27
  let actionNum
27
28
  if (status === 1 || status === 3) {
@@ -30,23 +31,23 @@ export default function Action({
30
31
  actionNum = 2
31
32
  } else { // status = 0
32
33
  // 如果超过了开播时间,不管有没有预约,都直接进入直播
33
- // const now = new Date().getTime()
34
- // const begin = new Date(beginTime).getTime()
35
- // if (now > begin) {
36
- // actionNum = 1
37
- // return actionNum
38
- // }
34
+ const now = new Date().getTime()
35
+ const begin = new Date(beginTime).getTime()
36
+ if (now > begin) {
37
+ actionNum = 1
38
+ return actionNum
39
+ }
39
40
  // 开播前15分钟,只提供进入直播按钮
40
- // if (begin > now && (begin - now) < 15 * 60 * 1000) {
41
- // actionNum = 1
42
- // return actionNum
43
- // }
41
+ if (begin > now && (begin - now) < 15 * 60 * 1000) {
42
+ actionNum = 1
43
+ return actionNum
44
+ }
44
45
  // 开播前15分钟之外
45
46
  const subscriptionItem = find(subscription, {
46
47
  live_id: liveId
47
48
  })
48
49
  if (subscriptionItem?.is_subscribe) { // 已预约
49
- actionNum = 4;
50
+ actionNum = 4
50
51
  } else { // 未预约
51
52
  actionNum = 3
52
53
  }
@@ -62,20 +63,22 @@ export default function Action({
62
63
  handleLogin(data)
63
64
  return
64
65
  }
65
- onSubscribe(data)
66
+
66
67
  await openLiveSubscribe({
67
68
  liveId
68
69
  })
69
70
  message.success('预约成功')
70
71
  const now = new Date().getTime()
71
72
  const begin = new Date(beginTime).getTime()
72
- setIsSubscribe(true);
73
+ setIsSubscribe(true)
73
74
  if (begin > now && (begin - now) < 15 * 60 * 1000) {
74
75
  setCurAction(1)
75
76
  } else {
76
77
  setCurAction(4)
77
78
  }
79
+ onSubscribe({...data, is_subscribe:true})
78
80
  } catch (error) {
81
+ onSubscribe({...data, is_subscribe:false})
79
82
  if (error?.response?.data?.message === '直播开始前15分钟无法预约') {
80
83
  setCurAction(3)
81
84
  }
@@ -3,16 +3,16 @@ import dayjs from 'dayjs'
3
3
  import classNames from 'classnames'
4
4
  import Avatar from '@/component/Avatar'
5
5
  import Icon from '@/component/Icon'
6
- import Action from './Action'
7
6
  import { formatLikesCount, formatUVCount } from '@/util/liveCountUtil'
8
7
  import { getResourceLikes } from '@/service/like'
8
+ import { find } from 'lodash'
9
+ import Action from './Action'
9
10
  import DefaultCover from './img/live.png'
10
11
  import PlayImg from './img/play.svg'
11
12
  import dianZan from './img/dianzan.svg'
12
13
  import yiYue from './img/yiguankan.svg'
13
14
  import videoSvg from './img/video.svg'
14
15
  import style from './index.module.less'
15
- import { find } from 'lodash'
16
16
 
17
17
  const TagName = {
18
18
  0: '直播预告',
@@ -37,23 +37,21 @@ export default function ListItem({
37
37
  cover_url: coverUrl,
38
38
  status
39
39
  } = data
40
-
41
40
  const [liveExt, setLiveExt] = useState({})
42
- const [isSubscribe, setIsSubscribe]= useState(()=>{
43
- if(status === 0){
41
+ const [isSubscribe, setIsSubscribe] = useState(() => {
42
+ if (status===0) {
44
43
  // 开播前15分钟之外
45
44
  const subscriptionItem = find(subscription, {
46
45
  live_id: liveId
47
46
  })
48
47
  if (subscriptionItem?.is_subscribe) { // 已预约
49
- return true
48
+ return true
50
49
  } else { // 未预约
51
- return false
50
+ return false
52
51
  }
53
- }else {
52
+ } else {
54
53
  return false
55
54
  }
56
-
57
55
  })
58
56
 
59
57
  useEffect(() => {
@@ -63,7 +61,6 @@ export default function ListItem({
63
61
  })()
64
62
  }, [])
65
63
 
66
-
67
64
  const handleDetailClick = async () => {
68
65
  if (data.login && !isLogin) {
69
66
  handleLogin(data)
@@ -81,21 +78,19 @@ export default function ListItem({
81
78
  <div
82
79
  className={style.container}
83
80
  onClick={handleDetailClick}
84
-
85
81
  >
86
-
87
82
  <div className={style.right}>
88
83
  <div className={style['right-top']}>
89
84
  <div className={style.title}>{liveName}</div>
90
85
  </div>
91
86
  <div className={style['right-bottom']}>
92
- <div className={`${style.time} ${status === 0?style['foreshow-time']:''}`}>
93
- {isSubscribe ? <Icon type="web_icon_shijian_fill" className={style['time-icon']} /> : <img src={videoSvg} className={style['time-icon']} />}
94
-
87
+ <div className={`${style.time} ${status === 0 ? style['foreshow-time'] : ''}`}>
88
+ {isSubscribe ? <Icon type="web_icon_shijian_fill" className={style['time-icon']} /> : <img src={videoSvg} className={style['time-icon']} />}
89
+
95
90
  {status === 2 ? (
96
91
  `${dayjs(beginTime).format('YYYY/MM/DD HH:mm')}`
97
92
  ) : (
98
- `${dayjs(beginTime).format('YYYY/MM/DD HH:mm')} 开始`
93
+ `${dayjs(beginTime).format('YYYY/MM/DD HH:mm')} 开始`
99
94
  )}
100
95
 
101
96
  <div className={style.like_sty}>
@@ -107,18 +102,20 @@ export default function ListItem({
107
102
  <img src={dianZan} alt="" />
108
103
  {formatLikesCount(liveExt.like_count || 0)}
109
104
  </div>
110
- </div>
105
+ </div>
111
106
  </div>
112
- {status === 0?
113
- <Action
114
- data={data}
115
- subscription={subscription}
116
- onActionDetailClick={handleDetailClick}
117
- handleLogin={handleLogin}
118
- isLogin={isLogin}
119
- onSubscribe={onSubscribe}
120
- setIsSubscribe={setIsSubscribe}
121
- />:''}
107
+
108
+ <Action
109
+ data={data}
110
+ subscription={subscription}
111
+ onActionDetailClick={handleDetailClick}
112
+ handleLogin={handleLogin}
113
+ isLogin={isLogin}
114
+ onSubscribe={onSubscribe}
115
+ setIsSubscribe={setIsSubscribe}
116
+ status={status}
117
+ />
118
+
122
119
  </div>
123
120
  </div>
124
121
  <div className={style.left}>