Commit 0e8bdb14 by 黑潮

update: 修改

parent ce0bc314
...@@ -16,75 +16,76 @@ import '../static/font/iconfont.css'; // iconfont ...@@ -16,75 +16,76 @@ import '../static/font/iconfont.css'; // iconfont
import '../theme/index.css'; // 新主题 import '../theme/index.css'; // 新主题
import './assets/common.css'; import './assets/common.css';
import filters from './filters/index.js'; import filters from './filters/index.js';
window.getLimit(router, 'haoban-devops').then(() => {
Vue.config.productionTip = false;
Vue.use(ElementUI); Vue.config.productionTip = false;
Vue.use(VueAxios, axios);
// 注册一个全局自定义指令 `v-focus` Vue.use(ElementUI);
Vue.directive('focus', function (el) { Vue.use(VueAxios, axios);
el.querySelector('input').focus();
});
// 全局注册过滤器
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key]);
});
Vue.prototype.axios.withCredentials = true; // 跨域cookie访问 // 注册一个全局自定义指令 `v-focus`
Vue.directive('focus', function(el) {
el.querySelector('input').focus();
});
// 全局注册过滤器
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key]);
});
window.$bus = new Vue(); // 全局事件 Vue.prototype.axios.withCredentials = true; // 跨域cookie访问
// Vue.axios.defaults.baseURL = process.env['NODE_ENV'] === 'development' ? 'http://gicdev.demogic.com' : 'https://hope.demogic.com/'; window.$bus = new Vue(); // 全局事件
Vue.axios.interceptors.request.use(
config => { // Vue.axios.defaults.baseURL = process.env['NODE_ENV'] === 'development' ? 'http://gicdev.demogic.com' : 'https://hope.demogic.com/';
return config; Vue.axios.interceptors.request.use(
}, config => {
err => { return config;
return Promise.reject(err); },
} err => {
); return Promise.reject(err);
Vue.axios.interceptors.response.use( }
response => { );
if (response.status == 200) { Vue.axios.interceptors.response.use(
if (response.data.errorCode == 4002 || response.data.errorCode == 4011) { response => {
// 加上登录页 if (response.status == 200) {
window.location.href = window.location.origin + '/operation-platform/#/'; if (response.data.errorCode == 4002 || response.data.errorCode == 4011) {
} // 加上登录页
window.location.href = window.location.origin + '/operation-platform/#/';
} }
return response; }
}, return response;
error => { },
if (error.response) { error => {
switch (error.response.status) { if (error.response) {
case 401: switch (error.response.status) {
if (error.response.data.errorCode == 4011) { case 401:
ElementUI.MessageBox.confirm(error.response.data.message, '提示', { if (error.response.data.errorCode == 4011) {
confirmButtonText: '知道了', ElementUI.MessageBox.confirm(error.response.data.message, '提示', {
showCancelButton: false, confirmButtonText: '知道了',
type: 'warning' showCancelButton: false,
type: 'warning'
})
.then(_ => {
window.location.href = window.location.origin + '/operation-platform/#/';
}) })
.then(_ => { .catch(() => {});
window.location.href = window.location.origin + '/operation-platform/#/'; } else {
}) // 加上登录页
.catch(() => { }); window.location.href = window.location.origin + '/operation-platform/#/';
} else { }
// 加上登录页 break;
window.location.href = window.location.origin + '/operation-platform/#/'; case 403:
} if (error.response.data.errorCode == 4004) {
break; ElementUI.Message.error(error.response.data.message);
case 403: }
if (error.response.data.errorCode == 4004) { break;
ElementUI.Message.error(error.response.data.message);
}
break;
}
} }
return Promise.reject(error.response.status.toString());
} }
); return Promise.reject(error.response.status.toString());
}
);
/* eslint-disable no-new */ /* eslint-disable no-new */
window.getLimit(router, 'haoban-devops').then(() => {
new Vue({ new Vue({
el: '#app', el: '#app',
router, router,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment