fix prod build not working & thumbnails on web

This commit is contained in:
Oscar Beaumont 2022-11-04 17:19:46 +08:00 committed by GitHub
parent 26c1c8cadb
commit dc97f087c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 10 deletions

View file

@ -5,6 +5,7 @@
use std::error::Error;
use std::path::PathBuf;
use std::time::Duration;
use sd_core::Node;
use tauri::async_runtime::block_on;
@ -14,6 +15,7 @@ use tauri::{
Manager, RunEvent,
};
use tokio::task::block_in_place;
use tokio::time::sleep;
use tracing::{debug, error};
#[cfg(target_os = "macos")]
mod macos;
@ -56,17 +58,20 @@ async fn main() -> Result<(), Box<dyn Error>> {
})
.setup(|app| {
let app = app.handle();
#[cfg(target_os = "macos")]
{
// use macos::{lock_app_theme, AppThemeType};
// lock_app_theme(AppThemeType::Dark as _);
}
app.windows().iter().for_each(|(_, window)| {
window.hide().unwrap();
tokio::spawn({
let window = window.clone();
async move {
sleep(Duration::from_secs(3)).await;
if window.is_visible().unwrap_or(true) == false {
println!("Window did not emit `app_ready` event fast enough. Showing window...");
let _ = window.show();
}
}
});
#[cfg(target_os = "windows")]
window.set_decorations(true).unwrap();

View file

@ -33,7 +33,8 @@ async function getOs(): Promise<OperatingSystem> {
const platform: Platform = {
platform: 'tauri',
getThumbnailUrlById: (casId) => `spacedrive://thumbnail/${encodeURIComponent(casId)}`,
getThumbnailUrlById: (casId) =>
`${window.location.origin}/spacedrive/thumbnail/${encodeURIComponent(casId)}`,
openLink: shell.open,
getOs,
openFilePickerDialog: () => dialog.open({ directory: true }),

View file

@ -8,6 +8,7 @@
</head>
<body style="overflow: hidden">
<div id="root"></div>
<!-- Script for React devtools. TODO: Make sure this isn't included in production builds. -->
<script src="http://localhost:8097"></script>
<script type="module" src="./index.tsx"></script>
</body>

View file

@ -2,7 +2,7 @@ declare global {
var isDev: boolean;
}
if (!globalThis.localStorage || !globalThis.isDev)
if (globalThis.localStorage === undefined || globalThis.isDev === undefined)
throw new Error('Please ensure you have patched `globalThis` before importing `@sd/client`!');
export * from './hooks';