发送log测试OK

This commit is contained in:
sunbeam0529 2025-04-14 15:02:33 +08:00
parent 03a61b5989
commit 3408150f84
3 changed files with 30 additions and 4 deletions

View File

@ -73,8 +73,8 @@
<v-card>{{ currentView }}</v-card>
</div>
<!-- 日志界面 -->
<div v-if="currentView === 'pageLog'" >
<LogPage />
<div v-show="currentView === 'pageLog'" >
<LogPage ref="logRef" />
</div>
</v-container>
</v-main>
@ -83,9 +83,12 @@
</template>
<script setup>
import { ref } from 'vue';
import { ref, provide } from 'vue';
import LogPage from './components/LogPage.vue';
const logRef = ref(null);
provide('logRef', logRef);
// 使 ref
let drawer = ref(true);
let currentView = ref("pageCANMsg");

View File

@ -103,6 +103,7 @@ function updatePagination(value) {
}
const PrintLog = (level, message) => {
console.log(`[${level}] ${message}`);
const newLog = {
timestamp: Date.now(),
level: level.toUpperCase(),

View File

@ -20,12 +20,34 @@
</div>
</v-col>
<v-col cols="4" class="bg-yellow">
<v-btn
@click="handleTestLog"
color="primary"
class="ma-4"
>
测试日志
</v-btn>
</v-col>
</v-row>
</v-container>
</template>
<script>
export default {
inject: ['logRef'],
methods: {
handleTestLog() {
//this.logRef?.PrintLog('INFO', '')
this.PrintLog('INFO', '来自座椅控制页面的测试日志')
alert('测试日志已发送')
},
PrintLog(level, message) {
this.logRef?.PrintLog(level, message)
}
}
}
</script>
<style>
.background-div {
background-image: url("..\assets\座椅.png");