日志最多保留200行

This commit is contained in:
li-xiaochen 2025-01-28 16:13:53 +08:00
parent 25f9915fcc
commit 942d93417b
3 changed files with 17 additions and 10 deletions

View file

@ -34,15 +34,19 @@ async function initialize_config() {
await init_version()
}
const log = ref('')
const log = ref([])
provide('log', log)
const log_ele = ref(null)
provide('log_ele', log_ele)
watch(log, () => {
nextTick(() => {
log_ele.value?.scrollTo({ position: 'bottom' })
})
})
watch(
log,
() => {
nextTick(() => {
log_ele.value?.scrollTo({ position: 'bottom' })
})
},
{ deep: true }
)
onMounted(() => {
if (window.pywebview && pywebview.api) {
@ -53,12 +57,15 @@ onMounted(() => {
})
}
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) {
log.value = ''
log.value.splice(0)
}
const running = ref(false)