SystemSelect.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <a-select :class="prefixCls" v-model:value="text" :options="OPTIONS" @change="handleMenuClick"> </a-select>
  3. </template>
  4. <script lang="ts" setup>
  5. // import { Button, Dropdown, Menu, MenuItem } from 'ant-design-vue';
  6. // import { DownOutlined } from '@ant-design/icons-vue';
  7. import { useDesign } from '/@/hooks/web/useDesign';
  8. import { ref } from 'vue';
  9. import { PageEnum } from '/@/enums/pageEnum';
  10. import { useRouter } from 'vue-router';
  11. import { useI18n } from '/@/hooks/web/useI18n';
  12. const { prefixCls } = useDesign('system-select');
  13. const router = useRouter();
  14. const { t } = useI18n();
  15. // 由于BASE_HOME仅代表了一个页面,其他页面都隶属于SECONDARY_HOME,所以简单处理
  16. const isBaseHome = router.currentRoute.value.path === PageEnum.BASE_HOME;
  17. const text = ref(isBaseHome ? PageEnum.BASE_HOME : PageEnum.SECONDARY_HOME);
  18. function handleMenuClick(value) {
  19. router.push({ path: value });
  20. }
  21. // const OPTIONS = ref({
  22. // [PageEnum.BASE_HOME]: t('routes.basic.baseHome'),
  23. // [PageEnum.SECONDARY_HOME]: t('routes.basic.secondaryHome'),
  24. // });
  25. const OPTIONS = ref([
  26. {
  27. value: PageEnum.BASE_HOME,
  28. label: t('routes.basic.baseHome'),
  29. },
  30. {
  31. value: PageEnum.SECONDARY_HOME,
  32. label: t('routes.basic.secondaryHome'),
  33. },
  34. ]);
  35. defineExpose({ OPTIONS, prefixCls, handleMenuClick });
  36. </script>
  37. <style lang="less" scoped>
  38. @prefix-cls: ~'@{namespace}-system-select';
  39. .@{prefix-cls} {
  40. max-width: 210px;
  41. width: 100%;
  42. min-width: 10px;
  43. margin-bottom: 10px;
  44. position: relative;
  45. z-index: @layout-basic-z-index;
  46. }
  47. .@{prefix-cls}.ant-select {
  48. :deep(.ant-select-selector) {
  49. background-color: @primary-color;
  50. .ant-select-selection-item {
  51. color: @white;
  52. }
  53. }
  54. :deep(.ant-select-arrow) {
  55. color: @white;
  56. }
  57. }
  58. </style>