Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add splashscreen #181

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/auto-bump-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
PATCH=${VERSION_PARTS[2]}
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
jq ".package.version = \"$NEW_VERSION\"" src-tauri/tauri.conf.json > src-tauri/tauri.conf.json.tmp && mv src-tauri/tauri.conf.json.tmp src-tauri/tauri.conf.json
jq --indent 4 ".package.version = \"$NEW_VERSION\"" src-tauri/tauri.conf.json > src-tauri/tauri.conf.json.tmp && mv src-tauri/tauri.conf.json.tmp src-tauri/tauri.conf.json
echo "new_version=$NEW_VERSION" >> "$GITHUB_ENV"

- name: Create Pull Request
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/refresh-main-tool-caches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-20.04, ubuntu-latest, windows-latest]
platform: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.platform }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tauri-pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-20.04, ubuntu-latest, windows-latest]
platform: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.platform }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tauri-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, ubuntu-20.04, windows-latest]
platform: [macos-latest, ubuntu-latest, windows-latest]

runs-on: ${{ matrix.platform }}
steps:
Expand Down
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ console_error_panic_hook = "0.1.7"
console_log = "1.0.0"
futures = "0.3.30"
js-sys = "0.3.69"
leptos = { version = "0.6.12", features = ["csr"] }
leptos_meta = { version = "0.6.12", features = ["csr"] }
log = "0.4.21"
serde = { version = "1.0.203", features = ["derive"] }
leptos = { version = "0.6.13", features = ["csr"] }
leptos_meta = { version = "0.6.13", features = ["csr"] }
log = "0.4.22"
serde = { version = "1.0.204", features = ["derive"] }
serde-wasm-bindgen = "0.6.5"
tauri-sys = { git = "https://github.com/JonasKruckenberg/tauri-sys", rev = "3e93a42", features = [
"event",
"tauri",
] }
thaw = { version = "0.3.2", features = ["csr"] }
thaw = { version = "0.3.3", features = ["csr"] }
thaw_utils = { version = "0.0.5", features = ["csr"] }

[workspace]
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<title>mDNS Browser</title>
<link data-trunk rel="css" href="styles.css" />
<link data-trunk rel="copy-dir" href="public" />
<link data-trunk rel="rust" data-wasm-opt="z" />
</head>
</html>
70 changes: 70 additions & 0 deletions public/splashscreen.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>mDNS-Browser loading...</title>
<style>
body, html {
height: 100%;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(26, 29, 30);
}
.splash-screen {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
color: rgb(255, 193, 49);
}
.spinner {
border: 12px solid rgb(26, 29, 30);
border-top: 12px solid rgb(36, 200, 219);
border-radius: 50%;
width: 100px;
height: 100px;
animation: spin 2s linear infinite;
margin-top: 10px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<div class="splash-screen">
<div class="spinner"></div>
<div id="loading-text">Joining multicast group...</div>
</div>
<script>
const loadingMessages = [
"Counting to infinity...",
"Summoning the algorithm...",
"Loading the flux capacitor...",
"Locating the nearest pizza...",
"Do not panic, we are panicking for you...",
"Pretending to work...",
"Finding the end of the internet...",
"Broadcasting multicast...",
"Resolving mDNS...",
"Querying multicast DNS...",
"Sending mDNS queries...",
"Listening for multicast responses...",
"Mapping network services...",
"Propagating multicast packets...",
"Negotiating network discovery...",
];

function changeLoadingText() {
const loadingTextElement = document.getElementById('loading-text');
const randomIndex = Math.floor(Math.random() * loadingMessages.length);
loadingTextElement.textContent = loadingMessages[randomIndex];
}
setInterval(changeLoadingText, 1500);
</script>
</body>
</html>
10 changes: 5 additions & 5 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ authors = ["hrzlgnm"]
edition = "2021"

[build-dependencies]
tauri-build = { version = "1.5.2", features = [] }
tauri-build = { version = "1.5.3", features = [] }

[dependencies]
tauri = { version = "1.6.8", features = [
tauri = { version = "1.7.1", features = [
"window-all",
"process-relaunch",
"process-exit",
Expand All @@ -19,14 +19,14 @@ tauri = { version = "1.6.8", features = [
"http-api",
"http-request",
] }
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.117"
serde = { version = "1.0.204", features = ["derive"] }
serde_json = "1.0.121"
mdns-sd = { version = "0.11.1", default-features = false, features = [
"async",
"log",
] }
tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
log = "0.4.21"
log = "0.4.22"

[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
Expand Down
17 changes: 12 additions & 5 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,20 @@ fn main() {
tauri::Builder::default()
.manage(MdnsState::new())
.setup(|app| {
let splashscreen_window = app.get_window("splashscreen").unwrap();
let main_window = app.get_window("main").unwrap();
let ver = app.config().package.version.clone();
main_window
.set_title(
format!("mDNS-Browser v{}", ver.unwrap_or(String::from("Unknown"))).as_str(),
)
.expect("title to be set");
tauri::async_runtime::spawn(async move {
std::thread::sleep(std::time::Duration::from_secs(6));
main_window.show().unwrap();
main_window
.set_title(
format!("mDNS-Browser v{}", ver.unwrap_or(String::from("Unknown")))
.as_str(),
)
.expect("title to be set");
splashscreen_window.close().unwrap();
});
Ok(())
})
.plugin(
Expand Down
164 changes: 89 additions & 75 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,80 +1,94 @@
{
"build": {
"beforeDevCommand": "trunk serve",
"beforeBuildCommand": "trunk build",
"devPath": "http://localhost:1420",
"distDir": "../dist",
"withGlobalTauri": true
},
"package": {
"productName": "mdns-browser",
"version": "0.6.4"
},
"tauri": {
"allowlist": {
"all": false,
"shell": {
"all": false,
"open": true
},
"dialog": {
"all": false,
"ask": true
},
"http": {
"all": false,
"request": true,
"scope": [
"https://mdns-browser-updates.knulp.duckdns.org/*"
]
},
"window": {
"all": true
},
"process": {
"exit": true,
"relaunch": true
}
"build": {
"beforeDevCommand": "trunk serve",
"beforeBuildCommand": "trunk build",
"devPath": "http://localhost:1420",
"distDir": "../dist",
"withGlobalTauri": true
},
"windows": [
{
"title": "mDNS-Browser",
"width": 1600,
"height": 900
}
],
"security": {
"csp": null
"package": {
"productName": "mdns-browser",
"version": "0.7.0"
},
"updater": {
"active": true,
"endpoints": [
"https://mdns-browser-updates.knulp.duckdns.org/updates.json"
],
"dialog": true,
"windows": {
"installMode": "passive"
},
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwQzYxQzI2MkI3NUI1RDgKUldUWXRYVXJKaHpHSUEvVmhlVGtNZW5HNXRNZ2xEREF3UkNtbXAxTW0zR0JJUVcveEhMZHFNMjgK"
},
"bundle": {
"active": true,
"targets": [
"deb",
"appimage",
"nsis",
"dmg",
"app",
"updater"
],
"identifier": "net.hrzlgnm.mdns-browser",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
"tauri": {
"allowlist": {
"all": false,
"shell": {
"all": false,
"open": true
},
"dialog": {
"all": false,
"ask": true
},
"http": {
"all": false,
"request": true,
"scope": [
"https://mdns-browser-updates.knulp.duckdns.org/*"
]
},
"window": {
"all": true
},
"process": {
"exit": true,
"relaunch": true
}
},
"windows": [
{
"title": "mDNS-Browser",
"url": "index.html",
"width": 1600,
"height": 900,
"label": "main",
"visible": false
},
{
"title": "Splashscreen",
"url": "public/splashscreen.html",
"label": "splashscreen",
"width": 640,
"height": 480,
"decorations": false,
"resizable": false,
"transparent": true,
"visible": true
}
],
"security": {
"csp": null
},
"updater": {
"active": true,
"endpoints": [
"https://mdns-browser-updates.knulp.duckdns.org/updates.json"
],
"dialog": true,
"windows": {
"installMode": "passive"
},
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDIwQzYxQzI2MkI3NUI1RDgKUldUWXRYVXJKaHpHSUEvVmhlVGtNZW5HNXRNZ2xEREF3UkNtbXAxTW0zR0JJUVcveEhMZHFNMjgK"
},
"bundle": {
"active": true,
"targets": [
"deb",
"appimage",
"nsis",
"dmg",
"app",
"updater"
],
"identifier": "net.hrzlgnm.mdns-browser",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}
}
}