index.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. import { defineComponent, PropType } from 'vue'
  18. import styles from './index.module.scss'
  19. import { NMenu } from 'naive-ui'
  20. import Logo from '../logo'
  21. import Locales from '../locales'
  22. import User from '../user'
  23. import Theme from '../theme'
  24. import { useMenuClick } from './use-menuClick'
  25. const Navbar = defineComponent({
  26. name: 'Navbar',
  27. emits: ['handleMenuClick'],
  28. props: {
  29. headerMenuOptions: {
  30. type: Array as PropType<any>,
  31. default: [],
  32. },
  33. localesOptions: {
  34. type: Array as PropType<any>,
  35. default: [],
  36. },
  37. profileOptions: {
  38. type: Array as PropType<any>,
  39. default: [],
  40. },
  41. },
  42. setup(props, ctx) {
  43. const { handleMenuClick } = useMenuClick(ctx)
  44. return { handleMenuClick }
  45. },
  46. render() {
  47. return (
  48. <div class={styles.container}>
  49. <Logo />
  50. <div class={styles.nav}>
  51. <NMenu
  52. default-value='home'
  53. mode='horizontal'
  54. options={this.headerMenuOptions}
  55. onUpdateValue={this.handleMenuClick}
  56. />
  57. </div>
  58. <div class={styles.settings}>
  59. <Theme />
  60. <Locales localesOptions={this.localesOptions} />
  61. <User profileOptions={this.profileOptions} />
  62. </div>
  63. </div>
  64. )
  65. },
  66. })
  67. export default Navbar