mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
feat: add LogsView component for displaying logs
- Introduced a new LogsView.vue component to present logs in a structured format. - Implemented functionality to scroll to the bottom of the logs view for better user experience. - Enhanced log processing to trim and format log entries for clarity.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,7 +2,6 @@
|
||||
.vscode/
|
||||
.DS_Store
|
||||
node_modules/
|
||||
logs/
|
||||
tmp/
|
||||
_book/
|
||||
*.lock
|
||||
|
||||
47
frontend/crawlab-ui/src/components/ui/logs/LogsView.vue
Normal file
47
frontend/crawlab-ui/src/components/ui/logs/LogsView.vue
Normal file
@@ -0,0 +1,47 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
logs?: string[];
|
||||
}>();
|
||||
|
||||
const content = computed(() => {
|
||||
const { logs } = props;
|
||||
const data: string[] = [];
|
||||
logs?.forEach(l => {
|
||||
l.trim()
|
||||
.split(/[\n\r]/)
|
||||
.map(line => {
|
||||
data.push(line.trim());
|
||||
});
|
||||
});
|
||||
return data.join('\n');
|
||||
});
|
||||
|
||||
const logsViewRef = ref<HTMLDivElement>();
|
||||
|
||||
const scrollToBottom = () => {
|
||||
logsViewRef.value?.scrollTo(0, logsViewRef.value?.scrollHeight);
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
scrollToBottom,
|
||||
});
|
||||
defineOptions({ name: 'ClLogsView' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="logs-view" ref="logsViewRef">
|
||||
<pre>{{ content }}</pre>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.logs-view {
|
||||
border: 1px solid rgb(244, 244, 245);
|
||||
padding: 10px;
|
||||
overflow: auto;
|
||||
min-height: 480px;
|
||||
max-height: 560px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user