fix: 修改模板
This commit is contained in:
parent
12f85a51ed
commit
e8f23283a2
@ -31,6 +31,9 @@ module.exports = {
|
|||||||
// 自定义您的规则
|
// 自定义您的规则
|
||||||
// Customize your rules
|
// Customize your rules
|
||||||
"react/jsx-no-useless-fragment": 0,
|
"react/jsx-no-useless-fragment": 0,
|
||||||
"@typescript-eslint/no-require-imports": 0
|
"@typescript-eslint/no-require-imports": 0,
|
||||||
|
"no-constant-binary-expression": 0,
|
||||||
|
"no-unused-private-class-members": 0,
|
||||||
|
"prefer-object-has-own": 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
54
.umirc.ts
54
.umirc.ts
@ -68,33 +68,33 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
// 'primary-color': '#2228e0',
|
'primary-color': '#2228e0',
|
||||||
// 'info-color': '#2228e0',
|
'info-color': '#2228e0',
|
||||||
// 'processing-color': '#2228e0',
|
'processing-color': '#2228e0',
|
||||||
// 'link-color': '#2228e0',
|
'link-color': '#2228e0',
|
||||||
// 'success-color': '#46cf84',
|
'success-color': '#46cf84',
|
||||||
// 'warning-color': '#ffa42e',
|
'warning-color': '#ffa42e',
|
||||||
// 'error-color': '#fa4646',
|
'error-color': '#fa4646',
|
||||||
// 'highlight-color': '#fa4646',
|
'highlight-color': '#fa4646',
|
||||||
// 'normal-color': '#e0e0e0',
|
'normal-color': '#e0e0e0',
|
||||||
// 'heading-color': '#000000',
|
'heading-color': '#000000',
|
||||||
// 'text-color': '#4a4a4a',
|
'text-color': '#4a4a4a',
|
||||||
// 'text-color-secondary': '#7c7c7c',
|
'text-color-secondary': '#7c7c7c',
|
||||||
// 'disabled-color': '#c7c7c7',
|
'disabled-color': '#c7c7c7',
|
||||||
// 'border-radius-base': '3px',
|
'border-radius-base': '3px',
|
||||||
// 'border-color-base': '#e0e0e0',
|
'border-color-base': '#e0e0e0',
|
||||||
// 'font-family':
|
'font-family':
|
||||||
// '"Alibaba PuHuiTi", "SourceHanSans TW", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
'"Alibaba PuHuiTi", "SourceHanSans TW", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
||||||
// 'padding-lg': '24px',
|
'padding-lg': '24px',
|
||||||
// 'padding-md': '16px',
|
'padding-md': '16px',
|
||||||
// 'padding-sm': '12px',
|
'padding-sm': '12px',
|
||||||
// 'padding-xs': '8px',
|
'padding-xs': '8px',
|
||||||
// 'padding-xxs': '4px',
|
'padding-xxs': '4px',
|
||||||
// 'margin-lg': '24px',
|
'margin-lg': '24px',
|
||||||
// 'margin-md': '16px',
|
'margin-md': '16px',
|
||||||
// 'margin-sm': '12px',
|
'margin-sm': '12px',
|
||||||
// 'margin-xs': '8px',
|
'margin-xs': '8px',
|
||||||
// 'margin-xxs': '4px',
|
'margin-xxs': '4px',
|
||||||
},
|
},
|
||||||
locale: {
|
locale: {
|
||||||
default: 'zh-CN',
|
default: 'zh-CN',
|
||||||
|
77
.vscode/react.code-snippets
vendored
Normal file
77
.vscode/react.code-snippets
vendored
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"函数组件模板": {
|
||||||
|
"prefix": "tsx",
|
||||||
|
"body": [
|
||||||
|
"// $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE - by dev",
|
||||||
|
"\n",
|
||||||
|
"import { } from 'react'",
|
||||||
|
"import { connect, ConnectProps } from 'umi'",
|
||||||
|
"import {} from 'antd-mobile'",
|
||||||
|
"import styles from './index.less'",
|
||||||
|
"\n",
|
||||||
|
"interface I$1 extends ConnectProps {",
|
||||||
|
"}",
|
||||||
|
"\n",
|
||||||
|
"export default connect(({}: {}) => ({",
|
||||||
|
"}))((props: I$1) => {",
|
||||||
|
" return (",
|
||||||
|
" <div className={styles.$1}>$1</div>",
|
||||||
|
" )",
|
||||||
|
"})",
|
||||||
|
],
|
||||||
|
"description": "umi 函数组件模板"
|
||||||
|
},
|
||||||
|
"model模板": {
|
||||||
|
"prefix": "mts",
|
||||||
|
"body": [
|
||||||
|
"import { ImmerReducer, Effect } from 'umi';",
|
||||||
|
"import { SubscriptionsMapObject } from 'dva';",
|
||||||
|
"import { } from './serve';",
|
||||||
|
"\n",
|
||||||
|
"export interface $1ModelState {",
|
||||||
|
"}",
|
||||||
|
"\n",
|
||||||
|
"export interface $1ModelType {",
|
||||||
|
" namespace: '$1';",
|
||||||
|
" state: $1ModelState;",
|
||||||
|
" effects: {",
|
||||||
|
" };",
|
||||||
|
" reducers: {",
|
||||||
|
" save: ImmerReducer<$1ModelState>;",
|
||||||
|
" reset: ImmerReducer<$1ModelState>;",
|
||||||
|
" };",
|
||||||
|
" subscriptions: SubscriptionsMapObject;",
|
||||||
|
"}",
|
||||||
|
"\n",
|
||||||
|
"const initialState: $1ModelState = {",
|
||||||
|
"}",
|
||||||
|
"\n",
|
||||||
|
"const $1Model: $1ModelType = {",
|
||||||
|
" namespace: '$1',",
|
||||||
|
" state: initialState,",
|
||||||
|
" effects: {",
|
||||||
|
" // *getFormList({ payload }, { call, put }) {",
|
||||||
|
" // const response = yield call(getCaseForm, payload);",
|
||||||
|
" // yield put({",
|
||||||
|
" // type: 'save',",
|
||||||
|
" // payload: response,",
|
||||||
|
" // });",
|
||||||
|
" //},",
|
||||||
|
" },",
|
||||||
|
" reducers: {",
|
||||||
|
" save(state, { payload }: any) {",
|
||||||
|
" return { ...state, ...payload }",
|
||||||
|
" },",
|
||||||
|
" reset(state, { payload }: any) {",
|
||||||
|
" return { ...initialState }",
|
||||||
|
" }",
|
||||||
|
" },",
|
||||||
|
" subscriptions: {}",
|
||||||
|
"};",
|
||||||
|
"\n",
|
||||||
|
|
||||||
|
"export default $1Model;"
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -41,8 +41,9 @@
|
|||||||
"@ant-design/icons": "^4.7.0",
|
"@ant-design/icons": "^4.7.0",
|
||||||
"@ant-design/pro-layout": "^6.15.4",
|
"@ant-design/pro-layout": "^6.15.4",
|
||||||
"antd": "^4.20.6",
|
"antd": "^4.20.6",
|
||||||
"axios": "^0.19.2",
|
"@ant-design/pro-components": "^1.1.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
|
"dayjs": "^1.11.2",
|
||||||
"js-cookie": "^2.2.1",
|
"js-cookie": "^2.2.1",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
|
@ -1,66 +1,52 @@
|
|||||||
import axios from 'axios';
|
import { extend } from 'umi-request';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import CodeMsg from '@/assets/data/code';
|
import CodeMsg from '@/assets/data/code';
|
||||||
import { BaseResponse } from '@/interfaces/base';
|
import { BaseResponse } from '@/interfaces/base';
|
||||||
|
|
||||||
export const DEFAULT_TIP_MESSAGE = '请求失败,请刷新重试';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 错误处理
|
* 错误处理
|
||||||
* @param data {Object} 请求返回的信息
|
* @param data {Object} 请求返回的信息
|
||||||
*/
|
*/
|
||||||
export function handleError(data: BaseResponse): void {
|
export function handleError(data: BaseResponse) {
|
||||||
const msg = CodeMsg[data.code] || data.msg || DEFAULT_TIP_MESSAGE;
|
const msg = CodeMsg[data.code] || data.msg || CodeMsg['DEFAULT_TIP_MESSAGE'];
|
||||||
message.error(msg);
|
message.error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create an axios instance
|
// create an axios instance
|
||||||
const service = axios.create({
|
const service = extend({
|
||||||
baseURL: process.env.BASE_API, // api的base_url
|
baseURL: process.env.BASE_API, // api的base_url
|
||||||
// timeout: 5000, // request timeout
|
timeout: 1000,
|
||||||
|
mode: 'cors',
|
||||||
|
errorHandler: (error: any) => handleError(error),
|
||||||
});
|
});
|
||||||
|
|
||||||
// request interceptor
|
// request interceptor
|
||||||
service.interceptors.request.use(
|
service.interceptors.request.use(
|
||||||
config => {
|
(url: string, config: any) => {
|
||||||
// 防止 GET 请求缓存GET
|
// 防止 GET 请求缓存GET
|
||||||
if (config.method === 'get') {
|
if (config.method === 'GET') {
|
||||||
const t = new Date().getTime();
|
const t = new Date().getTime();
|
||||||
config.params = config.params ? { ...config.params, t } : { t };
|
config.params = config.params ? { ...config.params, t } : { t };
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
},
|
|
||||||
error => {
|
|
||||||
// Do something with request error
|
|
||||||
if (error.status === '504') {
|
|
||||||
message.error('网关超时,请重试!');
|
|
||||||
} else {
|
|
||||||
message.error(`网络异常[-${error.status}]`);
|
|
||||||
console.log(error); // for debug
|
|
||||||
}
|
}
|
||||||
Promise.reject(error);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// response interceptor
|
// response interceptor
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
response => {
|
async (response: any) => {
|
||||||
const res = response.data;
|
const res = await response.clone().json();
|
||||||
if (!res.success) {
|
if (Number(res.code) !== 200) {
|
||||||
if (res.code === '1007') {
|
if (Number(res.code) === 1007) {
|
||||||
// 登录失效
|
// 登录失效
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
return;
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
handleError(res);
|
handleError(res);
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return res.data;
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
handleError(error);
|
|
||||||
console.log(`err${error}`); // for debug
|
|
||||||
return Promise.reject(error);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
|
|
||||||
export default service;
|
export default service;
|
||||||
|
Loading…
Reference in New Issue
Block a user