mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-25 17:42:25 +01:00
added virtual scroll list for log view
This commit is contained in:
39
frontend/src/components/ScrollView/LogItem.vue
Normal file
39
frontend/src/components/ScrollView/LogItem.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<div class="log-item">
|
||||
<div class="line-no">{{index}}</div>
|
||||
<div class="line-content">{{data}}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'LogItem',
|
||||
props: {
|
||||
index: {
|
||||
type: Number,
|
||||
default: 1
|
||||
},
|
||||
data: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.log-item {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.log-item .line-no {
|
||||
margin-right: 10px;
|
||||
text-align: right;
|
||||
flex-basis: 40px;
|
||||
}
|
||||
|
||||
.log-item .line-content {
|
||||
display: inline-block;
|
||||
flex-basis: calc(100% - 50px);
|
||||
}
|
||||
</style>
|
||||
78
frontend/src/components/ScrollView/LogView.vue
Normal file
78
frontend/src/components/ScrollView/LogView.vue
Normal file
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<virtual-list
|
||||
:size="18"
|
||||
:remain="100"
|
||||
:item="item"
|
||||
:itemcount="logData.length"
|
||||
:itemprops="getItemProps"
|
||||
>
|
||||
</virtual-list>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LogItem from './LogItem'
|
||||
import VirtualList from 'vue-virtual-scroll-list'
|
||||
|
||||
export default {
|
||||
name: 'LogView',
|
||||
components: {
|
||||
VirtualList
|
||||
},
|
||||
props: {
|
||||
data: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
item: LogItem
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
logData () {
|
||||
return this.data.split('\n')
|
||||
.map((d, i) => {
|
||||
return {
|
||||
index: i + 1,
|
||||
data: d
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getItemProps (index) {
|
||||
const logItem = this.logData[index]
|
||||
return {
|
||||
// <item/> will render with itemProps.
|
||||
// https://vuejs.org/v2/guide/render-function.html#createElement-Arguments
|
||||
props: {
|
||||
index: logItem.index,
|
||||
data: logItem.data
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.log-view {
|
||||
min-height: 100%;
|
||||
overflow-y: scroll;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.log-view .log-line {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.log-view .log-line:nth-child(odd) {
|
||||
}
|
||||
|
||||
.log-view .log-line:nth-child(even) {
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user