travel/admin/src/App.vue

49 lines
959 B
Vue
Raw Normal View History

2024-06-24 11:52:30 +08:00
<template>
<div id="app">
2024-06-25 16:16:51 +08:00
<!-- {{ username }} -->
2024-06-24 11:52:30 +08:00
<router-view />
</div>
</template>
<script>
import addWatermark from '@/directive/watermark'
export default {
watch: {
// 监听 name 的变化,更新水印
'$store.getters.name': 'updateWatermark'
},
created() {
// 在 created 钩子中添加默认水印
this.addDefaultWatermark()
},
mounted() {
// 在 mounted 钩子中更新水印,确保可以获取到 name 的最新值
this.updateWatermark()
},
methods: {
addDefaultWatermark() {
addWatermark({
container: document.body,
content: '金澳'
})
},
updateWatermark() {
const username = this.$store.getters.name
addWatermark({
container: document.body,
content: username ? `${username}` : '金澳'
})
}
}
}
</script>
2024-06-28 17:06:01 +08:00
<style scoped>
@import "./assets/fonts/font.css";
body{
font-family: PingFang !important;
}
</style>