Make the app

This commit is contained in:
Lncvrt committed 2025-06-14 17:18:12 -07:00
1 parent e906684be4
commit dd75ef1f95
6 files changed
+107 -18

No files matched your search

+2 -1
View File
@@ -1,7 +1,8 @@
{ {
"name": "berry-leaderboards", "name": "berry-leaderboards",
"displayName": "Berry Leaderboards",
"private": true, "private": true,
"version": "0.1.0", "version": "1.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
+1 -1
View File
@@ -259,7 +259,7 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]] [[package]]
name = "berry-leaderboards" name = "berry-leaderboards"
version = "0.1.0" version = "1.0.0"
dependencies = [ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
+3 -3
View File
@@ -1,8 +1,8 @@
[package] [package]
name = "berry-leaderboards" name = "berry-leaderboards"
version = "0.1.0" version = "1.0.0"
description = "A Tauri App" description = "A desktop and mobile leaderboards viewer for Berry Dash"
authors = ["you"] authors = ["Lncvrt"]
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+4 -2
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "https://schema.tauri.app/config/2", "$schema": "https://schema.tauri.app/config/2",
"productName": "berry-leaderboards", "productName": "Berry Leaderboards",
"version": "0.1.0", "version": "1.0.0",
"identifier": "xyz.lncvrt.Berry-Leaderboards", "identifier": "xyz.lncvrt.Berry-Leaderboards",
"build": { "build": {
"beforeDevCommand": "yarn dev", "beforeDevCommand": "yarn dev",
@@ -16,6 +16,8 @@
"title": "Berry Leaderboards", "title": "Berry Leaderboards",
"width": 800, "width": 800,
"height": 600, "height": 600,
"minWidth": 600,
"minHeight": 400,
"transparent": true "transparent": true
} }
], ],
+49 -1
View File
@@ -1,9 +1,57 @@
body { body {
color: white; color: white;
background-color: #121212; background-color: #242424;
font-family: 'Lexend'; font-family: 'Lexend';
user-select: none;
}
button {
all: unset;
cursor: pointer;
background-color: #484848;
border-radius: 8px;
padding: 4px 8px;
} }
.macos-body { .macos-body {
background-color: transparent !important; background-color: transparent !important;
} }
.top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1rem;
}
.top span {
flex: 1;
text-align: center;
}
.list {
background-color: #484848;
border-radius: 16px;
padding: 16px 0px;
}
.list .item {
display: flex;
justify-content: space-between;
padding: 0 16px;
position: relative;
}
.list .item + .item::before {
content: "";
position: absolute;
top: -16px;
left: 16px;
right: 16px;
height: 1px;
background-color: rgb(128, 128, 128);
}
.list .item + .item {
margin-top: 32px;
}
+48 -10
View File
@@ -1,18 +1,56 @@
import { useEffect } from "react"; import { useEffect, useRef, useState } from "react"
import "./App.css"; import "./App.css"
import '@fontsource/lexend'; import '@fontsource/lexend'
import { platform } from "@tauri-apps/plugin-os"; import { platform } from "@tauri-apps/plugin-os"
function App() { function App() {
const [status, setStatus] = useState("")
const [players, setPlayers] = useState<string[][]>([])
const initialized = useRef(false)
useEffect(() => { useEffect(() => {
if (platform() == 'macos') document.body.classList.add('macos-body'); if (initialized.current) return;
}); if (platform() == 'macos') document.body.classList.add('macos-body')
refresh();
initialized.current = true;
}, [])
const refresh = async () => {
setStatus("Loading")
setPlayers([]);
try {
const res = await fetch("https://berrydash.lncvrt.xyz/database/getTopPlayersAPI.php")
if (!res.ok) throw new Error(`HTTP ${res.status}`)
const txt = await res.text()
const entries = txt.split(";").map(x => {
const [b64, score] = x.split(":")
return [atob(b64), score]
})
setPlayers(entries)
setStatus("")
} catch (err: any) {
setStatus(`Error: ${err.message}`)
}
}
return ( return (
<main className="container"> <main>
<p>Berry Leaderboards</p> <div className="top">
<span style={{ color: status.startsWith("Error") ? "red" : "inherit" }}>{status}</span>
<button onClick={refresh}>Refresh</button>
</div>
{players.length > 0 && (
<div className="list">
{players.map(([user, score], i) => (
<div className="item" key={i}>
<span>{user}</span>
<span>{Number(score).toLocaleString()}</span>
</div>
))}
</div>
)}
</main> </main>
); )
} }
export default App; export default App