将调试内容抽离出Component
This commit is contained in:
49
miniprogram/src/components/DebugComp.vue
Normal file
49
miniprogram/src/components/DebugComp.vue
Normal 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>
|
Reference in New Issue
Block a user