Commit ae176f56 authored by lei's avatar lei

add:孵化器企业信息

parent 36fdc16d
// var ServiceURL = 'http://192.168.3.216:9002'; // var ServiceURL = 'http://192.168.3.216:9002';
// var ServiceURL = 'http://192.168.3.250:9103'; // var ServiceURL = 'http://192.168.3.250:9103';
var ServiceURL = 'http://gqfhq.gemho.cn:9103'; // 正式环境 // var ServiceURL = 'http://gqfhq.gemho.cn:9103'; // 正式环境
// var ServiceURL = 'http://192.168.3.226:9103' // 测试环境 var ServiceURL = "http://192.168.2.37:9103"; // 测试环境
window.VUE_APP_API = {ServiceURL:ServiceURL} window.VUE_APP_API = { ServiceURL: ServiceURL };
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
"codemirror": "^5.49.2", "codemirror": "^5.49.2",
"connect": "3.6.6", "connect": "3.6.6",
"core-js": "^2.6.12", "core-js": "^2.6.12",
"echarts": "^5.6.0",
"element-ui": "^2.13.2", "element-ui": "^2.13.2",
"file-saver": "1.3.8", "file-saver": "1.3.8",
"fuse.js": "3.4.4", "fuse.js": "3.4.4",
......
import router from './routers' import router from "./routers";
import store from '@/store' import store from "@/store";
import Config from '@/settings' import Config from "@/settings";
import NProgress from 'nprogress' // progress bar import NProgress from "nprogress"; // progress bar
import 'nprogress/nprogress.css'// progress bar style import "nprogress/nprogress.css"; // progress bar style
import { getToken } from '@/utils/auth' // getToken from cookie import { getToken } from "@/utils/auth"; // getToken from cookie
import { buildMenus } from '@/api/system/menu' import { buildMenus } from "@/api/system/menu";
import { filterAsyncRouter } from '@/store/modules/permission' import { filterAsyncRouter } from "@/store/modules/permission";
NProgress.configure({ showSpinner: false }) // NProgress Configuration NProgress.configure({ showSpinner: false }); // NProgress Configuration
const whiteList = ['/plus/login', '/register'] // no redirect whitelist const whiteList = ["/plus/login", "/register"]; // no redirect whitelist
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
if (to.meta.title) { if (to.meta.title) {
//document.title = to.meta.title + ' - ' + Config.title //document.title = to.meta.title + ' - ' + Config.title
document.title = to.meta.title document.title = to.meta.title;
} }
NProgress.start(); NProgress.start();
if (getToken()) { if (getToken()) {
// 已登录且要跳转的页面是登录页 // 已登录且要跳转的页面是登录页
if (to.path === '/plus/login') { if (to.path === "/plus/login") {
next({ path: '/' }) next({ path: "/" });
NProgress.done() NProgress.done();
} else { } else {
if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息 if (store.getters.roles.length === 0) {
store.dispatch('GetInfo').then(() => { // 拉取user_info // 判断当前用户是否已拉取完user_info信息
// 动态路由,拉取菜单 store
loadMenus(next, to) .dispatch("GetInfo")
}).catch(() => { .then(() => {
store.dispatch('LogOut').then(() => { // 拉取user_info
location.reload() // 为了重新实例化vue-router对象 避免bug // 动态路由,拉取菜单
}) loadMenus(next, to);
}) })
// 登录时未拉取 菜单,在此处拉取 .catch(() => {
} else if (store.getters.loadMenus) { store.dispatch("LogOut").then(() => {
// 修改成false,防止死循环 location.reload(); // 为了重新实例化vue-router对象 避免bug
store.dispatch('updateLoadMenus') });
loadMenus(next, to) });
} else { // 登录时未拉取 菜单,在此处拉取
next() } else if (store.getters.loadMenus) {
} // 修改成false,防止死循环
} store.dispatch("updateLoadMenus");
} else { loadMenus(next, to);
/* has no token*/ } else {
if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入 next();
next() }
} else { }
window.location.href = `/plus/login?redirect=${to.fullPath}`; } else {
NProgress.done() /* has no token*/
} if (whiteList.indexOf(to.path) !== -1) {
} // 在免登录白名单,直接进入
}) next();
} else {
window.location.href = `/plus/login?redirect=${to.fullPath}`;
NProgress.done();
}
}
});
export const loadMenus = (next, to) => { export const loadMenus = (next, to) => {
buildMenus().then(res => { buildMenus().then(res => {
const sdata = JSON.parse(JSON.stringify(res)) const sdata = JSON.parse(JSON.stringify(res));
const rdata = JSON.parse(JSON.stringify(res)) const rdata = JSON.parse(JSON.stringify(res));
const sidebarRoutes = filterAsyncRouter(sdata) const sidebarRoutes = filterAsyncRouter(sdata);
const rewriteRoutes = filterAsyncRouter(rdata, true) const rewriteRoutes = filterAsyncRouter(rdata, true);
rewriteRoutes.push({ path: '*', redirect: '/404', hidden: true }) rewriteRoutes.push({ path: "*", redirect: "/404", hidden: true });
store.dispatch('GenerateRoutes', rewriteRoutes).then(() => { // 存储路由 store.dispatch("GenerateRoutes", rewriteRoutes).then(() => {
router.addRoutes(rewriteRoutes) // 动态添加可访问路由表 // 存储路由
next({ ...to, replace: true }) router.addRoutes(rewriteRoutes); // 动态添加可访问路由表
}) next({ ...to, replace: true });
store.dispatch('SetSidebarRouters', sidebarRoutes) });
}) store.dispatch("SetSidebarRouters", sidebarRoutes);
} });
};
router.afterEach(() => { router.afterEach(() => {
NProgress.done() // finish progress bar NProgress.done(); // finish progress bar
}) });
import axios from 'axios' import axios from "axios";
import { Notification } from 'element-ui' import { Notification } from "element-ui";
import { getToken } from '@/utils/auth' import { getToken } from "@/utils/auth";
import Config from '@/settings' import Config from "@/settings";
// 使请求头可以携带cookie // 使请求头可以携带cookie
axios.defaults.withCredentials = true; axios.defaults.withCredentials = true;
//var baseURL = (VUE_APP_API.ServiceURL || process.env.VUE_APP_LOCAL_API) + '/'; //var baseURL = (VUE_APP_API.ServiceURL || process.env.VUE_APP_LOCAL_API) + '/';
var baseURL = process.env.NODE_ENV var baseURL =
=== 'development' ? process.env.VUE_APP_LOCAL_API + '/' : (VUE_APP_API.ServiceURL || process.env.VUE_APP_LOCAL_API) + '/'; process.env.NODE_ENV === "development"
? process.env.VUE_APP_BASE_API + "/"
: (VUE_APP_API.ServiceURL || process.env.VUE_APP_BASE_API) + "/";
// 创建axios实例 // 创建axios实例
const service = axios.create({ const service = axios.create({
baseURL: baseURL, baseURL: baseURL,
timeout: Config.timeout // 请求超时时间 timeout: Config.timeout // 请求超时时间
}) });
// request拦截器 // request拦截器
service.interceptors.request.use( service.interceptors.request.use(
config => { config => {
if (getToken()) { if (getToken()) {
config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 config.headers["Authorization"] = getToken(); // 让每个请求携带自定义token 请根据实际情况自行修改
} }
config.headers['Content-Type'] = 'application/json' config.headers["Content-Type"] = "application/json";
return config return config;
}, },
error => { error => {
Promise.reject(error) Promise.reject(error);
} }
) );
// response 拦截器 // response 拦截器
service.interceptors.response.use( service.interceptors.response.use(
response => { response => {
return response.data return response.data;
}, },
error => { error => {
if (error.response.status) { if (error.response.status) {
const responseCode = error.response.status const responseCode = error.response.status;
switch (responseCode) { switch (responseCode) {
case 400: case 400:
Notification({ Notification({
title: error.response.data.msg, title: error.response.data.msg,
duration: 2000, duration: 2000,
type: 'warning' type: "warning"
}) });
break break;
// token 过期 // token 过期
case 401: case 401:
Notification({ Notification({
title: '登录过期,请重新登录', title: "登录过期,请重新登录",
duration: 2000, duration: 2000,
type: 'warning' type: "warning"
}) });
setTimeout(() => { // setTimeout(() => {
window.localStorage.removeItem('token') // window.localStorage.removeItem("token");
window.location = '#/'; // // window.location = '#/';
location.reload() // location.reload();
}, 1000) // }, 1000);
break break;
default: default:
break break;
} }
return error.response.data return error.response.data;
} }
} }
) );
export default service export default service;
This diff is collapsed.
This diff is collapsed.
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