mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 09:49:20 +08:00
feat: 优化店铺和公司侧边栏
This commit is contained in:
@@ -3,15 +3,17 @@ import type { CompanyVO } from '#/api/company/types';
|
||||
|
||||
import { ColPage } from '@vben/common-ui';
|
||||
|
||||
import { useColSidebarLayout } from '#/store/col-sidebar-layout';
|
||||
import CompanySidebarList from '#/views/company/components/CompanySidebarList.vue';
|
||||
|
||||
defineOptions({ name: 'CompanyColPage' });
|
||||
|
||||
/** 公司侧栏:展开/宽度走全局持久化,跨页面共用 */
|
||||
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
selectedCompanyId?: number;
|
||||
autoContentHeight?: boolean;
|
||||
leftWidth?: number;
|
||||
leftMinWidth?: number;
|
||||
leftMaxWidth?: number;
|
||||
leftCollapsedWidth?: number;
|
||||
@@ -22,10 +24,9 @@ withDefaults(
|
||||
}>(),
|
||||
{
|
||||
autoContentHeight: true,
|
||||
leftWidth: 22,
|
||||
leftMinWidth: 16,
|
||||
leftMaxWidth: 36,
|
||||
leftCollapsedWidth: 5,
|
||||
leftCollapsedWidth: 3,
|
||||
leftCollapsible: true,
|
||||
resizable: true,
|
||||
splitHandle: false,
|
||||
@@ -37,37 +38,62 @@ const emit = defineEmits<{
|
||||
'update:selectedCompanyId': [id: number | undefined];
|
||||
select: [company: CompanyVO.CompanyInfoVO];
|
||||
}>();
|
||||
|
||||
const { width: leftWidth, collapsed: leftCollapsed } =
|
||||
useColSidebarLayout('company');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ColPage
|
||||
:auto-content-height="autoContentHeight"
|
||||
:left-width="leftWidth"
|
||||
:left-min-width="leftMinWidth"
|
||||
:left-max-width="leftMaxWidth"
|
||||
:left-collapsed-width="leftCollapsedWidth"
|
||||
:left-collapsible="leftCollapsible"
|
||||
:right-width="100 - leftWidth"
|
||||
:resizable="resizable"
|
||||
:split-handle="splitHandle"
|
||||
:split-line="splitLine"
|
||||
content-class="!p-2 sm:!p-3"
|
||||
>
|
||||
<template #left="{ isCollapsed, expand, collapse }">
|
||||
<div class="flex h-full min-h-0 min-w-0 flex-col overflow-hidden">
|
||||
<CompanySidebarList
|
||||
fluid
|
||||
:collapsed="isCollapsed"
|
||||
show-collapse-action
|
||||
:selected-company-id="selectedCompanyId"
|
||||
@collapse="collapse"
|
||||
@expand="expand"
|
||||
@update:selected-company-id="emit('update:selectedCompanyId', $event)"
|
||||
@select="emit('select', $event)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<div class="company-col-page h-full min-h-0">
|
||||
<ColPage
|
||||
v-model:left-width="leftWidth"
|
||||
v-model:left-collapsed="leftCollapsed"
|
||||
:auto-content-height="autoContentHeight"
|
||||
:left-min-width="leftMinWidth"
|
||||
:left-max-width="leftMaxWidth"
|
||||
:left-collapsed-width="leftCollapsedWidth"
|
||||
:left-collapsible="leftCollapsible"
|
||||
:right-width="100 - leftWidth"
|
||||
:resizable="resizable"
|
||||
:split-handle="splitHandle"
|
||||
:split-line="splitLine"
|
||||
content-class="!p-2 sm:!p-3"
|
||||
>
|
||||
<template #left="{ isCollapsed, expand, collapse }">
|
||||
<div
|
||||
class="flex h-full min-h-0 flex-col"
|
||||
:class="
|
||||
isCollapsed
|
||||
? 'company-sidebar-collapsed-mark min-w-[56px] overflow-visible'
|
||||
: 'min-w-0 overflow-hidden'
|
||||
"
|
||||
>
|
||||
<CompanySidebarList
|
||||
fluid
|
||||
:collapsed="isCollapsed"
|
||||
show-collapse-action
|
||||
:selected-company-id="selectedCompanyId"
|
||||
@collapse="collapse"
|
||||
@expand="expand"
|
||||
@update:selected-company-id="emit('update:selectedCompanyId', $event)"
|
||||
@select="emit('select', $event)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<slot />
|
||||
</ColPage>
|
||||
<slot />
|
||||
</ColPage>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 收起态:logo 36 + p-0.5 + ring-2 + offset-1,固定 56px */
|
||||
.company-col-page :deep([data-panel]:has(.company-sidebar-collapsed-mark)),
|
||||
.company-col-page :deep([data-panel-group-direction] > *:first-child:has(.company-sidebar-collapsed-mark)) {
|
||||
flex: 0 0 56px !important;
|
||||
width: 56px !important;
|
||||
min-width: 56px !important;
|
||||
max-width: 56px !important;
|
||||
overflow: visible;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -22,6 +22,7 @@ const props = withDefaults(
|
||||
|
||||
const BuildingIcon = createIconifyIcon('lucide:building-2');
|
||||
|
||||
/** 无 logo 时用名称首字;仍无则显示公司图标 */
|
||||
const fallbackText = computed(() => {
|
||||
const text = props.name?.trim();
|
||||
return text ? text.charAt(0).toUpperCase() : '';
|
||||
@@ -34,9 +35,14 @@ const fallbackText = computed(() => {
|
||||
:src="logo"
|
||||
:alt="name"
|
||||
shape="square"
|
||||
class="company-logo-avatar shrink-0 !rounded-md !bg-muted"
|
||||
class="company-logo-avatar shrink-0 !rounded-md !bg-slate-200 !text-slate-700 dark:!bg-slate-600 dark:!text-slate-100"
|
||||
>
|
||||
<span v-if="fallbackText" class="text-xs font-medium">{{ fallbackText }}</span>
|
||||
<span
|
||||
v-if="fallbackText"
|
||||
class="company-logo-avatar__text text-xs font-semibold"
|
||||
>
|
||||
{{ fallbackText }}
|
||||
</span>
|
||||
<BuildingIcon v-else class="h-4 w-4 text-muted-foreground" />
|
||||
</Avatar>
|
||||
</template>
|
||||
@@ -48,8 +54,9 @@ const fallbackText = computed(() => {
|
||||
justify-content: center !important;
|
||||
}
|
||||
|
||||
.company-logo-avatar span {
|
||||
.company-logo-avatar__text {
|
||||
display: block;
|
||||
line-height: 1;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -25,8 +25,11 @@ defineOptions({ name: 'CompanySidebarList' });
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
selectedCompanyId?: number;
|
||||
/** 填满父容器宽度(ColPage 左栏);默认固定 320px */
|
||||
fluid?: boolean;
|
||||
/** 显示标题栏收起按钮(配合 ColPage collapse) */
|
||||
showCollapseAction?: boolean;
|
||||
/** 窄栏模式:仅展示 logo 列表(ColPage 收起态) */
|
||||
collapsed?: boolean;
|
||||
}>(),
|
||||
{
|
||||
@@ -122,7 +125,7 @@ onMounted(() => {
|
||||
</Tooltip>
|
||||
|
||||
<div
|
||||
class="flex min-h-0 w-full flex-1 flex-col items-center gap-1.5 overflow-y-auto px-1 pb-1 pt-2"
|
||||
class="flex min-h-0 w-full flex-1 flex-col items-center gap-1.5 overflow-y-auto px-1.5 pb-1 pt-2"
|
||||
>
|
||||
<Spin
|
||||
:spinning="companiesLoading"
|
||||
@@ -319,6 +322,7 @@ onMounted(() => {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
:deep(.company-sidebar-collapsed-spin .ant-spin-container) {
|
||||
@@ -326,5 +330,6 @@ onMounted(() => {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
overflow: visible;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user