<script lang="ts">
// #ifdef APP-PLUS || H5
import { TUIChatKit } from "./TUIKit";
import { useCounterStore } from "@/stores/counter";
import { onMounted } from "vue";
const counter = useCounterStore();
TUIChatKit.init();
// #endif
// Required information
// You can get userSig from TencentCloud chat console for Testing TUIKit.
// Deploy production environment please get it from your server.
// View https://cloud.tencent.com/document/product/269/32688

export default {
  data() {
    return {
      info: {},
      userSig: "",
      chatInfo: {},
    };
  },

  onLoad(option) {
    this.AutomaticCleaning();
    uni.getStorage({
      key: "userinfo",
      success: (res) => {
        this.info = res.data;
        counter.$patch({ myitem: this.info });
      },
      fail: () => {},
    });
  },
  methods: {
    //自动清理缓存
    AutomaticCleaning() {
      const lastCleanTime = uni.getStorageSync("last_clean_time") || 0;
      const now = Date.now();
      if (now - lastCleanTime < 7 * 24 * 3600 * 1000) return; // 7 days
      uni.clearStorage();
      uni.setStorageSync("last_clean_time", now);
    },
  },
  provide() {
    return {
      $global: {
        lastPage: null,
      },
    };
  },
};
</script>
<style>
/* common css for page */
uni-page-body,
html,
body,
page {
  width: 100% !important;
  height: 100% !important;
  overflow: hidden;
}
</style>
