日志最多保留200行
This commit is contained in:
parent
25f9915fcc
commit
942d93417b
3 changed files with 17 additions and 10 deletions
|
@ -34,15 +34,19 @@ async function initialize_config() {
|
||||||
await init_version()
|
await init_version()
|
||||||
}
|
}
|
||||||
|
|
||||||
const log = ref('')
|
const log = ref([])
|
||||||
provide('log', log)
|
provide('log', log)
|
||||||
const log_ele = ref(null)
|
const log_ele = ref(null)
|
||||||
provide('log_ele', log_ele)
|
provide('log_ele', log_ele)
|
||||||
watch(log, () => {
|
watch(
|
||||||
nextTick(() => {
|
log,
|
||||||
log_ele.value?.scrollTo({ position: 'bottom' })
|
() => {
|
||||||
})
|
nextTick(() => {
|
||||||
})
|
log_ele.value?.scrollTo({ position: 'bottom' })
|
||||||
|
})
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (window.pywebview && pywebview.api) {
|
if (window.pywebview && pywebview.api) {
|
||||||
|
@ -53,12 +57,15 @@ onMounted(() => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
window.addEventListener('log', (e) => {
|
window.addEventListener('log', (e) => {
|
||||||
log.value += e.detail.log
|
log.value.push(e.detail.log)
|
||||||
|
if (log.value.length > 200) {
|
||||||
|
log.value.shift()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function set_page(value) {
|
function set_page(value) {
|
||||||
log.value = ''
|
log.value.splice(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
const running = ref(false)
|
const running = ref(false)
|
||||||
|
|
|
@ -11,7 +11,7 @@ const current_state = inject('current_state')
|
||||||
const notification = useNotification()
|
const notification = useNotification()
|
||||||
|
|
||||||
async function start() {
|
async function start() {
|
||||||
log.value = ''
|
log.value = []
|
||||||
running.value = true
|
running.value = true
|
||||||
for (const [i, step] of steps.value.entries()) {
|
for (const [i, step] of steps.value.entries()) {
|
||||||
current_step.value = i + 1
|
current_step.value = i + 1
|
||||||
|
|
|
@ -51,7 +51,7 @@ hljs.registerLanguage('naive-log', () => ({
|
||||||
<template>
|
<template>
|
||||||
<n-config-provider :theme="darkTheme" class="provider" :hljs="hljs">
|
<n-config-provider :theme="darkTheme" class="provider" :hljs="hljs">
|
||||||
<n-card class="full" content-style="height: 100%">
|
<n-card class="full" content-style="height: 100%">
|
||||||
<n-log :log="log" class="full selectable-log" ref="log_ele" language="naive-log" />
|
<n-log :lines="log" class="full selectable-log" ref="log_ele" language="naive-log" />
|
||||||
</n-card>
|
</n-card>
|
||||||
</n-config-provider>
|
</n-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Add table
Reference in a new issue