mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-07 01:46:42 +08:00
Compare commits
29 Commits
master
...
ebiz-uat-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
738add6f18 | ||
|
|
a7763057c4 | ||
|
|
421e2b2c51 | ||
|
|
12e91854fe | ||
|
|
3852a92ab3 | ||
|
|
56103bbdf6 | ||
|
|
d2f3b2d79c | ||
|
|
4e1940b36f | ||
|
|
3e344a8374 | ||
|
|
82598dd5e0 | ||
|
|
da72c156e9 | ||
|
|
f731bb425f | ||
|
|
8c2f128578 | ||
|
|
f16c6eb157 | ||
|
|
6016e00ae8 | ||
|
|
7155976f31 | ||
|
|
4ca01ba233 | ||
|
|
7368fa7a8c | ||
|
|
d09cbfac5f | ||
|
|
fd903d0974 | ||
|
|
42885e0d61 | ||
|
|
0b3b9ad082 | ||
|
|
38fe538e4e | ||
|
|
052ab0be6f | ||
|
|
4c453e3974 | ||
|
|
47dde458de | ||
|
|
3701605f7a | ||
|
|
b021be2f6f | ||
|
|
11e34ca335 |
14
src/App.vue
14
src/App.vue
@@ -87,4 +87,16 @@
|
|||||||
border: 1px solid #e7e7e7 !important;
|
border: 1px solid #e7e7e7 !important;
|
||||||
box-shadow: 0px 1px 5px 1px rgba(92,98,111,.3);
|
box-shadow: 0px 1px 5px 1px rgba(92,98,111,.3);
|
||||||
}
|
}
|
||||||
</style>
|
|
||||||
|
#app {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app > *:not(.case-expert-dialog) {
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.case-expert-dialog {
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
241
src/api/ajax.js
241
src/api/ajax.js
@@ -19,88 +19,93 @@ import errorCode from '@/utils/errorCode'
|
|||||||
|
|
||||||
|
|
||||||
// const ReLoginUrl=process.env.VUE_APP_LOGIN_URL;
|
// const ReLoginUrl=process.env.VUE_APP_LOGIN_URL;
|
||||||
const TokenName='XBOE-Access-Token';
|
const TokenName = 'XBOE-Access-Token';
|
||||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||||
//只是用于发送json对象数据时使用post,put,patch
|
//只是用于发送json对象数据时使用post,put,patch
|
||||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||||
//只是用于发送json对象数据时使用post,put,patch
|
//只是用于发送json对象数据时使用post,put,patch
|
||||||
//用于普通的发送请求
|
//用于普通的发送请求
|
||||||
const formRequest=axios.create({
|
const formRequest = axios.create({
|
||||||
// headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
// headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
// baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
|
// baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
})
|
})
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
formRequest.interceptors.request.use(config => {
|
formRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
});
|
});
|
||||||
formRequest.interceptors.response.use(res => {
|
formRequest.interceptors.response.use(res => {
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
} else {
|
||||||
if(code === 401){
|
if (code === 401) {
|
||||||
//Message({message: msg, type: 'error'});
|
//Message({message: msg, type: 'error'});
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = this.webBaseUrl + ReLoginUrl;
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
})
|
top.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
}else if(code===403){
|
} else {
|
||||||
var msg='当前操作没有权限';
|
window.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
Message({message: msg, type: 'error'});
|
}
|
||||||
return Promise.reject(new Error(msg))
|
// location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
}else{
|
})
|
||||||
//Message({message: res.data.message, type: 'error'});
|
} else if (code === 403) {
|
||||||
//console.log('err' + res.data.error);
|
var msg = '当前操作没有权限';
|
||||||
return res.data
|
Message({ message: msg, type: 'error' });
|
||||||
}
|
return Promise.reject(new Error(msg))
|
||||||
}
|
} else {
|
||||||
},
|
//Message({message: res.data.message, type: 'error'});
|
||||||
error => {
|
//console.log('err' + res.data.error);
|
||||||
|
return res.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => {
|
||||||
console.log('err' + error)
|
console.log('err' + error)
|
||||||
let { message } = error;
|
let { message } = error;
|
||||||
if (message == "Network Error") {
|
if (message == "Network Error") {
|
||||||
message = "网络异常,请稍后重试";
|
message = "网络异常,请稍后重试";
|
||||||
}
|
}
|
||||||
else if (message.includes("timeout")) {
|
else if (message.includes("timeout")) {
|
||||||
message = "网络异常或接口错误,请求超时";
|
message = "网络异常或接口错误,请求超时";
|
||||||
}
|
}
|
||||||
else if (message.includes("Request failed with status code")) {
|
else if (message.includes("Request failed with status code")) {
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
}
|
}
|
||||||
Message({
|
Message({
|
||||||
message: message,
|
message: message,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
duration: 5 * 1000
|
duration: 5 * 1000
|
||||||
})
|
})
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* request请求,可以自定义参数
|
* request请求,可以自定义参数
|
||||||
*/
|
*/
|
||||||
const request=formRequest.request;
|
const request = formRequest.request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get请求 ,只有url
|
* get请求 ,只有url
|
||||||
*/
|
*/
|
||||||
const get = function(baseURL,url){
|
const get = function (baseURL, url) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'}
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,61 +113,61 @@ const get = function(baseURL,url){
|
|||||||
* @param {Object} url
|
* @param {Object} url
|
||||||
* @param {Object} postData
|
* @param {Object} postData
|
||||||
*/
|
*/
|
||||||
const post=function(baseURL,url,postData){
|
const post = function (baseURL, url, postData) {
|
||||||
if(postData){
|
if (postData) {
|
||||||
postData=qs.stringify(postData);
|
postData = qs.stringify(postData);
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data:postData,
|
data: postData,
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'}
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//post请求
|
//post请求
|
||||||
const postForm=function(baseURL,url,data){
|
const postForm = function (baseURL, url, data) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url,
|
url,
|
||||||
data,
|
data,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'}
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// const postJson=jsonRequest.post;
|
// const postJson=jsonRequest.post;
|
||||||
|
|
||||||
const postJson=function(baseURL,url,postData){
|
const postJson = function (baseURL, url, postData) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data:postData,
|
data: postData,
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const postPdf=function(baseURL,url,postData){
|
const postPdf = function (baseURL, url, postData) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data:postData,
|
data: postData,
|
||||||
headers:{'Content-Type':'application/pdf'},
|
headers: { 'Content-Type': 'application/pdf' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出文件请求定义
|
// 导出文件请求定义
|
||||||
const postJsonToFile=function(baseURL,url,postData){
|
const postJsonToFile = function (baseURL, url, postData) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data:postData,
|
data: postData,
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,39 +175,39 @@ const postJsonToFile=function(baseURL,url,postData){
|
|||||||
/**
|
/**
|
||||||
* put请求
|
* put请求
|
||||||
*/
|
*/
|
||||||
const put=function(baseURL,url,data){
|
const put = function (baseURL, url, data) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data:data,
|
data: data,
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'}
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const putJson=function(baseURL,url,data){
|
const putJson = function (baseURL, url, data) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data:data,
|
data: data,
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
tokenName:TokenName,
|
tokenName: TokenName,
|
||||||
request,
|
request,
|
||||||
get,
|
get,
|
||||||
post,
|
post,
|
||||||
postJson,
|
postJson,
|
||||||
postJsonToFile,
|
postJsonToFile,
|
||||||
put,
|
put,
|
||||||
putJson,
|
putJson,
|
||||||
postPdf,
|
postPdf,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,90 +19,95 @@ import errorCode from '@/utils/errorCode'
|
|||||||
|
|
||||||
|
|
||||||
// const ReLoginUrl=process.env.VUE_APP_LOGIN_URL;
|
// const ReLoginUrl=process.env.VUE_APP_LOGIN_URL;
|
||||||
const TokenName='token';
|
const TokenName = 'token';
|
||||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||||
//只是用于发送json对象数据时使用post,put,patch
|
//只是用于发送json对象数据时使用post,put,patch
|
||||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||||
//只是用于发送json对象数据时使用post,put,patch
|
//只是用于发送json对象数据时使用post,put,patch
|
||||||
//用于普通的发送请求
|
//用于普通的发送请求
|
||||||
const formRequest=axios.create({
|
const formRequest = axios.create({
|
||||||
// headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
// headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
// baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
|
// baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
})
|
})
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
formRequest.interceptors.request.use(config => {
|
formRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
let curToken=getToken();
|
let curToken = getToken();
|
||||||
//curToken='eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91LmJvZS5jb20iLCJpYXQiOjE2NzIzMTE2MTIsImV4cCI6MTY3MjMxODgxMiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVzZXJJZCI6IjZCMDQ5RkFGLUMzMTQtN0NDRi0wRDI4LTBEMjNGNEM0MjUzMSIsInVJZCI6Ijk2NTM0MjAyNzQ5NzYwNzE2OCIsInBlcm1pc3Npb24iOiIifQ==.a4f41376e994c5fcd3ab537ce17572ef4c633863f87785cf7b6ffa353e2ed51c';
|
//curToken='eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC91LmJvZS5jb20iLCJpYXQiOjE2NzIzMTE2MTIsImV4cCI6MTY3MjMxODgxMiwiR2l2ZW5OYW1lIjoiYm9ldSIsInVzZXJJZCI6IjZCMDQ5RkFGLUMzMTQtN0NDRi0wRDI4LTBEMjNGNEM0MjUzMSIsInVJZCI6Ijk2NTM0MjAyNzQ5NzYwNzE2OCIsInBlcm1pc3Npb24iOiIifQ==.a4f41376e994c5fcd3ab537ce17572ef4c633863f87785cf7b6ffa353e2ed51c';
|
||||||
if (curToken && !isToken) {
|
if (curToken && !isToken) {
|
||||||
config.headers[TokenName] = curToken // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = curToken // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
});
|
});
|
||||||
formRequest.interceptors.response.use(res => {
|
formRequest.interceptors.response.use(res => {
|
||||||
//console.log(res);
|
//console.log(res);
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
} else {
|
||||||
if(code === 401){
|
if (code === 401) {
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = this.webBaseUrl + ReLoginUrl;
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
})
|
top.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
}else if(code===403){
|
} else {
|
||||||
var msg='当前操作没有权限';
|
window.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
Message({message: msg, type: 'error'});
|
}
|
||||||
return Promise.reject(new Error(msg))
|
// location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
}else{
|
})
|
||||||
//Message({message: res.data.message, type: 'error'});
|
} else if (code === 403) {
|
||||||
//console.log('err' + res.data.error);
|
var msg = '当前操作没有权限';
|
||||||
return res.data
|
Message({ message: msg, type: 'error' });
|
||||||
}
|
return Promise.reject(new Error(msg))
|
||||||
}
|
} else {
|
||||||
},
|
//Message({message: res.data.message, type: 'error'});
|
||||||
error => {
|
//console.log('err' + res.data.error);
|
||||||
console.log('err',error)
|
return res.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log('err', error)
|
||||||
let { message } = error;
|
let { message } = error;
|
||||||
if (message == "Network Error") {
|
if (message == "Network Error") {
|
||||||
message = "网络异常,请稍后重试";
|
message = "网络异常,请稍后重试";
|
||||||
}
|
}
|
||||||
else if (message.includes("timeout")) {
|
else if (message.includes("timeout")) {
|
||||||
message = "网络异常或接口错误,请求超时";
|
message = "网络异常或接口错误,请求超时";
|
||||||
}
|
}
|
||||||
else if (message.includes("Request failed with status code")) {
|
else if (message.includes("Request failed with status code")) {
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
}
|
}
|
||||||
Message({
|
Message({
|
||||||
message: message,
|
message: message,
|
||||||
type: 'error',
|
type: 'error',
|
||||||
duration: 5 * 1000
|
duration: 5 * 1000
|
||||||
})
|
})
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* request请求,可以自定义参数
|
* request请求,可以自定义参数
|
||||||
*/
|
*/
|
||||||
const request=formRequest.request;
|
const request = formRequest.request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get请求 ,只有url
|
* get请求 ,只有url
|
||||||
*/
|
*/
|
||||||
const get = function(baseURL,url){
|
const get = function (baseURL, url) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'}
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -110,49 +115,49 @@ const get = function(baseURL,url){
|
|||||||
* @param {Object} url
|
* @param {Object} url
|
||||||
* @param {Object} postData
|
* @param {Object} postData
|
||||||
*/
|
*/
|
||||||
const post=function(baseURL,url,postData){
|
const post = function (baseURL, url, postData) {
|
||||||
if(postData){
|
if (postData) {
|
||||||
postData=qs.stringify(postData);
|
postData = qs.stringify(postData);
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data:postData,
|
data: postData,
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'}
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//post请求
|
//post请求
|
||||||
const postForm=function(baseURL,url,data){
|
const postForm = function (baseURL, url, data) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url,
|
url,
|
||||||
data,
|
data,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'}
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// const postJson=jsonRequest.post;
|
// const postJson=jsonRequest.post;
|
||||||
|
|
||||||
const postJson=function(baseURL,url,postData){
|
const postJson = function (baseURL, url, postData) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data:postData,
|
data: postData,
|
||||||
headers:{'Content-Type':'application/json'},
|
headers: { 'Content-Type': 'application/json' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出文件请求定义
|
// 导出文件请求定义
|
||||||
const postJsonToFile=function(baseURL,url,postData){
|
const postJsonToFile = function (baseURL, url, postData) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data:postData,
|
data: postData,
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
responseType: 'blob'
|
responseType: 'blob'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,38 +165,38 @@ const postJsonToFile=function(baseURL,url,postData){
|
|||||||
/**
|
/**
|
||||||
* put请求
|
* put请求
|
||||||
*/
|
*/
|
||||||
const put=function(baseURL,url,data){
|
const put = function (baseURL, url, data) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data:data,
|
data: data,
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'}
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const putJson=function(baseURL,url,data){
|
const putJson = function (baseURL, url, data) {
|
||||||
return request({
|
return request({
|
||||||
baseURL,
|
baseURL,
|
||||||
url: url,
|
url: url,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data:data,
|
data: data,
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
tokenName:TokenName,
|
tokenName: TokenName,
|
||||||
request,
|
request,
|
||||||
get,
|
get,
|
||||||
post,
|
post,
|
||||||
postJson,
|
postJson,
|
||||||
postJsonToFile,
|
postJsonToFile,
|
||||||
put,
|
put,
|
||||||
putJson,
|
putJson,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,191 +18,201 @@ import errorCode from '@/utils/errorCode'
|
|||||||
*delete请求 axios.delete(url[, config])
|
*delete请求 axios.delete(url[, config])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ReLoginUrl=process.env.VUE_APP_LOGIN_URL;
|
const ReLoginUrl = process.env.VUE_APP_LOGIN_URL;
|
||||||
const TokenName='token';
|
const TokenName = 'token';
|
||||||
|
|
||||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||||
//只是用于发送json对象数据时使用post,put,patch
|
//只是用于发送json对象数据时使用post,put,patch
|
||||||
const jsonRequest=axios.create({
|
const jsonRequest = axios.create({
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_BOE_BASE_API,
|
baseURL: process.env.VUE_APP_BOE_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
});
|
});
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
jsonRequest.interceptors.request.use(config => {
|
jsonRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
jsonRequest.interceptors.response.use(res => {
|
jsonRequest.interceptors.response.use(res => {
|
||||||
|
|
||||||
const code1 = res.data.status || 200;
|
const code1 = res.data.status || 200;
|
||||||
const code=parseInt(code1);
|
const code = parseInt(code1);
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
} else {
|
||||||
if(code == 6001){ //对方是字符串,所以这里不要使用三个等号
|
if (code == 6001) { //对方是字符串,所以这里不要使用三个等号
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = ReLoginUrl;
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
})
|
top.location.href = ReLoginUrl;
|
||||||
}else if(code===403){
|
} else {
|
||||||
var msg='当前操作没有权限';
|
window.location.href = ReLoginUrl;
|
||||||
Message({message: msg, type: 'error'});
|
}
|
||||||
return Promise.reject(new Error(msg))
|
// location.href = ReLoginUrl;
|
||||||
//return res.data;
|
})
|
||||||
}else{
|
} else if (code === 403) {
|
||||||
//Message({message: res.data.message, type: 'error'});
|
var msg = '当前操作没有权限';
|
||||||
//console.log('err:' + res.data.error);
|
Message({ message: msg, type: 'error' });
|
||||||
//return Promise.reject(new Error(res.data.message))
|
return Promise.reject(new Error(msg))
|
||||||
return res.data;
|
//return res.data;
|
||||||
}
|
} else {
|
||||||
}
|
//Message({message: res.data.message, type: 'error'});
|
||||||
},
|
//console.log('err:' + res.data.error);
|
||||||
error => {
|
//return Promise.reject(new Error(res.data.message))
|
||||||
console.log('err' + error)
|
return res.data;
|
||||||
let { message } = error;
|
}
|
||||||
if (message == "Network Error") {
|
}
|
||||||
message = "网络异常,请稍后重试";
|
},
|
||||||
}
|
error => {
|
||||||
else if (message.includes("timeout")) {
|
console.log('err' + error)
|
||||||
message = "系统接口请求超时";
|
let { message } = error;
|
||||||
//location.href = this.webBaseUrl + ReLoginUrl;
|
if (message == "Network Error") {
|
||||||
}
|
message = "网络异常,请稍后重试";
|
||||||
else if (message.includes("Request failed with status code")) {
|
}
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
else if (message.includes("timeout")) {
|
||||||
}
|
message = "系统接口请求超时";
|
||||||
Message({
|
//location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
message: message,
|
}
|
||||||
type: 'error',
|
else if (message.includes("Request failed with status code")) {
|
||||||
duration: 5 * 1000
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
})
|
}
|
||||||
return Promise.reject(error)
|
Message({
|
||||||
}
|
message: message,
|
||||||
|
type: 'error',
|
||||||
|
duration: 5 * 1000
|
||||||
|
})
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//用于普通的发送请求
|
//用于普通的发送请求
|
||||||
const formRequest=axios.create({
|
const formRequest = axios.create({
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_BOE_BASE_API,
|
baseURL: process.env.VUE_APP_BOE_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
})
|
})
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
formRequest.interceptors.request.use(config => {
|
formRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
});
|
});
|
||||||
formRequest.interceptors.response.use(res => {
|
formRequest.interceptors.response.use(res => {
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
} else {
|
||||||
if(code == 6001){ //对方是字符串,所以这里不要使用三个等号
|
if (code == 6001) { //对方是字符串,所以这里不要使用三个等号
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = ReLoginUrl;
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
})
|
top.location.href = ReLoginUrl;
|
||||||
}else if(code===403){
|
} else {
|
||||||
var msg='当前操作没有权限';
|
window.location.href = ReLoginUrl;
|
||||||
Message({message: msg, type: 'error'});
|
}
|
||||||
return Promise.reject(new Error(msg))
|
// location.href = ReLoginUrl;
|
||||||
}else{
|
})
|
||||||
//Message({message: res.data.message, type: 'error'});
|
} else if (code === 403) {
|
||||||
//console.log('err' + res.data.error);
|
var msg = '当前操作没有权限';
|
||||||
//return Promise.reject(new Error(res.data.message))
|
Message({ message: msg, type: 'error' });
|
||||||
return res.data;//返回给用户做业务处理
|
return Promise.reject(new Error(msg))
|
||||||
}
|
} else {
|
||||||
}
|
//Message({message: res.data.message, type: 'error'});
|
||||||
},
|
//console.log('err' + res.data.error);
|
||||||
error => {
|
//return Promise.reject(new Error(res.data.message))
|
||||||
console.log('err' + error)
|
return res.data;//返回给用户做业务处理
|
||||||
let { message } = error;
|
}
|
||||||
if (message == "Network Error") {
|
}
|
||||||
message = "网络异常,请稍后重试";
|
},
|
||||||
}
|
error => {
|
||||||
else if (message.includes("timeout")) {
|
console.log('err' + error)
|
||||||
message = "系统接口请求超时";
|
let { message } = error;
|
||||||
//location.href = this.webBaseUrl + ReLoginUrl;
|
if (message == "Network Error") {
|
||||||
}
|
message = "网络异常,请稍后重试";
|
||||||
else if (message.includes("Request failed with status code")) {
|
}
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
else if (message.includes("timeout")) {
|
||||||
}
|
message = "系统接口请求超时";
|
||||||
Message({
|
//location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
message: message,
|
}
|
||||||
type: 'error',
|
else if (message.includes("Request failed with status code")) {
|
||||||
duration: 5 * 1000
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
})
|
}
|
||||||
return Promise.reject(error)
|
Message({
|
||||||
}
|
message: message,
|
||||||
|
type: 'error',
|
||||||
|
duration: 5 * 1000
|
||||||
|
})
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//request请求
|
//request请求
|
||||||
const request=function(cfg){
|
const request = function (cfg) {
|
||||||
if(cfg.data){
|
if (cfg.data) {
|
||||||
cfg.data=qs.stringify(cfg.data);
|
cfg.data = qs.stringify(cfg.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//requestJson请求
|
//requestJson请求
|
||||||
const requestJson=jsonRequest.request;
|
const requestJson = jsonRequest.request;
|
||||||
//get请求
|
//get请求
|
||||||
const get=formRequest.request;
|
const get = formRequest.request;
|
||||||
//post请求
|
//post请求
|
||||||
const post=function(url,data,config){
|
const post = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.post(url,data,config);
|
return formRequest.post(url, data, config);
|
||||||
}
|
}
|
||||||
//postJson请求
|
//postJson请求
|
||||||
const postJson=jsonRequest.post;
|
const postJson = jsonRequest.post;
|
||||||
//put请求
|
//put请求
|
||||||
const put=function(url,data,config){
|
const put = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.put(url,data,config);
|
return formRequest.put(url, data, config);
|
||||||
}
|
}
|
||||||
//putJson请求
|
//putJson请求
|
||||||
const putJson=jsonRequest.put;
|
const putJson = jsonRequest.put;
|
||||||
//patch请求
|
//patch请求
|
||||||
const patch=function(url,data,config){
|
const patch = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.patch(url,data,config);
|
return formRequest.patch(url, data, config);
|
||||||
}
|
}
|
||||||
//patchJson请求
|
//patchJson请求
|
||||||
const patchJson=jsonRequest.patch;
|
const patchJson = jsonRequest.patch;
|
||||||
//delete请求
|
//delete请求
|
||||||
const del=formRequest.delete;
|
const del = formRequest.delete;
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
request,
|
request,
|
||||||
requestJson,
|
requestJson,
|
||||||
get,
|
get,
|
||||||
post,
|
post,
|
||||||
postJson,
|
postJson,
|
||||||
put,
|
put,
|
||||||
putJson,
|
putJson,
|
||||||
patch,
|
patch,
|
||||||
patchJson,
|
patchJson,
|
||||||
del
|
del
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,186 +16,196 @@ import errorCode from '@/utils/errorCode'
|
|||||||
*patchJson请求 axios.patch(url[, data[, config]])
|
*patchJson请求 axios.patch(url[, data[, config]])
|
||||||
*delete请求 axios.delete(url[, config])
|
*delete请求 axios.delete(url[, config])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ReLoginUrl="/login";
|
const ReLoginUrl = "/login";
|
||||||
const TokenName='XBOE-Access-Token';
|
const TokenName = 'XBOE-Access-Token';
|
||||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||||
//只是用于发送json对象数据时使用post,put,patch
|
//只是用于发送json对象数据时使用post,put,patch
|
||||||
const jsonRequest=axios.create({
|
const jsonRequest = axios.create({
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
|
baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
});
|
});
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
jsonRequest.interceptors.request.use(config => {
|
jsonRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
jsonRequest.interceptors.response.use(res => {
|
jsonRequest.interceptors.response.use(res => {
|
||||||
|
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
} else {
|
||||||
if(code === 401){
|
if (code === 401) {
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = this.webBaseUrl + ReLoginUrl;
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
})
|
top.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
}else if(code===403){
|
} else {
|
||||||
var msg='当前操作没有权限';
|
window.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
Message({message: msg, type: 'error'});
|
}
|
||||||
return Promise.reject(new Error(msg))
|
// location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
}else{
|
})
|
||||||
//Message({message: res.data.message, type: 'error'});
|
} else if (code === 403) {
|
||||||
//console.log('err:' + res.data.error);
|
var msg = '当前操作没有权限';
|
||||||
return res.data;
|
Message({ message: msg, type: 'error' });
|
||||||
//return Promise.reject(new Error(res.data.message))
|
return Promise.reject(new Error(msg))
|
||||||
}
|
} else {
|
||||||
}
|
//Message({message: res.data.message, type: 'error'});
|
||||||
},
|
//console.log('err:' + res.data.error);
|
||||||
error => {
|
return res.data;
|
||||||
console.log('err' + error)
|
//return Promise.reject(new Error(res.data.message))
|
||||||
let { message } = error;
|
}
|
||||||
if (message == "Network Error") {
|
}
|
||||||
message = "网络异常,请稍后重试";
|
},
|
||||||
}
|
error => {
|
||||||
else if (message.includes("timeout")) {
|
console.log('err' + error)
|
||||||
message = "系统接口请求超时";
|
let { message } = error;
|
||||||
}
|
if (message == "Network Error") {
|
||||||
else if (message.includes("Request failed with status code")) {
|
message = "网络异常,请稍后重试";
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
}
|
||||||
}
|
else if (message.includes("timeout")) {
|
||||||
Message({
|
message = "系统接口请求超时";
|
||||||
message: message,
|
}
|
||||||
type: 'error',
|
else if (message.includes("Request failed with status code")) {
|
||||||
duration: 5 * 1000
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
})
|
}
|
||||||
return Promise.reject(error)
|
Message({
|
||||||
}
|
message: message,
|
||||||
|
type: 'error',
|
||||||
|
duration: 5 * 1000
|
||||||
|
})
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//用于普通的发送请求
|
//用于普通的发送请求
|
||||||
const formRequest=axios.create({
|
const formRequest = axios.create({
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
|
baseURL: process.env.VUE_APP_CESOURCE_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
})
|
})
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
formRequest.interceptors.request.use(config => {
|
formRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
});
|
});
|
||||||
formRequest.interceptors.response.use(res => {
|
formRequest.interceptors.response.use(res => {
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
|
return res.data
|
||||||
|
} else {
|
||||||
|
if (code === 401) {
|
||||||
|
store.dispatch('LogOut').then(() => {
|
||||||
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
|
top.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
|
} else {
|
||||||
|
window.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
|
}
|
||||||
|
// location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
|
})
|
||||||
|
} else if (code === 403) {
|
||||||
|
var msg = '当前操作没有权限';
|
||||||
|
Message({ message: msg, type: 'error' });
|
||||||
|
return Promise.reject(new Error(msg))
|
||||||
|
} else {
|
||||||
|
//Message({message: res.data.message, type: 'error'});
|
||||||
|
//console.log('err' + res.data.error);
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
}
|
||||||
if(code === 401){
|
}
|
||||||
store.dispatch('LogOut').then(() => {
|
},
|
||||||
location.href = this.webBaseUrl + ReLoginUrl;
|
error => {
|
||||||
})
|
console.log('err' + error)
|
||||||
}else if(code===403){
|
let { message } = error;
|
||||||
var msg='当前操作没有权限';
|
if (message == "Network Error") {
|
||||||
Message({message: msg, type: 'error'});
|
message = "网络异常,请稍后重试";
|
||||||
return Promise.reject(new Error(msg))
|
}
|
||||||
}else{
|
else if (message.includes("timeout")) {
|
||||||
//Message({message: res.data.message, type: 'error'});
|
message = "系统接口请求超时";
|
||||||
//console.log('err' + res.data.error);
|
}
|
||||||
return res.data
|
else if (message.includes("Request failed with status code")) {
|
||||||
}
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
}
|
}
|
||||||
},
|
Message({
|
||||||
error => {
|
message: message,
|
||||||
console.log('err' + error)
|
type: 'error',
|
||||||
let { message } = error;
|
duration: 5 * 1000
|
||||||
if (message == "Network Error") {
|
})
|
||||||
message = "网络异常,请稍后重试";
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
else if (message.includes("timeout")) {
|
|
||||||
message = "系统接口请求超时";
|
|
||||||
}
|
|
||||||
else if (message.includes("Request failed with status code")) {
|
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
|
||||||
}
|
|
||||||
Message({
|
|
||||||
message: message,
|
|
||||||
type: 'error',
|
|
||||||
duration: 5 * 1000
|
|
||||||
})
|
|
||||||
return Promise.reject(error)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//request请求
|
//request请求
|
||||||
const request=function(cfg){
|
const request = function (cfg) {
|
||||||
if(cfg.data){
|
if (cfg.data) {
|
||||||
cfg.data=qs.stringify(cfg.data);
|
cfg.data = qs.stringify(cfg.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//requestJson请求
|
//requestJson请求
|
||||||
const requestJson=jsonRequest.request;
|
const requestJson = jsonRequest.request;
|
||||||
//get请求
|
//get请求
|
||||||
const get=formRequest.request;
|
const get = formRequest.request;
|
||||||
//post请求
|
//post请求
|
||||||
const post=function(url,data,config){
|
const post = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.post(url,data,config);
|
return formRequest.post(url, data, config);
|
||||||
}
|
}
|
||||||
//postJson请求
|
//postJson请求
|
||||||
const postJson=jsonRequest.post;
|
const postJson = jsonRequest.post;
|
||||||
//put请求
|
//put请求
|
||||||
const put=function(url,data,config){
|
const put = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.put(url,data,config);
|
return formRequest.put(url, data, config);
|
||||||
}
|
}
|
||||||
//putJson请求
|
//putJson请求
|
||||||
const putJson=jsonRequest.put;
|
const putJson = jsonRequest.put;
|
||||||
//patch请求
|
//patch请求
|
||||||
const patch=function(url,data,config){
|
const patch = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.patch(url,data,config);
|
return formRequest.patch(url, data, config);
|
||||||
}
|
}
|
||||||
//patchJson请求
|
//patchJson请求
|
||||||
const patchJson=jsonRequest.patch;
|
const patchJson = jsonRequest.patch;
|
||||||
//delete请求
|
//delete请求
|
||||||
const del=formRequest.delete;
|
const del = formRequest.delete;
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
request,
|
request,
|
||||||
requestJson,
|
requestJson,
|
||||||
get,
|
get,
|
||||||
post,
|
post,
|
||||||
postJson,
|
postJson,
|
||||||
put,
|
put,
|
||||||
putJson,
|
putJson,
|
||||||
patch,
|
patch,
|
||||||
patchJson,
|
patchJson,
|
||||||
del
|
del
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,185 +17,195 @@ import errorCode from '@/utils/errorCode'
|
|||||||
*delete请求 axios.delete(url[, config])
|
*delete请求 axios.delete(url[, config])
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ReLoginUrl="/login";
|
const ReLoginUrl = "/login";
|
||||||
const TokenName='XBOE-Access-Token';
|
const TokenName = 'XBOE-Access-Token';
|
||||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||||
//只是用于发送json对象数据时使用post,put,patch
|
//只是用于发送json对象数据时使用post,put,patch
|
||||||
const jsonRequest=axios.create({
|
const jsonRequest = axios.create({
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_STAT_BASE_API,
|
baseURL: process.env.VUE_APP_STAT_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
});
|
});
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
jsonRequest.interceptors.request.use(config => {
|
jsonRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
jsonRequest.interceptors.response.use(res => {
|
jsonRequest.interceptors.response.use(res => {
|
||||||
|
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
} else {
|
||||||
if(code === 401){
|
if (code === 401) {
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = this.webBaseUrl + ReLoginUrl;
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
})
|
top.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
}else if(code===403){
|
} else {
|
||||||
var msg='当前操作没有权限';
|
window.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
Message({message: msg, type: 'error'});
|
}
|
||||||
return Promise.reject(new Error(msg))
|
// location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
}else{
|
})
|
||||||
//Message({message: res.data.message, type: 'error'});
|
} else if (code === 403) {
|
||||||
//console.log('err:' + res.data.error);
|
var msg = '当前操作没有权限';
|
||||||
return res.data;
|
Message({ message: msg, type: 'error' });
|
||||||
//return Promise.reject(new Error(res.data.message))
|
return Promise.reject(new Error(msg))
|
||||||
}
|
} else {
|
||||||
}
|
//Message({message: res.data.message, type: 'error'});
|
||||||
},
|
//console.log('err:' + res.data.error);
|
||||||
error => {
|
return res.data;
|
||||||
console.log('err' + error)
|
//return Promise.reject(new Error(res.data.message))
|
||||||
let { message } = error;
|
}
|
||||||
if (message == "Network Error") {
|
}
|
||||||
message = "网络异常,请稍后重试";
|
},
|
||||||
}
|
error => {
|
||||||
else if (message.includes("timeout")) {
|
console.log('err' + error)
|
||||||
message = "系统接口请求超时";
|
let { message } = error;
|
||||||
}
|
if (message == "Network Error") {
|
||||||
else if (message.includes("Request failed with status code")) {
|
message = "网络异常,请稍后重试";
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
}
|
||||||
}
|
else if (message.includes("timeout")) {
|
||||||
Message({
|
message = "系统接口请求超时";
|
||||||
message: message,
|
}
|
||||||
type: 'error',
|
else if (message.includes("Request failed with status code")) {
|
||||||
duration: 5 * 1000
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
})
|
}
|
||||||
return Promise.reject(error)
|
Message({
|
||||||
}
|
message: message,
|
||||||
|
type: 'error',
|
||||||
|
duration: 5 * 1000
|
||||||
|
})
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//用于普通的发送请求
|
//用于普通的发送请求
|
||||||
const formRequest=axios.create({
|
const formRequest = axios.create({
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_STAT_BASE_API,
|
baseURL: process.env.VUE_APP_STAT_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
})
|
})
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
formRequest.interceptors.request.use(config => {
|
formRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
});
|
});
|
||||||
formRequest.interceptors.response.use(res => {
|
formRequest.interceptors.response.use(res => {
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
|
return res.data
|
||||||
|
} else {
|
||||||
|
if (code === 401) {
|
||||||
|
store.dispatch('LogOut').then(() => {
|
||||||
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
|
top.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
|
} else {
|
||||||
|
window.location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
|
}
|
||||||
|
// location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
|
})
|
||||||
|
} else if (code === 403) {
|
||||||
|
var msg = '当前操作没有权限';
|
||||||
|
Message({ message: msg, type: 'error' });
|
||||||
|
return Promise.reject(new Error(msg))
|
||||||
|
} else {
|
||||||
|
//Message({message: res.data.message, type: 'error'});
|
||||||
|
//console.log('err' + res.data.error);
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
}
|
||||||
if(code === 401){
|
}
|
||||||
store.dispatch('LogOut').then(() => {
|
},
|
||||||
location.href = this.webBaseUrl + ReLoginUrl;
|
error => {
|
||||||
})
|
console.log('err' + error)
|
||||||
}else if(code===403){
|
let { message } = error;
|
||||||
var msg='当前操作没有权限';
|
if (message == "Network Error") {
|
||||||
Message({message: msg, type: 'error'});
|
message = "网络异常,请稍后重试";
|
||||||
return Promise.reject(new Error(msg))
|
}
|
||||||
}else{
|
else if (message.includes("timeout")) {
|
||||||
//Message({message: res.data.message, type: 'error'});
|
message = "系统接口请求超时";
|
||||||
//console.log('err' + res.data.error);
|
}
|
||||||
return res.data
|
else if (message.includes("Request failed with status code")) {
|
||||||
}
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
}
|
}
|
||||||
},
|
Message({
|
||||||
error => {
|
message: message,
|
||||||
console.log('err' + error)
|
type: 'error',
|
||||||
let { message } = error;
|
duration: 5 * 1000
|
||||||
if (message == "Network Error") {
|
})
|
||||||
message = "网络异常,请稍后重试";
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
else if (message.includes("timeout")) {
|
|
||||||
message = "系统接口请求超时";
|
|
||||||
}
|
|
||||||
else if (message.includes("Request failed with status code")) {
|
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
|
||||||
}
|
|
||||||
Message({
|
|
||||||
message: message,
|
|
||||||
type: 'error',
|
|
||||||
duration: 5 * 1000
|
|
||||||
})
|
|
||||||
return Promise.reject(error)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
//request请求
|
//request请求
|
||||||
const request=function(cfg){
|
const request = function (cfg) {
|
||||||
if(cfg.data){
|
if (cfg.data) {
|
||||||
cfg.data=qs.stringify(cfg.data);
|
cfg.data = qs.stringify(cfg.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//requestJson请求
|
//requestJson请求
|
||||||
const requestJson=jsonRequest.request;
|
const requestJson = jsonRequest.request;
|
||||||
//get请求
|
//get请求
|
||||||
const get=formRequest.request;
|
const get = formRequest.request;
|
||||||
//post请求
|
//post请求
|
||||||
const post=function(url,data,config){
|
const post = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.post(url,data,config);
|
return formRequest.post(url, data, config);
|
||||||
}
|
}
|
||||||
//postJson请求
|
//postJson请求
|
||||||
const postJson=jsonRequest.post;
|
const postJson = jsonRequest.post;
|
||||||
//put请求
|
//put请求
|
||||||
const put=function(url,data,config){
|
const put = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.put(url,data,config);
|
return formRequest.put(url, data, config);
|
||||||
}
|
}
|
||||||
//putJson请求
|
//putJson请求
|
||||||
const putJson=jsonRequest.put;
|
const putJson = jsonRequest.put;
|
||||||
//patch请求
|
//patch请求
|
||||||
const patch=function(url,data,config){
|
const patch = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.patch(url,data,config);
|
return formRequest.patch(url, data, config);
|
||||||
}
|
}
|
||||||
//patchJson请求
|
//patchJson请求
|
||||||
const patchJson=jsonRequest.patch;
|
const patchJson = jsonRequest.patch;
|
||||||
//delete请求
|
//delete请求
|
||||||
const del=formRequest.delete;
|
const del = formRequest.delete;
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
request,
|
request,
|
||||||
requestJson,
|
requestJson,
|
||||||
get,
|
get,
|
||||||
post,
|
post,
|
||||||
postJson,
|
postJson,
|
||||||
put,
|
put,
|
||||||
putJson,
|
putJson,
|
||||||
patch,
|
patch,
|
||||||
patchJson,
|
patchJson,
|
||||||
del
|
del
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
109
src/security.js
109
src/security.js
@@ -11,16 +11,16 @@ import xpage from '@/utils/xpage'
|
|||||||
|
|
||||||
NProgress.configure({ showSpinner: false })
|
NProgress.configure({ showSpinner: false })
|
||||||
|
|
||||||
const whiteList = ['/login','/logout','/loading','/pc/loading','/500','/auth-redirect','/forget','/reset/password']
|
const whiteList = ['/login', '/logout', '/loading', '/pc/loading', '/500', '/auth-redirect', '/forget', '/reset/password']
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
watermark.set("");
|
watermark.set("");
|
||||||
//动态计算文件的路径
|
//动态计算文件的路径
|
||||||
let configPath=process.env.VUE_APP_FILE_RELATIVE_PATH;
|
let configPath = process.env.VUE_APP_FILE_RELATIVE_PATH;
|
||||||
if(configPath.startsWith('http')){
|
if (configPath.startsWith('http')) {
|
||||||
xpage.constants.fileBaseUrl=configPath;
|
xpage.constants.fileBaseUrl = configPath;
|
||||||
}else{
|
} else {
|
||||||
xpage.constants.fileBaseUrl=window.location.protocol+'//'+window.location.host+configPath;
|
xpage.constants.fileBaseUrl = window.location.protocol + '//' + window.location.host + configPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
@@ -28,66 +28,71 @@ router.beforeEach((to, from, next) => {
|
|||||||
if (whiteList.indexOf(to.path) !== -1) {
|
if (whiteList.indexOf(to.path) !== -1) {
|
||||||
// 在免登录白名单,直接进入
|
// 在免登录白名单,直接进入
|
||||||
next()
|
next()
|
||||||
}else{
|
} else {
|
||||||
if(getToken()){
|
if (getToken()) {
|
||||||
if(to.path === '/login'){
|
if (to.path === '/login') {
|
||||||
// 如果是外部用户,把配置的路由跳转到个人中心
|
// 如果是外部用户,把配置的路由跳转到个人中心
|
||||||
if(store.getters.userInfo.role === 2){
|
if (store.getters.userInfo.role === 2) {
|
||||||
next({ path: process.env.VUE_APP_PUBLIC_PATH+'/uc/study/courses' })
|
next({ path: process.env.VUE_APP_PUBLIC_PATH + '/uc/study/courses' })
|
||||||
}else{
|
} else {
|
||||||
next({ path: process.env.VUE_APP_PUBLIC_PATH+'/index' })
|
next({ path: process.env.VUE_APP_PUBLIC_PATH + '/index' })
|
||||||
}
|
}
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
} else {
|
} else {
|
||||||
//console.log('store.getters.userInfo:',store.getters.userInfo.role)
|
//console.log('store.getters.userInfo:',store.getters.userInfo.role)
|
||||||
// 如果是外部用户,把配置的路由跳转到个人中心
|
// 如果是外部用户,把配置的路由跳转到个人中心
|
||||||
if(store.getters.userInfo.role === 2){
|
if (store.getters.userInfo.role === 2) {
|
||||||
if(to.path === '/index' || to.path === '/course' || to.path === '/case' || to.path === '/article' ) location.href = '/pc/uc/study/task'
|
if (to.path === '/index' || to.path === '/course' || to.path === '/case' || to.path === '/article') location.href = '/pc/uc/study/task'
|
||||||
}
|
}
|
||||||
//后续这里需要增加一定的控制
|
//后续这里需要增加一定的控制
|
||||||
if (!store.getters.init) {
|
if (!store.getters.init) {
|
||||||
sessionStorage.removeItem(xpage.constants.localCaseFiltersKey);
|
sessionStorage.removeItem(xpage.constants.localCaseFiltersKey);
|
||||||
sessionStorage.removeItem(xpage.constants.localCourseFiltersKey);
|
sessionStorage.removeItem(xpage.constants.localCourseFiltersKey);
|
||||||
// 判断当前控制台是否已拉取完数据
|
// 判断当前控制台是否已拉取完数据
|
||||||
store.dispatch('InitData').then(res => {
|
store.dispatch('InitData').then(res => {
|
||||||
//加载白名单信息
|
//加载白名单信息
|
||||||
//testUser.init();
|
//testUser.init();
|
||||||
//加载信息资源归属,系统分类信息
|
//加载信息资源归属,系统分类信息
|
||||||
store.dispatch('resOwner/loadResOwners');
|
store.dispatch('resOwner/loadResOwners');
|
||||||
store.dispatch('sysType/loadSysTypes');
|
store.dispatch('sysType/loadSysTypes');
|
||||||
|
|
||||||
store.commit('app/SET_INITDATA',true);
|
store.commit('app/SET_INITDATA', true);
|
||||||
//routers数据先使用固定的,以后在初始化接口中返回
|
//routers数据先使用固定的,以后在初始化接口中返回
|
||||||
let myRouters=routers();
|
let myRouters = routers();
|
||||||
store.dispatch('GenerateRoutes',{routers:myRouters}).then(accessRoutes=>{
|
store.dispatch('GenerateRoutes', { routers: myRouters }).then(accessRoutes => {
|
||||||
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
||||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||||
});
|
});
|
||||||
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
store.commit('app/SET_INITDATA',false);
|
store.commit('app/SET_INITDATA', false);
|
||||||
//如果初始化错误,就不再执行了,不然会一直循环下去
|
//如果初始化错误,就不再执行了,不然会一直循环下去
|
||||||
next({ path: '/500' })
|
next({ path: '/500' })
|
||||||
//NProgress.done();
|
//NProgress.done();
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
to.meta.keepAlive = true
|
to.meta.keepAlive = true
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//next();
|
//next();
|
||||||
}else{
|
} else {
|
||||||
|
|
||||||
//next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
//next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
|
||||||
//设置之前的路径
|
//设置之前的路径
|
||||||
//store.commit('portal/SetBackUrl',location.href);
|
//store.commit('portal/SetBackUrl',location.href);
|
||||||
//console.log(location.href,'location.href');
|
//console.log(location.href,'location.href');
|
||||||
//let urlPre=window.location.protocol+'//'+window.location.host;
|
//let urlPre=window.location.protocol+'//'+window.location.host;
|
||||||
//let backUrl=location.href.substring(urlPre.length); encodeURIComponent()
|
//let backUrl=location.href.substring(urlPre.length); encodeURIComponent()
|
||||||
location.href=process.env.VUE_APP_LOGIN_URL+"?returnUrl="+encodeURIComponent(location.href);
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
NProgress.done()
|
top.location.href = process.env.VUE_APP_LOGIN_URL + "?returnUrl=" + encodeURIComponent(location.href);
|
||||||
|
} else {
|
||||||
|
window.location.href = process.env.VUE_APP_LOGIN_URL + "?returnUrl=" + encodeURIComponent(location.href);
|
||||||
|
}
|
||||||
|
// location.href=process.env.VUE_APP_LOGIN_URL+"?returnUrl="+encodeURIComponent(location.href);
|
||||||
|
NProgress.done()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,215 +19,255 @@ import errorCode from '@/utils/errorCode'
|
|||||||
|
|
||||||
//const ReLoginUrl="/login";
|
//const ReLoginUrl="/login";
|
||||||
|
|
||||||
const ReLoginUrl=process.env.VUE_APP_LOGIN_URL;
|
const ReLoginUrl = process.env.VUE_APP_LOGIN_URL;
|
||||||
|
|
||||||
const TokenName='XBOE-Access-Token';
|
const TokenName = 'XBOE-Access-Token';
|
||||||
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
/**axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded'**/
|
||||||
//只是用于发送json对象数据时使用post,put,patch
|
//只是用于发送json对象数据时使用post,put,patch
|
||||||
const jsonRequest=axios.create({
|
const jsonRequest = axios.create({
|
||||||
headers:{'Content-Type':'application/json;charset=utf-8'},
|
headers: { 'Content-Type': 'application/json;charset=utf-8' },
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_BASE_API,
|
baseURL: process.env.VUE_APP_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 60000,
|
timeout: 60000,
|
||||||
});
|
});
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
jsonRequest.interceptors.request.use(config => {
|
jsonRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
jsonRequest.interceptors.response.use(res => {
|
jsonRequest.interceptors.response.use(res => {
|
||||||
|
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
} else {
|
||||||
if(code == 6001){ //针对于老系统的处理
|
if (code == 6001) { //针对于老系统的处理
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = ReLoginUrl;
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
})
|
top.location.href = ReLoginUrl;
|
||||||
}else if(code === 401){
|
} else {
|
||||||
store.dispatch('LogOut').then(() => {
|
window.location.href = ReLoginUrl;
|
||||||
location.href = ReLoginUrl;
|
}
|
||||||
})
|
// location.href = ReLoginUrl;
|
||||||
}else if(code === 402){
|
})
|
||||||
store.dispatch('LogOut').then(() => {
|
} else if (code === 401) {
|
||||||
location.href = ReLoginUrl;
|
store.dispatch('LogOut').then(() => {
|
||||||
})
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
}else if(code===403){
|
top.location.href = ReLoginUrl;
|
||||||
var msg='当前操作没有权限';
|
} else {
|
||||||
Message({message: msg, type: 'error'});
|
window.location.href = ReLoginUrl;
|
||||||
return Promise.reject(new Error(msg))
|
}
|
||||||
//return res.data;
|
// location.href = ReLoginUrl;
|
||||||
}else if(code===302){
|
})
|
||||||
location.href = ReLoginUrl;
|
} else if (code === 402) {
|
||||||
}else{
|
store.dispatch('LogOut').then(() => {
|
||||||
//Message({message: res.data.message, type: 'error'});
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
//console.log('err:' + res.data.error);
|
top.location.href = ReLoginUrl;
|
||||||
//return Promise.reject(new Error(res.data.message))
|
} else {
|
||||||
return res.data;
|
window.location.href = ReLoginUrl;
|
||||||
|
}
|
||||||
|
// location.href = ReLoginUrl;
|
||||||
|
})
|
||||||
|
} else if (code === 403) {
|
||||||
|
var msg = '当前操作没有权限';
|
||||||
|
Message({ message: msg, type: 'error' });
|
||||||
|
return Promise.reject(new Error(msg))
|
||||||
|
//return res.data;
|
||||||
|
} else if (code === 302) {
|
||||||
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
|
top.location.href = ReLoginUrl;
|
||||||
|
} else {
|
||||||
|
window.location.href = ReLoginUrl;
|
||||||
}
|
}
|
||||||
}
|
// location.href = ReLoginUrl;
|
||||||
},
|
} else {
|
||||||
error => {
|
//Message({message: res.data.message, type: 'error'});
|
||||||
console.log('err' + error)
|
//console.log('err:' + res.data.error);
|
||||||
let { message } = error;
|
//return Promise.reject(new Error(res.data.message))
|
||||||
if (message == "Network Error") {
|
return res.data;
|
||||||
message = "网络异常,请稍后重试";
|
}
|
||||||
}
|
}
|
||||||
else if (message.includes("timeout")) {
|
},
|
||||||
message = "系统接口请求超时";
|
error => {
|
||||||
//location.href = this.webBaseUrl + ReLoginUrl;
|
console.log('err' + error)
|
||||||
}
|
let { message } = error;
|
||||||
else if (message.includes("Request failed with status code")) {
|
if (message == "Network Error") {
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
message = "网络异常,请稍后重试";
|
||||||
}
|
}
|
||||||
Message({
|
else if (message.includes("timeout")) {
|
||||||
message: message,
|
message = "系统接口请求超时";
|
||||||
type: 'error',
|
//location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
duration: 5 * 1000
|
}
|
||||||
})
|
else if (message.includes("Request failed with status code")) {
|
||||||
return Promise.reject(error)
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
}
|
}
|
||||||
|
Message({
|
||||||
|
message: message,
|
||||||
|
type: 'error',
|
||||||
|
duration: 5 * 1000
|
||||||
|
})
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//用于普通的发送请求
|
//用于普通的发送请求
|
||||||
const formRequest=axios.create({
|
const formRequest = axios.create({
|
||||||
headers:{'Content-Type':'application/x-www-form-urlencoded'},
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
// axios中请求配置有baseURL选项,表示请求URL公共部分
|
||||||
baseURL: process.env.VUE_APP_BASE_API,
|
baseURL: process.env.VUE_APP_BASE_API,
|
||||||
//超时
|
//超时
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
})
|
})
|
||||||
//发送json对象的拦截器
|
//发送json对象的拦截器
|
||||||
formRequest.interceptors.request.use(config => {
|
formRequest.interceptors.request.use(config => {
|
||||||
//是否需要设置 token
|
//是否需要设置 token
|
||||||
const isToken = (config.headers || {}).isToken === false
|
const isToken = (config.headers || {}).isToken === false
|
||||||
if (getToken() && !isToken) {
|
if (getToken() && !isToken) {
|
||||||
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
config.headers[TokenName] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
}, error => {
|
}, error => {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
});
|
});
|
||||||
formRequest.interceptors.response.use(res => {
|
formRequest.interceptors.response.use(res => {
|
||||||
const code = res.data.status || 200;
|
const code = res.data.status || 200;
|
||||||
if(code===200){
|
if (code === 200) {
|
||||||
return res.data
|
return res.data
|
||||||
}else{
|
} else {
|
||||||
if(code == 6001){ //针对于老系统的处理,因为老系统是字符串,所以这里不使用三等于号
|
if (code == 6001) { //针对于老系统的处理,因为老系统是字符串,所以这里不使用三等于号
|
||||||
store.dispatch('LogOut').then(() => {
|
store.dispatch('LogOut').then(() => {
|
||||||
location.href = ReLoginUrl;
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
})
|
top.location.href = ReLoginUrl;
|
||||||
}else if(code === 401){
|
} else {
|
||||||
store.dispatch('LogOut').then(() => {
|
window.location.href = ReLoginUrl;
|
||||||
location.href = ReLoginUrl;
|
}
|
||||||
})
|
// location.href = ReLoginUrl;
|
||||||
}else if(code === 402){
|
})
|
||||||
store.dispatch('LogOut').then(() => {
|
} else if (code === 401) {
|
||||||
location.href = ReLoginUrl;
|
store.dispatch('LogOut').then(() => {
|
||||||
})
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
}else if(code===403){
|
top.location.href = ReLoginUrl;
|
||||||
var msg='当前操作没有权限';
|
} else {
|
||||||
Message({message: msg, type: 'error'});
|
window.location.href = ReLoginUrl;
|
||||||
return Promise.reject(new Error(msg))
|
}
|
||||||
}else if(code===302){
|
// location.href = ReLoginUrl;
|
||||||
location.href = ReLoginUrl;
|
})
|
||||||
}else{
|
} else if (code === 402) {
|
||||||
//Message({message: res.data.message, type: 'error'});
|
store.dispatch('LogOut').then(() => {
|
||||||
//console.log('err' + res.data.error);
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
//return Promise.reject(new Error(res.data.message))
|
top.location.href = ReLoginUrl;
|
||||||
return res.data;//返回给用户做业务处理
|
} else {
|
||||||
|
window.location.href = ReLoginUrl;
|
||||||
|
}
|
||||||
|
// location.href = ReLoginUrl;
|
||||||
|
})
|
||||||
|
} else if (code === 403) {
|
||||||
|
var msg = '当前操作没有权限';
|
||||||
|
Message({ message: msg, type: 'error' });
|
||||||
|
return Promise.reject(new Error(msg))
|
||||||
|
} else if (code === 302) {
|
||||||
|
if (top !== window) { // 判断当前是否在iframe内
|
||||||
|
top.location.href = ReLoginUrl;
|
||||||
|
} else {
|
||||||
|
window.location.href = ReLoginUrl;
|
||||||
}
|
}
|
||||||
}
|
// location.href = ReLoginUrl;
|
||||||
},
|
} else {
|
||||||
error => {
|
//Message({message: res.data.message, type: 'error'});
|
||||||
console.log('err' + error)
|
//console.log('err' + res.data.error);
|
||||||
let { message } = error;
|
//return Promise.reject(new Error(res.data.message))
|
||||||
if (message == "Network Error") {
|
return res.data;//返回给用户做业务处理
|
||||||
message = "网络异常,请稍后重试";
|
}
|
||||||
}
|
}
|
||||||
else if (message.includes("timeout")) {
|
},
|
||||||
message = "系统接口请求超时";
|
error => {
|
||||||
//location.href = this.webBaseUrl + ReLoginUrl;
|
console.log('err' + error)
|
||||||
}
|
let { message } = error;
|
||||||
else if (message.includes("Request failed with status code")) {
|
if (message == "Network Error") {
|
||||||
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
message = "网络异常,请稍后重试";
|
||||||
}
|
}
|
||||||
Message({
|
else if (message.includes("timeout")) {
|
||||||
message: message,
|
message = "系统接口请求超时";
|
||||||
type: 'error',
|
//location.href = this.webBaseUrl + ReLoginUrl;
|
||||||
duration: 5 * 1000
|
}
|
||||||
})
|
else if (message.includes("Request failed with status code")) {
|
||||||
return Promise.reject(error)
|
message = "系统接口" + message.substr(message.length - 3) + "异常";
|
||||||
}
|
}
|
||||||
|
Message({
|
||||||
|
message: message,
|
||||||
|
type: 'error',
|
||||||
|
duration: 5 * 1000
|
||||||
|
})
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
//request请求
|
//request请求
|
||||||
const request=function(cfg){
|
const request = function (cfg) {
|
||||||
if(cfg.data){
|
if (cfg.data) {
|
||||||
cfg.data=qs.stringify(cfg.data);
|
cfg.data = qs.stringify(cfg.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//requestJson请求
|
//requestJson请求
|
||||||
const requestJson=jsonRequest.request;
|
const requestJson = jsonRequest.request;
|
||||||
//get请求
|
//get请求
|
||||||
const get=formRequest.request;
|
const get = formRequest.request;
|
||||||
//post请求
|
//post请求
|
||||||
const post=function(url,data,config){
|
const post = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.post(url,data,config);
|
return formRequest.post(url, data, config);
|
||||||
}
|
}
|
||||||
//post请求
|
//post请求
|
||||||
const postForm=function(url,data,config){
|
const postForm = function (url, data, config) {
|
||||||
return formRequest.post(url,data,config);
|
return formRequest.post(url, data, config);
|
||||||
}
|
}
|
||||||
//postJson请求
|
//postJson请求
|
||||||
const postJson=jsonRequest.post;
|
const postJson = jsonRequest.post;
|
||||||
//put请求
|
//put请求
|
||||||
const put=function(url,data,config){
|
const put = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.put(url,data,config);
|
return formRequest.put(url, data, config);
|
||||||
}
|
}
|
||||||
//putJson请求
|
//putJson请求
|
||||||
const putJson=jsonRequest.put;
|
const putJson = jsonRequest.put;
|
||||||
//patch请求
|
//patch请求
|
||||||
const patch=function(url,data,config){
|
const patch = function (url, data, config) {
|
||||||
if(data){
|
if (data) {
|
||||||
data=qs.stringify(data);
|
data = qs.stringify(data);
|
||||||
}
|
}
|
||||||
return formRequest.patch(url,data,config);
|
return formRequest.patch(url, data, config);
|
||||||
}
|
}
|
||||||
//patchJson请求
|
//patchJson请求
|
||||||
const patchJson=jsonRequest.patch;
|
const patchJson = jsonRequest.patch;
|
||||||
//delete请求
|
//delete请求
|
||||||
const del=formRequest.delete;
|
const del = formRequest.delete;
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
request,
|
request,
|
||||||
requestJson,
|
requestJson,
|
||||||
get,
|
get,
|
||||||
post,
|
post,
|
||||||
postJson,
|
postJson,
|
||||||
put,
|
put,
|
||||||
putJson,
|
putJson,
|
||||||
patch,
|
patch,
|
||||||
patchJson,
|
patchJson,
|
||||||
del,
|
del,
|
||||||
postForm
|
postForm
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,28 +153,29 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="xindex-content">
|
<div class="xindex-content">
|
||||||
|
|
||||||
<!-- 推荐课程 -->
|
<!-- 推荐课程 -->
|
||||||
<div class="modules xcontent2">
|
<div class="modules xcontent2">
|
||||||
<!-- <div class="xcontent2-main"> -->
|
<!-- <div class="xcontent2-main"> -->
|
||||||
<!--内容块-->
|
<!--内容块-->
|
||||||
|
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
<!-- 精品课模块 -->
|
<!-- 精品课模块 -->
|
||||||
<div class="xcontent2-main">
|
<div class="xcontent2-main">
|
||||||
<div class="modules-title xindex-main" v-if="this.qusisityList.list.length > 0">
|
<div class="modules-title xindex-main" v-if="this.qusisityList.list.length > 0">
|
||||||
<!-- <span class="modules-text" style="color: #3D86F4;">精品课</span> -->
|
<!-- <span class="jin-text">精品课</span> -->
|
||||||
|
<div class="jin-zhe"></div>
|
||||||
<span class="quyer-tag" style="margin-left: 0px;">
|
<span class="quyer-tag" style="margin-left: 0px;">
|
||||||
<!-- <img src="../assets/images/tutoring1.pn" alt=""> -->
|
|
||||||
<img class="modules-text" style="height: 28px;" src="../assets/images/course/courseTitle.png" alt="">
|
<img class="modules-text" style="height: 28px;" src="../assets/images/course/courseTitle.png" alt="">
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class="more">
|
<span class="more">
|
||||||
<router-link to="/qualityCourse">查看更多>></router-link>
|
<router-link to="/qualityCourse">查看更多>></router-link>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-for="(course, eIndex) in exquisiteList"
|
v-for="(course, eIndex) in exquisiteList"
|
||||||
:key="'cc' + eIndex"
|
:key="'cc' + eIndex"
|
||||||
@@ -231,7 +232,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--内容块-->
|
<!--内容块-->
|
||||||
<div class="modules-title xindex-main">
|
<div class="modules-title xindex-main">
|
||||||
<span class="modules-text">推荐课程</span>
|
<span class="modules-text">推荐课程</span>
|
||||||
@@ -1308,7 +1309,7 @@ export default {
|
|||||||
return this.courseList.list.slice(3)
|
return this.courseList.list.slice(3)
|
||||||
},
|
},
|
||||||
// 精品课展示
|
// 精品课展示
|
||||||
exquisiteList() {
|
exquisiteList() {
|
||||||
return this.qusisityList.list.slice(0,3)
|
return this.qusisityList.list.slice(0,3)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1567,7 +1568,7 @@ export default {
|
|||||||
let course = {
|
let course = {
|
||||||
aid: this.userInfo.aid,
|
aid: this.userInfo.aid,
|
||||||
}
|
}
|
||||||
apiIndex.qualitylist(course).then((res) => {
|
apiIndex.qualitylist(course).then((res) => {
|
||||||
let courseIds = [];
|
let courseIds = [];
|
||||||
res.data.result.forEach((item) => {
|
res.data.result.forEach((item) => {
|
||||||
item.authorInfo = {
|
item.authorInfo = {
|
||||||
@@ -2826,6 +2827,15 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
.modules-title {
|
.modules-title {
|
||||||
|
position: relative;
|
||||||
|
.jin-zhe{
|
||||||
|
width: 410px;
|
||||||
|
height: 30px;
|
||||||
|
background: #f7f7f9;
|
||||||
|
position: absolute;
|
||||||
|
left: 86px;
|
||||||
|
|
||||||
|
}
|
||||||
.modules-text {
|
.modules-text {
|
||||||
height: 28px;
|
height: 28px;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
@@ -3136,4 +3146,13 @@ export default {
|
|||||||
border: 1px solid #d9edf7;
|
border: 1px solid #d9edf7;
|
||||||
//overflow: hidden;
|
//overflow: hidden;
|
||||||
}
|
}
|
||||||
|
.jin-text{
|
||||||
|
font-family: "Source Han Sans CN", "SourceHanSansCN", sans-serif !important;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 20px;
|
||||||
|
color: #3E87F5;
|
||||||
|
// line-height: 29px;/
|
||||||
|
text-align: justify;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -5,56 +5,61 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Cookies from 'vue-cookies'
|
import Cookies from "vue-cookies";
|
||||||
import apiLogin from '@/api/login.js'
|
import apiLogin from "@/api/login.js";
|
||||||
import { getToken,setToken } from '@/utils/token'
|
import { getToken, setToken } from "@/utils/token";
|
||||||
export default{
|
export default {
|
||||||
mounted(){
|
mounted() {
|
||||||
this.toUrl=this.$route.query.returnUrl;
|
this.toUrl = this.$route.query.returnUrl;
|
||||||
let token=getToken();
|
let token = getToken();
|
||||||
let $this=this;
|
let $this = this;
|
||||||
if(!token){
|
if (!token) {
|
||||||
//console.log(token,'未获取token');
|
//console.log(token,'未获取token');
|
||||||
setTimeout(function(){
|
setTimeout(function () {
|
||||||
$this.curToken=getToken();
|
$this.curToken = getToken();
|
||||||
if(!$this.curToken){
|
if (!$this.curToken) {
|
||||||
//console.log(token,'第二次未获取token');
|
//console.log(token,'第二次未获取token');
|
||||||
location.href = process.env.VUE_APP_LOGIN_URL;
|
if (top !== window) {
|
||||||
}else{
|
// 判断当前是否在iframe内
|
||||||
$this.boeLogin();
|
top.location.href = process.env.VUE_APP_LOGIN_URL;
|
||||||
|
} else {
|
||||||
|
window.location.href = process.env.VUE_APP_LOGIN_URL;
|
||||||
}
|
}
|
||||||
|
// location.href = process.env.VUE_APP_LOGIN_URL;
|
||||||
},500);
|
} else {
|
||||||
}else{
|
$this.boeLogin();
|
||||||
this.curToken=token;
|
}
|
||||||
this.boeLogin();
|
}, 500);
|
||||||
}
|
} else {
|
||||||
},
|
this.curToken = token;
|
||||||
data(){
|
this.boeLogin();
|
||||||
return {
|
|
||||||
curToken:'',
|
|
||||||
toUrl:''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods:{
|
|
||||||
boeLogin(){
|
|
||||||
apiLogin.boeLogin(this.curToken).then(rs=>{
|
|
||||||
if(rs.status==200){
|
|
||||||
//setToken(rs.result.access_token);
|
|
||||||
localStorage.setItem(this.$xpage.constants.newLoginKey,1);
|
|
||||||
if(this.toUrl){
|
|
||||||
location.href=this.toUrl;
|
|
||||||
}else{
|
|
||||||
this.$router.push({ path: "/index" })
|
|
||||||
}
|
|
||||||
//this.$router.push({ path: "/index" })
|
|
||||||
}else{
|
|
||||||
this.$message.error("登录失败:"+rs.message);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
curToken: "",
|
||||||
|
toUrl: "",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
boeLogin() {
|
||||||
|
apiLogin.boeLogin(this.curToken).then((rs) => {
|
||||||
|
if (rs.status == 200) {
|
||||||
|
//setToken(rs.result.access_token);
|
||||||
|
localStorage.setItem(this.$xpage.constants.newLoginKey, 1);
|
||||||
|
if (this.toUrl) {
|
||||||
|
location.href = this.toUrl;
|
||||||
|
} else {
|
||||||
|
this.$router.push({ path: "/index" });
|
||||||
|
}
|
||||||
|
//this.$router.push({ path: "/index" })
|
||||||
|
} else {
|
||||||
|
this.$message.error("登录失败:" + rs.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -2,17 +2,15 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- 最大化状态的弹窗 -->
|
<!-- 最大化状态的弹窗 -->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-show=" windowState === 'maximized'"
|
v-if="dialogVisible && windowState === 'maximized'"
|
||||||
v-if="dialogVisible"
|
|
||||||
:visible="true"
|
:visible="true"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
:show-close="true"
|
:show-close="true"
|
||||||
@close="onClose"
|
@close="onClose"
|
||||||
class="case-expert-dialog"
|
class="case-expert-dialog"
|
||||||
:modal="false"
|
:modal="false"
|
||||||
:append-to-body="true"
|
|
||||||
:fullscreen="false"
|
:fullscreen="false"
|
||||||
top="10vh"
|
top="0"
|
||||||
v-resizeable
|
v-resizeable
|
||||||
v-draggable
|
v-draggable
|
||||||
>
|
>
|
||||||
@@ -35,6 +33,7 @@
|
|||||||
class="welcome-message"
|
class="welcome-message"
|
||||||
ref="messageContainer"
|
ref="messageContainer"
|
||||||
@scroll="handleScroll"
|
@scroll="handleScroll"
|
||||||
|
@wheel="handleWheel"
|
||||||
>
|
>
|
||||||
<div class="message-text" v-for="(item, index) in messageList" :key="index">
|
<div class="message-text" v-for="(item, index) in messageList" :key="index">
|
||||||
<messages :messageData="item" :suggestions="suggestions" @getMinWindow="minimizeWindow"></messages>
|
<messages :messageData="item" :suggestions="suggestions" @getMinWindow="minimizeWindow"></messages>
|
||||||
@@ -193,7 +192,7 @@ export default {
|
|||||||
left: parseInt(dialogEl.style.left),
|
left: parseInt(dialogEl.style.left),
|
||||||
top: parseInt(dialogEl.style.top)
|
top: parseInt(dialogEl.style.top)
|
||||||
};
|
};
|
||||||
sessionStorage.setItem('aiCallDialogPosition', JSON.stringify(currentPosition));
|
// sessionStorage.setItem('aiCallDialogPosition', JSON.stringify(currentPosition));
|
||||||
|
|
||||||
// 移除全局事件监听
|
// 移除全局事件监听
|
||||||
document.removeEventListener('mousemove', handleMouseMove);
|
document.removeEventListener('mousemove', handleMouseMove);
|
||||||
@@ -498,6 +497,9 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
dialogVisible: {
|
dialogVisible: {
|
||||||
handler(newVal) {
|
handler(newVal) {
|
||||||
|
console.log('dialogVisible发生变化');
|
||||||
|
console.log(newVal);
|
||||||
|
console.log(this.windowState);
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
// 获取对话框元素
|
// 获取对话框元素
|
||||||
@@ -514,12 +516,12 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 检查是否有保存的位置状态
|
// 检查是否有保存的位置状态
|
||||||
const savedPosition = sessionStorage.getItem('aiCallDialogPosition');
|
// const savedPosition = sessionStorage.getItem('aiCallDialogPosition');
|
||||||
if (savedPosition) {
|
// if (savedPosition) {
|
||||||
const { left, top } = JSON.parse(savedPosition);
|
// const { left, top } = JSON.parse(savedPosition);
|
||||||
dialogEl.style.left = left + 'px';
|
// dialogEl.style.left = left + 'px';
|
||||||
dialogEl.style.top = top + 'px';
|
// dialogEl.style.top = top + 'px';
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
let doc = document.querySelector('.welcome-message')
|
let doc = document.querySelector('.welcome-message')
|
||||||
@@ -566,7 +568,7 @@ closeMinimizedWindow() {
|
|||||||
console.log('关闭弹窗')
|
console.log('关闭弹窗')
|
||||||
// 清除保存的状态
|
// 清除保存的状态
|
||||||
sessionStorage.removeItem('aiCallDialogSize');
|
sessionStorage.removeItem('aiCallDialogSize');
|
||||||
sessionStorage.removeItem('aiCallDialogPosition');
|
// sessionStorage.removeItem('aiCallDialogPosition');
|
||||||
this.$emit('close')
|
this.$emit('close')
|
||||||
// 可以在这里执行其他逻辑
|
// 可以在这里执行其他逻辑
|
||||||
},
|
},
|
||||||
@@ -595,6 +597,7 @@ closeMinimizedWindow() {
|
|||||||
|
|
||||||
// 处理加载状态
|
// 处理加载状态
|
||||||
handleLoading(status) {
|
handleLoading(status) {
|
||||||
|
console.log('handleLoading---'+status);
|
||||||
this.isLoading = status;
|
this.isLoading = status;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -655,6 +658,31 @@ closeMinimizedWindow() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 处理鼠标滚轮事件
|
||||||
|
handleWheel(event) {
|
||||||
|
const element = this.$refs.messageContainer;
|
||||||
|
if (!element) return;
|
||||||
|
|
||||||
|
// 阻止事件冒泡,防止滚动底层页面
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
// 计算滚动方向和距离
|
||||||
|
const delta = event.deltaY || event.detail || event.wheelDelta;
|
||||||
|
|
||||||
|
// 检查是否可以继续滚动
|
||||||
|
if (delta < 0 && element.scrollTop === 0) {
|
||||||
|
// 向上滚动且已在顶部,阻止默认行为
|
||||||
|
event.preventDefault();
|
||||||
|
} else if (delta > 0 && element.scrollHeight - element.scrollTop <= element.clientHeight) {
|
||||||
|
// 向下滚动且已在底部,阻止默认行为
|
||||||
|
event.preventDefault();
|
||||||
|
} else {
|
||||||
|
// 允许在容器内滚动
|
||||||
|
element.scrollTop += delta;
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 最小化窗口的点击事件处理方法
|
// 最小化窗口的点击事件处理方法
|
||||||
onMinimizedWindowClick() {
|
onMinimizedWindowClick() {
|
||||||
// 当点击最小化窗口时,如果dialogVisible为false,则通过事件通知父组件显示对话框
|
// 当点击最小化窗口时,如果dialogVisible为false,则通过事件通知父组件显示对话框
|
||||||
@@ -669,6 +697,9 @@ closeMinimizedWindow() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
::v-deep .el-dialog__wrapper{
|
||||||
|
position: unset!important;
|
||||||
|
}
|
||||||
.case-expert-dialog {
|
.case-expert-dialog {
|
||||||
::v-deep .el-dialog{
|
::v-deep .el-dialog{
|
||||||
background: url("./components/u762.svg") no-repeat ;
|
background: url("./components/u762.svg") no-repeat ;
|
||||||
@@ -677,6 +708,8 @@ closeMinimizedWindow() {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
pointer-events: auto;
|
||||||
|
z-index: 2000;
|
||||||
|
|
||||||
//background-color: rgba(255, 255, 255, 0.8);
|
//background-color: rgba(255, 255, 255, 0.8);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
|||||||
type="textarea"
|
type="textarea"
|
||||||
class="input-placeholder"
|
class="input-placeholder"
|
||||||
placeholder="有问题,尽管问"
|
placeholder="有问题,尽管问"
|
||||||
@keyup.enter.native="handleSend"
|
@keyup.enter.native.prevent="handleSend"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:autosize="{ minRows: 2, maxRows: 4}"
|
:autosize="{ minRows: 2, maxRows: 4}"
|
||||||
resize="none"
|
resize="none"
|
||||||
@@ -56,7 +56,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSend() {
|
handleSend(event) {
|
||||||
|
// 阻止事件的默认行为和冒泡
|
||||||
|
if (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
console.log('preventDefault');
|
||||||
|
}
|
||||||
|
console.log('handleSend');
|
||||||
if (!this.inputContent.trim() || this.disabled) return
|
if (!this.inputContent.trim() || this.disabled) return
|
||||||
// 添加用户消息到列表
|
// 添加用户消息到列表
|
||||||
const userMessage = {
|
const userMessage = {
|
||||||
|
|||||||
@@ -2590,7 +2590,7 @@ a.custom2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.course-tags {
|
.course-tags {
|
||||||
margin: 5px 0;
|
margin: 10px 0 0;
|
||||||
min-height: 20px;
|
min-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2477,6 +2477,10 @@ export default {
|
|||||||
background-color: #f4f4f5;
|
background-color: #f4f4f5;
|
||||||
border-color: #e9e9eb;
|
border-color: #e9e9eb;
|
||||||
}
|
}
|
||||||
|
.course-tags {
|
||||||
|
margin: 10px 0 0;
|
||||||
|
min-height: 20px;
|
||||||
|
}
|
||||||
.course-tags ::v-deep .el-tag .keyword-highlight,
|
.course-tags ::v-deep .el-tag .keyword-highlight,
|
||||||
.course-tags ::v-deep .el-tag .exact-match-highlight {
|
.course-tags ::v-deep .el-tag .exact-match-highlight {
|
||||||
color: #387DF7 !important;
|
color: #387DF7 !important;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user