From 65fbca47f9831a2850c5c10e1f93520cc6f19203 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 20 Feb 2021 15:57:30 +0900 Subject: [PATCH] Improve widget performance --- src/client/widgets/define.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/client/widgets/define.ts b/src/client/widgets/define.ts index b5498204b3..08a346d97c 100644 --- a/src/client/widgets/define.ts +++ b/src/client/widgets/define.ts @@ -1,4 +1,5 @@ import { defineComponent } from 'vue'; +import { throttle } from 'throttle-debounce'; import { Form } from '@/scripts/form'; import * as os from '@/os'; @@ -21,7 +22,10 @@ export default function (data: { data() { 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 (data: { this.save(); }, - - save() { - this.$emit('updateProps', this.props); - } } }); }