diff options
| author | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-10 21:42:17 +0900 |
|---|---|---|
| committer | syuilo <4439005+syuilo@users.noreply.github.com> | 2025-03-10 21:42:17 +0900 |
| commit | a4ba096e2aa6897ba6782e4ad17262ac04f12b94 (patch) | |
| tree | a19f9b9041e96fa57477e90fa1606ef7d91b5588 /packages/frontend/src/preferences | |
| parent | enhance(frontend): テーマ設定で簡易プレビューを表示するよ... (diff) | |
| download | sharkey-a4ba096e2aa6897ba6782e4ad17262ac04f12b94.tar.gz sharkey-a4ba096e2aa6897ba6782e4ad17262ac04f12b94.tar.bz2 sharkey-a4ba096e2aa6897ba6782e4ad17262ac04f12b94.zip | |
chore(frontend): improve preference store stability
Diffstat (limited to 'packages/frontend/src/preferences')
| -rw-r--r-- | packages/frontend/src/preferences/store.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/frontend/src/preferences/store.ts b/packages/frontend/src/preferences/store.ts index e10afcc308..e061021be3 100644 --- a/packages/frontend/src/preferences/store.ts +++ b/packages/frontend/src/preferences/store.ts @@ -45,12 +45,14 @@ export class Store<Data extends Record<string, any>> extends EventEmitter<StoreE } public commit<K extends keyof Data>(key: K, value: Data[K]) { - this.r[key].value = this.s[key] = value; - this.emit('updated', { key, value }); + const v = JSON.parse(JSON.stringify(value)); // deep copy 兼 vueのプロキシ解除 + this.r[key].value = this.s[key] = v; + this.emit('updated', { key, value: v }); } public rewrite<K extends keyof Data>(key: K, value: Data[K]) { - this.r[key].value = this.s[key] = value; + const v = JSON.parse(JSON.stringify(value)); // deep copy 兼 vueのプロキシ解除 + this.r[key].value = this.s[key] = v; } /** |