Browse Source

[Feature][UI Next]: Rearrange the routing and format the code (#7533)

* fix: Rearrange the routing and format the code

* To fix the problem

To fix the problem
3.0.0/version-upgrade
labbomb 3 years ago committed by GitHub
parent
commit
4c49a8b91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 34
      dolphinscheduler-ui-next/src/layouts/basic/components/header/index.tsx
  2. 20
      dolphinscheduler-ui-next/src/layouts/basic/components/logo/index.tsx
  3. 30
      dolphinscheduler-ui-next/src/layouts/basic/components/sider/index.tsx
  4. 158
      dolphinscheduler-ui-next/src/layouts/basic/index.tsx
  5. 12
      dolphinscheduler-ui-next/src/layouts/content/Content.tsx
  6. 24
      dolphinscheduler-ui-next/src/router/index.ts
  7. 41
      dolphinscheduler-ui-next/src/router/modules/datasource.ts
  8. 49
      dolphinscheduler-ui-next/src/router/modules/monitor.ts
  9. 49
      dolphinscheduler-ui-next/src/router/modules/projects.ts
  10. 49
      dolphinscheduler-ui-next/src/router/modules/resources.ts
  11. 49
      dolphinscheduler-ui-next/src/router/modules/security.ts
  12. 191
      dolphinscheduler-ui-next/src/router/routes.ts
  13. 2
      dolphinscheduler-ui-next/src/utils/index.ts

34
dolphinscheduler-ui-next/src/layouts/basic/components/header/index.tsx

@ -15,16 +15,16 @@
* limitations under the License.
*/
import { defineComponent, ref } from "vue";
import { defineComponent, ref } from 'vue'
import styles from "./index.module.scss";
import { NDropdown, NIcon, NLayoutHeader, NMenu } from "naive-ui";
import { Logo } from "@/layouts/basic/components/logo";
import { IosArrowDown } from "@vicons/ionicons4";
import { UserAlt } from "@vicons/fa";
import styles from './index.module.scss'
import { NDropdown, NIcon, NLayoutHeader, NMenu } from 'naive-ui'
import Logo from '@/layouts/basic/components/logo'
import { IosArrowDown } from '@vicons/ionicons4'
import { UserAlt } from '@vicons/fa'
const Header = defineComponent({
name: "Header",
name: 'Header',
props: {
inverted: {
type: Boolean,
@ -50,26 +50,26 @@ const Header = defineComponent({
},
},
setup(props, context) {
const currentMenuRef = ref({});
const currentMenuRef = ref({})
const handleMenuClick = (key, data) => {
currentMenuRef.value = data;
context.emit("menuClick", data);
};
currentMenuRef.value = data
context.emit('menuClick', data)
}
return { handleMenuClick };
return { handleMenuClick }
},
render() {
return (
<NLayoutHeader
class={styles["header-model"]}
class={styles['header-model']}
inverted={this.inverted}
bordered
>
<Logo />
<div class={styles.nav}>
<NMenu
mode="horizontal"
mode='horizontal'
onUpdate:value={this.handleMenuClick}
defaultValue={this.defaultMenuKey}
class={styles.menu}
@ -99,8 +99,8 @@ const Header = defineComponent({
</div>
</div>
</NLayoutHeader>
);
)
},
});
})
export { Header };
export { Header }

20
dolphinscheduler-ui-next/src/layouts/basic/components/logo/index.tsx

@ -15,24 +15,20 @@
* limitations under the License.
*/
import { defineComponent, ref } from "vue";
import { defineComponent } from 'vue'
import styles from "./index.module.scss";
import styles from './index.module.scss'
const Logo = defineComponent({
name: "Logo",
setup() {
const invertedRef = ref(true);
return { invertedRef };
},
name: 'Logo',
setup() {},
render() {
return (
<div class={styles.logo}>
<img src="../../../src/assets/images/nav-logo.svg" alt="" />
<img src='./src/assets/images/nav-logo.svg' alt='' />
</div>
);
)
},
});
})
export { Logo };
export default Logo

30
dolphinscheduler-ui-next/src/layouts/basic/components/sider/index.tsx

@ -15,11 +15,11 @@
* limitations under the License.
*/
import { defineComponent, ref } from "vue";
import { NLayoutSider, NMenu } from "naive-ui";
import { defineComponent, ref } from 'vue'
import { NLayoutSider, NMenu } from 'naive-ui'
const Sider = defineComponent({
name: "Sider",
name: 'Sider',
props: {
visible: {
type: Boolean,
@ -41,20 +41,21 @@ const Sider = defineComponent({
},
},
setup(props) {
const currentMenuRef = ref({});
const currentMenuRef = ref({})
const handleMenuClick = (key, data) => {
currentMenuRef.value = data;
};
currentMenuRef.value = data
}
return { handleMenuClick };
return { handleMenuClick }
},
render() {
if (this.visible) {
return (
return
this.visible ?
(
<NLayoutSider
width={240}
collapseMode={"width"}
collapseMode={'width'}
collapsedWidth={64}
inverted={this.inverted}
nativeScrollbar={false}
@ -69,11 +70,8 @@ const Sider = defineComponent({
options={this.menuOptions}
/>
</NLayoutSider>
);
} else {
return "";
}
) : ''
},
});
})
export { Sider };
export { Sider }

158
dolphinscheduler-ui-next/src/layouts/basic/index.tsx

@ -15,186 +15,186 @@
* limitations under the License.
*/
import { h, defineComponent, ref } from "vue";
import styles from "./index.module.scss";
import { useI18n } from "vue-i18n";
import { h, defineComponent, ref } from 'vue'
import styles from './index.module.scss'
import { useI18n } from 'vue-i18n'
import {
PersonCircleOutline,
LogOutOutline,
FileTrayFullOutline,
Server,
SettingsOutline,
} from "@vicons/ionicons5";
} from '@vicons/ionicons5'
import {
HomeOutlined,
FolderOutlined,
SafetyCertificateOutlined,
UserOutlined,
} from "@vicons/antd";
import { Database, Notes, Users } from "@vicons/tabler";
import { MonitorFilled, AcUnitOutlined } from "@vicons/material";
import { Flow } from "@vicons/carbon";
import { Header } from "./components/header";
import { Sider } from "./components/sider";
import { NLayout, NLayoutContent, NIcon } from "naive-ui";
} from '@vicons/antd'
import { Database, Notes, Users } from '@vicons/tabler'
import { MonitorFilled, AcUnitOutlined } from '@vicons/material'
import { Flow } from '@vicons/carbon'
import { Header } from './components/header'
import { Sider } from './components/sider'
import { NLayout, NLayoutContent, NIcon } from 'naive-ui'
function renderIcon(icon) {
return () => h(NIcon, null, { default: () => h(icon) });
return () => h(NIcon, null, { default: () => h(icon) })
}
const switchLanguageOptions = [
{
label: "English",
key: "en",
label: 'English',
key: 'en',
},
{
label: "中文",
key: "zh",
label: '中文',
key: 'zh',
},
];
]
const profileOptions = [
{
label: "用户信息",
key: "profile",
label: '用户信息',
key: 'profile',
icon: renderIcon(PersonCircleOutline),
},
{
label: "退出登录",
key: "logout",
label: '退出登录',
key: 'logout',
icon: renderIcon(LogOutOutline),
},
];
]
const menuOptions = [
{
label: "首页",
key: "home",
label: '首页',
key: 'home',
icon: renderIcon(HomeOutlined),
},
{
label: "项目管理",
key: "project",
label: '项目管理',
key: 'project',
icon: renderIcon(Notes),
children: [
{
label: "项目",
key: "projects-list",
label: '项目',
key: 'projects-list',
icon: renderIcon(Notes),
},
{
label: "工作流监控",
key: "projects-index",
label: '工作流监控',
key: 'projects-index',
icon: renderIcon(Flow),
},
],
},
{
label: "资源中心",
key: "resources",
label: '资源中心',
key: 'resources',
icon: renderIcon(FolderOutlined),
children: [
{
label: "文件管理",
key: "file",
label: '文件管理',
key: 'file',
icon: renderIcon(FileTrayFullOutline),
},
{
label: "创建资源",
key: "resource-file-create",
label: '创建资源',
key: 'resource-file-create',
icon: renderIcon(AcUnitOutlined),
},
],
},
{
label: "数据源中心",
key: "datasource",
label: '数据源中心',
key: 'datasource',
icon: renderIcon(Database),
children: [
{
label: "数据源中心",
key: "datasource-list",
label: '数据源中心',
key: 'datasource-list',
icon: renderIcon(Database),
},
],
},
{
label: "监控中心",
key: "monitor",
label: '监控中心',
key: 'monitor',
icon: renderIcon(MonitorFilled),
children: [
{
key: "servers-master",
title: "服务管理-Master",
key: 'servers-master',
title: '服务管理-Master',
icon: renderIcon(Server),
},
{
key: "servers-worker",
title: "服务管理-Worker",
key: 'servers-worker',
title: '服务管理-Worker',
icon: renderIcon(SettingsOutline),
},
],
},
{
label: "安全中心",
key: "security",
label: '安全中心',
key: 'security',
icon: renderIcon(SafetyCertificateOutlined),
children: [
{
key: "tenement-manage",
label: "租户管理",
key: 'tenement-manage',
label: '租户管理',
icon: renderIcon(UserOutlined),
},
{
key: "users-manage",
label: "用户管理",
key: 'users-manage',
label: '用户管理',
icon: renderIcon(Users),
},
],
},
];
]
const basic = defineComponent({
name: "basic",
name: 'basic',
setup() {
const invertedRef = ref(true);
const hasSiderRef = ref(false);
const defaultMenuKeyRef = ref("home");
const currentMenuRef = ref({});
const topMenuOptionsRef = ref([]);
const sideMenuOptionsRef = ref([]);
const invertedRef = ref(true)
const hasSiderRef = ref(false)
const defaultMenuKeyRef = ref('home')
const currentMenuRef = ref({})
const topMenuOptionsRef = ref([])
const sideMenuOptionsRef = ref([])
const handleTopMenuClick = (data) => {
currentMenuRef.value = data;
generateMenus();
};
currentMenuRef.value = data
generateMenus()
}
const handleSideMenuClick = (key, data) => {
console.log(data);
};
console.log(data)
}
const generateMenus = () => {
topMenuOptionsRef.value = [];
sideMenuOptionsRef.value = [];
hasSiderRef.value = false;
topMenuOptionsRef.value = []
sideMenuOptionsRef.value = []
hasSiderRef.value = false
menuOptions.forEach((option) => {
topMenuOptionsRef.value.push({
label: option.label,
key: option.key,
icon: option.icon,
});
})
if (
currentMenuRef.value.key === option.key ||
defaultMenuKeyRef.value === option.key
) {
if (option.hasOwnProperty("children") && option.children) {
sideMenuOptionsRef.value = option.children;
hasSiderRef.value = true;
if (option.hasOwnProperty('children') && option.children) {
sideMenuOptionsRef.value = option.children
hasSiderRef.value = true
}
}
});
};
generateMenus();
})
}
generateMenus()
return {
topMenuOptionsRef,
sideMenuOptionsRef,
@ -203,7 +203,7 @@ const basic = defineComponent({
defaultMenuKeyRef,
handleTopMenuClick,
handleSideMenuClick,
};
}
},
render() {
return (
@ -227,8 +227,8 @@ const basic = defineComponent({
</NLayoutContent>
</NLayout>
</NLayout>
);
)
},
});
})
export default basic;
export default basic

12
dolphinscheduler-ui-next/src/layouts/content/Content.tsx

@ -15,11 +15,11 @@
* limitations under the License.
*/
import { defineComponent } from "vue";
import { NLayout, NLayoutContent } from "naive-ui";
import { defineComponent } from 'vue'
import { NLayout, NLayoutContent } from 'naive-ui'
const Content = defineComponent({
name: "Content",
name: 'Content',
render() {
return (
<NLayout>
@ -27,8 +27,8 @@ const Content = defineComponent({
<router-view />
</NLayoutContent>
</NLayout>
);
)
},
});
})
export default Content;
export default Content

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

@ -20,17 +20,17 @@ import {
createWebHistory,
NavigationGuardNext,
RouteLocationNormalized,
} from "vue-router";
import routes from "./routes";
} from 'vue-router'
import routes from './routes'
// NProgress
import NProgress from "nprogress";
import "nprogress/nprogress.css";
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
const router = createRouter({
history: createWebHistory(),
routes,
});
})
/**
* Routing to intercept
@ -41,14 +41,14 @@ router.beforeEach(
from: RouteLocationNormalized,
next: NavigationGuardNext
) => {
NProgress.start();
next();
NProgress.done();
NProgress.start()
next()
NProgress.done()
}
);
)
router.afterEach(() => {
NProgress.done();
});
NProgress.done()
})
export default router;
export default router

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

@ -0,0 +1,41 @@
/*
* 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 type { Component } from 'vue'
import utils from '@/utils'
// All TSX files under the views folder automatically generate mapping relationship
const modules = import.meta.glob('/src/views/**/**.tsx')
const components: { [key: string]: Component } = utils.mapping(modules)
export default {
path: '/datasource',
name: 'datasource',
redirect: { name: 'datasource-list' },
meta: { title: '数据源中心' },
component: () => import('@/layouts/basic'),
children: [
{
path: '/datasource/list',
name: 'datasource-list',
component: components['home'],
meta: {
title: '数据源中心'
}
}
]
}

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

@ -0,0 +1,49 @@
/*
* 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 type { Component } from 'vue'
import utils from '@/utils'
// All TSX files under the views folder automatically generate mapping relationship
const modules = import.meta.glob('/src/views/**/**.tsx')
const components: { [key: string]: Component } = utils.mapping(modules)
export default {
path: '/monitor',
name: 'monitor',
meta: { title: 'monitor' },
redirect: { name: 'servers-master' },
component: () => import('@/layouts/basic'),
children: [
{
path: '/monitor/servers/master',
name: 'servers-master',
component: components['home'],
meta: {
title: '服务管理-Master',
},
},
{
path: '/monitor/servers/worker',
name: 'servers-worker',
component: components['home'],
meta: {
title: '服务管理-Worker'
}
}
]
}

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

@ -0,0 +1,49 @@
/*
* 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 type { Component } from 'vue'
import utils from '@/utils'
// All TSX files under the views folder automatically generate mapping relationship
const modules = import.meta.glob('/src/views/**/**.tsx')
const components: { [key: string]: Component } = utils.mapping(modules)
export default {
path: '/projects',
name: 'projects',
redirect: { name: 'projects-list' },
meta: { title: '项目管理' },
component: () => import('@/layouts/basic'),
children: [
{
path: '/projects/list',
name: 'projects-list',
component: components['home'],
meta: {
title: '项目',
},
},
{
path: '/projects/:projectCode/index',
name: 'projects-index',
component: components['home'],
meta: {
title: '工作流监控'
}
}
]
}

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

@ -0,0 +1,49 @@
/*
* 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 type { Component } from 'vue'
import utils from '@/utils'
// All TSX files under the views folder automatically generate mapping relationship
const modules = import.meta.glob('/src/views/**/**.tsx')
const components: { [key: string]: Component } = utils.mapping(modules)
export default {
path: '/resource',
name: 'resource',
redirect: { name: 'file' },
meta: { title: '资源中心' },
component: () => import('@/layouts/basic'),
children: [
{
path: '/resource/file',
name: 'file',
component: components['home'],
meta: {
title: '文件管理',
},
},
{
path: '/resource/file/create',
name: 'resource-file-create',
component: components['home'],
meta: {
title: '创建资源'
}
}
]
}

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

@ -0,0 +1,49 @@
/*
* 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 type { Component } from 'vue'
import utils from '@/utils'
// All TSX files under the views folder automatically generate mapping relationship
const modules = import.meta.glob('/src/views/**/**.tsx')
const components: { [key: string]: Component } = utils.mapping(modules)
export default {
path: '/security',
name: 'security',
meta: { title: '安全中心' },
redirect: { name: 'tenement-manage' },
component: () => import('@/layouts/basic'),
children: [
{
path: '/security/tenant',
name: 'tenement-manage',
component: components['home'],
meta: {
title: '租户管理',
},
},
{
path: '/security/users',
name: 'users-manage',
component: components['home'],
meta: {
title: '用户管理'
}
}
]
}

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

@ -15,189 +15,58 @@
* limitations under the License.
*/
import type { RouteRecordRaw } from "vue-router";
import type { Component } from "vue";
import utils from "@/utils";
import { useI18n } from "vue-i18n";
import type { RouteRecordRaw } from 'vue-router'
import type { Component } from 'vue'
import utils from '@/utils'
import projectsPage from './modules/projects'
import resourcesPage from './modules/resources'
import datasourcePage from './modules/datasource'
import monitorPage from './modules/monitor'
import securityPage from './modules/security'
// All TSX files under the views folder automatically generate mapping relationship
const modules = import.meta.glob("/src/views/**/**.tsx");
const components: { [key: string]: Component } = utils.mapping(modules);
const modules = import.meta.glob('/src/views/**/**.tsx')
const components: { [key: string]: Component } = utils.mapping(modules)
/**
* Basic page
*/
const basePage: RouteRecordRaw[] = [
{
path: "/",
redirect: { name: "home" },
meta: { title: "首页" },
component: () => import("@/layouts/basic"),
path: '/',
redirect: { name: 'home' },
meta: { title: '首页' },
component: () => import('@/layouts/basic'),
children: [
{
path: "/home",
name: "home",
component: components["home"],
path: '/home',
name: 'home',
component: components['home'],
meta: {
title: "首页",
title: '首页',
},
},
],
},
];
const projectsPage = [
{
path: "/projects",
name: "projects",
redirect: { name: "projects-list" },
meta: { title: "项目管理" },
component: () => import("@/layouts/basic"),
children: [
{
path: "/projects/list",
name: "projects-list",
component: components["home"],
meta: {
title: "项目",
},
},
{
path: "/projects/:projectCode/index",
name: "projects-index",
component: components["home"],
meta: {
title: "工作流监控",
},
},
],
},
];
const resourcesPage = [
{
path: "/resource",
name: "resource",
redirect: { name: "file" },
meta: { title: "资源中心" },
component: () => import("@/layouts/basic"),
children: [
{
path: "/resource/file",
name: "file",
component: components["home"],
meta: {
title: "文件管理",
},
},
{
path: "/resource/file/create",
name: "resource-file-create",
component: components["home"],
meta: {
title: "创建资源",
},
},
],
},
];
const datasourcePage = [
{
path: "/datasource",
name: "datasource",
redirect: { name: "datasource-list" },
meta: { title: "数据源中心" },
component: () => import("@/layouts/basic"),
children: [
{
path: "/datasource/list",
name: "datasource-list",
component: components["home"],
meta: {
title: "数据源中心",
},
},
],
},
];
const monitorPage = [
{
path: "/monitor",
name: "monitor",
meta: { title: "monitor" },
redirect: { name: "servers-master" },
component: () => import("@/layouts/basic"),
children: [
{
path: "/monitor/servers/master",
name: "servers-master",
component: components["home"],
meta: {
title: "服务管理-Master",
},
},
{
path: "/monitor/servers/worker",
name: "servers-worker",
component: components["home"],
meta: {
title: "服务管理-Worker",
},
},
],
},
];
const securityPage: RouteRecordRaw[] = [
{
path: "/security",
name: "security",
meta: { title: "安全中心" },
redirect: { name: "tenement-manage" },
component: () => import("@/layouts/basicLayout"),
children: [
{
path: "/security/tenant",
name: "tenement-manage",
component: components["home"],
meta: {
title: "租户管理",
},
},
{
path: "/security/users",
name: "users-manage",
component: components["home"],
meta: {
title: "用户管理",
},
},
],
},
];
projectsPage,
resourcesPage,
datasourcePage,
monitorPage,
securityPage,
]
/**
* Login page
*/
const loginPage: RouteRecordRaw[] = [
{
path: "/login",
name: "login",
component: components["login"],
path: '/login',
name: 'login',
component: components['login'],
},
];
]
const routes: RouteRecordRaw[] = [
...basePage,
...loginPage,
...projectsPage,
...resourcesPage,
...datasourcePage,
...monitorPage,
...securityPage,
];
const routes: RouteRecordRaw[] = [...basePage, ...loginPage]
// 重新组织后导出
export default routes;
export default routes

2
dolphinscheduler-ui-next/src/utils/index.ts

@ -18,7 +18,7 @@
import mapping from './mapping'
const utils = {
mapping
mapping,
}
export default utils

Loading…
Cancel
Save