menu.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="menu">
  3. <a-menu style="flex:1" :inlineIndent="5" v-model:selectedKeys="current" mode="inline" active-text-color="#000" @click="itemClick">
  4. <a-sub-menu v-for="item in mods" :key="item.systemmoduleid">
  5. <template #title>
  6. <div>
  7. <img width="15" style="margin-top:-2px;margin-right:5px" :src="item.iconurl" alt="">
  8. {{item.systemmodulename}}
  9. </div>
  10. </template>
  11. <a-menu-item v-for="app in item.apps" :key="app.systemappid" @click="routeChange(app)">{{app.meta.title}}</a-menu-item>
  12. </a-sub-menu>
  13. </a-menu>
  14. <a-dropdown>
  15. <a class="ant-dropdown-link" @click.prevent>
  16. 切换主题
  17. <DownOutlined />
  18. </a>
  19. <template #overlay>
  20. <a-menu>
  21. <a-menu-item>
  22. <a @click="setTheme('normal')">默认主题</a>
  23. </a-menu-item>
  24. <a-menu-item>
  25. <a @click="setTheme('light')">明亮主题</a>
  26. </a-menu-item>
  27. <a-menu-item>
  28. <a @click="setTheme('caffairs')">商务主题</a>
  29. </a-menu-item>
  30. </a-menu>
  31. </template>
  32. </a-dropdown>
  33. </div>
  34. </template>
  35. <script setup>
  36. import { ref,onBeforeMount} from 'vue';
  37. import { useAuthStore } from '@/stores/modules/auth'
  38. import { storeToRefs } from 'pinia'
  39. import { useRouter } from "vue-router"
  40. import { MenuFoldOutlined,MenuUnfoldOutlined} from '@ant-design/icons-vue'
  41. import {ConfigProvider, Modal } from 'ant-design-vue';
  42. const router = useRouter()
  43. const store = useAuthStore()
  44. let { mods } = storeToRefs(store)
  45. const current = ref([])
  46. const itemClick = (item, key, keyPath)=>{
  47. current.value = item.keyPath
  48. }
  49. const routeChange = (app)=>{
  50. store.appData(app)
  51. router.push({path:app.path})
  52. }
  53. const colorState = ref({})
  54. const setTheme = (themeName)=> {
  55. if (themeName === 'light') {
  56. colorState.value = {
  57. primaryColor: '#f23557',
  58. errorColor: '#eb586f',
  59. warningColor: '#ffde7d',
  60. successColor: '#4aa0d5',
  61. infoColor: '#d8e9f0',
  62. }
  63. ConfigProvider.config({
  64. theme: colorState.value
  65. });
  66. } else if (themeName === 'normal') {
  67. colorState.value = {
  68. primaryColor: '#14317D',
  69. errorColor: '#ff4d4f',
  70. warningColor: '#faad14',
  71. successColor: '#52c41a',
  72. infoColor: '#1890ff',
  73. }
  74. ConfigProvider.config({
  75. theme: colorState.value
  76. });
  77. } else if (themeName === 'caffairs') {
  78. colorState.value = {
  79. primaryColor: '#404b69',
  80. errorColor: '#ff5f5f',
  81. warningColor: '#ffc93c',
  82. successColor: '#1fab89',
  83. infoColor: '#dbedf3',
  84. menuBg:'#fff'
  85. }
  86. ConfigProvider.config({
  87. theme: colorState.value
  88. });
  89. }
  90. }
  91. onBeforeMount(()=>{
  92. setTheme('light')
  93. })
  94. </script>
  95. <style scoped>
  96. .menu{
  97. width: 158px;
  98. background: #002671;
  99. }
  100. </style>