fix(lceonline): client not opening & webview window for lceonline login (#129)

This commit is contained in:
str1k3r
2026-07-12 09:43:17 +03:00
committed by GitHub
parent 124bbad12c
commit e8038f3c3e
7 changed files with 60 additions and 39 deletions
+2 -2
View File
@@ -66,7 +66,7 @@ LCE Emerald Launcher is the easiest way to play Minecraft Legacy Console Edition
| **Controller Support** | Full gamepad navigation support (keyboard support included) |
| **Discord Rich Presence** | Show your current activity and game status on Discord |
| **Workshop** | Community content like DLCs, Textures, Skins and more |
| **Free Multiplayer** | Powered by LCELive, Emerald provides a free multiplayer service so you can play with anyone without port forwarding! |
| **Free Multiplayer** | Powered by LCEOnline, Emerald provides a free multiplayer service so you can play with anyone without port forwarding! |
---
@@ -183,7 +183,7 @@ sudo apt install --reinstall libwebkit2gtk-4.1-0
- **The Emerald Team** - Technical development and maintenance
- **4J Studios & Mojang** - Original creators of Legacy Console Edition
- **The LCE Community** - Research and foundations for LCE on PC
- **Veroxsity (Racoon)** - Original creator of LCELive
- **Str1k3r** - Original creator of LCEOnline
---
+1
View File
@@ -12,6 +12,7 @@
"core:resources:default",
"core:tray:default",
"core:webview:default",
"core:webview:allow-create-webview-window",
"core:window:default",
"core:window:allow-set-decorations",
"core:window:allow-is-fullscreen",
+3 -3
View File
@@ -27,9 +27,9 @@ pub async fn launch_game(
perform_instance_sync(&app, &instance_id).await?;
let working_dir = util::get_instance_working_dir(&app, &instance_id);
let config_val = config::load_config_raw(app.clone());
let lce_live = McServer { name: "LCELive Game".into(), ip: "127.0.0.1".into(), port: 61000 };
if !servers.iter().any(|s| s.ip == lce_live.ip && s.port == lce_live.port) {
servers.push(lce_live);
let lce_online = McServer { name: "LCEOnline Game".into(), ip: "127.0.0.1".into(), port: 61000 };
if !servers.iter().any(|s| s.ip == lce_online.ip && s.port == lce_online.port) {
servers.push(lce_online);
}
if let Some(ref saved) = config_val.saved_servers {
for s in saved {
+34 -6
View File
@@ -9,6 +9,8 @@ import {
import ChooseInstanceModal from "../modals/ChooseInstanceModal";
import { lceOnlineService } from "../../services/LceOnlineService";
import { TauriService } from "../../services/TauriService";
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
import { listen } from "@tauri-apps/api/event";
interface LceOnlineViewProps {
addFriendTarget?: string | null;
onClearAddFriendTarget?: () => void;
@@ -28,6 +30,7 @@ const LceOnlineView = memo(function LceOnlineView({
const { playPressSound, playBackSound } = useAudio();
const game = useGame();
const [isSignedIn, setIsSignedIn] = useState(lceOnlineService.signedIn);
const opened = useRef(false);
const [currentTab, setCurrentTab] = useState<
"friends" | "requests" | "invites"
>("friends");
@@ -73,12 +76,29 @@ const LceOnlineView = memo(function LceOnlineView({
}, []);
useEffect(() => {
if (!isSignedIn) {
TauriService.openUrl(
"https://mclegacyedition.xyz/internal/auth?appId=emerald_launcher",
);
}
}, []);
if (isSignedIn) return;
if (!opened.current) {
opened.current = true;
new WebviewWindow('LCEOnline', {
url: "https://mclegacyedition.xyz/internal/auth?appId=emerald_launcher",
width: 400,
height: 570,
resizable: false,
title: 'Emerald Legacy Launcher - LCEOnline',
});
};
const unlisten = listen<string[]>('deep-link', async (event) => {
const authUrl = event.payload.find(u => u.startsWith('emerald://'));
if (!authUrl) return;
const token = new URL(authUrl).searchParams.get('token');
if (token) setIsSignedIn(true);
(await WebviewWindow.getByLabel('LCEOnline'))?.close();
});
return () => { unlisten.then(f => f()); };
}, [isSignedIn]);
useEffect(() => {
if (!addFriendTarget) return;
@@ -619,6 +639,14 @@ const LceOnlineView = memo(function LceOnlineView({
>
{renderContent()}
</div>
<div className="flex justify-center pt-4 pb-2">
<img
src="/images/lceonline.png"
alt="LCEOnline"
className="h-5 opacity-70 cursor-pointer"
onClick={() => TauriService.openUrl("https://mclegacyedition.xyz/")}
/>
</div>
</div>
<AnimatePresence>
+1 -1
View File
@@ -497,7 +497,7 @@ export function useGameManager({
profile,
PARTNERSHIP_SERVERS,
currentEdition?.lceOnline
? extraLaunchArgs!.concat([
? (extraLaunchArgs ?? []).concat([
"-token",
localStorage.getItem("lceonline_session")
? JSON.parse(localStorage.getItem("lceonline_session")!).accessToken
+6 -14
View File
@@ -1,17 +1,9 @@
import { useState, useEffect, useRef } from "react";
import { lceOnlineService } from "../services/LceOnlineService";
export function useLceOnlineNotifications() {
const [friendRequestMessage, setFriendRequestMessage] = useState<
string | null
>(null);
const [friendRequestMessage, setFriendRequestMessage] = useState<string | null>(null);
const [InviteMessage, setInviteMessage] = useState<string | null>(null);
const [invites, setInvites] = useState<
Array<{
inviteid: string;
from: { uuid: string; username: string };
sessionid: string;
}>
>([]);
const [invites, setInvites] = useState<Array<{ inviteid: string; from: { uuid: string; username: string; }; sessionid: string; }>>([]);
const seenRequests = useRef<Set<string>>(new Set());
const seenInvites = useRef<Set<string>>(new Set());
useEffect(() => {
@@ -24,7 +16,7 @@ export function useLceOnlineNotifications() {
lists.requests.forEach((r: string) => {
if (!seenRequests.current.has(r)) {
seenRequests.current.add(r);
setFriendRequestMessage(`New Friend request from ${r}`);
setFriendRequestMessage(`${r} wants to be friends!`);
}
});
} catch (e) {}
@@ -34,7 +26,7 @@ export function useLceOnlineNotifications() {
invitesData.forEach((i) => {
if (!seenInvites.current.has(i.inviteid)) {
seenInvites.current.add(i.inviteid);
setInviteMessage(`New invite from ${i.from.username}`);
setInviteMessage(`${i.from.username} invited you to play!`);
}
});
} catch { }
@@ -47,7 +39,7 @@ export function useLceOnlineNotifications() {
lists.requests.forEach((r: string) => {
if (!seenRequests.current.has(r)) {
seenRequests.current.add(r);
setFriendRequestMessage(`New Friend request from ${r}`);
setFriendRequestMessage(`${r} wants to be friends!`);
}
});
} catch (e) {}
@@ -57,7 +49,7 @@ export function useLceOnlineNotifications() {
invitesData.forEach((i) => {
if (!seenInvites.current.has(i.inviteid)) {
seenInvites.current.add(i.inviteid);
setInviteMessage(`New invite from ${i.from.username}`);
setInviteMessage(`${i.from.username} invited you to play!`);
}
});
} catch { }