Commit 996f4b87b09a7d424371fe263300fc962b4a6924
1 parent
0e80ddda
fix(src/store): 修改tab切换websocket控制台报错
Showing
1 changed file
with
26 additions
and
4 deletions
@@ -69,10 +69,17 @@ export const useSocketStore = defineStore({ | @@ -69,10 +69,17 @@ export const useSocketStore = defineStore({ | ||
69 | }) | 69 | }) |
70 | } else { | 70 | } else { |
71 | const keysRecord: Record<string, KeyBoundComponentList[]> = {} | 71 | const keysRecord: Record<string, KeyBoundComponentList[]> = {} |
72 | - | ||
73 | - keys.forEach(key => { | 72 | + /**这里修改自定义tab切换传的单个属性问题 |
73 | + * ft | ||
74 | + * 源代码 keys.forEach | ||
75 | + * 修改代码 const overrideKeys = typeof keys==="string"?[keys]: keys overrideKeys.forEach | ||
76 | + */ | ||
77 | + const overrideKeys = typeof keys==="string"?[keys]: keys | ||
78 | + | ||
79 | + overrideKeys.forEach(key => { | ||
74 | Reflect.set(keysRecord, key, [{ componentId }]) | 80 | Reflect.set(keysRecord, key, [{ componentId }]) |
75 | }) | 81 | }) |
82 | + //ft | ||
76 | Reflect.set(this.connectionPool, entityId, keysRecord) | 83 | Reflect.set(this.connectionPool, entityId, keysRecord) |
77 | } | 84 | } |
78 | return this.refreshSubscribedMessage(entityId) | 85 | return this.refreshSubscribedMessage(entityId) |
@@ -177,15 +184,22 @@ export const useSocketStore = defineStore({ | @@ -177,15 +184,22 @@ export const useSocketStore = defineStore({ | ||
177 | */ | 184 | */ |
178 | getNeedUpdateComponentsIdBySubscribeId(subscribeId: number, keys: string[]) { | 185 | getNeedUpdateComponentsIdBySubscribeId(subscribeId: number, keys: string[]) { |
179 | const entityId = this.subscribePool.find(item => item.subscribeId === subscribeId)?.entityId | 186 | const entityId = this.subscribePool.find(item => item.subscribeId === subscribeId)?.entityId |
187 | + /**这里修改自定义tab切换传的单个属性问题 | ||
188 | + * ft | ||
189 | + * 源代码 keys.map(key => keysRecord[key]) | ||
190 | + * 修改代码 const overrideKeys = typeof keys==="string"?[keys]: keys overrideKeys.map(key => keysRecord[key]) | ||
191 | + */ | ||
192 | + const overrideKeys = typeof keys==="string"?[keys]: keys | ||
180 | 193 | ||
181 | if (entityId) { | 194 | if (entityId) { |
182 | const keysRecord = Reflect.get(this.connectionPool, entityId) | 195 | const keysRecord = Reflect.get(this.connectionPool, entityId) |
183 | - const needUpdateComponents = keys.map(key => keysRecord[key]) | 196 | + const needUpdateComponents = overrideKeys.map(key => keysRecord[key]) |
184 | const ids = needUpdateComponents | 197 | const ids = needUpdateComponents |
185 | .reduce((prev, next) => [...prev, ...next], []) | 198 | .reduce((prev, next) => [...prev, ...next], []) |
186 | .map((item: KeyBoundComponentList) => item.componentId) | 199 | .map((item: KeyBoundComponentList) => item.componentId) |
187 | return [...new Set(ids)] | 200 | return [...new Set(ids)] |
188 | } | 201 | } |
202 | + //ft | ||
189 | }, | 203 | }, |
190 | 204 | ||
191 | /** | 205 | /** |
@@ -198,7 +212,15 @@ export const useSocketStore = defineStore({ | @@ -198,7 +212,15 @@ export const useSocketStore = defineStore({ | ||
198 | const { request: { requestParams } } = targetComponent | 212 | const { request: { requestParams } } = targetComponent |
199 | const { Params } = requestParams | 213 | const { Params } = requestParams |
200 | const { keys = [] } = Params | 214 | const { keys = [] } = Params |
201 | - const targetComponentBindKeys = keys as unknown as string[] | 215 | + /**这里修改自定义tab切换传的单个属性问题 |
216 | + * ft | ||
217 | + * 源代码 keys as unknown as string[] | ||
218 | + * 修改代码 const overrideKeys = typeof keys==="string"?[keys]: keys overrideKeys as unknown as string[] | ||
219 | + */ | ||
220 | + const overrideKeys = typeof keys==="string"?[keys]: keys | ||
221 | + | ||
222 | + const targetComponentBindKeys = overrideKeys as unknown as string[] | ||
223 | + //ft | ||
202 | 224 | ||
203 | const _value = cloneDeep(value) || { data: {}, latestValues: {} } | 225 | const _value = cloneDeep(value) || { data: {}, latestValues: {} } |
204 | _value.data = targetComponentBindKeys.reduce((prev, next) => { | 226 | _value.data = targetComponentBindKeys.reduce((prev, next) => { |