Should be ready for release now. Will do some testing before.
This commit is contained in:
3 files changed
+53
-54
No files matched your search
+32
-13
@@ -19,7 +19,6 @@ use tauri::window::{ProgressBarState, ProgressBarStatus};
|
|||||||
use tauri::{AppHandle, Emitter, Manager};
|
use tauri::{AppHandle, Emitter, Manager};
|
||||||
use tauri_plugin_os::platform;
|
use tauri_plugin_os::platform;
|
||||||
use tauri_plugin_prevent_default::Flags;
|
use tauri_plugin_prevent_default::Flags;
|
||||||
use tauri_plugin_updater::UpdaterExt;
|
|
||||||
use tokio::io::AsyncReadExt;
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio::{io::AsyncWriteExt, time::timeout};
|
use tokio::{io::AsyncWriteExt, time::timeout};
|
||||||
use zip::ZipArchive;
|
use zip::ZipArchive;
|
||||||
@@ -31,6 +30,9 @@ use sysinfo::System;
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
use tauri_plugin_updater::UpdaterExt;
|
||||||
|
|
||||||
static CANCEL_MAP: OnceLock<DashMap<String, bool>> = OnceLock::new();
|
static CANCEL_MAP: OnceLock<DashMap<String, bool>> = OnceLock::new();
|
||||||
|
|
||||||
fn cancel_map() -> &'static DashMap<String, bool> {
|
fn cancel_map() -> &'static DashMap<String, bool> {
|
||||||
@@ -561,35 +563,52 @@ pub fn run() {
|
|||||||
cancel_download
|
cancel_download
|
||||||
])
|
])
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
|
let window = app.get_webview_window("main").unwrap();
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
{
|
||||||
use tauri_plugin_decorum::WebviewWindowExt;
|
use tauri_plugin_decorum::WebviewWindowExt;
|
||||||
if let Some(main_window) = app.get_webview_window("main") {
|
if let Err(e) = window.create_overlay_titlebar() {
|
||||||
if let Err(e) = main_window.create_overlay_titlebar() {
|
eprintln!("Failed to create overlay titlebar: {:?}", e);
|
||||||
eprintln!("Failed to create overlay titlebar: {:?}", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let handle = app.handle().clone();
|
#[cfg(not(debug_assertions))]
|
||||||
tauri::async_runtime::spawn(async move {
|
{
|
||||||
update(handle).await.unwrap();
|
let handle = app.handle().clone();
|
||||||
});
|
tauri::async_runtime::spawn(async move {
|
||||||
|
update(handle, window.clone()).await.unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
{
|
||||||
|
let mut new_url = window.url().unwrap();
|
||||||
|
new_url.set_path("/main");
|
||||||
|
window.navigate(new_url).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update(app: tauri::AppHandle) -> tauri_plugin_updater::Result<()> {
|
#[cfg(not(debug_assertions))]
|
||||||
let window = app.get_webview_window("main").unwrap();
|
async fn update(
|
||||||
|
app: tauri::AppHandle,
|
||||||
|
window: tauri::WebviewWindow,
|
||||||
|
) -> tauri_plugin_updater::Result<()> {
|
||||||
let target = {
|
let target = {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
if std::path::Path::new("/etc/debian_version").exists() {
|
if std::path::Path::new("/etc/debian_version").exists() {
|
||||||
"linux-debian"
|
"linux-debian"
|
||||||
} else {
|
} else if std::path::Path::new("/etc/redhat-release").exists() {
|
||||||
"linux-fedora"
|
"linux-fedora"
|
||||||
|
} else {
|
||||||
|
let mut new_url = window.url().unwrap();
|
||||||
|
new_url.set_path("/update/outdated");
|
||||||
|
window.navigate(new_url).unwrap();
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
|
|||||||
+1
-41
@@ -5,7 +5,6 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
|||||||
import Sidebar from '@/components/Sidebar'
|
import Sidebar from '@/components/Sidebar'
|
||||||
import { DownloadProgress } from '@/types/DownloadProgress'
|
import { DownloadProgress } from '@/types/DownloadProgress'
|
||||||
import { app } from '@tauri-apps/api'
|
import { app } from '@tauri-apps/api'
|
||||||
import { openUrl } from '@tauri-apps/plugin-opener'
|
|
||||||
import { GlobalProvider } from '@/providers/GlobalProvider'
|
import { GlobalProvider } from '@/providers/GlobalProvider'
|
||||||
import { Roboto } from 'next/font/google'
|
import { Roboto } from 'next/font/google'
|
||||||
import { ServerVersionsResponse } from '@/types/ServerVersionsResponse'
|
import { ServerVersionsResponse } from '@/types/ServerVersionsResponse'
|
||||||
@@ -51,7 +50,6 @@ export default function RootLayout ({
|
|||||||
}) {
|
}) {
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [loadingText, setLoadingText] = useState('Loading...')
|
const [loadingText, setLoadingText] = useState('Loading...')
|
||||||
const [outdated, setOutdated] = useState(false)
|
|
||||||
const [version, setVersion] = useState<string | null>(null)
|
const [version, setVersion] = useState<string | null>(null)
|
||||||
const [platformName, setPlatformName] = useState<string | null>(null)
|
const [platformName, setPlatformName] = useState<string | null>(null)
|
||||||
|
|
||||||
@@ -266,27 +264,6 @@ export default function RootLayout ({
|
|||||||
setPlatformName(platform())
|
setPlatformName(platform())
|
||||||
const client = await app.getVersion()
|
const client = await app.getVersion()
|
||||||
setVersion(client)
|
setVersion(client)
|
||||||
if (process.env.NODE_ENV === 'production') {
|
|
||||||
try {
|
|
||||||
const response = await fetch(
|
|
||||||
'https://games.lncvrt.xyz/api/launcher/latest'
|
|
||||||
)
|
|
||||||
const signature = response.headers.get('x-signature') ?? ''
|
|
||||||
const data = await response.text()
|
|
||||||
if (await verifySignature(data, signature)) {
|
|
||||||
if (data !== client) {
|
|
||||||
setOutdated(true)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setLoadingText('Failed to check latest version.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
setLoadingText('Failed to check latest version.')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://games.lncvrt.xyz/api/launcher/versions?platform=${platform()}&arch=${arch()}`
|
`https://games.lncvrt.xyz/api/launcher/versions?platform=${platform()}&arch=${arch()}`
|
||||||
@@ -712,24 +689,7 @@ export default function RootLayout ({
|
|||||||
: 'h-screen'
|
: 'h-screen'
|
||||||
} flex items-center justify-center`}
|
} flex items-center justify-center`}
|
||||||
>
|
>
|
||||||
{outdated ? (
|
<p className='text-7xl text-center'>{loadingText}</p>
|
||||||
<div className='text-center'>
|
|
||||||
<p className='text-6xl mb-4'>Outdated Launcher!</p>
|
|
||||||
<p className='text-2xl mb-4'>
|
|
||||||
Please update to the latest version to continue.
|
|
||||||
</p>
|
|
||||||
<button
|
|
||||||
className='button btntheme1'
|
|
||||||
onClick={() =>
|
|
||||||
openUrl('https://games.lncvrt.xyz/download')
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Download latest version!
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<p className='text-7xl text-center'>{loadingText}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import { openUrl } from '@tauri-apps/plugin-opener'
|
||||||
|
|
||||||
|
export default function UpdateCheckingPage () {
|
||||||
|
return (
|
||||||
|
<div className='text-center'>
|
||||||
|
<p className='text-6xl mb-4'>Outdated Launcher!</p>
|
||||||
|
<p className='text-2xl mb-4'>
|
||||||
|
Please update to the latest version to continue.
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
className='button btntheme1'
|
||||||
|
onClick={() => openUrl('https://games.lncvrt.xyz/download')}
|
||||||
|
>
|
||||||
|
Download latest version!
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user