-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
153 additions
and
167 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<link rel="stylesheet" href="/src/styles.css" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Magic-Eye</title> | ||
</head> | ||
<body> | ||
<nav id="titlebar"></nav> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<link rel="stylesheet" href="/src/styles.css" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Magic-Eye</title> | ||
</head> | ||
<body> | ||
<nav id="titlebar"></nav> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
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 |
---|---|---|
|
@@ -2,8 +2,6 @@ | |
@tailwind components; | ||
@tailwind utilities; | ||
|
||
|
||
|
||
@layer components { | ||
*::-webkit-scrollbar { | ||
width: 0px; | ||
|
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,42 +1,44 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { invoke } from '@tauri-apps/api'; | ||
import { IServer } from '../../interfaces/IServer'; | ||
import { useEffect, useState } from "react"; | ||
import { invoke } from "@tauri-apps/api"; | ||
import { IServer } from "../../interfaces/IServer"; | ||
|
||
function useServerData() { | ||
const [configData, setConfigData] = useState<IServer | null>(null); | ||
const [apiIp, setApiIp] = useState<string | null>(null); | ||
const [serverError, setServerError] = useState<string | null>(null); | ||
const [configData, setConfigData] = useState<IServer | null>(null); | ||
const [apiIp, setApiIp] = useState<string | null>(null); | ||
const [serverError, setServerError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
async function fetchData() { | ||
try { | ||
const apiIpValue = await getApiIp(); | ||
setApiIp(apiIpValue); | ||
setServerError(null); | ||
useEffect(() => { | ||
async function fetchData() { | ||
try { | ||
const apiIpValue = await getApiIp(); | ||
setApiIp(apiIpValue); | ||
setServerError(null); | ||
|
||
const serverUrl = `http://${apiIpValue}/v3/config/global/get`; | ||
const response = await invoke('get_server_request', { url: serverUrl }); | ||
const parsedResponse: IServer = JSON.parse(response as string); | ||
setConfigData(parsedResponse); | ||
} catch (error) { | ||
setServerError('Unable to connect to the server.'); | ||
} | ||
} | ||
const serverUrl = `http://${apiIpValue}/v3/config/global/get`; | ||
const response = await invoke("get_server_request", { | ||
url: serverUrl | ||
}); | ||
const parsedResponse: IServer = JSON.parse(response as string); | ||
setConfigData(parsedResponse); | ||
} catch (error) { | ||
setServerError("Unable to connect to the server."); | ||
} | ||
} | ||
|
||
fetchData(); | ||
}, []); | ||
fetchData(); | ||
}, []); | ||
|
||
async function getApiIp() { | ||
try { | ||
const res = await invoke('get_api_ip'); | ||
return res.toString().replace(/^"(.*)"$/, '$1'); | ||
} catch (e) { | ||
console.error(e); | ||
return 'unable to get API Ip address.'; | ||
async function getApiIp() { | ||
try { | ||
const res = await invoke("get_api_ip"); | ||
return res.toString().replace(/^"(.*)"$/, "$1"); | ||
} catch (e) { | ||
console.error(e); | ||
return "unable to get API Ip address."; | ||
} | ||
} | ||
} | ||
|
||
return { configData, serverError, apiIp }; | ||
return { configData, serverError, apiIp }; | ||
} | ||
|
||
export default useServerData; |
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
Oops, something went wrong.