mirror of
https://github.com/yude-jp/yude.jp
synced 2024-12-23 04:30:11 +09:00
Compare commits
2 Commits
8b3a484d08
...
bb88dd6a02
Author | SHA1 | Date | |
---|---|---|---|
bb88dd6a02 | |||
622d43554f |
@ -6,8 +6,11 @@ Front page of [yude.jp](https://yude.jp).\
|
|||||||
Built with [Next.js](https://nextjs.org/) and [Tailwind CSS](https://tailwindcss.com/) and deployed on [Vercel](https://vercel.com).
|
Built with [Next.js](https://nextjs.org/) and [Tailwind CSS](https://tailwindcss.com/) and deployed on [Vercel](https://vercel.com).
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
* To setup your repository, please run `yarn`.
|
### Setup
|
||||||
* To preview, please run `yarn dev`.
|
1. Run `yarn`.
|
||||||
|
1. Rename `.env.local.sample` as `.env.local` and set value.
|
||||||
|
### Preview
|
||||||
|
* Run `yarn dev`.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
This repository is licensed under the MIT License.
|
This repository is licensed under the MIT License.
|
||||||
|
@ -7,27 +7,25 @@ function App (){
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { locale, locales, defaultLocale, pathname } = router
|
const { locale, locales, defaultLocale, pathname } = router
|
||||||
const { t, lang } = useTranslation("common")
|
const { t, lang } = useTranslation("common")
|
||||||
const [data, setData] = useState({ hits: [] });
|
const [dataPlaying, setDataPlaying] = useState({ hits: [] });
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
const result = await axios(
|
const result = await axios(
|
||||||
'https://discord.com/api/guilds/723409709306216498/widget.json',
|
'https://discord.com/api/guilds/723409709306216498/widget.json',
|
||||||
);
|
);
|
||||||
|
|
||||||
setData(result.data);
|
setDataPlaying(result.dataPlaying);
|
||||||
}, []);
|
}, []);
|
||||||
if (data === undefined){
|
if (dataPlaying === undefined){
|
||||||
console.log("[Discord API] データの取得に失敗しました。 / Failed to retrieve data.")
|
console.log("[Discord API] データの取得に失敗しました。 / Failed to retrieve data.")
|
||||||
return <p></p>
|
return <p></p>
|
||||||
}else{
|
}else{
|
||||||
const str = JSON.stringify(data)
|
const str = JSON.stringify(dataPlaying)
|
||||||
|
|
||||||
if (str.indexOf("game") !== -1){
|
if (str.indexOf("game") !== -1){
|
||||||
const yes_playing = t('yes_playing', {playing: data.members[0].game.name})
|
const yes_playing = t('yes_playing', {playing: dataPlaying.members[0].game.name})
|
||||||
return <p>{yes_playing}</p>
|
return <p>{yes_playing}</p>
|
||||||
console.log("[Discord API] Playing: " + data.members[0].game.name)
|
|
||||||
}else{
|
}else{
|
||||||
return <p></p>
|
return <p></p>
|
||||||
console.log("[Discord API] Nothing playing")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,10 +8,7 @@ const App = () => {
|
|||||||
.then((r) => r.json())
|
.then((r) => r.json())
|
||||||
.then((j) => setStatus(j.members[0].status))
|
.then((j) => setStatus(j.members[0].status))
|
||||||
}, []);
|
}, []);
|
||||||
if (status === undefined){
|
|
||||||
console.log("[Discord API] オンライン状態を取得できませんでした。 / Failed to retrieve online status.")
|
|
||||||
return <div></div>
|
|
||||||
}else{
|
|
||||||
if (status === "online") {
|
if (status === "online") {
|
||||||
return <div className="font-bold text-gray-700 rounded-full bg-green-500 flex w-5 h-5 items-center justify-center"></div>
|
return <div className="font-bold text-gray-700 rounded-full bg-green-500 flex w-5 h-5 items-center justify-center"></div>
|
||||||
}else{
|
}else{
|
||||||
@ -26,6 +23,5 @@ const App = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
export default App;
|
export default App;
|
@ -7,21 +7,21 @@ function App () {
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { locale, locales, defaultLocale, pathname } = router
|
const { locale, locales, defaultLocale, pathname } = router
|
||||||
const { t, lang } = useTranslation("common")
|
const { t, lang } = useTranslation("common")
|
||||||
const [data, setData] = useState({ hits: [] });
|
const [dataSpotify, setDataSpotify] = useState({ hits: [] });
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
const result = await axios(
|
const result = await axios(
|
||||||
'/api/Spotify',
|
'/api/Spotify',
|
||||||
);
|
);
|
||||||
|
|
||||||
setData(result.data);
|
setDataSpotify(result.dataSpotify);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
if (data === undefined){
|
if (dataSpotify === undefined){
|
||||||
console.log("[Spotify Web API] データの取得に失敗しました。 / Failed to retrieve data.")
|
console.log("[Spotify Web API] データの取得に失敗しました。 / Failed to retrieve data.")
|
||||||
return <p></p>
|
return <p></p>
|
||||||
}else{
|
}else{
|
||||||
if (data.isPlaying){
|
if (dataSpotify.isPlaying){
|
||||||
const status = data.artist + ' / ' + data.title
|
const status = dataSpotify.artist + ' / ' + dataSpotify.title
|
||||||
const listening = t('listening', {listening: status})
|
const listening = t('listening', {listening: status})
|
||||||
return <p>{listening}</p>
|
return <p>{listening}</p>
|
||||||
}else{
|
}else{
|
||||||
|
@ -55,10 +55,12 @@ export default function About(props) {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<p className="text-4xl subpixel-antialiased">yude</p>
|
<p className="text-4xl subpixel-antialiased">yude</p>
|
||||||
|
<div>
|
||||||
<DiscordPlaying />
|
<DiscordPlaying />
|
||||||
<Spotify />
|
<Spotify />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{
|
{
|
||||||
// Description
|
// Description
|
||||||
|
Loading…
Reference in New Issue
Block a user