diff --git a/.env.development b/.env.development index 7ab15e0..53fa7f4 100644 --- a/.env.development +++ b/.env.development @@ -4,5 +4,5 @@ ENV = 'development' # base api VUE_APP_BASE_API = http://weiyuan-ziliao-test.ali251.langye.net VUE_APP_UPLOAD_API = http://weiyuan-ziliao-test.ali251.langye.net/api/admin/upload-file -VUE_APP_AUTH_BASE_API = https://sso.szhct.edu.cn/cas/oauth2.0/authorize +VUE_APP_AUTH_BASE_API = http://ids.szhct.edu.cn/authserver/oauth2.0/authorize VUE_APP_VIEW_API=http://view.ali251.langye.net:8012/onlinePreview diff --git a/.env.production b/.env.production index 13e9049..ca99c37 100644 --- a/.env.production +++ b/.env.production @@ -2,10 +2,12 @@ ENV='production' # base api -#VUE_APP_BASE_API=http://192.168.105.242 -VUE_APP_BASE_API = https://zlhb.szhct.edu.cn -#VUE_APP_UPLOAD_API=http://192.168.105.242/api/admin/upload-file -VUE_APP_UPLOAD_API = https://zlhb.szhct.edu.cn/api/admin/upload-file -VUE_APP_AUTH_BASE_API=https://sso.szhct.edu.cn/cas/oauth2.0/authorize +VUE_APP_BASE_API=http://192.168.105.242 +#VUE_APP_BASE_API = https://zlhb.szhct.edu.cn +VUE_APP_UPLOAD_API=http://192.168.105.242/api/admin/upload-file +#VUE_APP_UPLOAD_API = https://zlhb.szhct.edu.cn/api/admin/upload-file +#VUE_APP_AUTH_BASE_API=https://sso.szhct.edu.cn/cas/oauth2.0/authorize +VUE_APP_AUTH_BASE_API=http://ids.szhct.edu.cn/authserver/oauth2.0/authorize #VUE_APP_AUTH_BASE_API = https://zlhb.szhct.edu.cn/cas/oauth2.0/authorize VUE_APP_VIEW_API=https://zlhbview.szhct.edu.cn/onlinePreview +#VUE_APP_VIEW_API=http://192.168.105.242:8012/onlinePreview diff --git a/src/api/reception/index.js b/src/api/reception/index.js index d6111c5..bc89566 100644 --- a/src/api/reception/index.js +++ b/src/api/reception/index.js @@ -3,7 +3,8 @@ import {getToken} from "@/utils/auth"; export function login (params, isLoading = false) { return request({ - url: '/api/user/login', + url: '/api/user/login_v2', + //url: '/api/user/login', method: 'get', params, isLoading diff --git a/src/permission.js b/src/permission.js index 8a5269d..aee9712 100644 --- a/src/permission.js +++ b/src/permission.js @@ -12,6 +12,9 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration const whiteList = ['/login'] // no redirect whitelist +const verifyToken = (token) => { + return !(!token || token === "undefined" || token === "null" || token === "false"); +} router.beforeEach(async(to, from, next) => { // start progress bar NProgress.start() @@ -22,19 +25,26 @@ router.beforeEach(async(to, from, next) => { if (/^\/index\/.*/.test(to.path)) { //setToken('31|wFxoNgXTLwNke7CCjfCyFYd3x4s9WG74VKpYyi8S','ReceptionTokenKey') - if (getToken('ReceptionTokenKey')) { + if (verifyToken(getToken('ReceptionTokenKey'))) { next() } else { if (to.query.code) { login({ code: to.query.code }).then(res => { - setToken(res.token,'ReceptionTokenKey') - next() + if (res.token) { + setToken(res.token,'ReceptionTokenKey') + next() + } else { + Message.error("登录失败") + } + }).catch(err => { + Message.error("登录失败") }) } else { let redirectUri = encodeURIComponent(window.location.href) - let client_id = 'db85478e4dd36937' + let client_id = '1172128036016324608' // new + //let client_id = 'db85478e4dd36937' //let client_id = 'd05e4c9d07f705ef' dev window.location.href = `${process.env.VUE_APP_AUTH_BASE_API}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&scope=base_api&state=wyd` } @@ -45,7 +55,7 @@ router.beforeEach(async(to, from, next) => { // determine whether the user has logged in const hasToken = getToken() - if (hasToken) { + if (verifyToken(hasToken)) { if (to.path === '/login') { // if is logged in, redirect to the home page next({ path: '/' })