refactor(@vben/layouts): remove @vben/widgets and migrate to @vben/layouts/src/widgets

This commit is contained in:
vince
2024-07-09 22:49:36 +08:00
parent d26a4ee022
commit 2731a1ec96
81 changed files with 62 additions and 182 deletions

View File

@@ -1,9 +1,10 @@
<script lang="ts" setup>
import { GlobalSearch, LanguageToggle, ThemeToggle } from '@vben/widgets';
import { usePreferences } from '@vben-core/preferences';
import { VbenFullScreen } from '@vben-core/shadcn-ui';
import { useCoreAccessStore } from '@vben-core/stores';
import { GlobalSearch, LanguageToggle, ThemeToggle } from '../../widgets';
interface Props {
/**
* Logo 主题

View File

@@ -1,7 +1,6 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { PreferencesWidget } from '@vben/widgets';
import { VbenAdminLayout } from '@vben-core/layout-ui';
import { $t } from '@vben-core/locales';
import {
@@ -13,6 +12,7 @@ import { VbenBackTop, VbenLogo } from '@vben-core/shadcn-ui';
import { mapTree } from '@vben-core/toolkit';
import { MenuRecordRaw } from '@vben-core/typings';
import { Breadcrumb, CozeAssistant, PreferencesWidget } from '../widgets';
import { LayoutContent } from './content';
import { Copyright } from './copyright';
import { LayoutFooter } from './footer';
@@ -25,7 +25,6 @@ import {
useMixedMenu,
} from './menu';
import { LayoutTabbar, LayoutTabbarTools } from './tabbar';
import { Breadcrumb } from './widgets';
defineOptions({ name: 'BasicLayout' });
@@ -160,6 +159,10 @@ function clearPreferencesAndLogout() {
</template>
<template #floating-groups>
<CozeAssistant
v-if="preferences.app.aiAssistant"
:is-mobile="preferences.app.isMobile"
/>
<VbenBackTop />
</template>

View File

@@ -1,90 +0,0 @@
<script lang="ts" setup>
import type { BreadcrumbStyleType } from '@vben-core/preferences';
import type { IBreadcrumb } from '@vben-core/shadcn-ui';
import { computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { $t } from '@vben-core/locales';
import { VbenBackgroundBreadcrumb, VbenBreadcrumb } from '@vben-core/shadcn-ui';
interface Props {
hideWhenOnlyOne?: boolean;
showHome?: boolean;
showIcon?: boolean;
type?: BreadcrumbStyleType;
}
const props = withDefaults(defineProps<Props>(), {
showHome: false,
showIcon: false,
type: 'normal',
});
const route = useRoute();
const router = useRouter();
const breadcrumbs = computed((): IBreadcrumb[] => {
const matched = route.matched;
const resultBreadcrumb: IBreadcrumb[] = [];
for (const match of matched) {
const {
meta,
path,
// children = []
} = match;
const { hideChildrenInMenu, hideInBreadcrumb, icon, name, title } =
meta || {};
if (hideInBreadcrumb || hideChildrenInMenu || !path) {
continue;
}
resultBreadcrumb.push({
icon: icon as string,
path: path || route.path,
title: $t((title || name) as string),
// items: children.map((child) => {
// return {
// icon: child?.meta?.icon as string,
// path: child.path,
// title: child?.meta?.title as string,
// };
// }),
});
}
if (props.showHome) {
resultBreadcrumb.unshift({
icon: 'mdi:home-outline',
isHome: true,
path: '/',
});
}
if (props.hideWhenOnlyOne && resultBreadcrumb.length === 1) {
return [];
}
return resultBreadcrumb;
});
function handleSelect(path: string) {
router.push(path);
}
</script>
<template>
<VbenBreadcrumb
v-if="type === 'normal'"
:breadcrumbs="breadcrumbs"
:show-icon="showIcon"
class="ml-2"
@select="handleSelect"
/>
<VbenBackgroundBreadcrumb
v-if="type === 'background'"
:breadcrumbs="breadcrumbs"
:show-icon="showIcon"
class="ml-2"
@select="handleSelect"
/>
</template>

View File

@@ -1 +0,0 @@
export { default as Breadcrumb } from './breadcrumb.vue';