fix: 修改模板
This commit is contained in:
parent
12f85a51ed
commit
e8f23283a2
33
.eslintrc.js
33
.eslintrc.js
@ -12,25 +12,28 @@ module.exports = {
|
||||
ecmaVersion: 2020,
|
||||
},
|
||||
"env": {
|
||||
// 您的环境变量(包含多个预定义的全局变量)
|
||||
// Your environments (which contains several predefined global variables)
|
||||
//
|
||||
// browser: true,
|
||||
// node: true,
|
||||
// mocha: true,
|
||||
// jest: true,
|
||||
// jquery: true
|
||||
// 您的环境变量(包含多个预定义的全局变量)
|
||||
// Your environments (which contains several predefined global variables)
|
||||
//
|
||||
// browser: true,
|
||||
// node: true,
|
||||
// mocha: true,
|
||||
// jest: true,
|
||||
// jquery: true
|
||||
},
|
||||
"globals": {
|
||||
// 您的全局变量(设置为 false 表示它不允许被重新赋值)
|
||||
// Your global variables (setting to false means it's not allowed to be reassigned)
|
||||
//
|
||||
// myGlobal: false
|
||||
// 您的全局变量(设置为 false 表示它不允许被重新赋值)
|
||||
// Your global variables (setting to false means it's not allowed to be reassigned)
|
||||
//
|
||||
// myGlobal: false
|
||||
},
|
||||
"rules": {
|
||||
// 自定义您的规则
|
||||
// Customize your rules
|
||||
// 自定义您的规则
|
||||
// Customize your rules
|
||||
"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: {
|
||||
// 'primary-color': '#2228e0',
|
||||
// 'info-color': '#2228e0',
|
||||
// 'processing-color': '#2228e0',
|
||||
// 'link-color': '#2228e0',
|
||||
// 'success-color': '#46cf84',
|
||||
// 'warning-color': '#ffa42e',
|
||||
// 'error-color': '#fa4646',
|
||||
// 'highlight-color': '#fa4646',
|
||||
// 'normal-color': '#e0e0e0',
|
||||
// 'heading-color': '#000000',
|
||||
// 'text-color': '#4a4a4a',
|
||||
// 'text-color-secondary': '#7c7c7c',
|
||||
// 'disabled-color': '#c7c7c7',
|
||||
// 'border-radius-base': '3px',
|
||||
// 'border-color-base': '#e0e0e0',
|
||||
// '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"',
|
||||
// 'padding-lg': '24px',
|
||||
// 'padding-md': '16px',
|
||||
// 'padding-sm': '12px',
|
||||
// 'padding-xs': '8px',
|
||||
// 'padding-xxs': '4px',
|
||||
// 'margin-lg': '24px',
|
||||
// 'margin-md': '16px',
|
||||
// 'margin-sm': '12px',
|
||||
// 'margin-xs': '8px',
|
||||
// 'margin-xxs': '4px',
|
||||
'primary-color': '#2228e0',
|
||||
'info-color': '#2228e0',
|
||||
'processing-color': '#2228e0',
|
||||
'link-color': '#2228e0',
|
||||
'success-color': '#46cf84',
|
||||
'warning-color': '#ffa42e',
|
||||
'error-color': '#fa4646',
|
||||
'highlight-color': '#fa4646',
|
||||
'normal-color': '#e0e0e0',
|
||||
'heading-color': '#000000',
|
||||
'text-color': '#4a4a4a',
|
||||
'text-color-secondary': '#7c7c7c',
|
||||
'disabled-color': '#c7c7c7',
|
||||
'border-radius-base': '3px',
|
||||
'border-color-base': '#e0e0e0',
|
||||
'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"',
|
||||
'padding-lg': '24px',
|
||||
'padding-md': '16px',
|
||||
'padding-sm': '12px',
|
||||
'padding-xs': '8px',
|
||||
'padding-xxs': '4px',
|
||||
'margin-lg': '24px',
|
||||
'margin-md': '16px',
|
||||
'margin-sm': '12px',
|
||||
'margin-xs': '8px',
|
||||
'margin-xxs': '4px',
|
||||
},
|
||||
locale: {
|
||||
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/pro-layout": "^6.15.4",
|
||||
"antd": "^4.20.6",
|
||||
"axios": "^0.19.2",
|
||||
"@ant-design/pro-components": "^1.1.2",
|
||||
"classnames": "^2.2.6",
|
||||
"dayjs": "^1.11.2",
|
||||
"js-cookie": "^2.2.1",
|
||||
"react": "^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 CodeMsg from '@/assets/data/code';
|
||||
import { BaseResponse } from '@/interfaces/base';
|
||||
|
||||
export const DEFAULT_TIP_MESSAGE = '请求失败,请刷新重试';
|
||||
|
||||
/**
|
||||
* 错误处理
|
||||
* @param data {Object} 请求返回的信息
|
||||
*/
|
||||
export function handleError(data: BaseResponse): void {
|
||||
const msg = CodeMsg[data.code] || data.msg || DEFAULT_TIP_MESSAGE;
|
||||
export function handleError(data: BaseResponse) {
|
||||
const msg = CodeMsg[data.code] || data.msg || CodeMsg['DEFAULT_TIP_MESSAGE'];
|
||||
message.error(msg);
|
||||
}
|
||||
|
||||
// create an axios instance
|
||||
const service = axios.create({
|
||||
const service = extend({
|
||||
baseURL: process.env.BASE_API, // api的base_url
|
||||
// timeout: 5000, // request timeout
|
||||
timeout: 1000,
|
||||
mode: 'cors',
|
||||
errorHandler: (error: any) => handleError(error),
|
||||
});
|
||||
|
||||
// request interceptor
|
||||
service.interceptors.request.use(
|
||||
config => {
|
||||
(url: string, config: any) => {
|
||||
// 防止 GET 请求缓存GET
|
||||
if (config.method === 'get') {
|
||||
if (config.method === 'GET') {
|
||||
const t = new Date().getTime();
|
||||
config.params = config.params ? { ...config.params, t } : { t };
|
||||
}
|
||||
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
|
||||
service.interceptors.response.use(
|
||||
response => {
|
||||
const res = response.data;
|
||||
if (!res.success) {
|
||||
if (res.code === '1007') {
|
||||
async (response: any) => {
|
||||
const res = await response.clone().json();
|
||||
if (Number(res.code) !== 200) {
|
||||
if (Number(res.code) === 1007) {
|
||||
// 登录失效
|
||||
window.location.href = '/';
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
handleError(res);
|
||||
return Promise.resolve();
|
||||
}
|
||||
return res;
|
||||
},
|
||||
error => {
|
||||
handleError(error);
|
||||
console.log(`err${error}`); // for debug
|
||||
return Promise.reject(error);
|
||||
},
|
||||
return res.data;
|
||||
}
|
||||
);
|
||||
|
||||
export default service;
|
||||
|
Loading…
Reference in New Issue
Block a user