From 05bea8606909063cea7a1ddac2ad174d21d81598 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 13 Dec 2024 18:07:16 +0800 Subject: [PATCH] bugfix --- bricks/bricks.js | 22 +++++++++++++++++++--- bricks/llm.js | 25 +++++++++++++++++++------ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/bricks/bricks.js b/bricks/bricks.js index 697f1cc..f8d6b58 100644 --- a/bricks/bricks.js +++ b/bricks/bricks.js @@ -48,9 +48,20 @@ params: */ bricks.uuid = function(){ - var d = crypto.randomUUID(); - var lst = d.split('-'); - return lst.join(''); + try{ + var d = crypto.randomUUID(); + var lst = d.split('-'); + return lst.join(''); + } catch(e) { + const vv = '1234567890qwertyuiopasdfghjklzxcvbnm'; + var ret = ''; + for (var i=0;i<30;i++){ + var j = parseInt(Math.random() * vv.length); + ret = ret + vv[j]; + } + console.log('uuid() return', ret); + return ret; + } } bricks.deviceid = function(appname){ @@ -522,6 +533,11 @@ bricks.App = class extends bricks.Layout { this.video_devices = null this.vpos = null; document.addEventListener('keydown', this.key_down_action.bind(this)); + this.screen_orient = window.screen.orientation.type; + window.screen.orientation.addEventListener('change', () => { + this.screen_orient = window.screen.orientation.type; + this.bind('orient_changed', this.screen_orient); + }); } async getCameras() { try { diff --git a/bricks/llm.js b/bricks/llm.js index 9979694..f611a17 100644 --- a/bricks/llm.js +++ b/bricks/llm.js @@ -55,7 +55,11 @@ bricks.ModelOutput = class extends bricks.HBox { opts.width = '100%'; super(opts); this.logid = null; - this.img = new bricks.Icon({rate:2,url:this.icon||bricks_resource('imgs/llm.png')}); + this.img = new bricks.Icon({ + rate:2, + tip:this.opts.model, + url:this.icon||bricks_resource('imgs/llm.png') + }); this.run = new bricks.BaseRunning({target:this}); this.add_widget(this.img); this.add_widget(this.run); @@ -163,7 +167,10 @@ bricks.LlmModel = class extends bricks.JsWidget { render_title(){ var w = new bricks.HBox({}); w.bind('click', this.show_setup_panel.bind(this)) - var img = new bricks.Icon({rate:2,url:this.opts.icon||bricks_resource('imgs/llm.png')}); + var img = new bricks.Icon({ + rate:2, + url:this.opts.icon||bricks_resource('imgs/llm.png') + }); var txt = new bricks.Text({text:this.opts.model}); w.add_widget(img); w.add_widget(txt); @@ -199,7 +206,8 @@ bricks.LlmModel = class extends bricks.JsWidget { var mout = new bricks.ModelOutput({ textvoice:this.textvoice, tts_url:this.tts_url, - icon:this.opts.icon, + icon:this.opts.icon, + model:this.opts.model, estimate_url:this.llmio.estimate_url, output_view:this.opts.output_view}); this.llmio.o_w.add_widget(mout); @@ -286,20 +294,25 @@ bricks.LlmIO = class extends bricks.VBox { constructor(opts){ super(opts); this.llmmodels = []; - this.title_w = new bricks.HBox({cheight:2}); + this.title_w = new bricks.HBox({cheight:3}); + var bottom_box = new bricks.HBox({cheight:3}); this.i_w = new bricks.Icon({ rate:2, url:bricks_resource('imgs/input.png'), + margin:'14px', tip:'input data', css:'clickable' }); this.nm_w = new bricks.Icon({ rate:2, url:bricks_resource('imgs/add.png'), + margin:'14px', tip:'add new model', css:'clickable' }); - this.title_w.add_widget(this.nm_w); + bottom_box.add_widget(this.i_w); + bottom_box.add_widget(this.nm_w); + this.nm_w.bind('click', this.open_search_models.bind(this)); this.i_w.bind('click', this.open_input_widget.bind(this)); this.o_w = new bricks.Filler({overflow:'auto'}); @@ -308,7 +321,7 @@ bricks.LlmIO = class extends bricks.VBox { if (this.models.length < 2 && this.tts_url){ this.textvoice = true; } - this.add_widget(this.i_w); + this.add_widget(bottom_box); this.models.forEach( m =>{ this.show_added_model(m); });