You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.3 KiB
72 lines
1.3 KiB
<template>
|
|
<div id="app" ref="containerS">
|
|
<router-view />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
getInfo
|
|
} from '@/api/user'
|
|
import {
|
|
getToken
|
|
} from '@/utils/auth'
|
|
import Watermark from "@/utils/waterMarker/index.js";
|
|
export default {
|
|
name: "App",
|
|
data() {
|
|
return {
|
|
username: "", // 这里设置用户名作为水印内容
|
|
};
|
|
},
|
|
watch: {
|
|
$route(to, from) {
|
|
this.$nextTick(function () {
|
|
|
|
this.loadUser()
|
|
});
|
|
},
|
|
username(to, from) {
|
|
Watermark.set(this.username, this.$refs.containerS);
|
|
}
|
|
},
|
|
mounted() {
|
|
},
|
|
methods: {
|
|
loadUser() {
|
|
|
|
var token = getToken();
|
|
console.log(token)
|
|
if (token) {
|
|
getInfo(token).then(response => {
|
|
|
|
const {
|
|
roles,
|
|
name,
|
|
avatar
|
|
} = response;
|
|
this.username = response.name+" "+this.$moment().format("HH:mm:ss");
|
|
Watermark.set(this.username, this.$refs.containerS);
|
|
}).catch(error => {
|
|
})
|
|
}
|
|
else {
|
|
this.username = "";
|
|
Watermark.set(this.username, this.$refs.containerS);
|
|
}
|
|
}
|
|
}
|
|
, created() {
|
|
|
|
this.$nextTick(function () {
|
|
this.loadUser()
|
|
});
|
|
}
|
|
};
|
|
</script>
|
|
<style lang="scss">
|
|
#app .sidebar-container.has-logo .el-scrollbar {
|
|
height: calc(100% - 60px) !important;
|
|
}
|
|
</style>
|