mirror of
https://github.com/EasyTier/EasytierGame.git
synced 2025-05-19 10:27:56 +00:00
34 lines
698 B
Vue
34 lines
698 B
Vue
<template>
|
|
<ElInput
|
|
type="textarea"
|
|
rows="17"
|
|
v-model="data.log"
|
|
resize="none"
|
|
readonly
|
|
placeholder="等待日志中..."
|
|
/>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
|
|
import { reactive, onMounted, onBeforeUnmount } from "vue";
|
|
const data = reactive({
|
|
log: ""
|
|
});
|
|
|
|
const listenStart = async () => {
|
|
const unListen = await listen("logs", event => {
|
|
data.log = (event.payload as string) || "";
|
|
});
|
|
return unListen;
|
|
};
|
|
|
|
let unlistenStart: UnlistenFn | null = null;
|
|
onMounted(async () => {
|
|
unlistenStart = await listenStart();
|
|
});
|
|
|
|
onBeforeUnmount(() => {
|
|
unlistenStart && unlistenStart();
|
|
});
|
|
</script>
|