diff --git a/spug_web/src/pages/welcome/info/Basic.js b/spug_web/src/pages/welcome/info/Basic.js index 6c7f051..f24009b 100644 --- a/spug_web/src/pages/welcome/info/Basic.js +++ b/spug_web/src/pages/welcome/info/Basic.js @@ -7,20 +7,20 @@ import React, { useState } from 'react'; import { Button, Form, Input, message } from 'antd'; import styles from './index.module.css'; import { http } from 'libs'; -import store from './store'; export default function Basic(props) { const [nickname, setNickname] = useState(localStorage.getItem('nickname')); + const [loading, setLoading] = useState(false); function handleSubmit() { - store.loading = true; + setLoading(true); http.patch('/api/account/self/', {nickname}) .then(() => { message.success('设置成功,重新登录或刷新页面后生效'); localStorage.setItem('nickname', nickname) }) - .finally(() => store.loading = false) + .finally(() =>setLoading(false)) } return ( @@ -31,7 +31,7 @@ export default function Basic(props) { setNickname(e.target.value)}/> - + diff --git a/spug_web/src/pages/welcome/info/Reset.js b/spug_web/src/pages/welcome/info/Reset.js index 9bab36e..6325bad 100644 --- a/spug_web/src/pages/welcome/info/Reset.js +++ b/spug_web/src/pages/welcome/info/Reset.js @@ -7,11 +7,11 @@ import React, { useState } from 'react'; import { Button, Form, Input, message } from 'antd'; import styles from './index.module.css'; import { http } from 'libs'; -import store from './store'; import history from 'libs/history'; export default function Reset(props) { + const [loading, setLoading] = useState(false); const [old_password, setOldPassword] = useState(); const [new_password, setNewPassword] = useState(); const [new2_password, setNew2Password] = useState(); @@ -24,14 +24,14 @@ export default function Reset(props) { } else if (new_password !== new2_password) { return message.error('两次输入密码不一致') } - store.loading = true; + setLoading(true); http.patch('/api/account/self/', {old_password, new_password}) .then(() => { message.success('密码修改成功'); history.push('/'); http.get('/api/account/logout/') }) - .finally(() => store.loading = false) + .finally(() => setLoading(false)) } return ( @@ -48,7 +48,7 @@ export default function Reset(props) { setNew2Password(e.target.value)}/> - + diff --git a/spug_web/src/pages/welcome/info/store.js b/spug_web/src/pages/welcome/info/store.js deleted file mode 100644 index ef18d68..0000000 --- a/spug_web/src/pages/welcome/info/store.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) OpenSpug Organization. https://github.com/openspug/spug - * Copyright (c) - * Released under the AGPL-3.0 License. - */ -import { observable } from "mobx"; - -class Store { - @observable loading = false; -} - -export default new Store()