templates/.vscode/react.code-snippets
2022-07-14 11:12:19 +08:00

77 lines
2.0 KiB
Plaintext

{
"函数组件模板": {
"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;"
]
}
}