Skip to content

Commit

Permalink
feat: 添加变量控制是否使用 title 覆盖 document.title
Browse files Browse the repository at this point in the history
  • Loading branch information
kssaerbeisi123 committed Dec 29, 2021
1 parent 3408e13 commit b88d3d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion example/src/MP4Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const props = {
autoplay: true,
shouldObserveResize: true,
src: 'https://zhstatic.zhihu.com/cfe/griffith/zhihu2018_sd.mp4',
overrideDocTitle: false,
}

const parseQuery = (search: string) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/griffith/README-zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ render(<Player {...props} />)
| `hiddenVolume` | `boolean` | `false` | 隐藏音量调节 |
| `hiddenFullScreenButton` | `boolean` | `false` | 隐藏全屏按钮 |
| `progressDots` | `ProgressDotItem[]` | `[]` | 进度条节点信息 |
| `overrideDocTitle` | `boolean` | `true` | standalone 模式,是否使用 title 覆盖 document.title |
| `noWriteDocTitle` | `boolean` | `false` | standalone 模式,是否使用 title 覆盖 document.title |

`sources` 字段:

Expand Down
13 changes: 7 additions & 6 deletions packages/griffith/src/components/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type InnerPlayerProps = ProviderOnlyProps & {
shouldShowPageFullScreenButton?: boolean
hideMobileControls?: boolean
hideCover?: boolean
overrideDocTitle?: boolean
noWriteDocTitle?: boolean
}

// 仅供 Provider 使用的属性
Expand Down Expand Up @@ -132,7 +132,7 @@ class InnerPlayer extends Component<InnerPlayerProps, State> {
progressDots: [],
hideMobileControls: false,
hideCover: false,
overrideDocTitle: true,
noWriteDocTitle: false,
}

state = {
Expand Down Expand Up @@ -253,12 +253,12 @@ class InnerPlayer extends Component<InnerPlayerProps, State> {
}

setDocumentTitle = () => {
const {title, standalone, overrideDocTitle} = this.props
const {title, standalone, noWriteDocTitle} = this.props
if (
standalone &&
typeof title === 'string' &&
title !== document.title &&
overrideDocTitle
!noWriteDocTitle
) {
document.title = title
}
Expand Down Expand Up @@ -545,6 +545,7 @@ class InnerPlayer extends Component<InnerPlayerProps, State> {

render() {
const {
title,
error,
cover,
standalone,
Expand Down Expand Up @@ -722,14 +723,14 @@ class InnerPlayer extends Component<InnerPlayerProps, State> {
}}
onClick={this.handleToggle}
/>
{document?.title && isFullScreen && (
{title && isFullScreen && (
<div
className={css(
styles.title,
showController && styles.titleShown
)}
>
{document.title}
{title}
</div>
)}
{/*首帧已加载完成时展示 MinimalTimeline 组件*/}
Expand Down

0 comments on commit b88d3d9

Please sign in to comment.