Commit 40d489f4 authored by duanledexianxianxian's avatar duanledexianxianxian 😁

sync code

parent 02708f8a
......@@ -26,6 +26,7 @@ function getModulePackageName(module: { context: string }) {
export default (config: any) => {
// preview.pro.ant.design only do not use in your production;
console.log(process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION, process.env.NODE_ENV);
if (
process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ||
process.env.NODE_ENV !== 'production'
......
......@@ -25,6 +25,7 @@ export default {
return `/${cssUrl}`;
},
};
console.log(options);
return client.changer.changeColor(options, Promise);
},
};
......@@ -7,6 +7,8 @@ export default {
resMessageKey: 'message', // 后台正常返回错误编码
successCode: 'sys.success', // 后台正常返回错误编码
isThrowError: true, // 默认为true
authCodes: ['system.authc'],
apiType: 0, // 接口模式0-code 模式 1-stauts模式
},
copyright: `${new Date().getFullYear()} KIM3.0技术中台部出品`,
homePage: '/dashboard/analysis',
......
......@@ -20,6 +20,7 @@ export interface SettingModelType {
const updateTheme = (newPrimaryColor?: string) => {
if (newPrimaryColor) {
console.log(newPrimaryColor);
const timeOut = 0;
const hideMessage = message.loading('正在切换主题!', timeOut);
themeColorClient.changeColor(newPrimaryColor).finally(() => hideMessage());
......@@ -121,9 +122,9 @@ const SettingModel: SettingModelType = {
primaryColor: appTheme,
layout: navigatorStyle === 0 ? 'sidemenu' : 'topmenu',
contentWidth: contentWidth === 0 ? 'Fluid' : 'Fixed',
fixedHeader: fixedHead,
autoHideHeader: hideHead,
fixSiderbar: fixedSide,
fixedHeader: fixedHead === 1,
autoHideHeader: hideHead === 1,
fixSiderbar: fixedSide === 1,
};
}
yield put({
......
......@@ -2,6 +2,7 @@
/* eslint-disable no-bitwise */
import pathToRegexp from 'path-to-regexp';
import { parse } from 'qs';
import { async } from 'q';
/**
* 获取链接的query url部分
......
import axios from 'axios';
import { string } from 'prop-types';
class HttpRequest {
constructor(options) {
......
import { notification } from 'antd';
import router from 'umi/router';
import HttpRequest from './kim-request';
import config from '@/config';
import store from '@/utils/store';
import { clearLoginStatus } from '@/utils/utils';
/**
* todo 还需处理国际化
......@@ -32,7 +34,7 @@ const {
resMessageKey,
successCode,
isThrowError = true,
redirectFunc,
authCodes = ['system.authc'],
},
} = config;
......@@ -84,7 +86,7 @@ const handleResponse = (response, more) => {
const handleError = error => {
const { response } = error;
// 如果response存在
// status
if (response && response.status) {
const errorText = codeMessage[response.status] || response.statusText;
const {
......@@ -92,17 +94,36 @@ const handleError = error => {
config: { url },
} = response;
notification.error({
message: `请求错误 ${status}: ${url}`,
description: errorText,
message: `请求错误 ${status}`,
description: `${url}${errorText}`,
});
// if (status >= 404 && status < 422) {
// router.push('/exception/404');
// }
if (status <= 504 && status >= 500) {
router.push('/exception/500');
}
// 跳转到登录页面 可能原因:token 失效
if (status === 403 && status === 401) {
clearLoginStatus();
router.push('/user/login');
}
} else {
// code
const { code, message } = error;
notification.error({
key: `notification_${code ? message : code}`,
message: '请求错误',
description: message,
});
// 跳转到登录页面 可能原因:token 失效
if (authCodes && authCodes.includes(code)) {
// 清空相关信息
clearLoginStatus();
router.push('/user/login');
}
}
if (isThrowError) {
throw error;
} else {
......
import store from '@/utils/store';
/* eslint no-useless-escape:0 import/prefer-default-export:0 */
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
......@@ -22,4 +24,9 @@ const isAntDesignProOrDev = (): boolean => {
return isAntDesignPro();
};
export { isAntDesignProOrDev, isAntDesignPro, isUrl };
const clearLoginStatus = () => {
store.set('token', '');
store.set('userId', '');
};
export { isAntDesignProOrDev, isAntDesignPro, isUrl, clearLoginStatus };
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment