From d5e57af489235b439c61618a2c8ab1a3c1b016d8 Mon Sep 17 00:00:00 2001 From: catchonme Date: Mon, 3 Jun 2019 09:58:42 +0800 Subject: [PATCH] =?UTF-8?q?audio=20=E5=A2=9E=E5=8A=A0=E5=9C=A8table?= =?UTF-8?q?=E4=B8=AD=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/components/CRUD/Fields.jsx | 5 +++++ examples/components/Video.jsx | 1 + mock/crud/list.js | 1 + package.json | 2 +- scss/components/form/_select.scss | 2 +- src/Scoped.tsx | 2 +- src/renderers/Audio.tsx | 23 ++++++++++++----------- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/examples/components/CRUD/Fields.jsx b/examples/components/CRUD/Fields.jsx index 9dda381c3..8c1d5d1ab 100644 --- a/examples/components/CRUD/Fields.jsx +++ b/examples/components/CRUD/Fields.jsx @@ -10,6 +10,11 @@ export default { label: "ID", type: "text" }, + { + name: "audio", + label: "音频", + type: "audio" + }, { name: "carousel", label: "轮播图", diff --git a/examples/components/Video.jsx b/examples/components/Video.jsx index f48703cfa..897e859f3 100644 --- a/examples/components/Video.jsx +++ b/examples/components/Video.jsx @@ -6,6 +6,7 @@ export default { { "type": "video", "autoPlay": false, + "rates": [1.0, 1.5, 2.0], "src": "https://media.w3.org/2010/05/sintel/trailer_hd.mp4", "poster": "https://video-react.js.org/assets/poster.png" } diff --git a/mock/crud/list.js b/mock/crud/list.js index 78094566f..d65512661 100644 --- a/mock/crud/list.js +++ b/mock/crud/list.js @@ -24,6 +24,7 @@ module.exports = function(req, res) { title: '{{name.title}}', description: '{{lorem.words}}' }), Math.round(Math.random() * 10)), + audio: 'https://news-bos.cdn.bcebos.com/mvideo/%E7%9A%87%E5%90%8E%E5%A4%A7%E9%81%93%E4%B8%9C.aac', carousel: [ { image: 'https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=3893101144,2877209892&fm=23&gp=0.jpg' diff --git a/package.json b/package.json index d08c94525..84011686b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amis", - "version": "1.0.0-rc.2", + "version": "1.0.0-rc.3", "description": "一种MIS页面生成工具", "main": "lib/index.js", "scripts": { diff --git a/scss/components/form/_select.scss b/scss/components/form/_select.scss index 7cd7ccc1a..d3e7d84de 100644 --- a/scss/components/form/_select.scss +++ b/scss/components/form/_select.scss @@ -30,6 +30,7 @@ position: relative; flex-grow: 1; line-height: 1; + max-width: 100%; } &-placeholder { @@ -170,7 +171,6 @@ } &-option { - min-width: px2rem(100px); padding: ( $Form-select-menu-height - $Form-input-lineHeight * $Form-input-fontSize - px2rem(2px) diff --git a/src/Scoped.tsx b/src/Scoped.tsx index abdbd7809..cb0058df6 100644 --- a/src/Scoped.tsx +++ b/src/Scoped.tsx @@ -16,7 +16,7 @@ import { RendererData, Action } from './types'; interface ScopedComponentType extends React.Component { doAction?: (action: Action, data: RendererData, throwErrors?: boolean) => void; receive?: (values: RendererData, subPath?: string) => void; - reload?: (subPpath?:string, query?:RendererData | null, ctx?: RendererData) => void; + reload?: (subPath?:string, query?:RendererData | null, ctx?: RendererData) => void; } diff --git a/src/renderers/Audio.tsx b/src/renderers/Audio.tsx index 311af06d7..1b78c6f5a 100644 --- a/src/renderers/Audio.tsx +++ b/src/renderers/Audio.tsx @@ -15,6 +15,7 @@ export interface AudioProps extends RendererProps { } export interface AudioState { + src?: string; isReady?: boolean; muted?: boolean; playing?: boolean; @@ -47,6 +48,7 @@ export class Audio extends React.Component { }; state: AudioState = { + src: this.props.value || this.props.src || '', isReady: false, muted: false, playing: false, @@ -79,7 +81,7 @@ export class Audio extends React.Component { @autobind progress() { clearTimeout(this.progressTimeout); - if (this.props.src && this.audio) { + if (this.state.src && this.audio) { const currentTime = this.audio.currentTime || 0; const duration = this.audio.duration; const played = currentTime / duration; @@ -116,7 +118,7 @@ export class Audio extends React.Component { @autobind handleMute() { - if (!this.props.src) { + if (!this.state.src) { return; } const {muted, prevVolume} = this.state; @@ -130,7 +132,7 @@ export class Audio extends React.Component { @autobind handlePlaying() { - if (!this.props.src) { + if (!this.state.src) { return; } let playing = this.state.playing; @@ -142,7 +144,7 @@ export class Audio extends React.Component { @autobind getCurrentTime() { - if (!this.audio || !this.props.src || !this.state.isReady) { + if (!this.audio || !this.state.src || !this.state.isReady) { return '0:00'; } const duration = this.audio.duration; @@ -152,7 +154,7 @@ export class Audio extends React.Component { @autobind getDuration() { - if (!this.audio || !this.props.src) { + if (!this.audio || !this.state.src) { return '0:00'; } if (!this.state.isReady) { @@ -180,7 +182,7 @@ export class Audio extends React.Component { @autobind onSeekChange(e: any) { - if (!this.props.src) { + if (!this.state.src) { return; } const played = e.target.value; @@ -212,7 +214,7 @@ export class Audio extends React.Component { @autobind setVolume(e: any) { - if (!this.props.src) { + if (!this.state.src) { return; } const volume = e.target.value; @@ -242,7 +244,7 @@ export class Audio extends React.Component { @autobind toggleHandlePlaybackRate() { - if (!this.props.src) { + if (!this.state.src) { return; } this.setState({ @@ -252,7 +254,7 @@ export class Audio extends React.Component { @autobind toggleHandleVolume(type: boolean) { - if (!this.props.src) { + if (!this.state.src) { return; } this.setState({ @@ -370,13 +372,12 @@ export class Audio extends React.Component { const { className, inline, - src, autoPlay, loop, controls, classnames: cx } = this.props; - const {muted} = this.state; + const {muted, src} = this.state; return (