From c53223235ed02981c7233758a65c408902208d77 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 26 Dec 2024 17:33:08 +0800 Subject: [PATCH] bugfix --- bricks/build.sh | 2 +- bricks/iconbarpage.js | 55 +++++++++++++++++++++++++++++++++++++++++++ bricks/iframe.js | 1 + 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 bricks/iconbarpage.js diff --git a/bricks/build.sh b/bricks/build.sh index 0e0ebbc..7dd5f69 100755 --- a/bricks/build.sh +++ b/bricks/build.sh @@ -8,7 +8,7 @@ SOURCES=" page_data_loader.js factory.js uitypesdef.js utils.js uitype.js \ floaticonbar.js miniform.js wterm.js dynamicaccordion.js \ binstreaming.js streaming_audio.js vadtext.js rtc.js docxviewer.js \ llm_dialog.js llm.js websocket.js datarow.js tabular.js \ - line.js pie.js bar.js gobang.js period.js " + line.js pie.js bar.js gobang.js period.js iconbarpage.js " echo ${SOURCES} cat ${SOURCES} > ../dist/bricks.js # uglifyjs --compress --mangle -- ../dist/bricks.js > ../dist/bricks.min.js diff --git a/bricks/iconbarpage.js b/bricks/iconbarpage.js new file mode 100644 index 0000000..5adec22 --- /dev/null +++ b/bricks/iconbarpage.js @@ -0,0 +1,55 @@ +var bricks = window.bricks || {}; +bricks.IconbarPage = class extends bricks.VBox { + /* + opts={ + bar_opts: + bar_at: top or bottom + } + bar_opts:{ + margin: + rate: + tools: + } + tools = [ + tool, ... + ] + tool = { + name: + icon: + label: optional + tip, + dynsize + rate: + context: + } + */ + + constructor(opts){ + opts.height = '100%' + opts.bar_at = opts.bar_at || 'top'; + super(opts); + var bar = new bricks.IconTextBar(this.bar_opts); + this.content = new bricks.Filler({}); + if (this.bar_at == 'top'){ + this.add_widget(bar); + this.add_widget(this.content); + } else { + this.add_widget(this.content); + this.add_widget(bar); + } + bar.bind('command', this.command_handle.bind(this)) + schedule_once(this.show_content.bind(this, this.bar_opts.tools[0]), 0.1); + } + async command_handle(event){ + var tool = event.params; + await this.show_content(tool); + } + async show_content(tool){ + var w = await bricks.widgetBuild(tool.content, this); + if (w && ! w.parent) { + this.content.add_widget(w); + } + } +} + +bricks.Factory.register('IconbarPage', bricks.IconbarPage); diff --git a/bricks/iframe.js b/bricks/iframe.js index 48e8a99..101f7c5 100644 --- a/bricks/iframe.js +++ b/bricks/iframe.js @@ -1,6 +1,7 @@ var bricks = window.bricks || {}; bricks.Iframe = class extends bricks.Layout { constructor(opts){ + opts.height = opts.height || '100%'; super(opts); this.dom_element.src = opts.url; }