<template>
  <div id="app">
    <router-view></router-view>
  </div>
</template>
<script>
import { ipcRenderer } from "electron";

export default {
  data() {
    return {
      update_info: null,
    };
  },
  mounted() {},
  methods: {
    async clearCache() {
      ipcRenderer.on("clear-checkList", (event, data) => {
        console.log("clear-checkList", data);
        console.log("clear-checkList", event);

        if (data.length === 0) {
          return this.$message.warning("请选择要清除的数据");
        }
        this.$confirm("是否确定清除?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            // return;
            for (let k of data) {
              if (k === "print-setting" || k === "deviceId") {
                let list = Object.keys(this.$dataStore.store).filter((el) =>
                  el.includes(k),
                );
                list.forEach((el) => {
                  this.$dataStore.delete(el);
                });
              } else if (k === "token") {
                this.$dataStore.delete("token");
                this.$dataStore.delete("user");
              } else {
                if (this.$dataStore.get(k)) {
                  this.$dataStore.delete(k);
                }
              }
            }
            window.location.reload();
          })
          .catch(() => {});
      });
    },
  },
  created() {
    this.clearCache();
  },
};
</script>
<style>
body {
  margin: 0;
  height: 100vh;
}

#app {
  height: 100vh;
  display: flex;
  overflow: hidden;
  width: 100vw;
  flex-direction: column;
}
</style>
