|
@@ -1,11 +1,17 @@
|
|
|
import Notify from './Notify.js';
|
|
import Notify from './Notify.js';
|
|
|
|
|
+import { notification } from 'ant-design-vue';
|
|
|
|
|
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
pageSize: 20,
|
|
pageSize: 20,
|
|
|
|
|
|
|
|
|
|
|
|
|
- // 异常处理
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 使用 BootstarpDialog 处理Ajax请求异常
|
|
|
|
|
+ * @param {*} XMLHttpRequest
|
|
|
|
|
+ * @param {*} textStatus
|
|
|
|
|
+ * @param {*} errorThrown
|
|
|
|
|
+ */
|
|
|
processException: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
processException: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
var _self = this;
|
|
var _self = this;
|
|
|
console.log(XMLHttpRequest);
|
|
console.log(XMLHttpRequest);
|
|
@@ -45,6 +51,49 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 使用 ant-design-vue 处理Ajax请求异常
|
|
|
|
|
+ * @param {*} XMLHttpRequest
|
|
|
|
|
+ */
|
|
|
|
|
+ processExceptionWithAntV: function (XMLHttpRequest) {
|
|
|
|
|
+ var _self = this;
|
|
|
|
|
+ console.log(XMLHttpRequest);
|
|
|
|
|
+ notification.error({
|
|
|
|
|
+ message: XMLHttpRequest.status,
|
|
|
|
|
+ description: XMLHttpRequest.responseText,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ if (XMLHttpRequest.status == 401) {
|
|
|
|
|
+ var currentUrl = window.location;
|
|
|
|
|
+ var href = window.location.href;
|
|
|
|
|
+ // 当前未处于登陆的界面
|
|
|
|
|
+ // 系统未登录
|
|
|
|
|
+ if (href.indexOf('login') < 0 && href.indexOf('redirectUrl=') < 0) {
|
|
|
|
|
+ // 处理钉钉免登陆
|
|
|
|
|
+ const clientId = this.getRouteParam('clientId');
|
|
|
|
|
+ const appName = this.getRouteParam('appName');
|
|
|
|
|
+ const corpId = this.getRouteParam('corpId');
|
|
|
|
|
+
|
|
|
|
|
+ let newUrl;
|
|
|
|
|
+ if (clientId != null && clientId.length > 0 && appName != null && appName.length > 0 && corpId != null && corpId.length > 0) {
|
|
|
|
|
+ newUrl = _self.getRedirectUrl('index.html#/login?clientId=' + clientId + '&appName=' + appName + '&corpId=' + corpId + '&redirectUrl=' + encodeURIComponent(currentUrl));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ newUrl = _self.getRedirectUrl('index.html#/login?redirectUrl=' + encodeURIComponent(currentUrl));
|
|
|
|
|
+ }
|
|
|
|
|
+ window.location = newUrl;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (XMLHttpRequest.status == 500) {
|
|
|
|
|
+ // 500 Internal Server Error
|
|
|
|
|
+ if (XMLHttpRequest.responseText.indexOf('登录超时') >= 0) {
|
|
|
|
|
+ // 如果异常信息包含“登录超时”,则2秒后跳转到登录页面
|
|
|
|
|
+ setTimeout(function () {
|
|
|
|
|
+ window.location = _self.getRedirectUrl('index.html#/login');
|
|
|
|
|
+ }, 2 * 1000);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 获取主机地址
|
|
* 获取主机地址
|
|
@@ -201,12 +250,7 @@ export default {
|
|
|
* @param {*} url
|
|
* @param {*} url
|
|
|
*/
|
|
*/
|
|
|
getRedirectUrl: function (url) {
|
|
getRedirectUrl: function (url) {
|
|
|
- var href = window.location.href;
|
|
|
|
|
- if (href.indexOf('pcapp') >= 0) {
|
|
|
|
|
- return this.getHostPageBaseURL() + '/pcapp/' + url;
|
|
|
|
|
- } else {
|
|
|
|
|
- return this.getHostPageBaseURL() + '/' + url;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return this.getHostPageBaseURL() + '/' + url;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
clearLocalStorage: function () {
|
|
clearLocalStorage: function () {
|