fix(tree): folder icon now switches to open-folder on expand (typo + this.icon_url bug)

This commit is contained in:
yumoqing 2026-08-15 20:35:06 +08:00
parent b09ef14301
commit c98a8b6eeb
2 changed files with 9 additions and 8 deletions

View File

@ -5,7 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="{{entire_url('/bricks/3parties/xterm.css')}}" />
<link rel="stylesheet" href="{{entire_url('/bricks/css/bricks.css')}}?v=20260815e">
<link rel="stylesheet" href="{{entire_url('/bricks/css/bricks.css')}}?v=20260815f">
<link rel="stylesheet" href="{{entire_url('/bricks/css/api_doc.css')}}">
{% for mycss in cssfiles() %}
<link rel="stylesheet" href="{{entire_url(mycss)}}">
@ -37,7 +37,7 @@
<script type="module"
src="{{entire_url('/bricks/3parties/model-viewer.min.js')}}">
</script>
<script src="{{entire_url('/bricks/bricks.js')}}?v=20260815e"></script>
<script src="{{entire_url('/bricks/bricks.js')}}?v=20260815f"></script>
{% for myjs in jsfiles() %}
<script src="{{entire_url(myjs)}}"></script>
{% endfor %}

View File

@ -77,6 +77,7 @@ bricks.TreeNode = class extends bricks.VBox {
this.children_loaded = true;
}
this.container.show();
if (this.icon_w && this.icons_urls.open) this.icon_w.set_url(this.icons_urls.open);
}
collapse(){
this.node_state = 'close'
@ -84,6 +85,7 @@ bricks.TreeNode = class extends bricks.VBox {
return;
}
this.container.hide();
if (this.icon_w && this.icons_urls.close) this.icon_w.set_url(this.icons_urls.close);
}
create_triple(){
return new bricks.StatedSvg({
@ -126,15 +128,14 @@ bricks.TreeNode = class extends bricks.VBox {
} else {
icon_url = this.icons_urls.leaf;
if (this.is_leaf) icon_url = this.icons_urls.leaf;
else if (this.node_state == 'expand') this.icon_url = this.icons_urls.open;
else this.icon_url = this.icons_urls.close;
else if (this.node_state == 'open') icon_url = this.icons_urls.open;
else icon_url = this.icons_urls.close;
}
console.log('icons=', this.icons_urls, 'icon_url=', icon_url, this.user_data);
var img = new bricks.Svg({
this.icon_w = new bricks.Svg({
rate:1,
url:icon_url
});
widget.add_widget(img);
widget.add_widget(this.icon_w);
if (this.tree.node_view){
this.view_w = await bricks.widgetBuild(this.tree.node_view, widget, this.user_data);
if (this.view_w){
@ -171,7 +172,7 @@ bricks.TreeNode = class extends bricks.VBox {
}
if (! icons){
icons = {
open: bricks_resource('imgs/open-folders.svg'),
open: bricks_resource('imgs/open-folder.svg'),
close: bricks_resource('imgs/close-folder.svg'),
leaf: bricks_resource('imgs/close-folder.svg')
};