From cf1effc31bc2d88ac9ec917b4e3cf3414906bd55 Mon Sep 17 00:00:00 2001 From: xmcp Date: Thu, 18 Oct 2018 07:44:48 +0800 Subject: [PATCH] improvement stop audio auto-parsing fuck wechat --- src/AudioWidget.js | 15 ++++++++------- src/Title.js | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/AudioWidget.js b/src/AudioWidget.js index 96aa0dd0..1298db8b 100644 --- a/src/AudioWidget.js +++ b/src/AudioWidget.js @@ -22,15 +22,11 @@ export class AudioWidget extends Component { super(props); this.state={ url: this.props.src, - state: 'loading', + state: 'waiting', data: null, }; } - componentDidMount() { - this.load(); - } - load() { if(window.audio_cache[this.state.url]) { this.setState({ @@ -41,6 +37,9 @@ export class AudioWidget extends Component { } console.log('fetching audio',this.state.url); + this.setState({ + state: 'loading', + }); Promise.all([ fetch(this.state.url), load_amrnb(), @@ -80,10 +79,12 @@ export class AudioWidget extends Component { } render() { + if(this.state.state==='waiting') + return (

加载音频

); if(this.state.state==='loading') - return (

); + return (

正在下载……

); else if(this.state.state==='decoding') - return (

); + return (

正在解码……

); else if(this.state.state==='loaded') return (

); } diff --git a/src/Title.js b/src/Title.js index 4a755946..5a12d58d 100644 --- a/src/Title.js +++ b/src/Title.js @@ -58,7 +58,8 @@ class ControlBar extends PureComponent { componentDidMount() { if(window.location.hash) { - const text=window.location.hash.substr(1); + let text=window.location.hash.substr(1); + text=text.substr(0,text.lastIndexOf('?')); // fuck wechat '#param?nsukey=...' this.setState({ search_text: text, }, ()=>{