Improve widget performance

This commit is contained in:
syuilo 2021-02-20 15:57:30 +09:00
parent 53c7077d1d
commit 65fbca47f9

View file

@ -1,4 +1,5 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { throttle } from 'throttle-debounce';
import { Form } from '@/scripts/form'; import { Form } from '@/scripts/form';
import * as os from '@/os'; import * as os from '@/os';
@ -21,7 +22,10 @@ export default function <T extends Form>(data: {
data() { data() {
return { return {
props: this.widget ? JSON.parse(JSON.stringify(this.widget.data)) : {} props: this.widget ? JSON.parse(JSON.stringify(this.widget.data)) : {},
save: throttle(3000, () => {
this.$emit('updateProps', this.props);
}),
}; };
}, },
@ -66,10 +70,6 @@ export default function <T extends Form>(data: {
this.save(); this.save();
}, },
save() {
this.$emit('updateProps', this.props);
}
} }
}); });
} }