Files
tk-mini-program/App.vue

64 lines
1.4 KiB
Vue
Raw Normal View History

2025-05-13 19:39:53 +08:00
<script lang="ts">
2025-05-20 00:10:07 +08:00
// #ifdef APP-PLUS || H5
2025-06-10 23:06:51 +08:00
import { TUIChatKit } from "./TUIKit";
import { useCounterStore } from "@/stores/counter";
import { onMounted } from "vue";
const counter = useCounterStore();
2025-05-13 19:39:53 +08:00
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 {
2025-05-20 00:10:07 +08:00
data() {
2025-05-19 18:34:04 +08:00
return {
2025-05-20 00:10:07 +08:00
info: {},
userSig: "",
chatInfo: {},
};
},
2025-06-10 23:06:51 +08:00
2025-05-20 00:10:07 +08:00
onLoad(option) {
2025-06-10 23:06:51 +08:00
this.AutomaticCleaning();
2025-05-30 22:04:45 +08:00
uni.getStorage({
key: "userinfo",
success: (res) => {
this.info = res.data;
2025-06-10 23:06:51 +08:00
counter.$patch({ myitem: this.info });
2025-05-30 22:04:45 +08:00
},
2025-06-10 23:06:51 +08:00
fail: () => {},
});
2025-05-19 18:34:04 +08:00
},
2025-06-06 22:36:41 +08:00
methods: {
//自动清理缓存
2025-06-10 23:06:51 +08:00
AutomaticCleaning() {
const lastCleanTime = uni.getStorageSync("last_clean_time") || 0;
2025-06-06 22:36:41 +08:00
const now = Date.now();
if (now - lastCleanTime < 7 * 24 * 3600 * 1000) return; // 7 days
uni.clearStorage();
2025-06-10 23:06:51 +08:00
uni.setStorageSync("last_clean_time", now);
},
2025-06-06 22:36:41 +08:00
},
2025-05-20 00:10:07 +08:00
provide() {
return {
$global: {
lastPage: null,
},
};
},
2025-05-13 19:39:53 +08:00
};
</script>
2025-05-12 14:12:36 +08:00
<style>
2025-05-13 19:39:53 +08:00
/* common css for page */
2025-05-20 00:10:07 +08:00
uni-page-body,
html,
body,
page {
2025-05-13 19:39:53 +08:00
width: 100% !important;
height: 100% !important;
overflow: hidden;
}
2025-05-20 00:10:07 +08:00
</style>