lina/src/App.vue
2025-04-02 19:14:40 +08:00

64 lines
1.3 KiB
Vue

<template>
<div id="app">
<router-view v-if="isRouterAlive" />
</div>
</template>
<script>
import { mapState, mapGetters } from 'vuex'
import { Watermark } from 'watermark-js-plus'
export default {
name: 'App',
data() {
return {
watermark: null
}
},
computed: {
...mapState({
isRouterAlive: state => state.common.isRouterAlive
}),
...mapGetters({
currentUser: 'currentUser',
publicSettings: 'publicSettings'
})
},
watch: {
currentUser: {
handler(newVal) {
this.createWatermark()
}
},
'publicSettings.SECURITY_WATERMARK_ENABLED': {
handler(newVal) {
if (!newVal) {
return setTimeout(() => {
this.watermark?.destroy()
this.watermark = null
})
}
this.createWatermark()
}
}
},
methods: {
createWatermark() {
if (this.currentUser?.username && this.publicSettings?.SECURITY_WATERMARK_ENABLED) {
this.watermark = new Watermark({
content: `${this.currentUser.username}(${this.currentUser.name})`,
width: 200,
height: 200,
rotate: 45,
fontWeight: 'normal',
fontColor: 'rgba(128, 128, 128, 0.2)'
})
this.watermark.create()
}
}
}
}
</script>