fix: 统一详情页返回上级列表

- 修正管理端插件、工作流与系统详情页返回目标

- 修正用户中心执行记录与助手详情返回目标

- 保留审批页签及关联资源筛选上下文
This commit is contained in:
2026-07-28 12:23:36 +08:00
parent 1404c2ddc5
commit dc35ddc3e4
14 changed files with 144 additions and 11 deletions

View File

@@ -0,0 +1,57 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
function readViewSource(relativePath: string) {
return readFileSync(resolve('app/src/views', relativePath), 'utf8');
}
describe('detail return navigation', () => {
it.each([
['system/sysFeedback/sysFeedbackDetail.vue', '/sys/sysFeedback'],
['system/sysJob/SysJobLogList.vue', '/sys/sysJob'],
['ai/workflow/WorkflowDesign.vue', '/ai/workflow'],
['ai/workflow/RunPage.vue', '/ai/workflow'],
['ai/workflow/execute/WorkflowExecResultList.vue', '/ai/workflow'],
])('returns %s to its fixed parent list', (relativePath, parentPath) => {
const source = readViewSource(relativePath);
expect(source).not.toMatch(/router\.(?:back|go)\s*\(/);
expect(source).toContain(`path: '${parentPath}'`);
});
it('returns approval details to the originating approval tab', () => {
const detailSource = readViewSource('system/approval/ApprovalDetail.vue');
const listSource = readViewSource('system/approval/ApprovalManage.vue');
expect(detailSource).not.toMatch(/router\.(?:back|go)\s*\(/);
expect(detailSource).toContain("path: '/sys/approval'");
expect(detailSource).toContain('query: { tab }');
expect(listSource).toContain('tab: activeTab.value');
});
it('returns plugin tool editing to its plugin tool list with a safe fallback', () => {
const editSource = readViewSource('ai/plugin/PluginToolEdit.vue');
const listSource = readViewSource('ai/plugin/PluginToolTable.vue');
expect(editSource).not.toMatch(/router\.(?:back|go)\s*\(/);
expect(editSource).toContain("path: '/ai/plugin/tools'");
expect(editSource).toContain("path: '/ai/plugin'");
expect(listSource).toContain('pluginId: props.pluginId');
});
it('returns execution steps to the filtered execution record list', () => {
const stepSource = readViewSource(
'ai/workflow/execute/WorkflowExecStepList.vue',
);
const recordSource = readViewSource(
'ai/workflow/execute/WorkflowExecResultList.vue',
);
expect(stepSource).not.toMatch(/router\.(?:back|go)\s*\(/);
expect(stepSource).toContain("name: 'ExecRecord'");
expect(stepSource).toContain('query: workflowId ? { workflowId } : {}');
expect(recordSource).toContain('workflowId: $route.query.workflowId');
});
});

View File

@@ -164,7 +164,15 @@ function handleClickHeader(index: number) {
}
function back() {
router.back();
const pluginId = String(route.query.pluginId || '');
if (pluginId) {
void router.replace({
path: '/ai/plugin/tools',
query: { id: pluginId },
});
return;
}
void router.replace({ path: '/ai/plugin' });
}
function updatePluginTool(index: number) {

View File

@@ -53,6 +53,7 @@ const handleEdit = (row: any) => {
query: {
id: row.id,
pageKey: '/ai/plugin',
pluginId: props.pluginId,
},
});
};

View File

@@ -61,7 +61,10 @@ function onAsyncExecute(info: any) {
class="bg-background-deep flex h-full max-h-[calc(100vh-90px)] w-full flex-col gap-6 overflow-hidden p-6"
>
<div>
<ElButton :icon="ArrowLeft" @click="router.back()">
<ElButton
:icon="ArrowLeft"
@click="router.replace({ path: '/ai/workflow' })"
>
{{ $t('button.back') }}
</ElButton>
</div>

View File

@@ -895,7 +895,7 @@ function onAsyncExecute(info: any) {
v-if="!props.shareMode"
:icon="ArrowLeft"
link
@click="router.back()"
@click="backToWorkflowList"
>
<span
class="max-w-[500px] overflow-hidden text-ellipsis text-nowrap text-base"

View File

@@ -82,6 +82,7 @@ function toStepPage(row: any) {
name: 'RecordStep',
query: {
recordId: row.id,
workflowId: $route.query.workflowId,
},
});
}
@@ -112,7 +113,10 @@ function getTagType(row: any) {
<template>
<div class="page-container border-border border">
<div class="mb-3">
<ElButton :icon="ArrowLeft" @click="router.back()">
<ElButton
:icon="ArrowLeft"
@click="router.replace({ path: '/ai/workflow' })"
>
{{ $t('button.back') }}
</ElButton>
</div>

View File

@@ -44,6 +44,13 @@ function reset(formEl: FormInstance | undefined) {
formEl?.resetFields();
pageDataRef.value.setQuery({});
}
function backToExecRecords() {
const workflowId = $route.query.workflowId;
void router.replace({
name: 'ExecRecord',
query: workflowId ? { workflowId } : {},
});
}
function getTagType(row: any) {
switch (row.status) {
case 1: {
@@ -71,7 +78,7 @@ function getTagType(row: any) {
<template>
<div class="page-container border-border border">
<div class="mb-3">
<ElButton :icon="ArrowLeft" @click="router.back()">
<ElButton :icon="ArrowLeft" @click="backToExecRecords">
{{ $t('button.back') }}
</ElButton>
</div>

View File

@@ -112,6 +112,23 @@ async function loadDetail() {
}
}
function backToApprovalList() {
const tab = String(route.query.tab || '');
if (
tab === 'flow' ||
tab === 'pending' ||
tab === 'processed' ||
tab === 'initiated'
) {
void router.replace({
path: '/sys/approval',
query: { tab },
});
return;
}
void router.replace({ path: '/sys/approval' });
}
async function submitApprovalAction(action: 'approve' | 'reject' | 'revoke') {
if (approvalActionLoading.value) {
return;
@@ -246,7 +263,7 @@ function formatEventInfo(row: Record<string, any>) {
<div class="flex h-full flex-col gap-4 p-6" v-loading="loading">
<div class="flex flex-wrap items-center justify-between gap-3">
<div class="flex items-center gap-3">
<ElButton :icon="ArrowLeft" @click="router.back()">
<ElButton :icon="ArrowLeft" @click="backToApprovalList">
{{ $t('button.back') }}
</ElButton>
<div class="flex items-center gap-2 text-lg font-semibold">

View File

@@ -466,7 +466,12 @@ function canSubmitApprovalAction(
}
function openInstanceDetail(row: any) {
router.push(`/sys/approval/detail/${row.id}`);
router.push({
path: `/sys/approval/detail/${row.id}`,
query: {
tab: activeTab.value,
},
});
}
function getFlowStatusType(status: string) {

View File

@@ -102,7 +102,7 @@ async function markStatus(_status: number) {
<ElButton
class="absolute left-5 top-5"
:icon="ArrowLeft"
@click="router.back()"
@click="router.replace({ path: '/sys/sysFeedback' })"
>
{{ $t('button.back') }}
</ElButton>

View File

@@ -48,7 +48,10 @@ function reset(formEl: FormInstance | undefined) {
<template>
<div class="page-container">
<div class="mb-3">
<ElButton :icon="ArrowLeft" @click="router.back()">
<ElButton
:icon="ArrowLeft"
@click="router.replace({ path: '/sys/sysJob' })"
>
{{ $t('button.back') }}
</ElButton>
</div>