feat: updtes

This commit is contained in:
2024-08-19 23:59:12 +08:00
parent 7c3459fa24
commit be3733fe54
7 changed files with 59 additions and 16 deletions

1
.gitignore vendored
View File

@@ -1 +0,0 @@
src-tauri/target/

View File

@@ -1,6 +1,10 @@
_:
@just --list
# development run
dev:
cd src-tauri && cargo tauri dev
# build application
build:
cd src-tauri && cargo tauri build

View File

@@ -1,5 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
/.idea/
/target/
# Generated by Tauri

View File

@@ -1,15 +1,26 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn greet(name: &str) -> String {
fn read_content() -> String {
// TODO ...
let args: Vec<String> = std::env::args().collect();
args.join(", ")
}
#[tauri::command]
fn save_content(name: &str) -> String {
// TOD save....
format!("Hello, {}! You've been greeted from Rust!", name)
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.invoke_handler(tauri::generate_handler![
read_content,
save_content,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@@ -4,13 +4,33 @@
<meta charset="UTF-8" />
<link rel="stylesheet" href="styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri App</title>
<title>Secure Editor</title>
<script type="module" src="/main.js" defer></script>
</head>
<body>
<div class="container">
<h1>Welcome to Tauri!</h1>
<table style="width: 100%; height: 100%;">
<tr>
<th>header</th>
</tr>
<tr>
<td>
<textarea id="content" style="margin: 1vh; padding: 1vh;"></textarea>
</td>
</tr>
<tr>
<td style="text-align: right;">
<button id="save">Save</button>
</td>
</tr>
<tr>
<td>
foot
</td>
</tr>
</table>
<!-- <h1>Welcome to Tauri! XXX</h1>
<div class="row">
<a href="https://tauri.app" target="_blank">
@@ -35,7 +55,7 @@
<button type="submit">Greet</button>
</form>
<p id="greet-msg"></p>
<p id="greet-msg"></p> -->
</div>
</body>
</html>

View File

@@ -1,18 +1,23 @@
const { invoke } = window.__TAURI__.tauri;
let greetInputEl;
let contentEl;
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 init_content() {
contentEl.value = await invoke("read_content");
}
async function save_content() {
contentEl.value = "test";
//greetMsgEl.textContent = await invoke("save_content", { name: greetInputEl.value }) + ' >>>';// + await invoke("read_content");
}
window.addEventListener("DOMContentLoaded", () => {
greetInputEl = document.querySelector("#greet-input");
greetMsgEl = document.querySelector("#greet-msg");
document.querySelector("#greet-form").addEventListener("submit", (e) => {
e.preventDefault();
greet();
contentEl = document.querySelector("#content");
contentEl.value = "aaaa";
//greetMsgEl = document.querySelector("#greet-msg");
init_content();
document.querySelector("#save").addEventListener("click", (e) => {
save_content();
});
});

View File

@@ -57,6 +57,7 @@ h1 {
}
input,
textarea,
button {
border-radius: 8px;
border: 1px solid transparent;
@@ -83,6 +84,7 @@ button:active {
}
input,
textarea,
button {
outline: none;
}
@@ -102,6 +104,7 @@ button {
}
input,
textarea,
button {
color: #ffffff;
background-color: #0f0f0f98;