App.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div id="app" class="bgcolor">
  3. <router-view />
  4. </div>
  5. </template>
  6. <script>
  7. import watermark from 'watermark-dom';
  8. export default {
  9. name: 'App',
  10. created() {
  11. // 当前设备:PC/mobile
  12. let isDevice = window.navigator.userAgent.match(
  13. /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
  14. );
  15. localStorage.setItem('isDevice', !isDevice ? 'PC' : 'mobile'); // !isDevice: true:PC false:mobile
  16. },
  17. mounted() {
  18. setTimeout(() => {
  19. let username = localStorage.getItem('nickName');
  20. if (username) {
  21. let now = new Date();
  22. let year = now.getFullYear();
  23. let month = now.getMonth() + 1;
  24. let day = now.getDate();
  25. month = month < 10 ? '0' + month : month;
  26. day = day < 10 ? '0' + day : day;
  27. let date = year + '-' + month + '-' + day;
  28. watermark.load({
  29. watermark_txt: username + '@立邦' + date,
  30. watermark_fontsize: '13px',
  31. watermark_width: 100,
  32. watermark_rows: 0,
  33. watermark_cols: 3,
  34. watermark_height: 50,
  35. watermark_x_space: 10,
  36. watermark_y_space: 60,
  37. watermark_alpha: 0.1,
  38. });
  39. }
  40. }, 1000);
  41. },
  42. methods: {},
  43. };
  44. </script>
  45. <style lang="scss">
  46. #wm_div_id {
  47. position: fixed;
  48. top: 0;
  49. right: 0;
  50. bottom: 0;
  51. left: 0;
  52. width: 100%;
  53. height: 100%;
  54. z-index: 9999999;
  55. }
  56. </style>