mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
refactor(windows): Add logo and version to About window (#3378)
Fixes #3354 Fixes #3229 --------- Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com>
This commit is contained in:
@@ -2,6 +2,7 @@ use anyhow::Result;
|
||||
use clap::{Args, Parser};
|
||||
use std::{os::windows::process::CommandExt, process::Command};
|
||||
|
||||
mod about;
|
||||
mod auth;
|
||||
mod crash_handling;
|
||||
mod debug_commands;
|
||||
@@ -35,7 +36,7 @@ pub const BUNDLE_ID: &str = "dev.firezone.client";
|
||||
/// * `g` doesn't mean anything
|
||||
/// * `ed5437c88` is the Git commit hash
|
||||
/// * `-modified` is present if the working dir has any changes from that commit number
|
||||
const GIT_VERSION: &str =
|
||||
pub const GIT_VERSION: &str =
|
||||
git_version::git_version!(args = ["--always", "--dirty=-modified", "--tags"]);
|
||||
|
||||
/// GuiParams prevents a problem where changing the args to `gui::run` breaks static analysis on non-Windows targets, where the gui is stubbed out
|
||||
|
||||
12
rust/windows-client/src-tauri/src/client/about.rs
Normal file
12
rust/windows-client/src-tauri/src/client/about.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
//! Everything related to the About window
|
||||
use crate::client::GIT_VERSION;
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn get_cargo_version() -> String {
|
||||
env!("CARGO_PKG_VERSION").to_string()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub(crate) fn get_git_version() -> String {
|
||||
GIT_VERSION.to_string()
|
||||
}
|
||||
@@ -7,7 +7,7 @@ use crate::client::{self, deep_link, network_changes, AppLocalDataDir, BUNDLE_ID
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use arc_swap::ArcSwap;
|
||||
use client::{
|
||||
logging,
|
||||
about, logging,
|
||||
settings::{self, AdvancedSettings},
|
||||
};
|
||||
use connlib_client_shared::{file_logger, ResourceDescription};
|
||||
@@ -137,6 +137,8 @@ pub(crate) fn run(params: client::GuiParams) -> Result<()> {
|
||||
}
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
about::get_cargo_version,
|
||||
about::get_git_version,
|
||||
logging::clear_logs,
|
||||
logging::count_logs,
|
||||
logging::export_logs,
|
||||
|
||||
@@ -5,32 +5,18 @@
|
||||
<link rel="stylesheet" href="output.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>About Firezone</title>
|
||||
<script src="../node_modules/flowbite/dist/flowbite.min.js" defer></script>
|
||||
<style>
|
||||
.logo.vanilla:hover {
|
||||
filter: drop-shadow(0 0 2em #ffe21c);
|
||||
}
|
||||
</style>
|
||||
<script src="./flowbite.min.js" defer></script>
|
||||
<script type="module" src="about.js" defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body class="bg-neutral-100 text-neutral-900">
|
||||
<div class="container">
|
||||
<h1>About Firezone</h1>
|
||||
|
||||
<div class="row">
|
||||
<a href="https://www.firezone.dev/?utm_source=windows-client" target="_blank">
|
||||
firezone.dev
|
||||
</a>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<a href="steam://browsemedia" target="_blank">
|
||||
app link?
|
||||
</a>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<img src="logo.png" alt="Firezone Logo" class="mt-16 w-64 h-64 mx-auto" />
|
||||
<p class="mt-12 text-center">
|
||||
Version
|
||||
<strong><span id="cargo-version"></span></strong>
|
||||
(<span id="git-version"></span>)
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
35
rust/windows-client/src/about.ts
Normal file
35
rust/windows-client/src/about.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import "./tauri_stub.js";
|
||||
|
||||
const invoke = window.__TAURI__.tauri.invoke;
|
||||
|
||||
const cargoVersionSpan = <HTMLSpanElement>(
|
||||
document.getElementById("cargo-version")
|
||||
);
|
||||
const gitVersionSpan = <HTMLSpanElement>document.getElementById("git-version");
|
||||
|
||||
function get_cargo_version() {
|
||||
invoke("get_cargo_version")
|
||||
.then((cargoVersion: string) => {
|
||||
cargoVersionSpan.innerText = cargoVersion;
|
||||
})
|
||||
.catch((e: Error) => {
|
||||
cargoVersionSpan.innerText = "Unknown";
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
|
||||
function get_git_version() {
|
||||
invoke("get_git_version")
|
||||
.then((gitVersion: string) => {
|
||||
gitVersionSpan.innerText = gitVersion;
|
||||
})
|
||||
.catch((e: Error) => {
|
||||
gitVersionSpan.innerText = "Unknown";
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
get_cargo_version();
|
||||
get_git_version();
|
||||
});
|
||||
BIN
rust/windows-client/src/logo.png
Normal file
BIN
rust/windows-client/src/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
@@ -5,6 +5,7 @@
|
||||
<link rel="stylesheet" href="output.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Settings</title>
|
||||
<script src="./flowbite.min.js" defer></script>
|
||||
<script type="module" src="settings.js" defer></script>
|
||||
</head>
|
||||
|
||||
@@ -176,6 +177,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="./flowbite.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
// Purpose: TypeScript file for the settings page.
|
||||
import "./tauri_stub.js";
|
||||
|
||||
const invoke = window.__TAURI__.tauri.invoke;
|
||||
const listen = window.__TAURI__.event.listen;
|
||||
|
||||
// Custom types
|
||||
interface Settings {
|
||||
@@ -7,46 +11,11 @@ interface Settings {
|
||||
log_filter: string;
|
||||
}
|
||||
|
||||
interface TauriEvent {
|
||||
type: string;
|
||||
payload: any;
|
||||
}
|
||||
|
||||
interface FileCount {
|
||||
files: number;
|
||||
bytes: number;
|
||||
}
|
||||
|
||||
// Stub Tauri API for TypeScript. Helpful when developing without Tauri running.
|
||||
export {};
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI__: {
|
||||
tauri: {
|
||||
invoke: (cmd: string, args?: any) => Promise<any>;
|
||||
};
|
||||
event: {
|
||||
listen: (cmd: string, callback: (event: TauriEvent) => void) => void;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
window.__TAURI__ = window.__TAURI__ || {
|
||||
tauri: {
|
||||
invoke: (_cmd: string, _args?: any) => {
|
||||
return Promise.reject("Tauri API not initialized");
|
||||
},
|
||||
},
|
||||
event: {
|
||||
listen: (_cmd: string, _callback: (event: TauriEvent) => void) => {
|
||||
console.error("Tauri API not initialized");
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const { invoke } = window.__TAURI__.tauri;
|
||||
const { listen } = window.__TAURI__.event;
|
||||
|
||||
// DOM elements
|
||||
const form = <HTMLFormElement>document.getElementById("advanced-settings-form");
|
||||
const authBaseUrlInput = <HTMLInputElement>(
|
||||
|
||||
32
rust/windows-client/src/tauri_stub.ts
Normal file
32
rust/windows-client/src/tauri_stub.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
// Stub Tauri API for TypeScript. Helpful when developing without Tauri running.
|
||||
|
||||
interface TauriEvent {
|
||||
type: string;
|
||||
payload: any;
|
||||
}
|
||||
|
||||
export {};
|
||||
declare global {
|
||||
interface Window {
|
||||
__TAURI__: {
|
||||
tauri: {
|
||||
invoke: (cmd: string, args?: any) => Promise<any>;
|
||||
};
|
||||
event: {
|
||||
listen: (cmd: string, callback: (event: TauriEvent) => void) => void;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
window.__TAURI__ = window.__TAURI__ || {
|
||||
tauri: {
|
||||
invoke: (_cmd: string, _args?: any) => {
|
||||
return Promise.reject("Tauri API not initialized");
|
||||
},
|
||||
},
|
||||
event: {
|
||||
listen: (_cmd: string, _callback: (event: TauriEvent) => void) => {
|
||||
console.error("Tauri API not initialized");
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user