mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
Fix tab selection on discovery page (#353)
* Fix: Ensure first tab is selected when no valid tab is active Co-authored-by: jxxghp <jxxghp@163.com> * Fix discover page tab selection logic when no tab is active Co-authored-by: jxxghp <jxxghp@163.com> * Fix tab selection logic in discover page lifecycle hooks Co-authored-by: jxxghp <jxxghp@163.com> * Remove unnecessary onMounted hook in discover page Co-authored-by: jxxghp <jxxghp@163.com> * Move dynamic header tab registration after tabs initialization Co-authored-by: jxxghp <jxxghp@163.com> * Refactor dynamic header tab registration in discover page Co-authored-by: jxxghp <jxxghp@163.com> * Fix tab selection logic in discover page to ensure first tab is selected Co-authored-by: jxxghp <jxxghp@163.com> * Update useDynamicHeaderTab to sync modelValue in tab configuration Co-authored-by: jxxghp <jxxghp@163.com> * Remove auto-tab selection logic from discover page Co-authored-by: jxxghp <jxxghp@163.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
co-authored by
jxxghp
Cursor Agent
parent
3b7c34258f
commit
28f38d8b80
@@ -91,6 +91,8 @@ export function useDynamicHeaderTab() {
|
|||||||
tabConfig.routePath = route.path
|
tabConfig.routePath = route.path
|
||||||
// 确保items是最新的
|
// 确保items是最新的
|
||||||
tabConfig.items = Array.isArray(config.items) ? config.items : config.items.value
|
tabConfig.items = Array.isArray(config.items) ? config.items : config.items.value
|
||||||
|
// 确保modelValue是最新的
|
||||||
|
tabConfig.modelValue = config.modelValue.value
|
||||||
|
|
||||||
if (registerDynamicHeaderTab) {
|
if (registerDynamicHeaderTab) {
|
||||||
registerDynamicHeaderTab(tabConfig)
|
registerDynamicHeaderTab(tabConfig)
|
||||||
|
|||||||
+12
-5
@@ -123,9 +123,9 @@ async function saveTabOrder() {
|
|||||||
// 使用动态标签页
|
// 使用动态标签页
|
||||||
const { registerHeaderTab } = useDynamicHeaderTab()
|
const { registerHeaderTab } = useDynamicHeaderTab()
|
||||||
|
|
||||||
// 注册动态标签页
|
// 注册动态标签页(在setup阶段,但使用computed保证响应性)
|
||||||
registerHeaderTab({
|
registerHeaderTab({
|
||||||
items: discoverTabItems, // 传递computed值,而不是.value
|
items: discoverTabItems, // 传递computed值,会自动响应变化
|
||||||
modelValue: activeTab,
|
modelValue: activeTab,
|
||||||
appendButtons: [
|
appendButtons: [
|
||||||
{
|
{
|
||||||
@@ -145,18 +145,25 @@ onBeforeMount(async () => {
|
|||||||
await loadOrderConfig()
|
await loadOrderConfig()
|
||||||
await loadExtraDiscoverSources()
|
await loadExtraDiscoverSources()
|
||||||
sortSubscribeOrder()
|
sortSubscribeOrder()
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
// 选中第一个标签页
|
// 选中第一个标签页
|
||||||
if (discoverTabs.value.length > 0) {
|
if (discoverTabs.value.length > 0) {
|
||||||
activeTab.value = discoverTabs.value[0].mediaid_prefix
|
activeTab.value = discoverTabs.value[0].mediaid_prefix
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onActivated(async () => {
|
onActivated(async () => {
|
||||||
await loadExtraDiscoverSources()
|
await loadExtraDiscoverSources()
|
||||||
sortSubscribeOrder()
|
sortSubscribeOrder()
|
||||||
|
// 如果当前没有选中任何标签页,或者当前选中的标签页不存在,则选中第一个标签页
|
||||||
|
if (!activeTab.value || !discoverTabs.value.find(tab => tab.mediaid_prefix === activeTab.value)) {
|
||||||
|
if (discoverTabs.value.length > 0) {
|
||||||
|
activeTab.value = discoverTabs.value[0].mediaid_prefix
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user