Working backend-frontend launcher
This commit is contained in:
@@ -27,6 +27,8 @@ fn download(version: &str) {
|
|||||||
let game_path = path!(&base_path, "minecraft");
|
let game_path = path!(&base_path, "minecraft");
|
||||||
let jre_path = path!(&base_path, "jre");
|
let jre_path = path!(&base_path, "jre");
|
||||||
|
|
||||||
|
println!("Downloading {version}");
|
||||||
|
|
||||||
match smallauncher_lib::download::download_minecraft_version(&game_path, &jre_path, &version) {
|
match smallauncher_lib::download::download_minecraft_version(&game_path, &jre_path, &version) {
|
||||||
Ok(_) => println!("Download completed!"),
|
Ok(_) => println!("Download completed!"),
|
||||||
Err(e) => println!("Download failed: {:?}", e),
|
Err(e) => println!("Download failed: {:?}", e),
|
||||||
|
|||||||
+13
-26
@@ -2,8 +2,8 @@ import { Button } from "@/components/ui/button";
|
|||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { LogOut, Play, Settings, User } from "lucide-react";
|
import { Play, Settings, User } from "lucide-react";
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
import { authenticate, launchMinecraft } from "./lib/launcher";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
return (
|
return (
|
||||||
@@ -16,46 +16,33 @@ export default function App() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-6">
|
<CardContent className="space-y-6">
|
||||||
<Tabs defaultValue="play" className="w-full">
|
<Tabs defaultValue="play" className="w-full">
|
||||||
<TabsList className="grid grid-cols-3">
|
<TabsList className="grid grid-cols-3 w-max mx-auto">
|
||||||
<TabsTrigger value="play">Play</TabsTrigger>
|
<TabsTrigger value="play">Play</TabsTrigger>
|
||||||
<TabsTrigger value="account">Account</TabsTrigger>
|
<TabsTrigger value="auth">Accounts</TabsTrigger>
|
||||||
<TabsTrigger value="settings">Settings</TabsTrigger>
|
<TabsTrigger value="settings">Settings</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
{/* Play Tab */}
|
|
||||||
<TabsContent value="play" className="space-y-4">
|
<TabsContent value="play" className="space-y-4">
|
||||||
<div className="flex flex-col items-center gap-4">
|
<div className="flex flex-col items-center gap-4">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
invoke('authenticate')
|
launchMinecraft('Amgxy', '1.21.4');
|
||||||
}}
|
}}
|
||||||
className="w-full font-bold text-lg flex items-center gap-2"
|
className="w-full font-bold text-lg flex items-center gap-2"
|
||||||
>Auth</Button>
|
><Play /> Launch</Button>
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
{/* Account Tab */}
|
<TabsContent value="auth" className="space-y-4">
|
||||||
<TabsContent value="account" className="space-y-4">
|
<Button
|
||||||
<div className="space-y-2">
|
onClick={() => {
|
||||||
<label className="text-sm font-medium text-zinc-200">Username</label>
|
authenticate();
|
||||||
<Input placeholder="Enter your username" className="bg-zinc-800 border-zinc-700" />
|
}}
|
||||||
</div>
|
className="w-full font-bold text-lg flex items-center gap-2"
|
||||||
<Button className="w-full flex items-center gap-2">
|
><User /> Authenticate</Button>
|
||||||
<User className="w-5 h-5" /> Login
|
|
||||||
</Button>
|
|
||||||
<Button variant="destructive" className="w-full flex items-center gap-2">
|
|
||||||
<LogOut className="w-5 h-5" /> Logout
|
|
||||||
</Button>
|
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
{/* Settings Tab */}
|
|
||||||
<TabsContent value="settings" className="space-y-4">
|
<TabsContent value="settings" className="space-y-4">
|
||||||
<div className="space-y-2">
|
|
||||||
<label className="text-sm font-medium text-zinc-200">
|
|
||||||
Java Path
|
|
||||||
</label>
|
|
||||||
<Input placeholder="/usr/bin/java" className="bg-zinc-800 border-zinc-700" />
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<label className="text-sm font-medium text-zinc-200">
|
<label className="text-sm font-medium text-zinc-200">
|
||||||
RAM Allocation (MB)
|
RAM Allocation (MB)
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
|
|
||||||
|
export const authenticate = () => invoke('authenticate');
|
||||||
|
export const download = (version: string) => invoke('download', { version });
|
||||||
|
export const checkVersion = (version: string) => invoke('check_version', { version });
|
||||||
|
export const launchMinecraft = (username: string, version: string) => invoke('launch_minecraft', { username, version });
|
||||||
Reference in New Issue
Block a user