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

@@ -96,16 +96,14 @@
</view>
</view>
<view v-if="debugMode">
<button @tap='debugCleanCache'>清除缓存</button>
<text decode="nbsp">{{ debugText }}</text>
</view>
<DebugComp />
</template>
<script>
import Taro from '@tarojs/taro'
import { eventCenter, getCurrentInstance } from '@tarojs/taro'
import ENUM from '../../utils/const.js'
import DebugComp from '../../components/DebugComp.vue'
import './index.css'
@@ -118,15 +116,15 @@ export default {
isVisitor: false,
isUser: false,
isAdmin: false,
debugMode: Taro.getApp().globalData.debugMode,
debugText: "",
}
},
components: {
DebugComp
},
mounted() {
eventCenter.once(getCurrentInstance().router.onShow, () => {
console.log('onShow')
console.log("ENUM", ENUM)
console.log("debugMode", this.debugMode)
this.userInfo = Taro.getStorageSync("userInfo");
this.displayUsername = this.userInfo?.username ?? "请登录";
@@ -154,36 +152,14 @@ export default {
"isUser", this.isUser,
"isAdmin", this.isAdmin
)
this.debugText = JSON.stringify({
"isVisitor": this.isVisitor,
"isUser": this.isUser,
"isAdmin": this.isAdmin,
"userInfo": this.userInfo
}, null, 4).replace(/[ ]/g, '&nbsp;&nbsp;')
}
})
},
methods: {
goCode() {
// Taro.navigateTo({
// url: '/pages/residents/code'
// })
Taro.switchTab({
url: '/pages/residents/code'
})
},
debugCleanCache() {
Taro.clearStorage({
success: function () {
Taro.showToast({
title: "成功",
icon: 'success'
})
Taro.reLaunch({
url: '/pages/index/index'
})
}
})
}
}
}