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

View File

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

View File

@ -20,12 +20,34 @@
</div> </div>
</v-col> </v-col>
<v-col cols="4" class="bg-yellow"> <v-col cols="4" class="bg-yellow">
<v-btn
@click="handleTestLog"
color="primary"
class="ma-4"
>
测试日志
</v-btn>
</v-col> </v-col>
</v-row> </v-row>
</v-container> </v-container>
</template> </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> <style>
.background-div { .background-div {
background-image: url("..\assets\座椅.png"); background-image: url("..\assets\座椅.png");