1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

将调试内容抽离出Component

This commit is contained in:
2022-11-26 00:48:09 +08:00
parent 08bab25a48
commit 3836427aec
7 changed files with 69 additions and 35 deletions

View File

@@ -0,0 +1,49 @@
<template>
<view v-if="debugMode">
<button @tap='debugCleanCache'>清除缓存</button>
<textarea maxlength="-1" disabled="true" auto-height="true" :value="debugText"></textarea>
</view>
</template>
<script>
import Taro from '@tarojs/taro'
import { eventCenter, getCurrentInstance } from '@tarojs/taro'
export default {
data() {
return {
userInfo: null,
debugMode: Taro.getApp().globalData.debugMode,
debugText: "",
}
},
mounted() {
eventCenter.once(getCurrentInstance().router.onShow, () => {
this.userInfo = Taro.getStorageSync("userInfo");
this.displayUsername = this.userInfo?.username ?? "请登录";
this.debugText = JSON.stringify({
"TARO_ENV": process.env.TARO_ENV,
// "isVisitor": this.isVisitor,
// "isUser": this.isUser,
// "isAdmin": this.isAdmin,
"userInfo": this.userInfo || 'null'
}, null, 4)
})
},
methods: {
debugCleanCache() {
Taro.clearStorage({
success: function () {
Taro.showToast({
title: "成功",
icon: 'success'
})
Taro.reLaunch({
url: '/pages/index/index'
})
}
})
}
}
}
</script>