From eb9a2ac2e063bae408d303663a339f647ab7134a Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 13 Aug 2023 20:13:27 +0800 Subject: [PATCH] code refactor --- src/stores/transactionTag.js | 6 ++++++ src/views/desktop/tags/ListPage.vue | 8 ++++---- src/views/mobile/tags/ListPage.vue | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/stores/transactionTag.js b/src/stores/transactionTag.js index 81904cd3..b918f2b1 100644 --- a/src/stores/transactionTag.js +++ b/src/stores/transactionTag.js @@ -60,6 +60,12 @@ export const useTransactionTagsStore = defineStore('transactionTags', { transactionTagListStateInvalid: true, }), actions: { + generateNewTransactionTagModel() { + return { + id: '', + name: '' + }; + }, updateTransactionTagListInvalidState(invalidState) { this.transactionTagListStateInvalid = invalidState; }, diff --git a/src/views/desktop/tags/ListPage.vue b/src/views/desktop/tags/ListPage.vue index 5c39c064..abcb80f9 100644 --- a/src/views/desktop/tags/ListPage.vue +++ b/src/views/desktop/tags/ListPage.vue @@ -222,12 +222,12 @@ import { export default { data() { + const transactionTagsStore = useTransactionTagsStore(); + const newTransactionTag = transactionTagsStore.generateNewTransactionTagModel(); + return { newTag: null, - editingTag: { - id: '', - name: '' - }, + editingTag: newTransactionTag, loading: true, updating: false, tagUpdating: {}, diff --git a/src/views/mobile/tags/ListPage.vue b/src/views/mobile/tags/ListPage.vue index 04af76fd..0c288e29 100644 --- a/src/views/mobile/tags/ListPage.vue +++ b/src/views/mobile/tags/ListPage.vue @@ -154,12 +154,12 @@ export default { 'f7router' ], data() { + const transactionTagsStore = useTransactionTagsStore(); + const newTransactionTag = transactionTagsStore.generateNewTransactionTagModel(); + return { newTag: null, - editingTag: { - id: '', - name: '' - }, + editingTag: newTransactionTag, loading: true, loadingError: null, showHidden: false,