Commit 40d489f4 authored by duanledexianxianxian's avatar duanledexianxianxian 😁

sync code

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