mirror of
https://github.com/yude-jp/yude.jp
synced 2024-12-22 20:20:09 +09:00
Change API source, Add server address
This commit is contained in:
parent
3400be0357
commit
b532bb04d3
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "Minecraft Multiplayer",
|
"title": "Minecraft Multiplayer",
|
||||||
"playing": "{{count}} player(s) online.",
|
"playing": "{{count}} player(s) online.",
|
||||||
"no_one": "No one is playing."
|
"no_one": "No one is playing.",
|
||||||
|
"offline": "Server is down.",
|
||||||
|
"address": "Server address"
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"title": "Minecraft マルチプレイ",
|
"title": "Minecraft マルチプレイ",
|
||||||
"playing": "{{count}} 人がプレイしています。",
|
"playing": "{{count}} 人がプレイしています。",
|
||||||
"no_one": "現在、誰もログインしていません。"
|
"no_one": "現在、誰もログインしていません。",
|
||||||
|
"offline": "サーバーがオフラインのようです。",
|
||||||
|
"address": "サーバー アドレス"
|
||||||
}
|
}
|
@ -14,7 +14,7 @@ export default function Minecraft(props) {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
const result = await axios(
|
const result = await axios(
|
||||||
'https://mcapi.us/server/status?ip=yude.jp',
|
'https://eu.mc-api.net/v3/server/ping/yude.jp',
|
||||||
);
|
);
|
||||||
setData(result.data);
|
setData(result.data);
|
||||||
};
|
};
|
||||||
@ -29,16 +29,21 @@ export default function Minecraft(props) {
|
|||||||
)
|
)
|
||||||
}else{
|
}else{
|
||||||
console.log(data)
|
console.log(data)
|
||||||
|
const status = data.online
|
||||||
const player = data.players && data.players.now
|
const player = data.players && data.players.now
|
||||||
const playing = t('minecraft:playing', {count: player})
|
const playing = t('minecraft:playing', {count: player})
|
||||||
const no_one = t('minecraft:no_one')
|
const no_one = t('minecraft:no_one')
|
||||||
|
const offline = t('minecraft:offline')
|
||||||
return (
|
return (
|
||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
{(() => {
|
{(() => {
|
||||||
if (player == 0) {
|
if (status) {
|
||||||
|
if (player == undefined) {
|
||||||
return <span>{no_one}</span>
|
return <span>{no_one}</span>
|
||||||
} else {
|
} else {
|
||||||
return <span>{playing}</span>
|
return <span>{playing}</span>
|
||||||
|
}}else{
|
||||||
|
return <span>{offline}</span>
|
||||||
}
|
}
|
||||||
})()}
|
})()}
|
||||||
</p>
|
</p>
|
||||||
|
@ -10,7 +10,7 @@ export default function About(props) {
|
|||||||
const { locale, locales, defaultLocale, pathname } = router
|
const { locale, locales, defaultLocale, pathname } = router
|
||||||
const { t, lang } = useTranslation("minecraft")
|
const { t, lang } = useTranslation("minecraft")
|
||||||
const title = t('title')
|
const title = t('title')
|
||||||
|
const address = t('address')
|
||||||
return (
|
return (
|
||||||
<Layout title={title}>
|
<Layout title={title}>
|
||||||
<div>
|
<div>
|
||||||
@ -25,6 +25,7 @@ export default function About(props) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Minecraft />
|
<Minecraft />
|
||||||
|
<p className="text-center">{address}: <code>yude.jp</code></p>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user