Browse Source

добавлена возможность смены тестового URL

pull/1/head
Sergey Verevkin 3 years ago
parent
commit
0de0c82563
  1. 11
      src/components/GamePage/GamePage.tsx
  2. 4
      src/store/apiStore/apiStore.ts

11
src/components/GamePage/GamePage.tsx

@ -21,6 +21,13 @@ type GameProps = {
const GamePage: React.FC<GameProps> = (props) => { const GamePage: React.FC<GameProps> = (props) => {
const {onExitGame} = props; const {onExitGame} = props;
const [state, setState] = useState(0); const [state, setState] = useState(0);
const [url, setUrl] = useState(apiStore.apiUrl);
const setNewUrl = (newUrl: string) => {
if (url === newUrl) return;
setUrl(newUrl);
apiStore.setApiUrl(newUrl);
};
const clickAtWitch = (guid: string) => { const clickAtWitch = (guid: string) => {
apiStore.turn(guid) apiStore.turn(guid)
@ -78,8 +85,8 @@ const GamePage: React.FC<GameProps> = (props) => {
<li>хостинг <li>хостинг
<input <input
type='text' type='text'
value={apiStore.apiUrl} value={url}
onChange={(e) => apiStore.setApiUrl(e.target.value)}/></li> onChange={(e) => setNewUrl(e.target.value)}/></li>
<li>прием CORS от ooya.ga</li> <li>прием CORS от ooya.ga</li>
</ul> </ul>
</div> </div>

4
src/store/apiStore/apiStore.ts

@ -108,7 +108,9 @@ class ApiStore {
} }
setApiUrl(apiUrl: string) { setApiUrl(apiUrl: string) {
if (apiUrl !== this.apiUrl) this.apiUrl = apiUrl; if (apiUrl !== this.apiUrl) {
this.apiUrl = apiUrl;
}
} }
setVersion(version: string) { setVersion(version: string) {

Loading…
Cancel
Save