优化 audio 组件
This commit is contained in:
parent
3ecb343750
commit
8221c638f8
|
@ -2925,7 +2925,7 @@ Action 是一种特殊的渲染器,它本身是一个按钮,同时它能触
|
||||||
"link": "/docs/index"
|
"link": "/docs/index"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
* `url` 当按钮点击后,新窗口打开指定页面。
|
* `url` 当按钮点击后,新窗口打开指定页面。
|
||||||
|
|
||||||
```schema:height="200"
|
```schema:height="200"
|
||||||
|
@ -2938,7 +2938,7 @@ Action 是一种特殊的渲染器,它本身是一个按钮,同时它能触
|
||||||
"url": "raw:http://www.baidu.com"
|
"url": "raw:http://www.baidu.com"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
* `dialog` 当按钮点击后,弹出一个对话框。 关于 dialog 配置,请查看 [Dialog 模型](#dialog)。
|
* `dialog` 当按钮点击后,弹出一个对话框。 关于 dialog 配置,请查看 [Dialog 模型](#dialog)。
|
||||||
|
|
||||||
```schema:height="200"
|
```schema:height="200"
|
||||||
|
@ -2964,7 +2964,7 @@ Action 是一种特殊的渲染器,它本身是一个按钮,同时它能触
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
* `drawer` 当按钮点击后,弹出一个抽出式对话框。 关于 drawer 配置,请查看 [Drawer 模型](#drawer)。
|
* `drawer` 当按钮点击后,弹出一个抽出式对话框。 关于 drawer 配置,请查看 [Drawer 模型](#drawer)。
|
||||||
|
|
||||||
|
@ -2991,7 +2991,7 @@ Action 是一种特殊的渲染器,它本身是一个按钮,同时它能触
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Dialog
|
## Dialog
|
||||||
|
|
||||||
|
@ -3465,6 +3465,28 @@ CRUD 支持三种模式:`table`、`cards`、`list`,默认为 `table`。
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Audio
|
||||||
|
|
||||||
|
音频播放器
|
||||||
|
|
||||||
|
|属性名 | 类型 | 默认值 | 说明 |
|
||||||
|
|---|---|---|---|
|
||||||
|
| type | `string` | `"audio"` | 指定为 audio 渲染器 |
|
||||||
|
| className | `string` | | 外层 Dom 的类名 |
|
||||||
|
| inline | `boolean` | true | 是否是内联模式 |
|
||||||
|
| src | `string` | | 音频地址 |
|
||||||
|
| loop | `boolean` | false | 是否循环播放 |
|
||||||
|
| autoPlay | `boolean` | false | 是否自动播放 |
|
||||||
|
| rates | `array` | `[1.0, 2.0, 4.0]` | 加速播放 |
|
||||||
|
|
||||||
|
```schema:height="500" scope="body"
|
||||||
|
{
|
||||||
|
"type": "audio",
|
||||||
|
"autoPlay": false,
|
||||||
|
"src": ""
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Video
|
## Video
|
||||||
|
|
||||||
视频播放器。
|
视频播放器。
|
||||||
|
|
|
@ -35,11 +35,16 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.#{$ns}Audio--inline {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
.#{$ns}Audio {
|
.#{$ns}Audio {
|
||||||
width: $Audio-width;
|
width: $Audio-width;
|
||||||
height: $Audio-height;
|
height: $Audio-height;
|
||||||
line-height: $Audio-lineHeight;
|
line-height: $Audio-lineHeight;
|
||||||
border: $Audio-border;
|
border: $Audio-border;
|
||||||
|
display: inline-block;
|
||||||
&-rates {
|
&-rates {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { volumeIcon, muteIcon, playIcon, pauseIcon} from '../components/icons';
|
||||||
|
|
||||||
export interface AudioProps extends RendererProps {
|
export interface AudioProps extends RendererProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
|
inline?: boolean,
|
||||||
src?: string,
|
src?: string,
|
||||||
autoPlay?: boolean,
|
autoPlay?: boolean,
|
||||||
loop?: boolean,
|
loop?: boolean,
|
||||||
|
@ -32,7 +33,8 @@ export class Audio extends React.Component<AudioProps, AudioState> {
|
||||||
audio: any;
|
audio: any;
|
||||||
progressTimeout: any;
|
progressTimeout: any;
|
||||||
|
|
||||||
static defaultProps:Partial<AudioProps> = {
|
static defaultProps:Pick<AudioProps, 'inline' | 'autoPlay' | 'playbackRate' | 'loop' | 'rates' | 'progressInterval'> = {
|
||||||
|
inline: true,
|
||||||
autoPlay: false,
|
autoPlay: false,
|
||||||
playbackRate: 1,
|
playbackRate: 1,
|
||||||
loop: false,
|
loop: false,
|
||||||
|
@ -215,6 +217,7 @@ export class Audio extends React.Component<AudioProps, AudioState> {
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
className,
|
className,
|
||||||
|
inline,
|
||||||
src,
|
src,
|
||||||
autoPlay,
|
autoPlay,
|
||||||
loop,
|
loop,
|
||||||
|
@ -233,7 +236,7 @@ export class Audio extends React.Component<AudioProps, AudioState> {
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className={cx(inline ? 'Audio--inline' : '')}>
|
||||||
<audio
|
<audio
|
||||||
className={cx('Audio-original')}
|
className={cx('Audio-original')}
|
||||||
ref={this.audioRef}
|
ref={this.audioRef}
|
||||||
|
@ -244,21 +247,21 @@ export class Audio extends React.Component<AudioProps, AudioState> {
|
||||||
loop={loop}>
|
loop={loop}>
|
||||||
<source src={src}/>
|
<source src={src}/>
|
||||||
</audio>
|
</audio>
|
||||||
{isReady ? <div className={cx('Audio', className)}>
|
{isReady ? (<div className={cx('Audio', className)}>
|
||||||
{rates ? <div className={cx('Audio-rates')}>
|
{rates ? (<div className={cx('Audio-rates')}>
|
||||||
<div className={cx('Audio-rate')}
|
<div className={cx('Audio-rate')}
|
||||||
onClick={this.toggleHandlePlaybackRate}>
|
onClick={this.toggleHandlePlaybackRate}>
|
||||||
x{playbackRate.toFixed(1)}
|
x{playbackRate.toFixed(1)}
|
||||||
</div>
|
</div>
|
||||||
{showHandlePlaybackRate ? <div className={cx('Audio-rateControl')}>
|
{showHandlePlaybackRate ? (<div className={cx('Audio-rateControl')}>
|
||||||
{rates.map((rate, index) =>
|
{rates.map((rate, index) =>
|
||||||
<span className={cx('Audio-rateControlItem')}
|
<span className={cx('Audio-rateControlItem')}
|
||||||
key={index}
|
key={index}
|
||||||
onClick={() => this.handlePlaybackRate(rate)}>
|
onClick={() => this.handlePlaybackRate(rate)}>
|
||||||
x{rate.toFixed(1)}
|
x{rate.toFixed(1)}
|
||||||
</span>
|
</span>
|
||||||
)} </div> : null}
|
)} </div>) : null}
|
||||||
</div>
|
</div>)
|
||||||
: null }
|
: null }
|
||||||
<div className={cx('Audio-play')} onClick={this.handlePlaying}>
|
<div className={cx('Audio-play')} onClick={this.handlePlaying}>
|
||||||
{playing ? pauseIcon : playIcon}
|
{playing ? pauseIcon : playIcon}
|
||||||
|
@ -277,7 +280,7 @@ export class Audio extends React.Component<AudioProps, AudioState> {
|
||||||
onMouseEnter={() => this.toggleHandleVolume(true)}
|
onMouseEnter={() => this.toggleHandleVolume(true)}
|
||||||
onMouseLeave={() => this.toggleHandleVolume(false)}>
|
onMouseLeave={() => this.toggleHandleVolume(false)}>
|
||||||
{showHandleVolume ?
|
{showHandleVolume ?
|
||||||
<div className={cx('Audio-volumeControl')}>
|
(<div className={cx('Audio-volumeControl')}>
|
||||||
<input
|
<input
|
||||||
type='range' min={0} max={1} step='any'
|
type='range' min={0} max={1} step='any'
|
||||||
value={volume}
|
value={volume}
|
||||||
|
@ -285,10 +288,10 @@ export class Audio extends React.Component<AudioProps, AudioState> {
|
||||||
<div className={cx('Audio-volumeControlIcon')}
|
<div className={cx('Audio-volumeControlIcon')}
|
||||||
onClick={this.handleMute}>
|
onClick={this.handleMute}>
|
||||||
{volume > 0 ? volumeIcon : muteIcon}
|
{volume > 0 ? volumeIcon : muteIcon}
|
||||||
</div></div>
|
</div></div>)
|
||||||
: volume > 0 ? volumeIcon : muteIcon}
|
: volume > 0 ? volumeIcon : muteIcon}
|
||||||
</div>
|
</div>
|
||||||
</div> : null}
|
</div>) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue