refactor(sj_1.1.0_beta1): 重构工作流路由

This commit is contained in:
xlsea 2024-06-19 14:39:40 +08:00
parent a7f0722cc9
commit 1b66376f9d
14 changed files with 88 additions and 299 deletions

View File

@ -9,18 +9,7 @@ export function setupElegantRouter() {
blank: 'src/layouts/blank-layout/index.vue' blank: 'src/layouts/blank-layout/index.vue'
}, },
customRoutes: { customRoutes: {
names: [ names: []
'exception_403',
'exception_404',
'exception_500',
'document_project',
'document_project-link',
'document_vue',
'document_vite',
'document_unocss',
'document_naive',
'document_antd'
]
}, },
routePathTransformer(routeName, routePath) { routePathTransformer(routeName, routePath) {
const key = routeName as RouteKey; const key = routeName as RouteKey;

View File

@ -301,14 +301,6 @@ const local: App.I18n.Schema = {
500: 'Server Error', 500: 'Server Error',
'iframe-page': 'Iframe', 'iframe-page': 'Iframe',
home: 'Home', home: 'Home',
document: 'Document',
document_project: 'Project Document',
'document_project-link': 'Project Document(External Link)',
document_vue: 'Vue Document',
document_vite: 'Vite Document',
document_unocss: 'UnoCSS Document',
document_naive: 'Naive UI Document',
document_antd: 'Ant Design Vue Document',
about: 'About', about: 'About',
pods: 'Online Machine', pods: 'Online Machine',
namespace: 'Namespace', namespace: 'Namespace',
@ -326,13 +318,14 @@ const local: App.I18n.Schema = {
workflow_task: 'Workflow Task', workflow_task: 'Workflow Task',
workflow_batch: 'Workflow Batch', workflow_batch: 'Workflow Batch',
workflow_form: 'Workflow', workflow_form: 'Workflow',
workflow_form_copy: 'Copy Workflow',
workflow_form_batch: 'Workflow Batch Detail',
workflow_form_detail: 'Workflow Detail',
workflow_form_edit: 'Edit Workflow',
workflow_form_add: 'Add Workflow',
job: 'Schedule Task Management', job: 'Schedule Task Management',
job_task: 'Schedule Task List', job_task: 'Schedule Task List',
job_batch: 'Schedule Task Batch List', job_batch: 'Schedule Task Batch List',
exception: 'Exception',
exception_403: '403',
exception_404: '404',
exception_500: '500',
group: 'Group Config' group: 'Group Config'
}, },
page: { page: {
@ -431,17 +424,7 @@ const local: App.I18n.Schema = {
pie: { pie: {
title: 'Success scale chart' title: 'Success scale chart'
} }
}, }
projectNews: {
title: 'Project News',
moreNews: 'More News',
desc1: 'Soybean created the open source project soybean-admin on May 28, 2021!',
desc2: 'Yanbowe submitted a bug to soybean-admin, the multi-tab bar will not adapt.',
desc3: 'Soybean is ready to do sufficient preparation for the release of soybean-admin!',
desc4: 'Soybean is busy writing project documentation for soybean-admin!',
desc5: 'Soybean just wrote some of the workbench pages casually, and it was enough to see!'
},
creativity: 'Creativity'
}, },
pods: { pods: {
title: 'Online Machine', title: 'Online Machine',

View File

@ -301,14 +301,6 @@ const local: App.I18n.Schema = {
500: '服务器错误', 500: '服务器错误',
'iframe-page': '外链页面', 'iframe-page': '外链页面',
home: '首页', home: '首页',
document: '文档',
document_project: '项目文档',
'document_project-link': '项目文档(外链)',
document_vue: 'Vue文档',
document_vite: 'Vite文档',
document_unocss: 'UnoCSS文档',
document_naive: 'Naive UI文档',
document_antd: 'Ant Design Vue文档',
about: '关于', about: '关于',
pods: '在线机器', pods: '在线机器',
namespace: '命名空间', namespace: '命名空间',
@ -327,13 +319,14 @@ const local: App.I18n.Schema = {
workflow_task: '任务管理', workflow_task: '任务管理',
workflow_batch: '执行批次', workflow_batch: '执行批次',
workflow_form: '工作流', workflow_form: '工作流',
workflow_form_copy: '复制工作流',
workflow_form_batch: '工作流批次详情',
workflow_form_detail: '工作流详情',
workflow_form_edit: '编辑工作流',
workflow_form_add: '新增工作流',
job: '定时任务', job: '定时任务',
job_task: '任务管理', job_task: '任务管理',
job_batch: '执行批次', job_batch: '执行批次'
exception: '异常页',
exception_403: '403',
exception_404: '404',
exception_500: '500'
}, },
page: { page: {
common: { common: {
@ -442,17 +435,7 @@ const local: App.I18n.Schema = {
pie: { pie: {
title: '成功比例图' title: '成功比例图'
} }
}, }
projectNews: {
title: '项目动态',
moreNews: '更多动态',
desc1: 'Soybean 在2021年5月28日创建了开源项目 soybean-admin!',
desc2: 'Yanbowe 向 soybean-admin 提交了一个bug多标签栏不会自适应。',
desc3: 'Soybean 准备为 soybean-admin 的发布做充分的准备工作!',
desc4: 'Soybean 正在忙于为soybean-admin写项目说明文档',
desc5: 'Soybean 刚才把工作台页面随便写了一些,凑合能看了!'
},
creativity: '创意'
}, },
pods: { pods: {
title: '在线机器', title: '在线机器',

View File

@ -35,6 +35,10 @@ export const views: Record<LastLevelRouteKey, RouteComponent | (() => Promise<Ro
retry_task: () => import("@/views/retry/task/index.vue"), retry_task: () => import("@/views/retry/task/index.vue"),
user_manager: () => import("@/views/user/manager/index.vue"), user_manager: () => import("@/views/user/manager/index.vue"),
workflow_batch: () => import("@/views/workflow/batch/index.vue"), workflow_batch: () => import("@/views/workflow/batch/index.vue"),
workflow_form: () => import("@/views/workflow/form/[type].vue"), workflow_form_add: () => import("@/views/workflow/form/add/index.vue"),
workflow_form_batch: () => import("@/views/workflow/form/batch/index.vue"),
workflow_form_copy: () => import("@/views/workflow/form/copy/index.vue"),
workflow_form_detail: () => import("@/views/workflow/form/detail/index.vue"),
workflow_form_edit: () => import("@/views/workflow/form/edit/index.vue"),
workflow_task: () => import("@/views/workflow/task/index.vue"), workflow_task: () => import("@/views/workflow/task/index.vue"),
}; };

View File

@ -295,14 +295,65 @@ export const generatedRoutes: GeneratedRoute[] = [
}, },
{ {
name: 'workflow_form', name: 'workflow_form',
path: '/workflow/form/:type', path: '/workflow/form',
component: 'view.workflow_form',
meta: { meta: {
title: 'workflow_form', title: 'workflow_form',
hideInMenu: true, hideInMenu: true,
i18nKey: 'route.workflow_form' i18nKey: 'route.workflow_form'
},
children: [
{
name: 'workflow_form_add',
path: '/workflow/form/add',
component: 'view.workflow_form_add',
meta: {
hideInMenu: true,
title: 'workflow_form_add',
i18nKey: 'route.workflow_form_add'
} }
}, },
{
name: 'workflow_form_batch',
path: '/workflow/form/batch',
component: 'view.workflow_form_batch',
meta: {
hideInMenu: true,
title: 'workflow_form_batch',
i18nKey: 'route.workflow_form_batch'
}
},
{
name: 'workflow_form_copy',
path: '/workflow/form/copy',
component: 'view.workflow_form_copy',
meta: {
title: 'workflow_form_copy',
hideInMenu: true,
i18nKey: 'route.workflow_form_copy'
}
},
{
name: 'workflow_form_detail',
path: '/workflow/form/detail',
component: 'view.workflow_form_detail',
meta: {
title: 'workflow_form_detail',
hideInMenu: true,
i18nKey: 'route.workflow_form_detail'
}
},
{
name: 'workflow_form_edit',
path: '/workflow/form/edit',
component: 'view.workflow_form_edit',
meta: {
title: 'workflow_form_edit',
hideInMenu: true,
i18nKey: 'route.workflow_form_edit'
}
}
]
},
{ {
name: 'workflow_task', name: 'workflow_task',
path: '/workflow/task', path: '/workflow/task',

View File

@ -8,162 +8,7 @@ import { transformElegantRoutesToVueRoutes } from '../elegant/transform';
* *
* @link https://github.com/soybeanjs/elegant-router?tab=readme-ov-file#custom-route * @link https://github.com/soybeanjs/elegant-router?tab=readme-ov-file#custom-route
*/ */
const customRoutes: CustomRoute[] = [ const customRoutes: CustomRoute[] = [];
{
name: 'exception',
path: '/exception',
component: 'layout.base',
meta: {
title: 'exception',
i18nKey: 'route.exception',
icon: 'ant-design:exception-outlined',
order: 7,
hideInMenu: true
},
children: [
{
name: 'exception_403',
path: '/exception/403',
component: 'view.403',
meta: {
title: 'exception_403',
i18nKey: 'route.exception_403',
icon: 'ic:baseline-block'
}
},
{
name: 'exception_404',
path: '/exception/404',
component: 'view.404',
meta: {
title: 'exception_404',
i18nKey: 'route.exception_404',
icon: 'ic:baseline-web-asset-off'
}
},
{
name: 'exception_500',
path: '/exception/500',
component: 'view.500',
meta: {
title: 'exception_500',
i18nKey: 'route.exception_500',
icon: 'ic:baseline-wifi-off'
}
}
]
},
{
name: 'document',
path: '/document',
component: 'layout.base',
meta: {
title: 'document',
i18nKey: 'route.document',
order: 2,
hideInMenu: true,
icon: 'mdi:file-document-multiple-outline'
},
children: [
{
name: 'document_antd',
path: '/document/antd',
component: 'view.iframe-page',
props: {
url: 'https://antdv.com/components/overview-cn'
},
meta: {
title: 'document_antd',
i18nKey: 'route.document_antd',
order: 7,
icon: 'logos:ant-design'
}
},
{
name: 'document_naive',
path: '/document/naive',
component: 'view.iframe-page',
props: {
url: 'https://www.naiveui.com/zh-CN/os-theme/docs/introduction'
},
meta: {
title: 'document_naive',
i18nKey: 'route.document_naive',
order: 6,
icon: 'logos:naiveui'
}
},
{
name: 'document_project',
path: '/document/project',
component: 'view.iframe-page',
props: {
url: 'https://docs.soybeanjs.cn/zh'
},
meta: {
title: 'document_project',
i18nKey: 'route.document_project',
order: 1,
localIcon: 'logo'
}
},
{
name: 'document_project-link',
path: '/document/project-link',
component: 'view.iframe-page',
meta: {
title: 'document_project-link',
i18nKey: 'route.document_project-link',
order: 2,
localIcon: 'logo',
href: 'https://docs.soybeanjs.cn/zh'
}
},
{
name: 'document_unocss',
path: '/document/unocss',
component: 'view.iframe-page',
props: {
url: 'https://unocss.dev/'
},
meta: {
title: 'document_unocss',
i18nKey: 'route.document_unocss',
order: 5,
icon: 'logos:unocss'
}
},
{
name: 'document_vite',
path: '/document/vite',
component: 'view.iframe-page',
props: {
url: 'https://cn.vitejs.dev/'
},
meta: {
title: 'document_vite',
i18nKey: 'route.document_vite',
order: 4,
icon: 'logos:vitejs'
}
},
{
name: 'document_vue',
path: '/document/vue',
component: 'view.iframe-page',
props: {
url: 'https://cn.vuejs.org/'
},
meta: {
title: 'document_vue',
i18nKey: 'route.document_vue',
order: 3,
icon: 'logos:vue'
}
}
]
}
];
/** create routes when the auth route mode is static */ /** create routes when the auth route mode is static */
export function createStaticRoutes() { export function createStaticRoutes() {

View File

@ -72,15 +72,17 @@ export function getGlobalMenusByAuthRoutes(routes: ElegantConstRoute[]) {
const menus: App.Global.Menu[] = []; const menus: App.Global.Menu[] = [];
routes.forEach(route => { routes.forEach(route => {
if (!route.meta?.hideInMenu) {
const menu = getGlobalMenuByBaseRoute(route); const menu = getGlobalMenuByBaseRoute(route);
if (route.children?.some(child => !child.meta?.hideInMenu)) { if (route.children) {
menu.children = getGlobalMenusByAuthRoutes(route.children); menu.children = getGlobalMenusByAuthRoutes(route.children);
} }
menus.push(menu); if (route.meta?.hideInMenu) {
menu.show = false;
} }
menus.push(menu);
}); });
return menus; return menus;

12
src/typings/app.d.ts vendored
View File

@ -167,6 +167,8 @@ declare namespace App {
icon?: () => VNode; icon?: () => VNode;
/** The menu children */ /** The menu children */
children?: Menu[]; children?: Menu[];
/** The menu show */
show?: boolean;
} }
type Breadcrumb = Omit<Menu, 'children'> & { type Breadcrumb = Omit<Menu, 'children'> & {
@ -608,16 +610,6 @@ declare namespace App {
title: string; title: string;
}; };
}; };
projectNews: {
title: string;
moreNews: string;
desc1: string;
desc2: string;
desc3: string;
desc4: string;
desc5: string;
};
creativity: string;
}; };
pods: { pods: {
title: string; title: string;

View File

@ -1,40 +0,0 @@
<script setup lang="ts">
import type { Component } from 'vue';
import { markRaw, ref } from 'vue';
import { useRouterPush } from '@/hooks/common/router';
import Add from './modules/add.vue';
import Edit from './modules/edit.vue';
import Batch from './modules/batch.vue';
import Detail from './modules/detail.vue';
import Copy from './modules/copy.vue';
defineOptions({
name: 'WorkflowForm'
});
interface Props {
type: string;
}
const props = defineProps<Props>();
const { routerPushByKey } = useRouterPush();
const workflowForm = ref<Record<string, Component>>({
add: markRaw(Add),
edit: markRaw(Edit),
batch: markRaw(Batch),
detail: markRaw(Detail),
copy: markRaw(Copy)
});
if (!workflowForm.value[props.type]) {
routerPushByKey('404');
}
</script>
<template>
<component :is="workflowForm[type]" />
</template>
<style scoped></style>

View File

@ -2,14 +2,10 @@
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import Workflow from '@/components/workflow'; import Workflow from '@/components/workflow';
import { $t } from '@/locales';
import { useWorkflowStore } from '@/store/modules/workflow'; import { useWorkflowStore } from '@/store/modules/workflow';
import { $t } from '@/locales';
import { fetchAddWorkflow } from '@/service/api'; import { fetchAddWorkflow } from '@/service/api';
defineOptions({
name: 'WorkflowFormAdd'
});
const store = useWorkflowStore(); const store = useWorkflowStore();
const router = useRouter(); const router = useRouter();

View File

@ -5,10 +5,6 @@ import Workflow from '@/components/workflow';
import { useWorkflowStore } from '@/store/modules/workflow'; import { useWorkflowStore } from '@/store/modules/workflow';
import { fetchWorkflowBatchInfo } from '@/service/api'; import { fetchWorkflowBatchInfo } from '@/service/api';
defineOptions({
name: 'WorkflowFormBatch'
});
const store = useWorkflowStore(); const store = useWorkflowStore();
const route = useRoute(); const route = useRoute();

View File

@ -6,10 +6,6 @@ import { $t } from '@/locales';
import { useWorkflowStore } from '@/store/modules/workflow'; import { useWorkflowStore } from '@/store/modules/workflow';
import { fetchAddWorkflow, fetchWorkflowInfo } from '@/service/api'; import { fetchAddWorkflow, fetchWorkflowInfo } from '@/service/api';
defineOptions({
name: 'WorkflowFormCopy'
});
const store = useWorkflowStore(); const store = useWorkflowStore();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();

View File

@ -2,12 +2,8 @@
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import Workflow from '@/components/workflow'; import Workflow from '@/components/workflow';
import { useWorkflowStore } from '@/store/modules/workflow';
import { fetchWorkflowInfo } from '@/service/api'; import { fetchWorkflowInfo } from '@/service/api';
import { useWorkflowStore } from '@/store/modules/workflow';
defineOptions({
name: 'WorkflowFormDetail'
});
const store = useWorkflowStore(); const store = useWorkflowStore();
const route = useRoute(); const route = useRoute();

View File

@ -2,14 +2,10 @@
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import Workflow from '@/components/workflow'; import Workflow from '@/components/workflow';
import { useWorkflowStore } from '@/store/modules/workflow';
import { $t } from '@/locales'; import { $t } from '@/locales';
import { useWorkflowStore } from '@/store/modules/workflow';
import { fetchUpdateWorkflow, fetchWorkflowInfo } from '@/service/api'; import { fetchUpdateWorkflow, fetchWorkflowInfo } from '@/service/api';
defineOptions({
name: 'WorkflowFormEdit'
});
const store = useWorkflowStore(); const store = useWorkflowStore();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();