From be3733fe5459bc1a3924d892a6f16e0b3bfd3387 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Mon, 19 Aug 2024 23:59:12 +0800 Subject: [PATCH] feat: updtes --- .gitignore | 1 - justfile | 4 ++++ src-tauri/.gitignore | 1 + src-tauri/src/main.rs | 17 ++++++++++++++--- src/index.html | 26 +++++++++++++++++++++++--- src/main.js | 23 ++++++++++++++--------- src/styles.css | 3 +++ 7 files changed, 59 insertions(+), 16 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8f230d9..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -src-tauri/target/ diff --git a/justfile b/justfile index 286ef2e..5cb730c 100644 --- a/justfile +++ b/justfile @@ -1,6 +1,10 @@ _: @just --list +# development run +dev: + cd src-tauri && cargo tauri dev + # build application build: cd src-tauri && cargo tauri build diff --git a/src-tauri/.gitignore b/src-tauri/.gitignore index b21bd68..89f9d1d 100644 --- a/src-tauri/.gitignore +++ b/src-tauri/.gitignore @@ -1,5 +1,6 @@ # Generated by Cargo # will have compiled files and executables +/.idea/ /target/ # Generated by Tauri diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 523550d..c883ecd 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -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 = 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"); } diff --git a/src/index.html b/src/index.html index 3b7e70d..ebfb718 100644 --- a/src/index.html +++ b/src/index.html @@ -4,13 +4,33 @@ - Tauri App + Secure Editor
-

Welcome to Tauri!

+ + + + + + + + + + + + + +
header
+ +
+ +
+ foot +
+
diff --git a/src/main.js b/src/main.js index 95a1702..cd68c66 100644 --- a/src/main.js +++ b/src/main.js @@ -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(); }); }); diff --git a/src/styles.css b/src/styles.css index e57b8ac..7257a59 100644 --- a/src/styles.css +++ b/src/styles.css @@ -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;