fix: default match tab to match center

This commit is contained in:
hajimi
2026-08-01 16:14:37 +08:00
parent 5633c9b51f
commit 42284ba6ac
5 changed files with 17 additions and 26 deletions
-4
View File
@@ -13,7 +13,6 @@ import { computed, ref, watch, onMounted } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import AppLoading from '@/components/app-loading/app-loading.vue'
import GlobalPopup from '@/components/global-popup/global-popup.vue'
const MATCH_SHELL_VIEW_KEY = 'match_shell_view'
import UTabbar from '@/uni_modules/vk-uview-ui/components/u-tabbar/u-tabbar.vue'
const props = withDefaults(defineProps<{
@@ -151,9 +150,6 @@ const handleChange = (index: number) => {
uni.navigateTo({ url: targetRoute })
return
}
if (targetRoute === '/packages_match/pages/worldcup') {
uni.setStorageSync(MATCH_SHELL_VIEW_KEY, 'worldcup')
}
if (nativeTabbar.includes(targetRoute)) {
uni.switchTab({ url: targetRoute })
} else {
@@ -12,17 +12,16 @@ import MatchCenterPanel from './MatchCenterPanel.vue'
import WorldCupPanel from './WorldCupPanel.vue'
type ShellView = 'worldcup' | 'match'
const MATCH_SHELL_VIEW_KEY = 'match_shell_view'
const props = withDefaults(defineProps<{
initialView?: ShellView
routeOptions?: Record<string, any>
}>(), {
initialView: 'worldcup',
initialView: 'match',
routeOptions: () => ({})
})
const currentView = ref<ShellView>('worldcup')
const currentView = ref<ShellView>('match')
const worldcupState = ref<{ tab: string; cid: number | null }>({
tab: 'live',
cid: null
@@ -53,27 +52,10 @@ const showMatchCenter = () => {
currentView.value = 'match'
}
const resetToWorldCup = () => {
currentView.value = 'worldcup'
worldcupState.value = {
tab: String(props.routeOptions?.tab || 'live'),
cid: parseNumber(props.routeOptions?.cid)
}
}
const consumeForcedView = () => {
const forceView = uni.getStorageSync(MATCH_SHELL_VIEW_KEY)
if (forceView === 'worldcup') {
uni.removeStorageSync(MATCH_SHELL_VIEW_KEY)
resetToWorldCup()
}
}
watch(
() => [props.initialView, props.routeOptions],
() => {
applyState()
consumeForcedView()
},
{ immediate: true, deep: true }
)
+1 -1
View File
@@ -1,5 +1,5 @@
<template>
<MatchShellPage initial-view="worldcup" :route-options="routeOptions" />
<MatchShellPage initial-view="match" :route-options="routeOptions" />
</template>
<script setup lang="ts">