feat(projects): 适配移动端,修复Tab关闭图标的bug

ISSUES CLOSED: #87,#106,#109,#111
This commit is contained in:
Soybean 2022-07-12 00:02:00 +08:00
parent cec0f25c6b
commit 296b154be5
4 changed files with 16 additions and 8 deletions

View File

@ -34,8 +34,8 @@
"@antv/data-set": "^0.11.8", "@antv/data-set": "^0.11.8",
"@antv/g2": "^4.2.5", "@antv/g2": "^4.2.5",
"@better-scroll/core": "^2.4.2", "@better-scroll/core": "^2.4.2",
"@soybeanjs/vue-admin-layout": "^1.0.6", "@soybeanjs/vue-admin-layout": "^1.1.1",
"@soybeanjs/vue-admin-tab": "^1.0.3", "@soybeanjs/vue-admin-tab": "^1.0.5",
"@vueuse/core": "^8.9.1", "@vueuse/core": "^8.9.1",
"axios": "^0.27.2", "axios": "^0.27.2",
"clipboard": "^2.0.11", "clipboard": "^2.0.11",
@ -46,7 +46,7 @@
"form-data": "^4.0.0", "form-data": "^4.0.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"naive-ui": "^2.31.0", "naive-ui": "^2.31.0",
"pinia": "^2.0.14", "pinia": "^2.0.15",
"print-js": "^1.6.0", "print-js": "^1.6.0",
"qs": "^6.11.0", "qs": "^6.11.0",
"swiper": "^8.3.0", "swiper": "^8.3.0",
@ -105,7 +105,7 @@
"vite-plugin-mock": "^2.9.6", "vite-plugin-mock": "^2.9.6",
"vite-plugin-svg-icons": "^2.0.1", "vite-plugin-svg-icons": "^2.0.1",
"vue-eslint-parser": "^9.0.3", "vue-eslint-parser": "^9.0.3",
"vue-tsc": "^0.38.4" "vue-tsc": "^0.38.5"
}, },
"homepage": "https://github.com/honghuangdc/soybean-admin", "homepage": "https://github.com/honghuangdc/soybean-admin",
"repository": { "repository": {

View File

@ -1,4 +1,5 @@
import { computed } from 'vue'; import { computed } from 'vue';
import { useBreakpoints, breakpointsTailwind } from '@vueuse/core';
import { useAppStore, useThemeStore } from '@/store'; import { useAppStore, useThemeStore } from '@/store';
type LayoutMode = 'vertical' | 'horizontal'; type LayoutMode = 'vertical' | 'horizontal';
@ -7,6 +8,7 @@ type LayoutHeaderProps = Record<EnumType.ThemeLayoutMode, GlobalHeaderProps>;
export function useBasicLayout() { export function useBasicLayout() {
const app = useAppStore(); const app = useAppStore();
const theme = useThemeStore(); const theme = useThemeStore();
const breakpoints = useBreakpoints(breakpointsTailwind);
const mode = computed(() => { const mode = computed(() => {
const vertical: LayoutMode = 'vertical'; const vertical: LayoutMode = 'vertical';
@ -14,6 +16,8 @@ export function useBasicLayout() {
return theme.layout.mode.includes(vertical) ? vertical : horizontal; return theme.layout.mode.includes(vertical) ? vertical : horizontal;
}); });
const isMobile = breakpoints.smaller('sm');
const layoutHeaderProps: LayoutHeaderProps = { const layoutHeaderProps: LayoutHeaderProps = {
vertical: { vertical: {
showLogo: false, showLogo: false,
@ -61,6 +65,7 @@ export function useBasicLayout() {
return { return {
mode, mode,
isMobile,
headerProps, headerProps,
siderVisible, siderVisible,
siderWidth, siderWidth,

View File

@ -1,7 +1,7 @@
<template> <template>
<admin-layout <admin-layout
:mode="mode" :mode="mode"
:min-width="theme.layout.minWidth" :is-mobile="isMobile"
:fixed-header-and-tab="theme.fixedHeaderAndTab" :fixed-header-and-tab="theme.fixedHeaderAndTab"
:header-height="theme.header.height" :header-height="theme.header.height"
:tab-visible="theme.tab.visible" :tab-visible="theme.tab.visible"
@ -12,6 +12,7 @@
:sider-collapse="app.siderCollapse" :sider-collapse="app.siderCollapse"
:add-main-overflow-hidden="addMainOverflowHidden" :add-main-overflow-hidden="addMainOverflowHidden"
:fixed-footer="theme.footer.fixed" :fixed-footer="theme.footer.fixed"
@update:sider-collapse="app.setSiderCollapse"
> >
<template #header> <template #header>
<global-header v-bind="headerProps" /> <global-header v-bind="headerProps" />
@ -51,7 +52,7 @@ defineOptions({ name: 'BasicLayout' });
const app = useAppStore(); const app = useAppStore();
const theme = useThemeStore(); const theme = useThemeStore();
const { mode, headerProps, siderVisible, siderWidth, siderCollapsedWidth } = useBasicLayout(); const { mode, isMobile, headerProps, siderVisible, siderWidth, siderCollapsedWidth } = useBasicLayout();
const { bool: addMainOverflowHidden, setBool: setAddMainOverflowHidden } = useBoolean(); const { bool: addMainOverflowHidden, setBool: setAddMainOverflowHidden } = useBoolean();
</script> </script>

View File

@ -2,8 +2,8 @@
<dark-mode-container class="global-header flex-y-center h-full" :inverted="theme.header.inverted"> <dark-mode-container class="global-header flex-y-center h-full" :inverted="theme.header.inverted">
<global-logo v-if="showLogo" :show-title="true" class="h-full" :style="{ width: theme.sider.width + 'px' }" /> <global-logo v-if="showLogo" :show-title="true" class="h-full" :style="{ width: theme.sider.width + 'px' }" />
<div v-if="!showHeaderMenu" class="flex-1-hidden flex-y-center h-full"> <div v-if="!showHeaderMenu" class="flex-1-hidden flex-y-center h-full">
<menu-collapse v-if="showMenuCollapse" /> <menu-collapse v-if="showMenuCollapse || isMobile" />
<global-breadcrumb v-if="theme.header.crumb.visible" /> <global-breadcrumb v-if="theme.header.crumb.visible && !isMobile" />
</div> </div>
<header-menu v-else /> <header-menu v-else />
<div class="flex justify-end h-full"> <div class="flex justify-end h-full">
@ -20,6 +20,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { useThemeStore } from '@/store'; import { useThemeStore } from '@/store';
import { useBasicLayout } from '@/composables';
import GlobalLogo from '../GlobalLogo/index.vue'; import GlobalLogo from '../GlobalLogo/index.vue';
import GlobalSearch from '../GlobalSearch/index.vue'; import GlobalSearch from '../GlobalSearch/index.vue';
import { import {
@ -48,6 +49,7 @@ interface Props {
defineProps<Props>(); defineProps<Props>();
const theme = useThemeStore(); const theme = useThemeStore();
const { isMobile } = useBasicLayout();
const showButton = import.meta.env.PROD && import.meta.env.VITE_VERCEL !== '1'; const showButton = import.meta.env.PROD && import.meta.env.VITE_VERCEL !== '1';
</script> </script>