From 16fcf932ff36b0cf5fec73180df2785a580d564e Mon Sep 17 00:00:00 2001 From: ival <160568032@qq.com> Date: Sun, 4 Apr 2021 21:19:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/iscs_new/animateHandle.js | 6 +++++- src/iscs_new/stateHandle.js | 15 ++++++++------- src/views/test/index.vue | 6 ++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/iscs_new/animateHandle.js b/src/iscs_new/animateHandle.js index 57474e6b3..5c6d77925 100644 --- a/src/iscs_new/animateHandle.js +++ b/src/iscs_new/animateHandle.js @@ -43,6 +43,10 @@ class Animate { return this._dispose; } + isEqual(code) { + return this._state.code == code; + } + animate() { const shape = this._state.shape; const frameList = this._state.frameList; @@ -83,7 +87,7 @@ class AnimateHandle { } animate(state) { - const animate = this._animates.find(el => el.code == state.code); + const animate = this._animates.find(el => el.isEqual(state.code)); if (animate) { animate.dispose(); } diff --git a/src/iscs_new/stateHandle.js b/src/iscs_new/stateHandle.js index 28b3aae70..141be67a7 100644 --- a/src/iscs_new/stateHandle.js +++ b/src/iscs_new/stateHandle.js @@ -8,9 +8,11 @@ export default class StateHandle { parse(shapeFactory, state) { const mapTemplate = shapeFactory.getMapTemplate(); const template = mapTemplate[state.type]; - const templateState = template.mapState[state.status]; + const templateState = template.mapState[state.status]||{}; + const frameList = templateState.frameList||[]; - if (templateState.needDefault) { + if (templateState && + templateState.needDefault) { templateState.frameList.unshift( Object.entries(template.mapShape).map(el => { return { name: el[0], ...el[1][utils.defStatus]}; @@ -18,18 +20,17 @@ export default class StateHandle { ); } - console.log(Object.entries(template.mapShape)) - return { ...state, ...templateState, shape: shapeFactory.getShapeByCode(state.code), - frameList: templateState.frameList.map(frame => { + frameList: frameList.map(frame => { return Object.fromEntries(frame.map(el => { - const mapState = template.mapShape[el.name]; + const mapState = template.mapShape[el.name]||{}; + const state = mapState[el.status]||{}; return [el.name, { ...el, - ...mapState[el.status] + ...state }] })); }) diff --git a/src/views/test/index.vue b/src/views/test/index.vue index dff11d677..1c9c5c170 100644 --- a/src/views/test/index.vue +++ b/src/views/test/index.vue @@ -318,6 +318,12 @@ export default { { status: 's1', code: '100', type: 'Device' }, { status: 's2', code: '101', type: 'Device' } ]); + setTimeout(e => { + this.$iscs.update([ + { status: 's0', code: '100', type: 'Device' }, + { status: 's0', code: '101', type: 'Device' }, + ]) + }, 15000) }, // 键盘快捷键事件 onKeyboard(hook) {