App.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div id="app">
  3. <router-view/>
  4. </div>
  5. </template>
  6. <script>
  7. import {removeToken} from "@/utils/auth";
  8. export default {
  9. name: 'App',
  10. mounted() {
  11. // 禁用鼠标右键
  12. document.getElementById("app").oncontextmenu = function (e) {
  13. return false;
  14. };
  15. // window.addEventListener("beforeunload", e => {
  16. // this.beforeunloadHandler(e)
  17. // let userAgent = navigator.userAgent
  18. // let isOpera = userAgent.indexOf("Opera") > -1;
  19. // if (isOpera) { //判断是否Opera浏览器
  20. // return "Opera"
  21. // }
  22. // else{
  23. // this.unloadHandler();
  24. // }
  25. // // if (userAgent.indexOf("Firefox") > -1) {
  26. // // this.unloadHandler();
  27. // // }
  28. // // if (userAgent.indexOf("MSIE") > -1) {
  29. // // this.unloadHandler();
  30. // // }
  31. // });
  32. // window.addEventListener("unload", async e => {
  33. // this.unloadHandler(e)
  34. // });
  35. },
  36. methods: {
  37. // beforeunloadHandler(e) {
  38. // this._beforeUnload_time = new Date().getTime();
  39. // },
  40. // unloadHandler(e) {
  41. // this._gap_time = new Date().getTime() - this._beforeUnload_time;
  42. // //判断是窗口关闭还是刷新
  43. // localStorage.setItem('time', this._gap_time)
  44. // if (this._gap_time <= 5) {
  45. // // // 发送设置同步 (退出登陆的api)
  46. // // this.$store.dispatch('LogOut').then(() => {
  47. // // location.href = '/index';
  48. // // })
  49. //
  50. //
  51. // this.$axios.post(
  52. // '/logout', {}
  53. // ).then((res) => {
  54. // this.$message.success(res.data)
  55. // removeToken()
  56. // //注销返回自己的登录页
  57. // this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  58. // })
  59. // } else {
  60. // }
  61. // },
  62. },
  63. // destroyed() {
  64. // window.removeEventListener("beforeunload", e =>
  65. // this.beforeunloadHandler(e)
  66. // );
  67. // window.removeEventListener("unload", e => this.unloadHandler(e));
  68. // }
  69. }
  70. </script>