@complex-suite/plugin
Advanced tools
+6
-0
@@ -10,2 +10,8 @@ <!-- | ||
| ### 5.0.19 | ||
| - feat(layout): `PluginLayout` 新增 `setVisibles(type, values)` 批量设置面板可见性,统一触发一次 `$countMain` | ||
| - refactor(layout): `triggerChange` 的 args 从 rest 参数改为数组参数,便于后续扩展 | ||
| - refactor(layout): `triggerChange` 触发 `change` 生命周期,`setVisible`/`setVisibles` 触发 `visible` 生命周期(替代原 `mainChange`) | ||
| - refactor(layout): `setVisibles` 改为逐条触发 `visible` 生命周期,与 `setVisible` 参数格式一致 | ||
| ### 5.0.18 | ||
@@ -12,0 +18,0 @@ - feat(layout): `PluginLayoutData.visible` 改为 `{ user, system }` 双维度对象,新增 `getVisible`/`getVisibleWidth`/`getVisibleHeight` 方法;移除 `show`/`hide`/`toggle` |
+2
-2
| { | ||
| "name": "@complex-suite/plugin", | ||
| "version": "5.0.18", | ||
| "version": "5.0.19", | ||
| "description": "a complex plugin", | ||
@@ -15,3 +15,3 @@ "type": "module", | ||
| "dependencies": { | ||
| "@complex-suite/utils": "3.0.18" | ||
| "@complex-suite/utils": "3.0.19" | ||
| }, | ||
@@ -18,0 +18,0 @@ "devDependencies": { |
+25
-5
@@ -195,3 +195,3 @@ import { _Data, Life, throttle } from "@complex-suite/utils" | ||
| } | ||
| triggerChange(prop: string, ...args: any[]) { | ||
| triggerChange(prop: string, args: any[]) { | ||
| const layoutData = this.data[prop] | ||
@@ -201,3 +201,3 @@ if (layoutData) { | ||
| this.$countMain(true) | ||
| this.triggerLife('mainChange', 'change', prop, ...args) | ||
| this.triggerLife('change', prop, ...args) | ||
| } else { | ||
@@ -208,3 +208,3 @@ this.$exportMsg(pluginLocale.t('layout.moduleNotFound', { prop }), 'error') | ||
| /** | ||
| * 程序化设置布局可见性(不触发 onChange,区别于用户交互的 triggerChange) | ||
| * 程序化设置单个面板可见性(不触发 onChange,区别于用户交互的 triggerChange) | ||
| * @param prop 面板名(sider/header/...) | ||
@@ -214,3 +214,4 @@ * @param type 维度:'user' 用户手动 | 'system' 系统自动 | ||
| * prop 未安装时静默返回不报错(系统自动调用场景下不应中断流程) | ||
| * 触发 'mainChange' 生命周期(source='visible'),供业务层监听 | ||
| * 触发 'visible' 生命周期,供业务层监听 | ||
| * 批量设置请用 setVisibles,避免重复触发 $countMain | ||
| */ | ||
@@ -222,4 +223,23 @@ setVisible(prop: string, type: 'user' | 'system', val: boolean) { | ||
| this.$countMain(true) | ||
| this.triggerLife('mainChange', 'visible', prop, type, val) | ||
| this.triggerLife('visible', prop, type, val) | ||
| } | ||
| /** | ||
| * 批量设置面板可见性(遍历赋值后统一触发一次 $countMain,避免重复计算) | ||
| * @param type 维度:'user' 用户手动 | 'system' 系统自动 | ||
| * @param values { [prop]: boolean },prop 未安装时跳过不报错 | ||
| * 每个实际修改的 prop 单独触发 'visible' 生命周期(与 setVisible 参数格式一致) | ||
| */ | ||
| setVisibles(type: 'user' | 'system', values: Record<string, boolean>) { | ||
| const changed: string[] = [] | ||
| for (const prop in values) { | ||
| const layoutData = this.data[prop] | ||
| if (!layoutData || layoutData.visible[type] === values[prop]) continue | ||
| layoutData.visible[type] = values[prop] | ||
| changed.push(prop) | ||
| } | ||
| if (changed.length) { | ||
| this.$countMain(true) | ||
| changed.forEach(prop => this.triggerLife('visible', prop, type, values[prop])) | ||
| } | ||
| } | ||
| destroy() { | ||
@@ -226,0 +246,0 @@ window.removeEventListener('resize', this.func) |
28772
5.12%587
3.53%+ Added
- Removed
Updated