This commit is contained in:
yumoqing 2025-09-28 12:19:23 +08:00
parent 9c23ed5cb2
commit 00c74e4bfc
2 changed files with 15 additions and 4 deletions

View File

@ -595,3 +595,13 @@ hr {
.resp-content { .resp-content {
background-color: #f0eed8; background-color: #f0eed8;
} }
.droparea {
border: 2px dashed #666;
border-radius: 10px;
color: #666;
}
.droparea:hover {
border-color: #00aaff;
color: #00aaff;
background: #f0faff;
}

View File

@ -495,6 +495,7 @@ bricks.UiImage =class extends bricks.VBox {
url:bricks_resource('imgs/camera.svg'), url:bricks_resource('imgs/camera.svg'),
tip:'use cemera to take a picture', tip:'use cemera to take a picture',
rate:2}); rate:2});
this.set_css('droparea');
this.add_widget(this.camera_w); this.add_widget(this.camera_w);
this.camera_w.bind('click', this.take_photo.bind(this)); this.camera_w.bind('click', this.take_photo.bind(this));
this.bind('dragover', (event) => { this.bind('dragover', (event) => {
@ -504,10 +505,10 @@ bricks.UiImage =class extends bricks.VBox {
this.bind(eventName, (e) => e.preventDefault(), false); this.bind(eventName, (e) => e.preventDefault(), false);
}); });
this.bind('dragenter', () => { this.bind('dragenter', () => {
this.css('hover'); this.set_css('hover');
}); });
this.bind('dragleave', () => { this.bind('dragleave', () => {
this.css('hover', true); this.set_css('hover', true);
}); });
this.bind('drop', this.dropHandle.bind(this)); this.bind('drop', this.dropHandle.bind(this));
this.input = document.createElement('input'); this.input = document.createElement('input');
@ -547,8 +548,8 @@ bricks.UiImage =class extends bricks.VBox {
this.show_image(file); this.show_image(file);
} }
dropHandle(event){ dropHandle(event){
e.preventDefault(); event.preventDefault();
this.css('hover', true); this.set_css('hover', true);
const file = e.dataTransfer.files[0]; const file = e.dataTransfer.files[0];
this.show_image(file); this.show_image(file);