自动滚动和自动高度

This commit is contained in:
fofolee 2022-04-28 20:21:55 +08:00
parent e113695a0a
commit 1e50cb07ae

View File

@ -16,10 +16,7 @@
> >
<q-btn flat round icon="close" color="negative" v-close-popup /> <q-btn flat round icon="close" color="negative" v-close-popup />
</q-toolbar> </q-toolbar>
<q-card-section <div style="max-height: calc(100% - 50px)" class="scroll">
style="max-height: calc(100% - 50px); padding: 0"
class="scroll"
>
<ResultArea <ResultArea
v-if="isResultShow" v-if="isResultShow"
@frameLoad="frameLoad" @frameLoad="frameLoad"
@ -30,7 +27,7 @@
:maxHeight="maxHeight" :maxHeight="maxHeight"
:key="timeStamp" :key="timeStamp"
/> />
</q-card-section> </div>
</q-card> </q-card>
</q-dialog> </q-dialog>
</div> </div>
@ -46,7 +43,7 @@
:key="timeStamp" :key="timeStamp"
/> />
</div> </div>
<q-resize-observer @resize="outputAutoHeight" debounce="0" /> <q-resize-observer @resize="autoHeight" debounce="0" />
</div> </div>
</template> </template>
@ -237,18 +234,23 @@ export default {
this.runResultStatus = isSuccess; this.runResultStatus = isSuccess;
if (!_.isArray(content)) content = [content]; if (!_.isArray(content)) content = [content];
this.runResult = this.runResult.concat(content); this.runResult = this.runResult.concat(content);
this.autoScroll();
}, },
// utools // utools
outputAutoHeight(e) { autoHeight(e) {
let autoScroll = 1; if (!this.fromUtools) return;
let pluginHeight = e.height < this.maxHeight ? e.height : this.maxHeight; let pluginHeight = e.height < this.maxHeight ? e.height : this.maxHeight;
this.fromUtools && utools.setExpendHeight(pluginHeight); utools.setExpendHeight(pluginHeight);
autoScroll && },
window.scroll({ autoScroll() {
top: e.height, if (this.enableHtml) return;
left: 0, this.$nextTick(() => {
let results = document.querySelectorAll(".result");
results[results.length - 1].scrollIntoView({
block: "end",
behavior: "smooth", behavior: "smooth",
}); });
});
}, },
stopRun() { stopRun() {
this.runResult = []; this.runResult = [];