-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(basic-routes-rematch-new):用ts重新案例
- Loading branch information
Showing
15 changed files
with
109 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createModel } from "@rematch/core" | ||
import { RootModel } from "./index" | ||
|
||
export default createModel<RootModel>()({ | ||
name: "demo", | ||
state: { | ||
title: "demo 标题" | ||
}, | ||
effects: () => ({ | ||
async very(_, store) { | ||
console.log("打印 demo", store.demo.title) | ||
} | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import login from "./login" | ||
import demo from "./demo" | ||
// @ts-ignore | ||
import { | ||
init, | ||
Models, | ||
Model, | ||
RematchRootState, | ||
RematchDispatch, | ||
} from '@rematch/core'; | ||
import loading, { ExtraModelsFromLoading } from '@rematch/loading'; | ||
|
||
export const models = { | ||
login, | ||
demo, | ||
} | ||
|
||
export interface RootModel extends Models<RootModel> { | ||
login: typeof login, | ||
demo: typeof demo, | ||
} | ||
export type FullModel = ExtraModelsFromLoading<RootModel> | ||
|
||
export const store = init<RootModel, FullModel>({ | ||
models, | ||
plugins: [loading()], | ||
}); | ||
|
||
export const { dispatch, addModel } = store; | ||
export type Store = typeof store; | ||
export type AddModel = typeof addModel; | ||
export type Dispatch = RematchDispatch<RootModel>; | ||
export type RootState = RematchRootState<RootModel, FullModel>; | ||
export type ModelDefault<T = any> = Model<RootModel, T>; | ||
|
||
export default store; |
7 changes: 4 additions & 3 deletions
7
...ic-routes-rematch-new/src/models/login.js → ...ic-routes-rematch-new/src/models/login.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...tes-rematch-new/src/routes/About/index.js → ...es-rematch-new/src/routes/About/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import React from "react"; | ||
import { useSelector } from 'react-redux' | ||
|
||
import { RootState } from "./../../models" | ||
const About = () => { | ||
const title = useSelector(({ demo }) => demo.title) | ||
|
||
const title = useSelector<RootState>((store) => store.demo.title) | ||
return <div>About {title}</div> | ||
} | ||
export default About; |
3 changes: 2 additions & 1 deletion
3
...utes-rematch-new/src/routes/Home/index.js → ...tes-rematch-new/src/routes/Home/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"lib": [ | ||
"esnext", | ||
"dom" | ||
], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"declaration": true, | ||
"baseUrl": ".", | ||
"jsx": "react-jsx", | ||
"noFallthroughCasesInSwitch": true, | ||
"noEmit": true, | ||
"paths": { | ||
"@/*": [ | ||
"./src/*" | ||
], | ||
} | ||
}, | ||
"include": [ | ||
"src/**/*", | ||
".kktssrrc.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,10 @@ | |
"@/*": [ | ||
"./src/*" | ||
], | ||
"@@/*": [ | ||
"./src/.uiw/*" | ||
] | ||
} | ||
}, | ||
"include": [ | ||
"src/**/*", | ||
".kktrc.ts" | ||
".kktssrrc.ts" | ||
] | ||
} |