<template>
  <div id="app">
    <icon class="bg" name="canary"></icon>
    <router-view />
  </div>
</template>

<script>
import { mapActions } from "vuex";
export default {
  name: "App",
  mounted() {
    window.addEventListener("beforeunload", (e) => this.beforeunloadHandler(e));
    window.addEventListener("unload", (e) => this.unloadHandler(e));
  },
  destroyed() {
    window.removeEventListener("beforeunload", (e) =>
      this.beforeunloadHandler(e)
    );
    window.removeEventListener("unload", (e) => this.unloadHandler(e));
  },
  methods: {
    ...mapActions(["setRowPwd"]),
    beforeunloadHandler() {
      this._beforeUnload_time = new Date().getTime();
    },
    unloadHandler(e) {
      this._gap_time = new Date().getTime() - this._beforeUnload_time;
      //判断是窗口关闭还是刷新
      if (this._gap_time <= 5) {
        // debugger
        console.log("退出程序清除主密码");
        this.setRowPwd(["", this]);
        // debugger
      }
    },
  },
};
</script>
<style lang="scss">
@import "./style/main";
@import "./style/font";
@import "~vue-material/dist/theme/engine";
@import "~vue-material/dist/theme/all";
body,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
p,
blockquote,
dl,
dt,
dd,
ul,
ol,
li,
pre,
form,
fieldset,
legend,
button,
input,
textarea,
th,
td {
  margin: 0;
  padding: 0;
}
body,
button,
input,
select,
textarea {
  font: 12px/1.5tahoma, arial, \5b8b\4f53;
}
h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: 100%;
}
address,
cite,
dfn,
em,
var {
  font-style: normal;
}
code,
kbd,
pre,
samp {
  font-family: couriernew, courier, monospace;
}
small {
  font-size: 12px;
}
ul,
ol {
  list-style: none;
}
a {
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
sup {
  vertical-align: text-top;
}
sub {
  vertical-align: text-bottom;
}
legend {
  color: #000;
}
fieldset,
img {
  border: 0;
}
button,
input,
select,
textarea {
  font-size: 100%;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}
button {
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  outline: none;
}
html[data-theme="dark"] {
  @include set-theme-dark();
  @import "~vue-material/dist/theme/all";
  .md-caption {
    color: rgba(255, 255, 255, 0.7);
  }
}
html[data-theme="light"] {
  @include set-theme-light();
  @import "~vue-material/dist/theme/all";
}
#app {
  font-family: "Roboto", "Helvetica Neue", Helvetica, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* text-align: center; */
  // color: #2c3e50;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -khtml-user-select: none;
  user-select: none;
}
.bg {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -100;
  height: 5rem;
  width: 5rem;
  margin-top: -2.5rem;
  margin-left: -2.5rem;
}

@media screen and (max-width: 500px) {
  .md-autocomplete-box-content {
    left: 0.2rem !important;
  }
}
#__vconsole {
  display: none;
}

.vconsole-show {
  display: block !important;
}
</style>
