修改代码

This commit is contained in:
ival 2021-04-04 21:19:17 +08:00
parent b8ef4c33da
commit 16fcf932ff
3 changed files with 19 additions and 8 deletions

View File

@ -43,6 +43,10 @@ class Animate {
return this._dispose; return this._dispose;
} }
isEqual(code) {
return this._state.code == code;
}
animate() { animate() {
const shape = this._state.shape; const shape = this._state.shape;
const frameList = this._state.frameList; const frameList = this._state.frameList;
@ -83,7 +87,7 @@ class AnimateHandle {
} }
animate(state) { animate(state) {
const animate = this._animates.find(el => el.code == state.code); const animate = this._animates.find(el => el.isEqual(state.code));
if (animate) { if (animate) {
animate.dispose(); animate.dispose();
} }

View File

@ -8,9 +8,11 @@ export default class StateHandle {
parse(shapeFactory, state) { parse(shapeFactory, state) {
const mapTemplate = shapeFactory.getMapTemplate(); const mapTemplate = shapeFactory.getMapTemplate();
const template = mapTemplate[state.type]; 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( templateState.frameList.unshift(
Object.entries(template.mapShape).map(el => { Object.entries(template.mapShape).map(el => {
return { name: el[0], ...el[1][utils.defStatus]}; return { name: el[0], ...el[1][utils.defStatus]};
@ -18,18 +20,17 @@ export default class StateHandle {
); );
} }
console.log(Object.entries(template.mapShape))
return { return {
...state, ...state,
...templateState, ...templateState,
shape: shapeFactory.getShapeByCode(state.code), shape: shapeFactory.getShapeByCode(state.code),
frameList: templateState.frameList.map(frame => { frameList: frameList.map(frame => {
return Object.fromEntries(frame.map(el => { 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, { return [el.name, {
...el, ...el,
...mapState[el.status] ...state
}] }]
})); }));
}) })

View File

@ -318,6 +318,12 @@ export default {
{ status: 's1', code: '100', type: 'Device' }, { status: 's1', code: '100', type: 'Device' },
{ status: 's2', code: '101', 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) { onKeyboard(hook) {