switch over to tauri

This commit is contained in:
none 2023-01-13 21:58:31 +01:00
parent a462e83394
commit 981a2641c0
14 changed files with 3571 additions and 1627 deletions

4
.gitignore vendored
View File

@ -1 +1,3 @@
/target /src-tauri/target
*_backup
*ignore*

1572
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +0,0 @@
[package]
name = "ipass-gui"
version = "0.0.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
winit = "0.27.5"
ip_lib = { path = "library/" }
[profile.release]
opt-level = 'z' # Optimize for size
lto = true # Enable link-time optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations
panic = 'abort' # Abort on panic
# strip = true # Strip symbols from binary; remove pdb

3296
src-tauri/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

30
src-tauri/Cargo.toml Normal file
View File

@ -0,0 +1,30 @@
[package]
name = "ipass-gui"
version = "0.0.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[build-dependencies]
tauri-build = { version = "1.2", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["shell-open"] }
ip_lib = { path = "../library/" }
[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = ["custom-protocol"]
# this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = ["tauri/custom-protocol"]
[profile.release]
opt-level = 'z' # Optimize for size
lto = true # Enable link-time optimization
codegen-units = 1 # Reduce number of codegen units to increase optimizations
panic = 'abort' # Abort on panic
# strip = true # Strip symbols from binary; remove pdb

3
src-tauri/build.rs Normal file
View File

@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}

BIN
src-tauri/icons/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

BIN
src-tauri/icons/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

24
src-tauri/src/main.rs Normal file
View File

@ -0,0 +1,24 @@
#![cfg_attr(
all(not(debug_assertions), target_os = "linux"),
windows_subsystem = "windows"
)]
extern crate ip_lib;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}
#[tauri::command]
fn get_version() -> String {
return option_env!("CARGO_PKG_VERSION").unwrap_or("x.x.x").to_string();
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet,get_version])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

67
src-tauri/tauri.conf.json Normal file
View File

@ -0,0 +1,67 @@
{
"build": {
"beforeDevCommand": "",
"beforeBuildCommand": "",
"devPath": "../src",
"distDir": "../src",
"withGlobalTauri": true
},
"package": {
"productName": "ipass",
"version": "0.0.1"
},
"tauri": {
"allowlist": {
"all": false,
"shell": {
"all": false,
"open": true
}
},
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"deb": {
"depends": []
},
"externalBin": [],
"icon": [
"icons/icon.ico",
"icons/icon.png"
],
"identifier": "rocks.ipost.ipass",
"longDescription": "",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null
},
"resources": [],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"security": {
"csp": null
},
"updater": {
"active": false
},
"windows": [
{
"fullscreen": false,
"height": 600,
"resizable": true,
"title": "ipass-gui",
"width": 800
}
]
}
}

37
src/index.html Normal file
View File

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="style.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title id="pageTitle">IPass - x.x.x</title>
<script type="module" src="/main.js"></script>
</head>
<body>
<h1>IPass</h1>
<div class="container">
<table>
<thead>
<tr>
<td>Entry name</td>
<td>Username</td>
<td>Password</td>
</tr>
<tr>
<td class="entry_name">
ENTRY-NAME-HERE
</td>
<td class="hidden entry_user">
<input type="text" name="" id="" value="ENTRY-USERNAME-HERE">
</td>
<td class="hidden entry_pass">
<input type="text" name="" id="" value="ENTRY-PASSWORD-HERE">
</td>
</tr>
</thead>
</table>
</div>
</body>
</html>

23
src/main.js Normal file
View File

@ -0,0 +1,23 @@
const { invoke } = window.__TAURI__.tauri;
let greetInputEl;
let greetMsgEl;
async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value });
}
async function updateTitle() {
document.getElementById("pageTitle").innerText = `IPass - ${await invoke("get_version")}`;
}
window.addEventListener("DOMContentLoaded", () => {
updateTitle()
greetInputEl = document.querySelector("#greet-input");
greetMsgEl = document.querySelector("#greet-msg");
document
.querySelector("#greet-button")
.addEventListener("click", () => greet());
});

View File

@ -1,37 +0,0 @@
use winit::{
event::{Event, WindowEvent},
event_loop::EventLoop,
window::WindowBuilder,
};
extern crate ip_lib;
fn main() {
let ver = option_env!("CARGO_PKG_VERSION").unwrap_or("x.x.x");
let event_loop = EventLoop::new();
WindowBuilder::new()
.with_title(format!("IPass - {ver}"))
.build(&event_loop).expect("Expected to create window");
event_loop.run(move |event, _, control_flow| {
control_flow.set_wait();
match event {
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} => {
println!("The close button was pressed; stopping");
control_flow.set_exit();
},
Event::RedrawRequested(_) => {
//TODO: redraw application
},
_ => (),
}
});
}

88
src/style.css Normal file
View File

@ -0,0 +1,88 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}
:root {
--green: #C2F9BB; /* links etc */
--fg-color: #303034; /* post background */
--bg-color: #1B1B1E; /* page background etc */
--text-color: #ECEAF1; /* text */
--blue-ish: #587291; /* buttons etc */
color: var(--text-color);
background-color: var(--bg-color);
}
a:hover {
color: #24c8db;
}
input,
button {
color: #ffffff;
background-color: #0f0f0f98;
}
.container {
margin: 0;
padding-top: 10vh;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
.row {
display: flex;
justify-content: center;
}
a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
h1 {
text-align: center;
}
input,
button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
color: #0f0f0f;
background-color: #ffffff;
transition: border-color 0.25s;
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.2);
}
button {
cursor: pointer;
}
button:hover {
border-color: #396cd8;
}
input,
button {
outline: none;
}
#greet-input {
margin-right: 5px;
}