From 819632b3dcf197722f2ab366bd451f5e3d4392a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=A1ssio?= Date: Thu, 26 Aug 2021 10:50:47 -0300 Subject: [PATCH] cnore: remove store --- .env.production | 1 - src/App.vue | 5 ----- src/bootstrap.js | 4 +--- src/helper-modules/user.module.js | 35 ------------------------------- src/store.js | 3 +-- src/userModuleFromRoot.js | 22 ------------------- vue.config.js | 2 -- 7 files changed, 2 insertions(+), 70 deletions(-) delete mode 100644 src/helper-modules/user.module.js delete mode 100644 src/userModuleFromRoot.js diff --git a/.env.production b/.env.production index 556f444..34ebbba 100644 --- a/.env.production +++ b/.env.production @@ -6,6 +6,5 @@ REMOTE_ROOT=root@https://mfe-module-federation-vue-root.netlify.app/remoteEntry. REMOTE_CART=cart@https://mfe-module-federation-vue-cart.netlify.app/remoteEntry.js REMOTE_PRODUCTS=products@https://mfe-module-federation-vue-products.netlify.app/remoteEntry.js REMOTE_PROFILE=profile@https://mfe-module-federation-vue-profile.netlify.app/remoteEntry.js -REMOTE_STORE=store@https://mfe-module-federation-vue-store.netlify.app/remoteEntry.js REMOTE_AUTH=auth@https://mfe-module-federation-vue-auth.netlify.app/remoteEntry.js REMOTE_DS=ds@https://mfe-module-federation-vue-ds.netlify.app/remoteEntry.js diff --git a/src/App.vue b/src/App.vue index ea1cc8e..2e63918 100644 --- a/src/App.vue +++ b/src/App.vue @@ -30,11 +30,6 @@ export default { { title: "About", icon: "mdi-help-box" }, ], }), - mounted() { - // console.log("root", this.$store); - this.$store.dispatch("user/setUser", { usuario: "teste" }); - console.log("mounted - App.vue - root"); - }, methods: { changeMenuState() { this.drawer = !this.drawer; diff --git a/src/bootstrap.js b/src/bootstrap.js index 054795d..91b9a9e 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -3,7 +3,6 @@ import App from "./App.vue"; import VueRouter from "vue-router"; import router from "./router"; import store from "./store"; -import userConfig from "./helper-modules/user.module"; import UserTools from "auth/UserTools"; import { frameworkConfig } from "ds/DSConfig"; @@ -11,8 +10,7 @@ Vue.config.productionTip = false; Vue.use(VueRouter); const initApp = async () => { - await userConfig.getUser(); // Requesting once - await UserTools.service.firstLoadUserData(); // Requesting once (from store) + await UserTools.service.firstLoadUserData(); // Requesting once new Vue({ router, diff --git a/src/helper-modules/user.module.js b/src/helper-modules/user.module.js deleted file mode 100644 index 3adf35b..0000000 --- a/src/helper-modules/user.module.js +++ /dev/null @@ -1,35 +0,0 @@ -import {getUser} from '@/service/user.service.js' - -class User { - data = null - - allData() { - if(!this.data) { - this.loadUser() - } - return this.data - } - - async getUser() { - const data2 = await getUser() - - if(!data2.id) return - - this.data = data2 - localStorage.setItem('user', JSON.stringify(data2)) // we could also use IndexDB xD - } - - loadUser() { - const user = JSON.parse(localStorage.getItem('user')) // we could also use IndexDB xD - this.data = user - } - - hasData() { - return this.data ? 'Yep! ;D' : 'no way :/' - } - -} - -const userConfig = new User() - -export default userConfig \ No newline at end of file diff --git a/src/store.js b/src/store.js index 1de1ae5..a002758 100644 --- a/src/store.js +++ b/src/store.js @@ -1,7 +1,6 @@ import Vue from "vue"; import Vuex from "vuex"; -import userModuleFromRoot from './userModuleFromRoot' Vue.use(Vuex); const cartModule = { @@ -33,7 +32,7 @@ const cartModule = { const store = new Vuex.Store({ modules: { cart: cartModule, - user: userModuleFromRoot, + user: {}, }, }); diff --git a/src/userModuleFromRoot.js b/src/userModuleFromRoot.js deleted file mode 100644 index ed029a4..0000000 --- a/src/userModuleFromRoot.js +++ /dev/null @@ -1,22 +0,0 @@ -export default { - namespaced: true, - state: { - user: null, - }, - mutations: { - SET_USER(state, user) { - state.user = user; - }, - }, - actions: { - setUser(context, user) { - context.commit("SET_USER", user); - }, - }, - getters: { - user: (state) => { - return state.user; - }, - }, -}; - diff --git a/vue.config.js b/vue.config.js index 9ca790e..4afcc1c 100644 --- a/vue.config.js +++ b/vue.config.js @@ -13,7 +13,6 @@ module.exports = { exposes: { "./userModuleFromRoot": "./src/userModuleFromRoot", "./userModuleFromRootByHelper": "./src/helper-modules/user.module", - "./store": "./src/store", }, remotes: { cart: process.env.REMOTE_CART, @@ -21,7 +20,6 @@ module.exports = { profile: process.env.REMOTE_PROFILE, root: process.env.REMOTE_ROOT, auth: process.env.REMOTE_AUTH, - store: process.env.REMOTE_STORE, ds: process.env.REMOTE_DS, }, shared: dependencies,