refactor(about): 重命名函数并重新组织代码结构

将 toLogin 重命名为 gotoLogin 以保持命名一致性
调整函数位置使相关功能更集中
This commit is contained in:
feige996
2025-09-01 15:52:59 +08:00
parent 0632985305
commit 40732df4d8

View File

@@ -22,12 +22,23 @@ definePage({
// 浏览器打印 isH5为true, isWeb为false大家尽量用 isH5
console.log({ isApp, isAppAndroid, isAppHarmony, isAppIOS, isAppPlus, isH5, isMpWeixin, isWeb })
function toLogin() {
function gotoLogin() {
uni.navigateTo({
url: `${LOGIN_PAGE}?redirect=${encodeURIComponent('/pages/about/about?a=1&b=2')}`,
})
}
function gotoTabbar() {
uni.switchTab({
url: '/pages/index/index',
})
}
// #region setTabbarBadge
function setTabbarBadge() {
tabbarStore.setTabbarItemBadge(1, 100)
}
// #endregion
function gotoAlova() {
uni.navigateTo({
url: '/pages/about/alova',
@@ -43,6 +54,7 @@ function gotoSubPage() {
url: '/pages-sub/demo/index',
})
}
// uniLayout里面的变量通过 expose 暴露出来后可以在 onReady 钩子获取到onLoad 钩子不行)
const uniLayout = ref()
onLoad(() => {
@@ -58,17 +70,6 @@ onShow(() => {
console.log('onShow:', uniLayout.value?.testUniLayoutExposedData) // onReady: testUniLayoutExposedData
})
function gotoTabbar() {
uni.switchTab({
url: '/pages/index/index',
})
}
// #region setTabbarBadge
function setTabbarBadge() {
tabbarStore.setTabbarItemBadge(1, 100)
}
// #endregion
const uniKuRoot = ref()
// 结论:(同上第一次通过onShow获取不到但是可以通过 onReady获取到后面就可以通过onShow获取到了
onReady(() => {
@@ -87,7 +88,7 @@ onShow(() => {
<view class="my-2 text-center">
<image src="/static/images/avatar.jpg" class="h-100px w-100px" />
</view>
<button class="mt-4 w-40 text-center" @click="toLogin">
<button class="mt-4 w-40 text-center" @click="gotoLogin">
点击去登录页
</button>
<button class="mt-4 w-60 text-center" @click="setTabbarBadge">