@lx-frontend/wrap-element-ui 1.0.24-beta.2 → 1.0.24-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lx-frontend/wrap-element-ui",
3
- "version": "1.0.24-beta.2",
3
+ "version": "1.0.24-beta.4",
4
4
  "description": "wrap-element-ui",
5
5
  "author": "",
6
6
  "main": "src/components/index.ts",
@@ -75,6 +75,7 @@ export function useViewSetting({
75
75
  }, {} as Record<string, { hidden: boolean, order: number }>),
76
76
  leftFixedColumnCount: leftFixedColumnCount.value,
77
77
  },
78
+ version: (props.settingStorgeMigrationConfigs ?? []).pop()?.version,
78
79
  schemaVersion: 1
79
80
  }))
80
81
  };
@@ -114,24 +115,36 @@ export function useViewSetting({
114
115
  leftFixedColumnCount.value = props.leftFixedCount as number;
115
116
  } else {
116
117
  try {
117
- // 缓存数据字段可能随着更新导致对不上,清理无效数据,防止出问题
118
118
  const handleMigration = (_cache: any) => {
119
119
  const schemaVersion = _cache?.schemaVersion ?? 0
120
- if (!storgeSchemaMigrationConfig[schemaVersion]) return _cache
121
- let __cache = storgeSchemaMigrationConfig[schemaVersion].migration(_cache, val)
122
-
123
- // 处理当前schema版本需要处理的变更
124
- const bizMigrationConfigs = (props.settingStorgeMigrationConfigs ?? []).filter(v => (v.schemaVersion ?? 1) === __cache.schemaVersion)
125
- if (bizMigrationConfigs.length) {
126
- __cache = bizMigrationConfigs.reduce((acc, curr) => ({
127
- ...curr.migration(acc.config, val),
128
- schemaVersion: __cache.schemaVersion,
129
- }), __cache)
120
+ if (!storgeSchemaMigrationConfig[schemaVersion]) { // 没有 schema 变动时,查找需要处理的业务迁移配置
121
+ const bizMigrationConfigs = (props.settingStorgeMigrationConfigs ?? [])
122
+ .filter(v => (v.schemaVersion ?? 1) === _cache.schemaVersion)
123
+
124
+ const _versionIndex = bizMigrationConfigs.findIndex(v => v.version)
125
+ if (_versionIndex > -1) {
126
+ for (let i = _versionIndex; i < bizMigrationConfigs.length; i++) {
127
+ const curr = bizMigrationConfigs[i]
128
+ _cache = curr.migration(_cache.config, val)
129
+ }
130
+ }
131
+ return _cache
132
+ } else {
133
+ let __cache = storgeSchemaMigrationConfig[schemaVersion].migration(_cache, val)
134
+
135
+ // 处理当前schema版本需要处理的变更
136
+ const bizMigrationConfigs = (props.settingStorgeMigrationConfigs ?? []).filter(v => (v.schemaVersion ?? 1) === __cache.schemaVersion)
137
+ if (bizMigrationConfigs.length) {
138
+ __cache = bizMigrationConfigs.reduce((acc, curr) => ({
139
+ ...curr.migration(acc.config, val),
140
+ schemaVersion: __cache.schemaVersion,
141
+ }), __cache)
142
+ }
143
+
144
+ return storgeSchemaMigrationConfig[schemaVersion].nextSchemaVersion
145
+ ? handleMigration(__cache)
146
+ : __cache
130
147
  }
131
-
132
- return storgeSchemaMigrationConfig[schemaVersion].nextSchemaVersion
133
- ? handleMigration(__cache)
134
- : __cache
135
148
  }
136
149
 
137
150
  const cache = handleMigration(JSON.parse(_cache)) as SettingStorgeConfig;
@@ -339,7 +339,7 @@ import {
339
339
  useDragSort,
340
340
  } from './bizHooks'
341
341
 
342
- import { ITableDataItem, IColumnConfig, IDefaultOperationType, IColorList } from './types';
342
+ import { ITableDataItem, IColumnConfig, IDefaultOperationType, IColorList, SettingStorgeMigrationConfigs } from './types';
343
343
 
344
344
  // defineProps泛型参数如果从外部传入,编译报错
345
345
  interface IProps {
@@ -382,6 +382,8 @@ interface IProps {
382
382
  pageSizes?: number[]
383
383
  /** 分页器展示数量 */
384
384
  pagerCount?: number;
385
+ /** 设置的迁移配置 */
386
+ settingStorgeMigrationConfigs?: SettingStorgeMigrationConfigs
385
387
  }
386
388
 
387
389
  interface IEmits {