Browse Source

[Fix][UI Next][V1.0.0-Alpha] Menu error (#9036)

* modify the sidebar menu control mode

* modify side menu

* store last path

* fix security auth error

* fix resource e2e

* fix resource manage e2e bug
3.0.0/version-upgrade
Devosend 3 years ago committed by GitHub
parent
commit
d91711b322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/ResourcePage.java
  2. 30
      dolphinscheduler-ui-next/src/layouts/content/components/navbar/index.tsx
  3. 4
      dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx
  4. 37
      dolphinscheduler-ui-next/src/layouts/content/index.tsx
  5. 17
      dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts
  6. 7
      dolphinscheduler-ui-next/src/router/index.ts
  7. 2
      dolphinscheduler-ui-next/src/router/modules/data-quality.ts
  8. 1
      dolphinscheduler-ui-next/src/router/modules/datasource.ts
  9. 5
      dolphinscheduler-ui-next/src/router/modules/monitor.ts
  10. 19
      dolphinscheduler-ui-next/src/router/modules/projects.ts
  11. 17
      dolphinscheduler-ui-next/src/router/modules/resources.ts
  12. 9
      dolphinscheduler-ui-next/src/router/modules/security.ts
  13. 1
      dolphinscheduler-ui-next/src/router/routes.ts
  14. 51
      dolphinscheduler-ui-next/src/store/menu/menu.ts
  15. 34
      dolphinscheduler-ui-next/src/store/route/route.ts
  16. 8
      dolphinscheduler-ui-next/src/store/route/types.ts
  17. 8
      dolphinscheduler-ui-next/src/views/login/use-login.ts
  18. 3
      dolphinscheduler-ui-next/src/views/projects/list/use-table.ts
  19. 2
      dolphinscheduler-ui-next/src/views/resource/file/index.tsx

7
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/resource/ResourcePage.java

@ -47,20 +47,21 @@ public class ResourcePage extends NavBarPage implements NavBarPage.NavBarItem {
public <T extends ResourcePage.Tab> T goToTab(Class<T> tab) { public <T extends ResourcePage.Tab> T goToTab(Class<T> tab) {
if (tab == FileManagePage.class) { if (tab == FileManagePage.class) {
new WebDriverWait(driver, 10).until(ExpectedConditions.urlContains("/file-manage"));
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(fileManageTab)); new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(fileManageTab));
fileManageTab.click(); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", fileManageTab());
return tab.cast(new FileManagePage(driver)); return tab.cast(new FileManagePage(driver));
} }
if (tab == UdfManagePage.class) { if (tab == UdfManagePage.class) {
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(udfManageTab)); new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(udfManageTab));
udfManageTab.click(); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", udfManageTab());
return tab.cast(new UdfManagePage(driver)); return tab.cast(new UdfManagePage(driver));
} }
if (tab == FunctionManagePage.class) { if (tab == FunctionManagePage.class) {
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(functionManageTab)); new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(functionManageTab));
functionManageTab.click(); ((JavascriptExecutor) driver).executeScript("arguments[0].click();", functionManageTab());
return tab.cast(new FunctionManagePage(driver)); return tab.cast(new FunctionManagePage(driver));
} }

30
dolphinscheduler-ui-next/src/layouts/content/components/navbar/index.tsx

@ -15,7 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineComponent, PropType } from 'vue' import { defineComponent, PropType, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import styles from './index.module.scss' import styles from './index.module.scss'
import { NMenu } from 'naive-ui' import { NMenu } from 'naive-ui'
import Logo from '../logo' import Logo from '../logo'
@ -23,8 +24,6 @@ import Locales from '../locales'
import Timezone from '../timezone' import Timezone from '../timezone'
import User from '../user' import User from '../user'
import Theme from '../theme' import Theme from '../theme'
import { useMenuClick } from './use-menuClick'
import { useMenuStore } from '@/store/menu/menu'
const Navbar = defineComponent({ const Navbar = defineComponent({
name: 'Navbar', name: 'Navbar',
@ -46,11 +45,24 @@ const Navbar = defineComponent({
default: [] default: []
} }
}, },
emits: ['handleMenuClick'], setup() {
setup(props, ctx) { const route = useRoute()
const { handleMenuClick } = useMenuClick(ctx) const router = useRouter()
const menuStore = useMenuStore()
return { handleMenuClick, menuStore } const menuKey = ref(route.meta.activeMenu as string)
const handleMenuClick = (key: string) => {
router.push({ path: `/${key}` })
}
watch(
() => route.path,
() => {
menuKey.value = route.meta.activeMenu as string
}
)
return { handleMenuClick, menuKey }
}, },
render() { render() {
return ( return (
@ -58,7 +70,7 @@ const Navbar = defineComponent({
<Logo /> <Logo />
<div class={styles.nav}> <div class={styles.nav}>
<NMenu <NMenu
value={this.menuStore.getMenuKey} value={this.menuKey}
mode='horizontal' mode='horizontal'
options={this.headerMenuOptions} options={this.headerMenuOptions}
onUpdateValue={this.handleMenuClick} onUpdateValue={this.handleMenuClick}

4
dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx

@ -18,7 +18,6 @@
import { defineComponent, ref, PropType } from 'vue' import { defineComponent, ref, PropType } from 'vue'
import { NLayoutSider, NMenu } from 'naive-ui' import { NLayoutSider, NMenu } from 'naive-ui'
import { useMenuClick } from './use-menuClick' import { useMenuClick } from './use-menuClick'
import { useMenuStore } from '@/store/menu/menu'
const Sidebar = defineComponent({ const Sidebar = defineComponent({
name: 'Sidebar', name: 'Sidebar',
@ -33,7 +32,6 @@ const Sidebar = defineComponent({
} }
}, },
setup() { setup() {
const menuStore = useMenuStore()
const collapsedRef = ref(false) const collapsedRef = ref(false)
const defaultExpandedKeys = [ const defaultExpandedKeys = [
'workflow', 'workflow',
@ -46,7 +44,7 @@ const Sidebar = defineComponent({
const { handleMenuClick } = useMenuClick() const { handleMenuClick } = useMenuClick()
return { collapsedRef, defaultExpandedKeys, handleMenuClick, menuStore } return { collapsedRef, defaultExpandedKeys, handleMenuClick }
}, },
render() { render() {
return ( return (

37
dolphinscheduler-ui-next/src/layouts/content/index.tsx

@ -20,8 +20,8 @@ import { NLayout, NLayoutContent, NLayoutHeader, useMessage } from 'naive-ui'
import NavBar from './components/navbar' import NavBar from './components/navbar'
import SideBar from './components/sidebar' import SideBar from './components/sidebar'
import { useDataList } from './use-dataList' import { useDataList } from './use-dataList'
import { useMenuStore } from '@/store/menu/menu'
import { useLocalesStore } from '@/store/locales/locales' import { useLocalesStore } from '@/store/locales/locales'
import { useRouteStore } from '@/store/route/route'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
@ -31,9 +31,9 @@ const Content = defineComponent({
window.$message = useMessage() window.$message = useMessage()
const route = useRoute() const route = useRoute()
const menuStore = useMenuStore()
const { locale } = useI18n() const { locale } = useI18n()
const localesStore = useLocalesStore() const localesStore = useLocalesStore()
const routeStore = useRouteStore()
const { const {
state, state,
changeMenuOption, changeMenuOption,
@ -51,16 +51,11 @@ const Content = defineComponent({
}) })
const getSideMenu = (state: any) => { const getSideMenu = (state: any) => {
const key = menuStore.getMenuKey const key = route.meta.activeMenu
state.sideMenuOptions = state.sideMenuOptions =
state.menuOptions.filter((menu: { key: string }) => menu.key === key)[0] state.menuOptions.filter((menu: { key: string }) => menu.key === key)[0]
?.children || state.menuOptions ?.children || state.menuOptions
state.isShowSide = menuStore.getShowSideStatus state.isShowSide = route.meta.showSide
}
const getSideMenuOptions = (item: any) => {
menuStore.setMenuKey(item.key)
getSideMenu(state)
} }
watch(useI18n().locale, () => { watch(useI18n().locale, () => {
@ -74,17 +69,26 @@ const Content = defineComponent({
() => route.path, () => route.path,
() => { () => {
if (route.path !== '/login') { if (route.path !== '/login') {
state.isShowSide = menuStore.getShowSideStatus routeStore.setLastRoute(route.path)
state.isShowSide = route.meta.showSide as boolean
if (route.matched[1].path === '/projects/:projectCode') { if (route.matched[1].path === '/projects/:projectCode') {
changeMenuOption(state) changeMenuOption(state)
getSideMenu(state)
} }
sideKeyRef.value = route.matched[1].path.includes(':projectCode')
? route.matched[1].path.replace( getSideMenu(state)
const currentSide = (
route.meta.activeSide
? route.meta.activeSide
: route.matched[1].path
) as string
sideKeyRef.value = currentSide.includes(':projectCode')
? currentSide.replace(
':projectCode', ':projectCode',
menuStore.getProjectCode route.params.projectCode as string
) )
: route.matched[1].path : currentSide
} }
}, },
{ immediate: true } { immediate: true }
@ -92,9 +96,7 @@ const Content = defineComponent({
return { return {
...toRefs(state), ...toRefs(state),
menuStore,
changeMenuOption, changeMenuOption,
getSideMenuOptions,
sideKeyRef sideKeyRef
} }
}, },
@ -104,7 +106,6 @@ const Content = defineComponent({
<NLayoutHeader style='height: 65px'> <NLayoutHeader style='height: 65px'>
<NavBar <NavBar
class='tab-horizontal' class='tab-horizontal'
onHandleMenuClick={this.getSideMenuOptions}
headerMenuOptions={this.headerMenuOptions} headerMenuOptions={this.headerMenuOptions}
localesOptions={this.localesOptions} localesOptions={this.localesOptions}
timezoneOptions={this.timezoneOptions} timezoneOptions={this.timezoneOptions}

17
dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts

@ -48,14 +48,14 @@ import {
BarsOutlined, BarsOutlined,
CloudServerOutlined CloudServerOutlined
} from '@vicons/antd' } from '@vicons/antd'
import { useMenuStore } from '@/store/menu/menu' import { useRoute } from 'vue-router'
import { useUserStore } from '@/store/user/user' import { useUserStore } from '@/store/user/user'
import { timezoneList } from '@/utils/timezone' import { timezoneList } from '@/utils/timezone'
import type { UserInfoRes } from '@/service/modules/users/types' import type { UserInfoRes } from '@/service/modules/users/types'
export function useDataList() { export function useDataList() {
const { t } = useI18n() const { t } = useI18n()
const menuStore = useMenuStore() const route = useRoute()
const userStore = useUserStore() const userStore = useUserStore()
const renderIcon = (icon: any) => { const renderIcon = (icon: any) => {
@ -87,6 +87,7 @@ export function useDataList() {
}) })
const changeMenuOption = (state: any) => { const changeMenuOption = (state: any) => {
const projectCode = route.params.projectCode || ''
state.menuOptions = [ state.menuOptions = [
{ {
label: t('menu.home'), label: t('menu.home'),
@ -100,7 +101,7 @@ export function useDataList() {
children: [ children: [
{ {
label: t('menu.project_overview'), label: t('menu.project_overview'),
key: `/projects/${menuStore.getProjectCode}`, key: `/projects/${projectCode}`,
icon: renderIcon(FundProjectionScreenOutlined) icon: renderIcon(FundProjectionScreenOutlined)
}, },
{ {
@ -110,15 +111,15 @@ export function useDataList() {
children: [ children: [
{ {
label: t('menu.workflow_relation'), label: t('menu.workflow_relation'),
key: `/projects/${menuStore.getProjectCode}/workflow/relation` key: `/projects/${projectCode}/workflow/relation`
}, },
{ {
label: t('menu.workflow_definition'), label: t('menu.workflow_definition'),
key: `/projects/${menuStore.getProjectCode}/workflow-definition` key: `/projects/${projectCode}/workflow-definition`
}, },
{ {
label: t('menu.workflow_instance'), label: t('menu.workflow_instance'),
key: `/projects/${menuStore.getProjectCode}/workflow/instances` key: `/projects/${projectCode}/workflow/instances`
} }
] ]
}, },
@ -129,11 +130,11 @@ export function useDataList() {
children: [ children: [
{ {
label: t('menu.task_definition'), label: t('menu.task_definition'),
key: `/projects/${menuStore.getProjectCode}/task/definitions` key: `/projects/${projectCode}/task/definitions`
}, },
{ {
label: t('menu.task_instance'), label: t('menu.task_instance'),
key: `/projects/${menuStore.getProjectCode}/task/instances` key: `/projects/${projectCode}/task/instances`
} }
] ]
} }

7
dolphinscheduler-ui-next/src/router/index.ts

@ -22,8 +22,6 @@ import {
RouteLocationNormalized RouteLocationNormalized
} from 'vue-router' } from 'vue-router'
import routes from './routes' import routes from './routes'
import { useMenuStore } from '@/store/menu/menu'
import { useUserStore } from '@/store/user/user' import { useUserStore } from '@/store/user/user'
import type { UserInfoRes } from '@/service/modules/users/types' import type { UserInfoRes } from '@/service/modules/users/types'
@ -40,6 +38,7 @@ const router = createRouter({
interface metaData { interface metaData {
title?: string title?: string
activeMenu?: string
showSide?: boolean showSide?: boolean
auth?: Array<string> auth?: Array<string>
} }
@ -54,14 +53,12 @@ router.beforeEach(
next: NavigationGuardNext next: NavigationGuardNext
) => { ) => {
NProgress.start() NProgress.start()
const menuStore = useMenuStore()
const userStore = useUserStore() const userStore = useUserStore()
const metaData: metaData = to.meta const metaData: metaData = to.meta
menuStore.setShowSideStatus(metaData.showSide || false)
if ( if (
metaData.auth?.includes('ADMIN_USER') && metaData.auth?.includes('ADMIN_USER') &&
(userStore.getUserInfo as UserInfoRes).userType !== 'ADMIN_USER' && (userStore.getUserInfo as UserInfoRes).userType !== 'ADMIN_USER' &&
menuStore.getMenuKey === 'security' metaData.activeMenu === 'security'
) { ) {
to.fullPath = '/security/token-manage' to.fullPath = '/security/token-manage'
next({ name: 'token-manage' }) next({ name: 'token-manage' })

2
dolphinscheduler-ui-next/src/router/modules/data-quality.ts

@ -35,6 +35,7 @@ export default {
component: components['data-quality-task-result'], component: components['data-quality-task-result'],
meta: { meta: {
title: '数据质量-task-result', title: '数据质量-task-result',
activeMenu: 'data-quality',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -45,6 +46,7 @@ export default {
component: components['data-quality-rule'], component: components['data-quality-rule'],
meta: { meta: {
title: '数据质量-rule', title: '数据质量-rule',
activeMenu: 'data-quality',
showSide: true, showSide: true,
auth: [] auth: []
} }

1
dolphinscheduler-ui-next/src/router/modules/datasource.ts

@ -34,6 +34,7 @@ export default {
component: components['datasource-list'], component: components['datasource-list'],
meta: { meta: {
title: '数据源中心', title: '数据源中心',
activeMenu: 'datasource',
showSide: false, showSide: false,
auth: [] auth: []
} }

5
dolphinscheduler-ui-next/src/router/modules/monitor.ts

@ -35,6 +35,7 @@ export default {
component: components['monitor-servers-master'], component: components['monitor-servers-master'],
meta: { meta: {
title: '服务管理-Master', title: '服务管理-Master',
activeMenu: 'monitor',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -45,6 +46,7 @@ export default {
component: components['monitor-servers-worker'], component: components['monitor-servers-worker'],
meta: { meta: {
title: '服务管理-Worker', title: '服务管理-Worker',
activeMenu: 'monitor',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -55,6 +57,7 @@ export default {
component: components['monitor-servers-db'], component: components['monitor-servers-db'],
meta: { meta: {
title: '服务管理-DB', title: '服务管理-DB',
activeMenu: 'monitor',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -65,6 +68,7 @@ export default {
component: components['monitor-statistics-statistics'], component: components['monitor-statistics-statistics'],
meta: { meta: {
title: '统计管理-Statistics', title: '统计管理-Statistics',
activeMenu: 'monitor',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -75,6 +79,7 @@ export default {
component: components['monitor-statistics-audit-log'], component: components['monitor-statistics-audit-log'],
meta: { meta: {
title: '审计日志-AuditLog', title: '审计日志-AuditLog',
activeMenu: 'monitor',
showSide: true, showSide: true,
auth: [] auth: []
} }

19
dolphinscheduler-ui-next/src/router/modules/projects.ts

@ -37,6 +37,7 @@ export default {
component: components['projects-list'], component: components['projects-list'],
meta: { meta: {
title: '项目', title: '项目',
activeMenu: 'projects',
showSide: false, showSide: false,
auth: [] auth: []
} }
@ -47,6 +48,7 @@ export default {
component: components['projects-overview'], component: components['projects-overview'],
meta: { meta: {
title: '项目概览', title: '项目概览',
activeMenu: 'projects',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -57,6 +59,7 @@ export default {
component: components['projects-workflow-relation'], component: components['projects-workflow-relation'],
meta: { meta: {
title: '工作流关系', title: '工作流关系',
activeMenu: 'projects',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -67,6 +70,7 @@ export default {
component: components['projects-workflow-definition'], component: components['projects-workflow-definition'],
meta: { meta: {
title: '工作流定义', title: '工作流定义',
activeMenu: 'projects',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -77,6 +81,8 @@ export default {
component: components['projects-workflow-definition-timing'], component: components['projects-workflow-definition-timing'],
meta: { meta: {
title: '定时管理', title: '定时管理',
activeMenu: 'projects',
activeSide: '/projects/:projectCode/workflow-definition',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -87,6 +93,8 @@ export default {
component: components['projects-workflow-definition-create'], component: components['projects-workflow-definition-create'],
meta: { meta: {
title: '创建工作流定义', title: '创建工作流定义',
activeMenu: 'projects',
activeSide: '/projects/:projectCode/workflow-definition',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -97,6 +105,8 @@ export default {
component: components['projects-workflow-definition-detail'], component: components['projects-workflow-definition-detail'],
meta: { meta: {
title: '工作流定义详情', title: '工作流定义详情',
activeMenu: 'projects',
activeSide: '/projects/:projectCode/workflow-definition',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -107,6 +117,7 @@ export default {
component: components['projects-workflow-instance'], component: components['projects-workflow-instance'],
meta: { meta: {
title: '工作流实例', title: '工作流实例',
activeMenu: 'projects',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -117,6 +128,8 @@ export default {
component: components['projects-workflow-instance-detail'], component: components['projects-workflow-instance-detail'],
meta: { meta: {
title: '工作流实例详情', title: '工作流实例详情',
activeMenu: 'projects',
activeSide: '/projects/:projectCode/workflow/instances',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -127,6 +140,8 @@ export default {
component: components['projects-workflow-instance-gantt'], component: components['projects-workflow-instance-gantt'],
meta: { meta: {
title: '工作流实例甘特图', title: '工作流实例甘特图',
activeMenu: 'projects',
activeSide: '/projects/:projectCode/workflow/instances',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -137,6 +152,7 @@ export default {
component: components['projects-task-definition'], component: components['projects-task-definition'],
meta: { meta: {
title: '任务定义', title: '任务定义',
activeMenu: 'projects',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -147,6 +163,7 @@ export default {
component: components['projects-task-instance'], component: components['projects-task-instance'],
meta: { meta: {
title: '任务实例', title: '任务实例',
activeMenu: 'projects',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -157,6 +174,8 @@ export default {
component: components['projects-workflow-definition-tree'], component: components['projects-workflow-definition-tree'],
meta: { meta: {
title: '工作流定义树形图', title: '工作流定义树形图',
activeMenu: 'projects',
activeSide: '/projects/:projectCode/workflow-definition',
showSide: true, showSide: true,
auth: [] auth: []
} }

17
dolphinscheduler-ui-next/src/router/modules/resources.ts

@ -35,6 +35,7 @@ export default {
component: components['resource-file'], component: components['resource-file'],
meta: { meta: {
title: '文件管理', title: '文件管理',
activeMenu: 'resource',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -45,6 +46,8 @@ export default {
component: components['resource-file-create'], component: components['resource-file-create'],
meta: { meta: {
title: '文件创建', title: '文件创建',
activeMenu: 'resource',
activeSide: '/resource/file-manage',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -55,6 +58,8 @@ export default {
component: components['resource-file-edit'], component: components['resource-file-edit'],
meta: { meta: {
title: '文件编辑', title: '文件编辑',
activeMenu: 'resource',
activeSide: '/resource/file-manage',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -65,6 +70,8 @@ export default {
component: components['resource-file'], component: components['resource-file'],
meta: { meta: {
title: '文件管理', title: '文件管理',
activeMenu: 'resource',
activeSide: '/resource/file-manage',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -75,6 +82,8 @@ export default {
component: components['resource-file-edit'], component: components['resource-file-edit'],
meta: { meta: {
title: '文件详情', title: '文件详情',
activeMenu: 'resource',
activeSide: '/resource/file-manage',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -85,6 +94,8 @@ export default {
component: components['resource-file-create'], component: components['resource-file-create'],
meta: { meta: {
title: '文件创建', title: '文件创建',
activeMenu: 'resource',
activeSide: '/resource/file-manage',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -95,6 +106,7 @@ export default {
component: components['resource-udf-resource'], component: components['resource-udf-resource'],
meta: { meta: {
title: '资源管理', title: '资源管理',
activeMenu: 'resource',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -105,6 +117,8 @@ export default {
component: components['resource-udf-resource'], component: components['resource-udf-resource'],
meta: { meta: {
title: '资源管理', title: '资源管理',
activeMenu: 'resource',
activeSide: '/resource/resource-manage',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -115,6 +129,7 @@ export default {
component: components['resource-udf-function'], component: components['resource-udf-function'],
meta: { meta: {
title: '函数管理', title: '函数管理',
activeMenu: 'resource',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -125,6 +140,7 @@ export default {
component: components['resource-task-group-option'], component: components['resource-task-group-option'],
meta: { meta: {
title: '任务组配置', title: '任务组配置',
activeMenu: 'resource',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -135,6 +151,7 @@ export default {
component: components['resource-task-group-queue'], component: components['resource-task-group-queue'],
meta: { meta: {
title: '任务组队列', title: '任务组队列',
activeMenu: 'resource',
showSide: true, showSide: true,
auth: [] auth: []
} }

9
dolphinscheduler-ui-next/src/router/modules/security.ts

@ -35,6 +35,7 @@ export default {
component: components['security-tenant-manage'], component: components['security-tenant-manage'],
meta: { meta: {
title: '租户管理', title: '租户管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: ['ADMIN_USER'] auth: ['ADMIN_USER']
} }
@ -45,6 +46,7 @@ export default {
component: components['security-user-manage'], component: components['security-user-manage'],
meta: { meta: {
title: '用户管理', title: '用户管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: ['ADMIN_USER'] auth: ['ADMIN_USER']
} }
@ -55,6 +57,7 @@ export default {
component: components['security-alarm-group-manage'], component: components['security-alarm-group-manage'],
meta: { meta: {
title: '告警组管理', title: '告警组管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: ['ADMIN_USER'] auth: ['ADMIN_USER']
} }
@ -65,6 +68,7 @@ export default {
component: components['security-worker-group-manage'], component: components['security-worker-group-manage'],
meta: { meta: {
title: 'Worker分组管理', title: 'Worker分组管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: ['ADMIN_USER'] auth: ['ADMIN_USER']
} }
@ -75,6 +79,7 @@ export default {
component: components['security-yarn-queue-manage'], component: components['security-yarn-queue-manage'],
meta: { meta: {
title: 'Yarn队列管理', title: 'Yarn队列管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: ['ADMIN_USER'] auth: ['ADMIN_USER']
} }
@ -85,6 +90,7 @@ export default {
component: components['security-environment-manage'], component: components['security-environment-manage'],
meta: { meta: {
title: '环境管理', title: '环境管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: ['ADMIN_USER'] auth: ['ADMIN_USER']
} }
@ -95,6 +101,7 @@ export default {
component: components['security-token-manage'], component: components['security-token-manage'],
meta: { meta: {
title: '令牌管理管理', title: '令牌管理管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: [] auth: []
} }
@ -105,6 +112,7 @@ export default {
component: components['security-alarm-instance-manage'], component: components['security-alarm-instance-manage'],
meta: { meta: {
title: '告警实例管理', title: '告警实例管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: ['ADMIN_USER'] auth: ['ADMIN_USER']
} }
@ -115,6 +123,7 @@ export default {
component: components['security-k8s-namespace-manage'], component: components['security-k8s-namespace-manage'],
meta: { meta: {
title: 'K8S命名空间管理', title: 'K8S命名空间管理',
activeMenu: 'security',
showSide: true, showSide: true,
auth: ['ADMIN_USER'] auth: ['ADMIN_USER']
} }

1
dolphinscheduler-ui-next/src/router/routes.ts

@ -45,6 +45,7 @@ const basePage: RouteRecordRaw[] = [
component: components['home'], component: components['home'],
meta: { meta: {
title: '首页', title: '首页',
activeMenu: 'home',
auth: [] auth: []
} }
}, },

51
dolphinscheduler-ui-next/src/store/menu/menu.ts

@ -1,51 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineStore } from 'pinia'
import MenuState from './types'
export const useMenuStore = defineStore({
id: 'menu',
state: (): MenuState => ({
menuKey: 'home',
isShowSide: false,
projectCode: ''
}),
persist: true,
getters: {
getMenuKey(): string {
return this.menuKey
},
getShowSideStatus(): boolean {
return this.isShowSide || false
},
getProjectCode(): string {
return this.projectCode || ''
}
},
actions: {
setMenuKey(menuKey: string): void {
this.menuKey = menuKey
},
setShowSideStatus(isShowSide: boolean): void {
this.isShowSide = isShowSide
},
setProjectCode(projectCode: string): void {
this.projectCode = projectCode
}
}
})

34
dolphinscheduler-ui-next/src/layouts/content/components/navbar/use-menuClick.ts → dolphinscheduler-ui-next/src/store/route/route.ts

@ -15,21 +15,23 @@
* limitations under the License. * limitations under the License.
*/ */
import { useRouter } from 'vue-router' import { defineStore } from 'pinia'
import type { Router } from 'vue-router' import RouteState from './types'
import { MenuOption } from 'naive-ui'
import { SetupContext } from 'vue'
export function useMenuClick(ctx: SetupContext<'handleMenuClick'[]>) { export const useRouteStore = defineStore({
const router: Router = useRouter() id: 'route',
state: (): RouteState => ({
const handleMenuClick = (key: string, item: MenuOption) => { lastRoute: 'home'
// console.log(key, item) }),
ctx.emit('handleMenuClick', item) persist: true,
router.push({ path: `/${key}` }) getters: {
} getLastRoute(): string {
return this.lastRoute
return { }
handleMenuClick },
actions: {
setLastRoute(lastRoute: string): void {
this.lastRoute = lastRoute
}
} }
} })

8
dolphinscheduler-ui-next/src/store/menu/types.ts → dolphinscheduler-ui-next/src/store/route/types.ts

@ -15,10 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
interface MenuState { interface RouteState {
menuKey: string lastRoute: string
isShowSide: boolean
projectCode: string
} }
export default MenuState export default RouteState

8
dolphinscheduler-ui-next/src/views/login/use-login.ts

@ -22,13 +22,13 @@ import { useUserStore } from '@/store/user/user'
import type { Router } from 'vue-router' import type { Router } from 'vue-router'
import type { SessionIdRes } from '@/service/modules/login/types' import type { SessionIdRes } from '@/service/modules/login/types'
import type { UserInfoRes } from '@/service/modules/users/types' import type { UserInfoRes } from '@/service/modules/users/types'
import { useMenuStore } from '@/store/menu/menu' import { useRouteStore } from '@/store/route/route'
import { useTimezoneStore } from '@/store/timezone/timezone' import { useTimezoneStore } from '@/store/timezone/timezone'
export function useLogin(state: any) { export function useLogin(state: any) {
const router: Router = useRouter() const router: Router = useRouter()
const userStore = useUserStore() const userStore = useUserStore()
const menuStore = useMenuStore() const routeStore = useRouteStore()
const timezoneStore = useTimezoneStore() const timezoneStore = useTimezoneStore()
const handleLogin = () => { const handleLogin = () => {
@ -45,9 +45,9 @@ export function useLogin(state: any) {
: Intl.DateTimeFormat().resolvedOptions().timeZone : Intl.DateTimeFormat().resolvedOptions().timeZone
await timezoneStore.setTimezone(timezone) await timezoneStore.setTimezone(timezone)
const key = menuStore.getMenuKey const path = routeStore.lastRoute
router.push({ path: key || 'home' }) router.push({ path: path || 'home' })
} }
}) })
} }

3
dolphinscheduler-ui-next/src/views/projects/list/use-table.ts

@ -24,7 +24,6 @@ import { parseTime } from '@/utils/common'
import { deleteProject } from '@/service/modules/projects' import { deleteProject } from '@/service/modules/projects'
import { format } from 'date-fns' import { format } from 'date-fns'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useMenuStore } from '@/store/menu/menu'
import { import {
NButton, NButton,
NEllipsis, NEllipsis,
@ -40,7 +39,6 @@ import { DeleteOutlined, EditOutlined } from '@vicons/antd'
export function useTable() { export function useTable() {
const { t } = useI18n() const { t } = useI18n()
const router: Router = useRouter() const router: Router = useRouter()
const menuStore = useMenuStore()
const handleEdit = (row: any) => { const handleEdit = (row: any) => {
variables.showModalRef = true variables.showModalRef = true
@ -82,7 +80,6 @@ export function useTable() {
ButtonLink, ButtonLink,
{ {
onClick: () => { onClick: () => {
menuStore.setProjectCode(row.code)
router.push({ path: `/projects/${row.code}` }) router.push({ path: `/projects/${row.code}` })
} }
}, },

2
dolphinscheduler-ui-next/src/views/resource/file/index.tsx

@ -192,7 +192,7 @@ export default defineComponent({
const initBreadcrumb = async (dirs: string[]) => { const initBreadcrumb = async (dirs: string[]) => {
let index = 0 let index = 0
for (let dir of dirs) { for (const dir of dirs) {
const newDir = dirs.slice(0, index + 1).join('/') const newDir = dirs.slice(0, index + 1).join('/')
if (newDir) { if (newDir) {
const id = 0 const id = 0

Loading…
Cancel
Save