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 @just --list
# development run
dev:
cd src-tauri && cargo tauri dev
# build application # build application
build: build:
cd src-tauri && cargo tauri build cd src-tauri && cargo tauri build

View File

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

View File

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

View File

@@ -4,13 +4,33 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="stylesheet" href="styles.css" /> <link rel="stylesheet" href="styles.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <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> <script type="module" src="/main.js" defer></script>
</head> </head>
<body> <body>
<div class="container"> <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"> <div class="row">
<a href="https://tauri.app" target="_blank"> <a href="https://tauri.app" target="_blank">
@@ -35,7 +55,7 @@
<button type="submit">Greet</button> <button type="submit">Greet</button>
</form> </form>
<p id="greet-msg"></p> <p id="greet-msg"></p> -->
</div> </div>
</body> </body>
</html> </html>

View File

@@ -1,18 +1,23 @@
const { invoke } = window.__TAURI__.tauri; const { invoke } = window.__TAURI__.tauri;
let greetInputEl; let contentEl;
let greetMsgEl; let greetMsgEl;
async function greet() { async function init_content() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command contentEl.value = await invoke("read_content");
greetMsgEl.textContent = await invoke("greet", { name: greetInputEl.value }); }
async function save_content() {
contentEl.value = "test";
//greetMsgEl.textContent = await invoke("save_content", { name: greetInputEl.value }) + ' >>>';// + await invoke("read_content");
} }
window.addEventListener("DOMContentLoaded", () => { window.addEventListener("DOMContentLoaded", () => {
greetInputEl = document.querySelector("#greet-input"); contentEl = document.querySelector("#content");
greetMsgEl = document.querySelector("#greet-msg"); contentEl.value = "aaaa";
document.querySelector("#greet-form").addEventListener("submit", (e) => { //greetMsgEl = document.querySelector("#greet-msg");
e.preventDefault(); init_content();
greet(); document.querySelector("#save").addEventListener("click", (e) => {
save_content();
}); });
}); });

View File

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