feat: 横向布局

This commit is contained in:
WANGFAN\wangf 2024-05-12 23:15:39 +08:00
parent 4031205771
commit f24de60956
7 changed files with 85 additions and 65 deletions

View File

@ -1,4 +1,2 @@
#!/usr/bin/env sh #!/usr/bin/env sh
. "$(dirname -- "$0")/husky.sh" . "${0%/*}/h"
npx --no-install commitlint --edit $1

View File

@ -1,5 +1,2 @@
#!/bin/sh #!/usr/bin/env sh
. "${0%/*}/h"
. "$(dirname "$0")/husky.sh"
npm run lint-staged

View File

@ -17,7 +17,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Breadcrumb from "@/layout/components/Header/components/breadcrumb/index.vue"; import Breadcrumb from "@/layout/components/Header/components/Breadcrumb/index.vue";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { useThemeConfig } from "@/store/modules/theme-config"; import { useThemeConfig } from "@/store/modules/theme-config";
const themeStore = useThemeConfig(); const themeStore = useThemeConfig();

View File

@ -104,7 +104,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Notice from "@/layout/components/Header/components/notice/index.vue"; import Notice from "@/layout/components/Header/components/Notice/index.vue";
import SystemSettings from "@/layout/components/Header/components/system-settings/index.vue"; import SystemSettings from "@/layout/components/Header/components/system-settings/index.vue";
import ThemeSettings from "@/layout/components/Header/components/theme-settings/index.vue"; import ThemeSettings from "@/layout/components/Header/components/theme-settings/index.vue";
import myImage from "@/assets/img/my-image.jpg"; import myImage from "@/assets/img/my-image.jpg";

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="logo_head"> <div :class="layoutType == 'layoutDefaults' ? 'logo_head' : 'logo_head no-border'">
<img :src="Logo" class="logo" /> <img :src="Logo" class="logo" />
<span :class="isDark ? 'logo_title dark' : 'logo_title'" v-if="!collapsed">dc admin</span> <span :class="isDark ? 'logo_title dark' : 'logo_title'" v-if="!collapsed">dc admin</span>
</div> </div>
@ -43,4 +43,7 @@ const isDark = computed(() => {
color: #fff; color: #fff;
} }
} }
.no-border {
border: unset;
}
</style> </style>

View File

@ -1,83 +1,105 @@
<template> <template>
<a-layout class="layout"> <div class="layout-head">
<a-layout> <div class="layout-head-top">
<a-layout-header class="header"> <a-layout-header class="header">
<div class="header_left"> <Logo />
<div class="logo_head"> <a-menu mode="horizontal" :selected-keys="[currentRoute.name]" @menu-item-click="onMenuItem">
<img :src="Logo" class="logo" /> <template v-for="item in routeTree" :key="item.name">
<span class="logo_title">dc admin</span> <a-sub-menu v-if="item.children && item.children.length > 0" :key="item.name">
</div> <template #icon v-if="item.meta.svgIcon || item.meta.icon">
<HeadMenu /> <MenuItemIcon :svg-icon="item.meta.svgIcon" :icon="item.meta.icon" />
</div> </template>
<template #title>{{ $t(`language.${item.meta.title}`) }}</template>
<MenuItem :route-tree="item.children" />
</a-sub-menu>
<a-menu-item v-else :key="item?.name">
<template #icon v-if="item.meta.svgIcon || item.meta.icon">
<MenuItemIcon :svg-icon="item.meta.svgIcon" :icon="item.meta.icon" />
</template>
<span>{{ $t(`language.${item.meta.title}`) }}</span>
</a-menu-item>
</template>
</a-menu>
<HeaderRight /> <HeaderRight />
</a-layout-header> </a-layout-header>
<Main /> <Main />
<Footer v-if="isFooter" /> <Footer v-if="isFooter" />
</a-layout> </div>
</a-layout> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import Logo from "@/assets/img/logo.jpg"; import Logo from "@/layout/components/Logo/index.vue";
import HeadMenu from "@/layout/components/head-menu/index.vue";
import HeaderRight from "@/layout/components/Header/components/header-right/index.vue"; import HeaderRight from "@/layout/components/Header/components/header-right/index.vue";
import Main from "@/layout/components/Main/index.vue"; import Main from "@/layout/components/Main/index.vue";
import Footer from "@/layout/components/Footer/index.vue"; import Footer from "@/layout/components/Footer/index.vue";
import MenuItem from "@/layout/components/Menu/menu-item.vue";
import MenuItemIcon from "@/layout/components/Menu/menu-item-icon.vue";
import { useRouter } from "vue-router";
import { storeToRefs } from "pinia"; import { storeToRefs } from "pinia";
import { useRoutesListStore } from "@/store/modules/route-list";
import { useRoutingMethod } from "@/hooks/useRoutingMethod";
import { useThemeConfig } from "@/store/modules/theme-config"; import { useThemeConfig } from "@/store/modules/theme-config";
const themeStore = useThemeConfig();
defineOptions({ name: "LayoutHead" }); defineOptions({ name: "LayoutHead" });
let { isFooter } = storeToRefs(themeStore); const router = useRouter();
const routerStore = useRoutesListStore();
const themeStore = useThemeConfig();
const { routeTree, currentRoute } = storeToRefs(routerStore);
const { isFooter } = storeToRefs(themeStore);
/**
* @description 菜单点击事件
* @param {String} key
*/
const onMenuItem = (key: string) => {
const { findLinearArray } = useRoutingMethod();
const find = findLinearArray(key);
// 404
if (find) {
router.push(find.path);
} else {
router.push("/404");
}
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.layout { .layout-head {
height: 100vh; height: 100%;
display: flex;
align-items: stretch; //
overflow: hidden;
&-top {
flex: 1; //
display: flex;
flex-direction: column; // flex
overflow: hidden;
} }
}
.header { .header {
height: 60px;
padding: 0 $padding; padding: 0 $padding;
height: 60px;
box-sizing: border-box; box-sizing: border-box;
border-bottom: $border-1 solid $color-border-2; border-bottom: $border-1 solid $color-border-2;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
// overflow: hidden;
.logo_head {
min-width: 150px;
height: 60px;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
.logo {
width: 30px;
} }
.logo_title {
font-weight: bold; :deep(.arco-menu-pop) {
font-size: $font-size-title-2; white-space: nowrap;
}
//
:deep(.arco-menu-horizontal) {
flex: 1;
overflow: hidden;
.arco-menu-inner {
padding-left: 0; // padding
.arco-menu-overflow-wrap {
white-space: nowrap; //
} }
} }
.header_left {
box-sizing: border-box;
display: flex;
width: 100%;
height: 100%;
}
}
// padding
:deep(.arco-menu-horizontal .arco-menu-inner) {
padding: unset;
}
// line-height,icon
:deep(.arco-menu-horizontal .arco-menu-item) {
line-height: unset;
}
// line-height,icon
:deep(.arco-menu-horizontal .arco-menu-pop-header) {
line-height: unset;
}
:deep(.arco-menu-selected-label) {
bottom: -16px;
} }
</style> </style>

View File

@ -63,7 +63,7 @@ export const useThemeConfig = defineStore("theme-config", {
"#00B42A", "#00B42A",
"#14C9C9", "#14C9C9",
"#3491FA", "#3491FA",
"#165DFF", "#c34d9c",
"#722ED1", "#722ED1",
"#D91AD9", "#D91AD9",
"#F5319D", "#F5319D",