BasicLayout.tsx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { css } from "@linaria/core";
  2. import { Layout, Menu, Spin } from "ant-design-vue";
  3. import { defineComponent, onMounted, reactive } from "vue";
  4. import { useRoute } from "vue-router";
  5. import { InitControllers } from "@/comm/ctx";
  6. import { menuData } from "@/pages/website/routes";
  7. const { Sider, Content } = Layout;
  8. export default defineComponent({
  9. setup() {
  10. const state = reactive({
  11. loading: true,
  12. menuKey: ["/backend/upload"],
  13. });
  14. const menuChange = (keyPath: any) => {
  15. state.menuKey = keyPath;
  16. };
  17. onMounted(() => {
  18. const data = useRoute();
  19. state.menuKey = [data.path];
  20. });
  21. return () => {
  22. return (
  23. <Layout class={HomeStyle}>
  24. <Sider width={200} trigger={null} collapsible>
  25. <div class="layout_menu">
  26. <Menu
  27. theme="dark"
  28. selectedKeys={state.menuKey}
  29. mode="inline"
  30. onSelect={(item: any) => {
  31. menuChange(item.keyPath);
  32. }}
  33. >
  34. {menuData?.children &&
  35. menuData.children.map((menu: any) => {
  36. return (
  37. <Menu.Item key={menu.path}>
  38. <router-link to={menu.path}>
  39. {menu.meta.title}
  40. </router-link>
  41. </Menu.Item>
  42. );
  43. })}
  44. </Menu>
  45. </div>
  46. </Sider>
  47. <Layout>
  48. <Content
  49. class="layout_background"
  50. style={{
  51. margin: "24px 16px",
  52. minHeight: 280,
  53. }}
  54. >
  55. <router-view />
  56. </Content>
  57. </Layout>
  58. </Layout>
  59. );
  60. };
  61. },
  62. });
  63. const HomeStyle = css`
  64. width: 100%;
  65. min-height: 100vh;
  66. .ant-layout-content {
  67. flex: 1;
  68. overflow: auto;
  69. }
  70. .layout_background {
  71. background-color: #fff;
  72. }
  73. .layout_menu {
  74. margin-top: 64px;
  75. }
  76. .header_right {
  77. text-align: right;
  78. }
  79. `;