parent
78c5bffcce
commit
d8cf875a85
@ -1,18 +1,24 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import Vue from 'vue';
|
||||
import App from './App.vue';
|
||||
import ElementUI from 'element-ui';
|
||||
import 'element-ui/lib/theme-chalk/index.css';
|
||||
import './assets/gloable.css'
|
||||
import './assets/gloable.css';
|
||||
import store from './store'; // 确保这个路径是正确的
|
||||
import router from './router';
|
||||
import request from "@/utils/request";
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
// 使用 ElementUI 组件库
|
||||
Vue.use(ElementUI, { size: 'small' });
|
||||
|
||||
Vue.prototype.request=request
|
||||
// 将 request 注册为 Vue 的实例属性
|
||||
Vue.prototype.request = request;
|
||||
|
||||
// 关闭生产提示
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
// 创建 Vue 实例
|
||||
new Vue({
|
||||
store, // 确保 Vuex store 被正确注册
|
||||
router,
|
||||
render: h => h(App)
|
||||
}).$mount('#app')
|
||||
render: h => h(App),
|
||||
}).$mount('#app');
|
||||
|
@ -0,0 +1,28 @@
|
||||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
token: localStorage.getItem('Authorization') || '', // 初始化 token
|
||||
},
|
||||
mutations: {
|
||||
setToken(state, token) {
|
||||
state.token = token;
|
||||
localStorage.setItem('Authorization', token);
|
||||
},
|
||||
clearToken(state) {
|
||||
state.token = '';
|
||||
localStorage.removeItem('Authorization');
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
setToken({ commit }, token) {
|
||||
commit('setToken', token);
|
||||
},
|
||||
clearToken({ commit }) {
|
||||
commit('clearToken');
|
||||
},
|
||||
},
|
||||
});
|
Loading…
Reference in new issue