From e465b660f245f7307263d88b14d1d3463eab667f Mon Sep 17 00:00:00 2001 From: RogerWork Date: Fri, 22 Sep 2023 13:21:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90modules=E7=9A=84=E5=AD=A6?= =?UTF-8?q?=E4=B9=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/ModuleA.js | 8 ++- src/store/modules/ModuleB.js | 6 +- src/views/CompositionAPIView.vue | 84 +++++++++++++++--------- src/views/OptionsAPIView.vue | 108 +++++++++++++++++-------------- 4 files changed, 125 insertions(+), 81 deletions(-) diff --git a/src/store/modules/ModuleA.js b/src/store/modules/ModuleA.js index 69c9967..00d45c5 100644 --- a/src/store/modules/ModuleA.js +++ b/src/store/modules/ModuleA.js @@ -9,12 +9,14 @@ export const moduleA = { }, mutations: { mutation_a(state, payload) { - state.state_a + payload.num; + state.state_a += payload.num; } }, actions: { - action_a(content, payload){ - content.commit('mutation_a', {num: payload.num}) + action_a(content, payload) { + if (content.state.state_a > 50) { + content.commit('mutation_a', {num: payload.num}) + } } } } diff --git a/src/store/modules/ModuleB.js b/src/store/modules/ModuleB.js index bbd8b38..0f1683a 100644 --- a/src/store/modules/ModuleB.js +++ b/src/store/modules/ModuleB.js @@ -10,12 +10,14 @@ export const moduleB = { }, mutations: { mutation_b: (state, payload) => { - state.state_b + payload.num; + state.state_b += payload.num; } }, actions: { action_b: (content, payload) => { - content.commit('mutation_b', {num: payload.num}) + if (content.state.state_b > 50) { + content.commit('mutation_b', {num: payload.num}) + } } } } diff --git a/src/views/CompositionAPIView.vue b/src/views/CompositionAPIView.vue index 05f9b53..093c864 100644 --- a/src/views/CompositionAPIView.vue +++ b/src/views/CompositionAPIView.vue @@ -1,49 +1,75 @@ diff --git a/src/views/OptionsAPIView.vue b/src/views/OptionsAPIView.vue index e26436a..5e46869 100644 --- a/src/views/OptionsAPIView.vue +++ b/src/views/OptionsAPIView.vue @@ -1,59 +1,73 @@