增加权限和 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 Plan from "./Plan";
import Auth from "./Auth";
class Root {
constructor() {
this.plan = new Plan(this);
this.auth = new Auth(this);
makeAutoObservable(this);
}
}

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

Loading…
Cancel
Save