Browse Source

Enabling Route Forwarding (#7909)

3.0.0/version-upgrade
labbomb 3 years ago committed by GitHub
parent
commit
7bc1591ef0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      dolphinscheduler-ui-next/src/layouts/content/components/navbar/index.tsx
  2. 4
      dolphinscheduler-ui-next/src/layouts/content/components/navbar/use-menuClick.ts
  3. 16
      dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.module.scss
  4. 7
      dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.tsx
  5. 6
      dolphinscheduler-ui-next/src/layouts/content/components/sidebar/use-menuClick.ts
  6. 9
      dolphinscheduler-ui-next/src/layouts/content/index.tsx
  7. 1
      dolphinscheduler-ui-next/src/store/menu/menu.ts
  8. 1
      dolphinscheduler-ui-next/src/store/theme/theme.ts

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

@ -23,6 +23,7 @@ import Locales from '../locales'
import User from '../user' import User from '../user'
import Theme from '../theme' import Theme from '../theme'
import { useMenuClick } from './use-menuClick' import { useMenuClick } from './use-menuClick'
import { useMenuStore } from '@/store/menu/menu'
const Navbar = defineComponent({ const Navbar = defineComponent({
name: 'Navbar', name: 'Navbar',
@ -43,7 +44,8 @@ const Navbar = defineComponent({
}, },
setup(props, ctx) { setup(props, ctx) {
const { handleMenuClick } = useMenuClick(ctx) const { handleMenuClick } = useMenuClick(ctx)
return { handleMenuClick } const menuStore = useMenuStore()
return { handleMenuClick, menuStore }
}, },
render() { render() {
return ( return (
@ -51,7 +53,7 @@ const Navbar = defineComponent({
<Logo /> <Logo />
<div class={styles.nav}> <div class={styles.nav}>
<NMenu <NMenu
default-value='home' default-value={this.menuStore.getMenuKey}
mode='horizontal' mode='horizontal'
options={this.headerMenuOptions} options={this.headerMenuOptions}
onUpdateValue={this.handleMenuClick} onUpdateValue={this.handleMenuClick}

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

@ -24,9 +24,9 @@ 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) => {
console.log(key, item) // console.log(key, item)
ctx.emit('handleMenuClick', item) ctx.emit('handleMenuClick', item)
// router.push({ path: 'home' }) router.push({ path: `/${key}` })
} }
return { return {

16
dolphinscheduler-ui-next/src/layouts/content/components/sidebar/index.module.scss

@ -1,16 +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.
*/

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

@ -15,9 +15,8 @@
* limitations under the License. * limitations under the License.
*/ */
import { defineComponent, ref, watch, PropType } from 'vue' import { defineComponent, ref, PropType } from 'vue'
import styles from './index.module.scss' import { NLayoutSider, NMenu } from 'naive-ui'
import { MenuOption, NLayoutSider, NMenu } from 'naive-ui'
import { useMenuClick } from './use-menuClick' import { useMenuClick } from './use-menuClick'
const Sidebar = defineComponent({ const Sidebar = defineComponent({
@ -39,6 +38,7 @@ const Sidebar = defineComponent({
const { handleMenuClick } = useMenuClick() const { handleMenuClick } = useMenuClick()
return { collapsedRef, defaultExpandedKeys, handleMenuClick } return { collapsedRef, defaultExpandedKeys, handleMenuClick }
}, },
render() { render() {
@ -53,6 +53,7 @@ const Sidebar = defineComponent({
onExpand={() => (this.collapsedRef = false)} onExpand={() => (this.collapsedRef = false)}
> >
<NMenu <NMenu
default-value={this.sideMenuOptions[0].key}
options={this.sideMenuOptions} options={this.sideMenuOptions}
defaultExpandedKeys={this.defaultExpandedKeys} defaultExpandedKeys={this.defaultExpandedKeys}
onUpdateValue={this.handleMenuClick} onUpdateValue={this.handleMenuClick}

6
dolphinscheduler-ui-next/src/layouts/content/components/sidebar/use-menuClick.ts

@ -18,13 +18,15 @@
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import type { Router } from 'vue-router' import type { Router } from 'vue-router'
import { MenuOption } from 'naive-ui' import { MenuOption } from 'naive-ui'
import { useMenuStore } from '@/store/menu/menu'
export function useMenuClick() { export function useMenuClick() {
const router: Router = useRouter() const router: Router = useRouter()
const menuStore = useMenuStore()
const handleMenuClick = (key: string, item: MenuOption) => { const handleMenuClick = (key: string, item: MenuOption) => {
console.log(key, item) // console.log(key, item)
// router.push({ path: 'home' }) router.push({ path: `/${menuStore.getMenuKey}/${key}` })
} }
return { return {

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

@ -40,7 +40,6 @@ const Content = defineComponent({
locale.value = localesStore.getLocales locale.value = localesStore.getLocales
onMounted(() => { onMounted(() => {
menuStore.setMenuKey('home')
changeMenuOption(state) changeMenuOption(state)
changeHeaderMenuOptions(state) changeHeaderMenuOptions(state)
genSideMenu(state) genSideMenu(state)
@ -57,14 +56,16 @@ const Content = defineComponent({
const genSideMenu = (state: any) => { const genSideMenu = (state: any) => {
const key = menuStore.getMenuKey const key = menuStore.getMenuKey
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 || [] .children || []
state.isShowSide =
state.menuOptions.filter((menu: { key: string }) => menu.key === key)[0]
.isShowSide || false
} }
const getSideMenuOptions = (item: any) => { const getSideMenuOptions = (item: any) => {
menuStore.setMenuKey(item.key) menuStore.setMenuKey(item.key)
genSideMenu(state) genSideMenu(state)
state.isShowSide = item.isShowSide
} }
return { return {

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

@ -23,6 +23,7 @@ export const useMenuStore = defineStore({
state: (): MenuState => ({ state: (): MenuState => ({
menuKey: '', menuKey: '',
}), }),
persist: true,
getters: { getters: {
getMenuKey(): string { getMenuKey(): string {
return this.menuKey return this.menuKey

1
dolphinscheduler-ui-next/src/store/theme/theme.ts

@ -23,6 +23,7 @@ export const useThemeStore = defineStore({
state: (): ThemeState => ({ state: (): ThemeState => ({
darkTheme: false, darkTheme: false,
}), }),
persist: true,
getters: { getters: {
getTheme(): boolean { getTheme(): boolean {
return this.darkTheme return this.darkTheme

Loading…
Cancel
Save