tauri shell, window controls, permissions

This commit is contained in:
2026-03-22 05:56:55 +02:00
parent b119358d7c
commit c9d5470950
63 changed files with 9865 additions and 0 deletions
+4674
View File
File diff suppressed because it is too large Load Diff
+21
View File
@@ -0,0 +1,21 @@
[package]
name = "jellyfin-client"
version = "0.1.0"
edition = "2021"
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
# `devtools` keeps the WebView2 inspector available in release builds
# (F12 / right-click -> Inspect). Adds a few MB to the binary but is
# essential while we're still verifying production behaviour.
tauri = { version = "2", features = ["devtools"] }
tauri-plugin-store = "2"
tauri-plugin-window-state = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
[lib]
name = "jellyfin_client_lib"
crate-type = ["lib", "cdylib", "staticlib"]
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
+20
View File
@@ -0,0 +1,20 @@
{
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"core:webview:allow-set-webview-zoom",
"core:window:allow-minimize",
"core:window:allow-maximize",
"core:window:allow-unmaximize",
"core:window:allow-toggle-maximize",
"core:window:allow-close",
"core:window:allow-is-maximized",
"core:window:allow-start-dragging",
"core:event:allow-listen",
"core:event:allow-unlisten",
"store:default",
"window-state:default"
]
}
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
{"default":{"identifier":"default","description":"Capability for the main window","local":true,"windows":["main"],"permissions":["core:default","core:webview:allow-set-webview-zoom","core:window:allow-minimize","core:window:allow-maximize","core:window:allow-unmaximize","core:window:allow-toggle-maximize","core:window:allow-close","core:window:allow-is-maximized","core:window:allow-start-dragging","core:event:allow-listen","core:event:allow-unlisten","store:default","window-state:default"]}}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 986 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1023 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 767 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 994 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 413 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 992 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

+67
View File
@@ -0,0 +1,67 @@
use std::path::PathBuf;
/// Resolve the directory the running EXE lives in. Falls back to the
/// process working directory if for some reason we can't read
/// `current_exe()` (sandboxed environments, etc.).
fn exe_dir() -> PathBuf {
std::env::current_exe()
.ok()
.and_then(|p| p.parent().map(|p| p.to_path_buf()))
.unwrap_or_else(|| std::env::current_dir().unwrap_or_default())
}
/// Configure all the env vars Tauri + WebView2 + the OS read when
/// resolving "where do I put my data" so EVERYTHING lands in a single
/// `./data/` folder next to the EXE - no AppData, no registry, no
/// hidden state. Has to run BEFORE the Tauri builder constructs the
/// webview, since WebView2 reads `WEBVIEW2_USER_DATA_FOLDER` only at
/// startup.
fn redirect_data_to_portable_folder() {
let root = exe_dir().join("data");
let _ = std::fs::create_dir_all(&root);
let appdata = root.join("appdata");
let local_appdata = root.join("localappdata");
let webview2 = root.join("webview2");
let cache = root.join("cache");
let temp = root.join("temp");
for d in [&appdata, &local_appdata, &webview2, &cache, &temp] {
let _ = std::fs::create_dir_all(d);
}
// Tauri's path resolver uses the `dirs` crate under the hood, which
// reads APPDATA / LOCALAPPDATA on Windows. Redirecting these
// catches every plugin that calls `app.path().app_config_dir()`,
// `app_data_dir()`, `app_local_data_dir()`, etc. - including
// tauri-plugin-store and tauri-plugin-window-state.
std::env::set_var("APPDATA", &appdata);
std::env::set_var("LOCALAPPDATA", &local_appdata);
// WebView2's own user data folder. This is where localStorage,
// IndexedDB, cookies, the HTTP cache, and the GPU shader cache go.
// Almost all our persisted state (zustand-persist stores) lives
// here, so this is the most important one to redirect.
std::env::set_var("WEBVIEW2_USER_DATA_FOLDER", &webview2);
// TEMP / TMP redirection so any temporary files (rare, but Tauri's
// file dialog plugin uses these) don't leak to %TEMP%.
std::env::set_var("TEMP", &temp);
std::env::set_var("TMP", &temp);
// XDG variants for Linux portability if we ever ship there.
std::env::set_var("XDG_DATA_HOME", &local_appdata);
std::env::set_var("XDG_CONFIG_HOME", &appdata);
std::env::set_var("XDG_CACHE_HOME", &cache);
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
redirect_data_to_portable_folder();
tauri::Builder::default()
.plugin(tauri_plugin_store::Builder::default().build())
.plugin(tauri_plugin_window_state::Builder::default().build())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
+5
View File
@@ -0,0 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
jellyfin_client_lib::run()
}
+48
View File
@@ -0,0 +1,48 @@
{
"$schema": "https://raw.githubusercontent.com/nicegram/nicegram-ios/refs/heads/nicegram/Tauri/tooling/cli/schema.json",
"productName": "Jellyfin",
"version": "0.1.0",
"identifier": "com.jellyfin.desktop",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:5173",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "Jellyfin",
"width": 1280,
"height": 720,
"minWidth": 800,
"minHeight": 500,
"center": true,
"decorations": false,
"resizable": true,
"transparent": false,
"additionalBrowserArgs": "--autoplay-policy=no-user-gesture-required --disable-features=AutoplayIgnoreWebAudio,BlockInsecurePrivateNetworkRequests --allow-running-insecure-content"
}
],
"security": {
"csp": "default-src 'self' tauri: asset: https://tauri.localhost; connect-src * data: blob:; img-src * data: blob:; media-src * data: blob:; frame-src 'self' https://www.youtube-nocookie.com https://www.youtube.com; child-src 'self' blob: https://www.youtube-nocookie.com https://www.youtube.com; script-src 'self' tauri: asset: https://tauri.localhost 'unsafe-inline'; style-src 'self' tauri: asset: https://tauri.localhost https://fonts.bunny.net 'unsafe-inline'; font-src 'self' https://fonts.bunny.net data:; worker-src 'self' blob:; object-src 'none'; base-uri 'self'; form-action 'none'; frame-ancestors 'none';"
}
},
"bundle": {
"active": false,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"windows": {
"webviewInstallMode": {
"type": "downloadBootstrapper"
}
}
},
"plugins": {}
}