fix: 统一详情页返回上级列表
- 修正管理端插件、工作流与系统详情页返回目标 - 修正用户中心执行记录与助手详情返回目标 - 保留审批页签及关联资源筛选上下文
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
@@ -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) {
|
||||
|
||||
@@ -53,6 +53,7 @@ const handleEdit = (row: any) => {
|
||||
query: {
|
||||
id: row.id,
|
||||
pageKey: '/ai/plugin',
|
||||
pluginId: props.pluginId,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
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([
|
||||
['execHistory/details/index.vue', '/execHistory'],
|
||||
['assistantMarket/assistant/index.vue', '/assistantMarket'],
|
||||
])('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}'`);
|
||||
});
|
||||
});
|
||||
@@ -234,7 +234,11 @@ function currentSwitchingRoundIds() {
|
||||
<ElMain
|
||||
class="border-border bg-background !flex flex-col rounded-xl border !p-6"
|
||||
>
|
||||
<ElSpace :size="16" class="cursor-pointer" @click="router.back()">
|
||||
<ElSpace
|
||||
:size="16"
|
||||
class="cursor-pointer"
|
||||
@click="router.replace({ path: '/assistantMarket' })"
|
||||
>
|
||||
<ElIcon :size="24"><ArrowLeft /></ElIcon>
|
||||
<ElSpace :size="12">
|
||||
<ElAvatar :size="36" :src="botInfo.icon || defaultBotAvatar" />
|
||||
|
||||
@@ -81,7 +81,11 @@ const steps = computed(() => {
|
||||
<template>
|
||||
<ElContainer class="bg-background-deep h-full">
|
||||
<ElHeader class="!p-8 !pb-0" height="auto">
|
||||
<ElSpace class="cursor-pointer" :size="10" @click="router.back()">
|
||||
<ElSpace
|
||||
class="cursor-pointer"
|
||||
:size="10"
|
||||
@click="router.replace({ path: '/execHistory' })"
|
||||
>
|
||||
<ElIcon size="24"><ArrowLeft /></ElIcon>
|
||||
<h1 class="text-2xl font-medium">
|
||||
{{ route.query.title }}
|
||||
|
||||
Reference in New Issue
Block a user