diff --git a/eng_management_version6.zip b/eng_management_version6.zip deleted file mode 100644 index f800b7b..0000000 Binary files a/eng_management_version6.zip and /dev/null differ diff --git a/src/permission.js b/src/permission.js index a268bd2..6edb396 100644 --- a/src/permission.js +++ b/src/permission.js @@ -20,6 +20,20 @@ router.beforeEach(async(to, from, next) => { // determine whether the user has logged in const hasToken = getToken() + // 检查当前环境 + const isDevelopment = process.env.NODE_ENV === 'development' + const isProduction = process.env.NODE_ENV === 'production' + + // 根据环境启用或禁用某些代码 + // 开发环境不启用ONEID + if (isDevelopment) { + console.log('开发环境,启用某些代码') + // 启用某些代码 + } else if (isProduction) { + console.log('生产环境,禁用某些代码') + // 禁用某些代码 + } + if (hasToken) { if (to.path === '/login' || to.path === '/callback') { // if is logged in, redirect to the home page @@ -39,9 +53,12 @@ router.beforeEach(async(to, from, next) => { // remove token and go to login page to re-login await store.dispatch('user/resetToken') Message.error(error || 'Has Error') - // next(`/login?redirect=${to.path}`) - // NProgress.done() - window.location.href = '' + if (isDevelopment) { + next(`/login?redirect=${to.path}`) + NProgress.done() + } else { + window.location.href = '' + } } } } @@ -52,9 +69,12 @@ router.beforeEach(async(to, from, next) => { next() } else { // other pages that do not have permission to access are redirected to the login page. - // next(`/login?redirect=${to.path}`) - window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' - // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://localhost:9528/callback&scope=openid%20phone' + if (isDevelopment) { + next(`/login?redirect=${to.path}`) + } else { + window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://csdc.siemens.com.cn:8001/callback&scope=openid%20phone' + // window.location.href = 'https://api.oneid.siemens.com.cn/api/bff/v1.2/developer/ciam/oauth/authorize?client_id=1b867769c8cb221fb7fdb0f8beba6138TwXkI4mX8um&response_type=code&redirect_uri=http://localhost:9528/callback&scope=openid%20phone' + } NProgress.done() } }