From 517b8f0d4d1433bc9a19656dbedfb998600e40e6 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 20 Mar 2024 15:44:25 +0800 Subject: [PATCH] bugfix --- bricks/accordion.js | 2 +- bricks/aggrid.js | 2 +- bricks/audio.js | 34 +++++++++++++++++++++++----------- bricks/image.js | 4 ++-- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/bricks/accordion.js b/bricks/accordion.js index c754921..d40ea5d 100644 --- a/bricks/accordion.js +++ b/bricks/accordion.js @@ -1,5 +1,5 @@ var bricks = window.bricks || {}; -bricks.Accordion = class oops extends bricks.VBox { +bricks.Accordion = class extends bricks.VBox { /* { item_size: diff --git a/bricks/aggrid.js b/bricks/aggrid.js index 46f7e88..a2cd978 100644 --- a/bricks/aggrid.js +++ b/bricks/aggrid.js @@ -1,5 +1,5 @@ var bricks = window.bricks || {}; -bricks.AG_Grid = class oops extends bricks.JsWidget { +bricks.AG_Grid = class extends bricks.JsWidget { /* { dataurl: diff --git a/bricks/audio.js b/bricks/audio.js index 3559174..479f672 100755 --- a/bricks/audio.js +++ b/bricks/audio.js @@ -12,7 +12,7 @@ var formatMs=function(ms,all){ return t; }; -bricks.AudioPlayer = class oops extends bricks.JsWidget { +bricks.AudioPlayer = class extends bricks.JsWidget { /* { url: @@ -54,13 +54,18 @@ bricks.AudioPlayer = class oops extends bricks.JsWidget { } -bricks.AudioRecorder = class oops extends bricks.HBox { +bricks.AudioRecorder = class extends bricks.HBox { /* + { + "upload_url": + "icon_rate": + "upload_resp":"text", or "json", or "bin" + } we need this module: https://gitee.com/xiangyuecn/Recorder events: record_started - record_finished wavdata + record_ended realtime record wave show need a another package we only use the wav file format */ @@ -68,7 +73,7 @@ bricks.AudioRecorder = class oops extends bricks.HBox { super(opts); this.start_icon = opts.start_icon || bricks_resource('imgs/start_recording.png'); this.stop_icon = opts.stop_icon || bricks_resource('imgs/stop_recording.png'); - this.rec_btn = new bricks.Icon({url:this.start_icon }); + this.rec_btn = new bricks.Icon({url:this.start_icon, rate:this.icon_rate }); // this.player = new bricks.AudioPlayer({url:"",width:'80px'}); this.rec_time = new bricks.Text({text:" record time", i18n:false, wrap:false, width:'120px'}); this.upload_url = opts.upload_url; @@ -79,9 +84,8 @@ bricks.AudioRecorder = class oops extends bricks.HBox { this.mic_opened = false; this.add_widget(this.rec_btn); this.add_widget(this.rec_time); - // this.add_widget(this.player); this.recordData = null; - this.bind('record_finished', this.upload.bind(this)); + this.bind('record_ended', this.upload.bind(this)); } rec_btn_pressed(){ bricks.debug(this.rec_btn.url, ':url:', this.start_icon, this.stop_icon); @@ -161,7 +165,6 @@ bricks.AudioRecorder = class oops extends bricks.HBox { bricks.debug("5JuL::未打开录音"); return; }; - // this.pause_recording(); this.rec.stop(function(blob,duration){ var localURL = this.URL.createObjectURL(blob); var d = { @@ -170,14 +173,12 @@ bricks.AudioRecorder = class oops extends bricks.HBox { duration:duration } this.recordData = d; - // this.player.set_source(this.recordData.url); - this.dispatch('record_finished', d); + this.dispatch('record_ended', d); }.bind(this),function(msg){ bricks.debug("kGZO::录音失败:"); }); this.recClose(); - this.dispatch('record_ended'); } upload = async function(){ if(!this.recordData){ @@ -196,7 +197,18 @@ bricks.AudioRecorder = class oops extends bricks.HBox { params:form }); bricks.debug('ret=', ret); - this.dispatch('uploaded', ret) + if (!this.upload_resp){ + this.upload_resp = 'text'; + } + data = null; + if (this.upload_resp == 'text'){ + data = await ret.text(); + } else if (this.upload_resp == 'json'){ + data = await ret.json(); + } else if (this.upload_resp == 'bin'){ + data = await ret.bin(); + } + this.dispatch('uploaded', data) } download(){ if(!this.recordData){ diff --git a/bricks/image.js b/bricks/image.js index 01bd58a..fdad73b 100755 --- a/bricks/image.js +++ b/bricks/image.js @@ -1,5 +1,5 @@ var bricks = window.bricks || {}; -bricks.Image = class oops extends bricks.JsWidget { +bricks.Image = class extends bricks.JsWidget { /* { url: @@ -49,7 +49,7 @@ bricks.Icon = class extends bricks.Image { } } -bricks.BlankIcon = class oops extends bricks.JsWidget { +bricks.BlankIcon = class extends bricks.JsWidget { constructor(opts){ super(opts); this.rate = opts.rate || 1;