Browse Source

feat:Improve layout modules (#7674)

3.0.0/version-upgrade
labbomb 3 years ago committed by GitHub
parent
commit
0a7610d070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dolphinscheduler-ui-next/src/layouts/content/components/language/index.tsx
  2. 6
      dolphinscheduler-ui-next/src/layouts/content/components/logo/index.tsx
  3. 7
      dolphinscheduler-ui-next/src/layouts/content/components/navbar/index.tsx
  4. 2
      dolphinscheduler-ui-next/src/layouts/content/components/navbar/use-menuClick.ts
  5. 24
      dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx
  6. 6
      dolphinscheduler-ui-next/src/layouts/content/components/user/index.tsx
  7. 20
      dolphinscheduler-ui-next/src/layouts/content/index.module.scss
  8. 19
      dolphinscheduler-ui-next/src/layouts/content/index.tsx
  9. 86
      dolphinscheduler-ui-next/src/layouts/content/use-dataList.ts
  10. 1
      dolphinscheduler-ui-next/src/views/login/use-translate.ts

6
dolphinscheduler-ui-next/src/layouts/content/components/language/index.tsx

@ -21,8 +21,8 @@ import styles from './index.module.scss'
import { DownOutlined } from '@vicons/antd' import { DownOutlined } from '@vicons/antd'
import { useDropDown } from './use-dropdown' import { useDropDown } from './use-dropdown'
const language = defineComponent({ const Language = defineComponent({
name: 'language', name: 'Language',
props: { props: {
languageOptions: { languageOptions: {
type: Array as PropType<any>, type: Array as PropType<any>,
@ -53,4 +53,4 @@ const language = defineComponent({
}, },
}) })
export default language export default Language

6
dolphinscheduler-ui-next/src/layouts/content/components/logo/index.tsx

@ -19,8 +19,8 @@ import { defineComponent } from 'vue'
import { useThemeStore } from '@/store/theme/theme' import { useThemeStore } from '@/store/theme/theme'
import styles from './index.module.scss' import styles from './index.module.scss'
const logo = defineComponent({ const Logo = defineComponent({
name: 'logo', name: 'Logo',
setup() { setup() {
const themeStore = useThemeStore() const themeStore = useThemeStore()
@ -38,4 +38,4 @@ const logo = defineComponent({
}, },
}) })
export default logo export default Logo

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

@ -24,8 +24,9 @@ import User from '../user'
import Theme from '../theme' import Theme from '../theme'
import { useMenuClick } from './use-menuClick' import { useMenuClick } from './use-menuClick'
const navbar = defineComponent({ const Navbar = defineComponent({
name: 'navbar', name: 'Navbar',
emits: ['handleMenuClick'],
props: { props: {
headerMenuOptions: { headerMenuOptions: {
type: Array as PropType<any>, type: Array as PropType<any>,
@ -66,4 +67,4 @@ const navbar = defineComponent({
}, },
}) })
export default navbar export default Navbar

2
dolphinscheduler-ui-next/src/layouts/content/components/navbar/use-menuClick.ts

@ -20,7 +20,7 @@ import type { Router } from 'vue-router'
import { MenuOption } from 'naive-ui' import { MenuOption } from 'naive-ui'
import { SetupContext } from 'vue' import { SetupContext } from 'vue'
export function useMenuClick(ctx: SetupContext<Record<string, any>>) { export function useMenuClick(ctx: SetupContext<"handleMenuClick"[]>) {
const router: Router = useRouter() const router: Router = useRouter()
const handleMenuClick = (key: string, item: MenuOption) => { const handleMenuClick = (key: string, item: MenuOption) => {

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

@ -15,22 +15,36 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineComponent, toRefs } from 'vue' import { defineComponent, PropType } from 'vue'
import styles from './index.module.scss' import styles from './index.module.scss'
import { NLayoutSider, NMenu } from 'naive-ui' import { NLayoutSider, NMenu } from 'naive-ui'
const sidebar = defineComponent({ const Sidebar = defineComponent({
name: 'sidebar', name: 'Sidebar',
props: {
sideMenuOptions: {
type: Array as PropType<any>,
default: [],
},
isShowSide: {
type: Boolean as PropType<boolean>,
default: false,
}
},
setup() { setup() {
return {} return {}
}, },
render() { render() {
if (this.isShowSide) {
return ( return (
<NLayoutSider bordered nativeScrollbar={false} show-trigger='bar'> <NLayoutSider bordered nativeScrollbar={false} show-trigger='bar'>
<NMenu /> <NMenu options={this.sideMenuOptions} default-expand-all />
</NLayoutSider> </NLayoutSider>
) )
} else {
return
}
}, },
}) })
export default sidebar export default Sidebar

6
dolphinscheduler-ui-next/src/layouts/content/components/user/index.tsx

@ -21,8 +21,8 @@ import styles from './index.module.scss'
import { DownOutlined, UserOutlined } from '@vicons/antd' import { DownOutlined, UserOutlined } from '@vicons/antd'
import { useDropDown } from './use-dropdown' import { useDropDown } from './use-dropdown'
const user = defineComponent({ const User = defineComponent({
name: 'user', name: 'User',
props: { props: {
profileOptions: { profileOptions: {
type: Array as PropType<any>, type: Array as PropType<any>,
@ -55,4 +55,4 @@ const user = defineComponent({
}, },
}) })
export default user export default User

20
dolphinscheduler-ui-next/src/layouts/content/index.module.scss

@ -0,0 +1,20 @@
/*
* 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.
*/
.content {
padding: 12px;
}

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

@ -15,8 +15,9 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineComponent, toRefs } from 'vue' import { defineComponent, ref, toRefs } from 'vue'
import { NLayout, NLayoutContent, NLayoutHeader } from 'naive-ui' import { NLayout, NLayoutContent, NLayoutHeader } from 'naive-ui'
import styles from './index.module.scss'
import NavBar from './components/navbar' import NavBar from './components/navbar'
import SideBar from './components/sidebar' import SideBar from './components/sidebar'
@ -26,11 +27,17 @@ const Content = defineComponent({
name: 'Content', name: 'Content',
setup() { setup() {
const { state, getHeaderMenuOptions } = useDataList() const { state, getHeaderMenuOptions } = useDataList()
const headerMenuOptions = getHeaderMenuOptions(state.menuOptions) const headerMenuOptions = getHeaderMenuOptions(state.menuOptions)
const sideMenuOptions = ref()
const getSideMenuOptions = (item: any) => { const getSideMenuOptions = (item: any) => {
console.log('123', item) sideMenuOptions.value = state.menuOptions.filter(menu => menu.key === item.key)[0].children || []
state.isShowSide = (sideMenuOptions.value.length !== 0)
} }
return { ...toRefs(state), headerMenuOptions, getSideMenuOptions }
return { ...toRefs(state), headerMenuOptions, getSideMenuOptions, sideMenuOptions }
}, },
render() { render() {
return ( return (
@ -41,11 +48,11 @@ const Content = defineComponent({
headerMenuOptions={this.headerMenuOptions} headerMenuOptions={this.headerMenuOptions}
languageOptions={this.languageOptions} languageOptions={this.languageOptions}
profileOptions={this.profileOptions} profileOptions={this.profileOptions}
></NavBar> />
</NLayoutHeader> </NLayoutHeader>
<NLayout has-sider> <NLayout has-sider>
<SideBar></SideBar> <SideBar sideMenuOptions={this.sideMenuOptions} isShowSide={this.isShowSide} />
<NLayoutContent> <NLayoutContent class={styles.content}>
<router-view /> <router-view />
</NLayoutContent> </NLayoutContent>
</NLayout> </NLayout>

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

@ -26,6 +26,20 @@ import {
SafetyCertificateOutlined, SafetyCertificateOutlined,
UserOutlined, UserOutlined,
LogoutOutlined, LogoutOutlined,
FundProjectionScreenOutlined,
PartitionOutlined,
SettingOutlined,
FileSearchOutlined,
RobotOutlined,
AppstoreOutlined,
UsergroupAddOutlined,
UserAddOutlined,
WarningOutlined,
InfoCircleOutlined,
ControlOutlined,
SlackOutlined,
EnvironmentOutlined,
KeyOutlined
} from '@vicons/antd' } from '@vicons/antd'
export function useDataList() { export function useDataList() {
@ -47,34 +61,31 @@ export function useDataList() {
{ {
label: '工作流监控', label: '工作流监控',
key: 'workflow-monitoring', key: 'workflow-monitoring',
icon: renderIcon(ProfileOutlined), icon: renderIcon(FundProjectionScreenOutlined),
}, },
{ {
label: '工作流关系', label: '工作流关系',
key: 'workflow-relationships', key: 'workflow-relationships',
icon: renderIcon(ProfileOutlined), icon: renderIcon(PartitionOutlined),
}, },
{ {
label: '工作流', label: '工作流',
key: 'workflow', key: 'workflow',
icon: renderIcon(ProfileOutlined), icon: renderIcon(SettingOutlined),
children: [ children: [
{ {
label: '工作流定义', label: '工作流定义',
key: 'workflow-definition', key: 'workflow-definition'
icon: renderIcon(ProfileOutlined),
}, },
{ {
label: '工作流实例', label: '工作流实例',
key: 'workflow-instance', key: 'workflow-instance'
icon: renderIcon(ProfileOutlined),
}, },
{ {
label: '任务实例', label: '任务实例',
key: 'task-instance', key: 'task-instance'
icon: renderIcon(ProfileOutlined), }
}, ]
],
}, },
], ],
}, },
@ -86,24 +97,22 @@ export function useDataList() {
{ {
label: '文件管理', label: '文件管理',
key: 'file-management', key: 'file-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(FileSearchOutlined),
}, },
{ {
label: 'UDF管理', label: 'UDF管理',
key: 'UDF-management', key: 'UDF-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(RobotOutlined),
children: [ children: [
{ {
label: '资源管理', label: '资源管理',
key: 'resource-management', key: 'resource-management'
icon: renderIcon(ProfileOutlined),
}, },
{ {
label: '函数管理', label: '函数管理',
key: 'function-management', key: 'function-management'
icon: renderIcon(ProfileOutlined), }
}, ]
],
}, },
], ],
}, },
@ -120,34 +129,30 @@ export function useDataList() {
{ {
label: '服务管理', label: '服务管理',
key: 'service-management', key: 'service-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(AppstoreOutlined),
children: [ children: [
{ {
label: 'Master', label: 'Master',
key: 'master', key: 'master'
icon: renderIcon(ProfileOutlined),
}, },
{ {
label: 'Worker', label: 'Worker',
key: 'worker', key: 'worker'
icon: renderIcon(ProfileOutlined),
}, },
{ {
label: 'DB', label: 'DB',
key: 'DB', key: 'DB'
icon: renderIcon(ProfileOutlined), }
}, ]
],
}, },
{ {
label: '统计管理', label: '统计管理',
key: 'statistical-management', key: 'statistical-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(AppstoreOutlined),
children: [ children: [
{ {
label: 'Statistics', label: 'Statistics',
key: 'statistics', key: 'statistics'
icon: renderIcon(ProfileOutlined),
}, },
], ],
}, },
@ -161,42 +166,42 @@ export function useDataList() {
{ {
label: '租户管理', label: '租户管理',
key: 'tenant-management', key: 'tenant-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(UsergroupAddOutlined),
}, },
{ {
label: '用户管理', label: '用户管理',
key: 'user-management', key: 'user-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(UserAddOutlined),
}, },
{ {
label: '告警组管理', label: '告警组管理',
key: 'alarm-group-management', key: 'alarm-group-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(WarningOutlined),
}, },
{ {
label: '告警实例管理', label: '告警实例管理',
key: 'alarm-instance-management', key: 'alarm-instance-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(InfoCircleOutlined),
}, },
{ {
label: 'Worker分组管理', label: 'Worker分组管理',
key: 'worker-group-management', key: 'worker-group-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(ControlOutlined),
}, },
{ {
label: 'Yarn 队列管理', label: 'Yarn 队列管理',
key: 'yarn-queue-management', key: 'yarn-queue-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(SlackOutlined),
}, },
{ {
label: '环境管理', label: '环境管理',
key: 'environmental-management', key: 'environmental-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(EnvironmentOutlined),
}, },
{ {
label: '令牌管理', label: '令牌管理',
key: 'token-management', key: 'token-management',
icon: renderIcon(ProfileOutlined), icon: renderIcon(KeyOutlined),
}, },
], ],
}, },
@ -241,9 +246,10 @@ export function useDataList() {
} }
const state = reactive({ const state = reactive({
isShowSide: false,
menuOptions: menuOptions, menuOptions: menuOptions,
languageOptions: languageOptions, languageOptions: languageOptions,
profileOptions: profileOptions, profileOptions: profileOptions
}) })
return { return {

1
dolphinscheduler-ui-next/src/views/login/use-translate.ts

@ -19,6 +19,7 @@ import { WritableComputedRef } from 'vue'
export function useTranslate(locale: WritableComputedRef<string>) { export function useTranslate(locale: WritableComputedRef<string>) {
const handleChange = (value: string) => { const handleChange = (value: string) => {
console.log('value', value)
locale.value = value locale.value = value
} }
return { return {

Loading…
Cancel
Save