import { Ref, ComputedRef } from 'vue'; import { ThemeType, ThemeConfig, MenuItem, MenuProps, SystemItem, SystemProps, UserAction, RegionTheme, FlattenedThemeConfig, MenuTrigger } from '../types'; /** * 布局组件公共 Props 接口 * 所有独立布局组件共享的 props 定义 * * @description * 重构后移除了 mode 参数,每个布局组件独立负责自己的布局逻辑。 * 此接口定义了所有布局组件的公共配置项。 */ export interface LayoutCommonProps { /** 主题类型 */ theme: ThemeType; /** 自定义主题配置 */ themeConfig?: ThemeConfig; /** 菜单数据 */ menuData: MenuItem[]; /** 菜单字段映射 */ menuProps?: MenuProps; /** 系统数据 */ systemData: SystemItem[]; /** 系统字段映射 */ systemProps?: SystemProps; /** 当前激活的系统/模块 key */ activeSystemKey?: string; /** 系统切换触发方式 */ systemTrigger: MenuTrigger; /** 折叠状态 */ collapsed: boolean; /** 侧边栏展开宽度 */ sideWidth: number; /** 侧边栏折叠宽度 */ sideCollapsedWidth: number; /** 顶部栏高度 */ topHeight: number; /** Logo 小图地址 */ logo?: string; /** Logo 大图地址 */ logoLarge?: string; /** Logo 大图宽度 */ logoLargeWidth: number; /** Logo 大图高度 */ logoLargeHeight: number; /** 系统标题 */ title: string; /** 当前激活的菜单项 key */ activeKey?: string; /** 响应式断点 */ breakpoint: number; /** 是否启用响应式自动折叠 */ enableAutoCollapse: boolean; /** 菜单触发方式 */ menuTrigger: MenuTrigger; /** 是否默认展开全部菜单 */ expandAll: boolean; /** 默认打开的 sub-menu 的 key 数组 */ defaultExpandedKeys: string[]; /** 是否只保持一个子菜单展开 */ uniqueOpened: boolean; /** 是否显示折叠按钮 */ showCollapseButton: boolean; /** 用户信息 */ userInfo?: any; /** 更多用户行为 */ moreUserActions: UserAction[]; } /** * 布局组件公共 Emits 接口 * * @description * 重构后移除了 mode-change 事件,因为每个布局组件独立工作,不再需要模式切换。 */ export interface LayoutCommonEmits { (e: 'update:collapsed', value: boolean): void; (e: 'update:activeKey', value: string): void; (e: 'update:activeSystemKey', value: string): void; (e: 'menu-click', item: MenuItem): void; (e: 'system-change', item: SystemItem): void; (e: 'collapse-change', collapsed: boolean): void; (e: 'resize', width: number, height: number): void; (e: 'user-action-click', action: UserAction): void; } /** * useLayoutCommon 返回值接口 */ export interface UseLayoutCommonReturn { /** 内部折叠状态(支持 v-model:collapsed 双向绑定) */ internalCollapsed: Ref; /** 内部激活系统/模块 key(支持 v-model:activeSystemKey 双向绑定) */ internalActiveSystemKey: Ref; /** 规范化后的菜单字段映射 */ normalizedMenuProps: ComputedRef>; /** 规范化后的系统字段映射 */ normalizedSystemProps: ComputedRef>; /** CSS 变量对象,用于 style 绑定 */ themeVars: ComputedRef>; /** 主题类名 */ themeClass: ComputedRef; /** 规范化后的区域主题配置 */ normalizedTheme: ComputedRef; /** 合并后的完整主题配置 */ mergedTheme: ComputedRef; /** 当前视口宽度 */ viewportWidth: Ref; /** 当前视口高度 */ viewportHeight: Ref; /** 检查当前视口是否低于断点的函数 */ isBelowBreakpoint: () => boolean; /** 切换折叠状态 */ handleToggleCollapse: () => void; /** 处理菜单项点击 */ handleMenuClick: (item: MenuItem) => void; /** 处理系统/模块切换 */ handleSystemChange: (item: SystemItem) => void; /** 处理用户行为点击 */ handleUserActionClick: (action: UserAction) => void; } /** * 布局组件公共逻辑 Composable * * @description * 提取所有独立布局组件共享的逻辑: * - 折叠状态管理(支持 v-model:collapsed 双向绑定) * - 系统/模块切换状态管理(支持 v-model:activeSystemKey 双向绑定) * - 主题配置(集成 useTheme) * - 响应式处理(集成 useResponsive) * - 事件处理 * * 重构说明: * - 移除了 mode 参数,每个布局组件独立负责自己的布局逻辑 * - 移除了 mode-change 事件 * - 优化了折叠状态和系统切换状态的双向绑定逻辑 * * @param props - 组件 props * @param emit - 组件 emit * @returns 公共状态和方法 * * @example * ```typescript * // 在布局组件中使用 * const { * internalCollapsed, * themeVars, * themeClass, * handleToggleCollapse, * handleMenuClick * } = useLayoutCommon(props, emit) * ``` */ export declare function useLayoutCommon(props: LayoutCommonProps, emit: LayoutCommonEmits): UseLayoutCommonReturn;