From 6d85757b6e51ddb9c7cbf4f99c9688cf965bd90f Mon Sep 17 00:00:00 2001 From: liancong Date: Thu, 13 Feb 2025 12:46:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20rjvId=20=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=96=B9=E5=BC=8F=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA=E5=AD=97=E7=AC=A6=E4=B8=B2=E5=A2=9E=E5=8A=A0=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/index.js | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/src/js/index.js b/src/js/index.js index 0e48d17..04016b3 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -31,7 +31,7 @@ class ReactJsonView extends React.PureComponent { } // reference id for this instance - rjvId = Date.now().toString() + rjvId = Date.now().toString() + Math.random().toString(36).slice(2) // all acceptable props and default values static defaultProps = { @@ -205,46 +205,39 @@ class ReactJsonView extends React.PureComponent { } updateSrc = () => { - const { - name, - namespace, - new_value, - existing_value, - variable_removed, - updated_src, - type - } = ObjectAttributes.get(this.rjvId, 'action', 'variable-update') + const { name, namespace, newValue, existingValue, updatedSrc, type } = + ObjectAttributes.get(this.rjvId, 'action', 'variable-update') const { onEdit, onDelete, onAdd } = this.props const { src } = this.state let result - const on_edit_payload = { - existing_src: src, - new_value, - updated_src, + const onEditPayload = { + existingSrc: src, + newValue, + updatedSrc, name, namespace, - existing_value + existingValue } switch (type) { case 'variable-added': - result = onAdd(on_edit_payload) + result = onAdd(onEditPayload) break case 'variable-edited': - result = onEdit(on_edit_payload) + result = onEdit(onEditPayload) break case 'variable-removed': - result = onDelete(on_edit_payload) + result = onDelete(onEditPayload) break } if (result !== false) { - ObjectAttributes.set(this.rjvId, 'global', 'src', updated_src) + ObjectAttributes.set(this.rjvId, 'global', 'src', updatedSrc) this.setState({ - src: updated_src + src: updatedSrc }) } else { this.setState({