diff --git a/examples/App.vue b/examples/App.vue index 14fab565..e0591145 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -22,7 +22,7 @@ import SliderNav from "./components/sliderNav"; import MainContent from "./components/mainContent"; import HeaderNav from "./components/headerNav"; -import {mapMutations, mapState} from "vuex"; +import {mapActions, mapMutations, mapState} from "vuex"; export default { name: 'app', @@ -42,7 +42,8 @@ export default { } }, methods: { - ...mapMutations(['setToken']), + ...mapMutations(['setToken', 'setFinanceUser']), + ...mapActions(['getUserInfo']), getToken(params) { if (params.access_token) { this.setToken([params.token_type, params.access_token].join(' ')) @@ -52,16 +53,6 @@ export default { } else this.$message.error(params.msg || "登录失败!") }, - getUserInfo() { - this.$axios.post("/admin/user/detail-phone").then(res => { - if (res?.data) { - this.$store.commit("setUserInfo", res.data) - if (/^\/project\/xiushan/.test(location.pathname)) { - this.$store.commit("setFinanceUser") - } - } - }) - }, handleLogin() { this.$axios.delete("/auth/token/logout").finally(() => { this.dialog = true @@ -69,8 +60,12 @@ export default { }, }, created() { - if (this.user.token) this.getUserInfo() wx = jWeixin + if (this.user.token) this.getUserInfo().then(() => { + if (/^\/project\/xiushan/.test(location.pathname)) { + this.setFinanceUser() + } + }) } } diff --git a/examples/store/index.js b/examples/store/index.js index fb58e995..ef9e5f4d 100644 --- a/examples/store/index.js +++ b/examples/store/index.js @@ -2,56 +2,28 @@ import Vue from 'vue' import Vuex from 'vuex' import preState from 'vuex-persistedstate' import request from '../router/axios' +import * as modules from "dvcp-ui/lib/js/modules" Vue.use(Vuex) -const user = { - state: { - info: {}, - token: '', - financeUser: {} - }, - mutations: { - setFinanceUser(state) { - request.post("appfinancialorganizationuser/checkUser").then(res => { - state.financeUser = res.data - }) - }, - setUserInfo(state, userInfo) { - state.info = userInfo - }, - setToken(state, token) { - state.token = token - } - } -} - export default new Vuex.Store({ state: { dicts: [], apps: [] }, mutations: { - setDicts(state, payload) { - if (payload) { - payload.map(p => { - if (state.dicts.some(d => d.key == p.key)) { - const index = state.dicts.findIndex(d => d.key == p.key) - state.dicts.splice(index, 1) - state.dicts.push(p) - } else { - state.dicts.push(p) - } - }) - } - }, addApp(state, app) { state.apps.push(app) }, cleanApps(state) { state.apps = [] - } + }, + setFinanceUser(state) { + request.post("appfinancialorganizationuser/checkUser").then(res => { + state.user.financeUser = res.data + }) + }, }, - modules: {user}, + modules, plugins: [preState()] }) diff --git a/vue.config.js b/vue.config.js index 2378458e..dfb8aa5b 100644 --- a/vue.config.js +++ b/vue.config.js @@ -10,7 +10,7 @@ module.exports = { filename: 'index.html' } }, - transpileDependencies: [/node_modules[/\\]dvcp-ui(.+)utils.js/], + transpileDependencies: [/node_modules[/\\]dvcp-ui(.+)utils.js/, /node_modules[/\\]dvcp-ui(.+)modules.js/], chainWebpack: (config) => { config.module .rule('js')