master
xy 1 year ago
parent 50837e66ed
commit 3480b55d09

@ -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

@ -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

@ -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

@ -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: '/' })

Loading…
Cancel
Save