增加权限和 useStore

release
Jimmy Liow 2 years ago
parent 0a3b4701cb
commit 43255a2cb5

@ -0,0 +1,11 @@
import { makeAutoObservable } from "mobx";
class Auth {
constructor(root) {
makeAutoObservable(this, { rootStore: false });
this.root = root;
}
}
export default Auth;

@ -1,9 +1,11 @@
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import Plan from "./Plan"; import Plan from "./Plan";
import Auth from "./Auth";
class Root { class Root {
constructor() { constructor() {
this.plan = new Plan(this); this.plan = new Plan(this);
this.auth = new Auth(this);
makeAutoObservable(this); makeAutoObservable(this);
} }
} }

@ -79,8 +79,7 @@ const data = [
function Plan() { function Plan() {
const {planId} = useParams(); const {planId} = useParams();
const store = useStore(); const {plan} = useStore();
const planStore = store.plan;
useEffect(() => { useEffect(() => {
console.info('planId: ' + planId); console.info('planId: ' + planId);
@ -94,8 +93,8 @@ function Plan() {
</Col> </Col>
<Col span={20}> <Col span={20}>
<Button onClick={() => planStore.increase()}>increase {planStore.count}</Button> <Button onClick={() => plan.increase()}>increase {plan.count}</Button>
<Button onClick={() => planStore.decrease()}>decrease {planStore.count}</Button> <Button onClick={() => plan.decrease()}>decrease {plan.count}</Button>
</Col> </Col>
</Row> </Row>
<Row> <Row>

Loading…
Cancel
Save