diff --git a/build/dev-store.spec b/build/dev-store.spec index 22b4a89e2df2dff8eca2ab4ddfa6fde7b902a18f..f4503a36dfa657317e82fc22eb87c0c4de64e062 100644 --- a/build/dev-store.spec +++ b/build/dev-store.spec @@ -1,7 +1,7 @@ %global debug_package %{nil} Name: dev-store -Version: 1.0.5 +Version: 1.0.6 Release: 1 Summary: Development Store Management System @@ -304,6 +304,8 @@ if [ $1 -eq 0 ]; then fi %changelog +* Thu Dec 11 2025 dingjiahui - 1.0.6-1 +- Fix the issue where clicking a component button incorrectly navigates to the Home page. * Tue Dec 9 2025 dingjiahui - 1.0.5-1 - Optimize the processing logic for parsing MCP READMEs * Wed Dec 3 2025 dingjiahui - 1.0.4-1 diff --git a/frontend/src/layout/index.vue b/frontend/src/layout/index.vue index d3a13fdd974af074e7556364fa65d507dba023df..074fe67a9e88e888357408c3af3b25d3a1a9edca 100644 --- a/frontend/src/layout/index.vue +++ b/frontend/src/layout/index.vue @@ -117,13 +117,13 @@ const updateTime = ref('2025'); // 页签管理 const { tabs, activeTabId, addTab, removeTab, setActiveTab, updateCurrentTab, updateCurrentTabId, updateTabTitle, reorderTabs, findHomeTab } = useTabStore(); -// 计算keep-alive的key:Home页使用固定key,Detail页使用path +// 计算keep-alive的key:基于route const keepAliveKey = computed(() => { - if (route.name === 'Home') { - // Home组件使用固定key,但内部通过页签ID管理不同状态 + if (route.path === '/') { + // Home页使用固定key return 'home'; } - // Detail页使用path,确保不同的detail有独立的缓存 + // Detail页使用path作为key return route.path; }); @@ -196,12 +196,13 @@ watch(() => route.fullPath, () => { // 根据路由类型更新ID和标题 if (route.path === '/') { - // Home页 - 只更新路由信息和标题,不改变页签ID - // Home页签的ID由toHomePage方法或初始化时确定 - updateCurrentTab({ path: route.path, query: route.query }); - updateTabTitle(activeTabId.value, 'Home'); + // Home页 - 只在当前活动页签是Home页签时才更新 + if (currentTabId === 'home') { + updateCurrentTab({ path: route.path, query: route.query }); + updateTabTitle(activeTabId.value, 'Home'); + } } else if (route.name === 'McpServerDetail' || route.name === 'OedpPluginDetail') { - // Detail页面 - 只有当页签ID匹配时才更新路由信息 + // Detail页面 // 从路径中提取 tag 和 key const pathParts = route.path.split('/').filter(p => p); if (pathParts.length >= 2) { @@ -209,10 +210,11 @@ watch(() => route.fullPath, () => { const key = pathParts[1]; const expectedTabId = `${tag}-${key}`; - // 只有当前页签ID匹配时才更新路由信息 - if (currentTabId === expectedTabId) { - updateCurrentTab({ path: route.path, query: route.query }); - } + // 激活对应的页签 + setActiveTab(expectedTabId); + + // 更新路由信息 + updateCurrentTab({ path: route.path, query: route.query }); } } }, { immediate: true }); diff --git a/frontend/src/stores/tabStore.ts b/frontend/src/stores/tabStore.ts index 612d92732fa5edc22d3f1f95363dd16b87f7943c..93159a2ee2d5d5e6b02bf640d32abced33a5b186 100644 --- a/frontend/src/stores/tabStore.ts +++ b/frontend/src/stores/tabStore.ts @@ -36,15 +36,19 @@ const tabStore = reactive({ }); export function useTabStore() { - const addTab = (tab: Tab) => { + const addTab = (tab: Tab, activate: boolean = true) => { const existingTab = tabStore.tabs.find(t => t.id === tab.id); if (existingTab) { - // 如果页签已存在,切换到该页签 - tabStore.activeTabId = tab.id; + // 如果页签已存在,根据activate参数决定是否切换 + if (activate) { + tabStore.activeTabId = tab.id; + } } else { // 否则新增页签 tabStore.tabs.push(tab); - tabStore.activeTabId = tab.id; + if (activate) { + tabStore.activeTabId = tab.id; + } } }; diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index efeed30f54c834df6ff3df7ec4ac074ce363f4d9..a7d7885c0fc7d8a13f67c7eed8ef68d51a31fe19 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -49,7 +49,7 @@ export async function updateRouteQuery( } }); - await router.push({ query: newQuery }); + await router.push({ path: route.path, query: newQuery }); } /** diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index c2e32a143214bb4f3697b46f9b020cb89def13f0..5c46ad51b3857300a7f6aa31bf91606cf749a3dd 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -313,6 +313,9 @@ const handleSortTabChange = async () => { watch( () => route.query.tag, (nv) => { + // 只在当前路由是 Home 页时才处理 + if (route.path !== '/') return; + const state = getCurrentState(); if (nv) { // 更新激活的 Tab @@ -321,7 +324,7 @@ watch( // 重新获取数据 } else { // 如果 URL 中没有 type 参数,跳转到默认值 - router.replace({ query: { ...route.query, tag: 'mcp' } }); + router.replace({ path: route.path, query: { ...route.query, tag: 'mcp' } }); } }, { immediate: true } @@ -352,12 +355,17 @@ const stopPolling = () => { // 监听同步成功事件的处理函数 const handleSyncSuccess = async () => { + // 只在当前路由是 Home 页时才刷新数据 + if (route.path !== '/') return; // 立即刷新数据 await getAndCheck(); }; // 初始化状态和URL参数的公共函数 const initializeStateAndUrl = () => { + // 只在当前路由是 Home 页时才处理 + if (route.path !== '/') return; + // 初始化当前页签的状态 const tabId = currentTabId.value; if (!homeStatesMap.has(tabId)) { @@ -405,7 +413,7 @@ const initializeStateAndUrl = () => { } if (needsUpdate) { - router.replace({ query: currentQuery }); + router.replace({ path: route.path, query: currentQuery }); } }; @@ -426,6 +434,9 @@ onMounted(async () => { // 组件被激活(显示)时 - keep-alive onActivated(() => { + // 只在当前路由是 Home 页时才处理 + if (route.path !== '/') return; + // 同步路由状态 initializeStateAndUrl(); diff --git a/frontend/src/views/components/GridDisplay.vue b/frontend/src/views/components/GridDisplay.vue index ce6c0f5a00ef8352de10d0fc06384ee70bd2b1db..9ef502491a03dc0476c84a1d6f192351c4115ece 100644 --- a/frontend/src/views/components/GridDisplay.vue +++ b/frontend/src/views/components/GridDisplay.vue @@ -88,19 +88,20 @@ const props = withDefaults( ); // 跳转至详情页 tag, key - 新增页签 -const goToDetail = (key: string) => { +const goToDetail = async (key: string) => { const item = props.itemList.find((i: any) => i.key === key); const detailPath = `/${props.tag}/${key}`; + const tabId = `${props.tag}-${key}`; - // 添加新页签 + // 先添加页签(不激活) addTab({ - id: `${props.tag}-${key}`, + id: tabId, title: item?.name || key, route: { path: detailPath } - }); + }, false); - // 跳转到详情页 - router.push(detailPath); + // 然后跳转到详情页 + await router.push(detailPath); };