@lx-frontend/wrap-element-ui 1.0.24-beta.3 → 1.0.24-beta.5

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.3",
3
+ "version": "1.0.24-beta.5",
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.to,
78
79
  schemaVersion: 1
79
80
  }))
80
81
  };
@@ -114,24 +115,35 @@ 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 ?? []).filter(v => (v.schemaVersion ?? 1) === _cache.schemaVersion)
122
+
123
+ const _versionIndex = bizMigrationConfigs.findIndex(v => v.version.form === _cache.version)
124
+ if (_versionIndex > -1) {
125
+ for (let i = _versionIndex; i < bizMigrationConfigs.length; i++) {
126
+ const curr = bizMigrationConfigs[i]
127
+ _cache = curr.migration(_cache.config, val)
128
+ }
129
+ }
130
+ return _cache
131
+ } else {
132
+ let __cache = storgeSchemaMigrationConfig[schemaVersion].migration(_cache, val)
133
+
134
+ // 处理当前schema版本需要处理的变更
135
+ const bizMigrationConfigs = (props.settingStorgeMigrationConfigs ?? []).filter(v => (v.schemaVersion ?? 1) === __cache.schemaVersion)
136
+ if (bizMigrationConfigs.length) {
137
+ __cache = bizMigrationConfigs.reduce((acc, curr) => ({
138
+ ...curr.migration(acc.config, val),
139
+ schemaVersion: __cache.schemaVersion,
140
+ }), __cache)
141
+ }
142
+
143
+ return storgeSchemaMigrationConfig[schemaVersion].nextSchemaVersion
144
+ ? handleMigration(__cache)
145
+ : __cache
130
146
  }
131
-
132
- return storgeSchemaMigrationConfig[schemaVersion].nextSchemaVersion
133
- ? handleMigration(__cache)
134
- : __cache
135
147
  }
136
148
 
137
149
  const cache = handleMigration(JSON.parse(_cache)) as SettingStorgeConfig;
@@ -169,7 +169,10 @@ export type SettingStorgeConfig = {
169
169
 
170
170
  export type SettingStorgeMigrationConfigs = {
171
171
  schemaVersion?: number
172
- version: string
172
+ version: {
173
+ form: string
174
+ to: string
175
+ }
173
176
  migration: (currentConfig: any, columns: IColumnConfig[]) => SettingStorgeConfig
174
177
  }[]
175
178