From d5aee2ea58a16e0cf65213fab9e46192882feba9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 17 Nov 2022 09:31:07 +0900 Subject: improve performance --- packages/client/src/widgets/widget.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'packages/client/src/widgets/widget.ts') diff --git a/packages/client/src/widgets/widget.ts b/packages/client/src/widgets/widget.ts index 9fdfe7f3e1..8bd56a5966 100644 --- a/packages/client/src/widgets/widget.ts +++ b/packages/client/src/widgets/widget.ts @@ -2,6 +2,7 @@ import { reactive, watch } from 'vue'; import { throttle } from 'throttle-debounce'; import { Form, GetFormResultType } from '@/scripts/form'; import * as os from '@/os'; +import { deepClone } from '@/scripts/clone'; export type Widget

> = { id: string; @@ -32,7 +33,7 @@ export const useWidgetPropsManager = void; configure: () => void; } => { - const widgetProps = reactive(props.widget ? JSON.parse(JSON.stringify(props.widget.data)) : {}); + const widgetProps = reactive(props.widget ? deepClone(props.widget.data) : {}); const mergeProps = () => { for (const prop of Object.keys(propsDef)) { @@ -43,14 +44,14 @@ export const useWidgetPropsManager = { mergeProps(); - }, { deep: true, immediate: true, }); + }, { deep: true, immediate: true }); const save = throttle(3000, () => { emit('updateProps', widgetProps); }); const configure = async () => { - const form = JSON.parse(JSON.stringify(propsDef)); + const form = deepClone(propsDef); for (const item of Object.keys(form)) { form[item].default = widgetProps[item]; } -- cgit v1.2.3-freya