-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix crash on macos. working examples
- Loading branch information
1 parent
200509c
commit 192eb22
Showing
12 changed files
with
653 additions
and
124 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<h1>Hello world from Python + Tauri</h1> | ||
<button>Invoke command</button> | ||
<a href="second.html"> | ||
<button>Navigate to second page</button> | ||
</a> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="description" content="Demo application showcasing integration of web front-end with Python backend"> | ||
<title>Tauric Demo</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1>Welcome to Tauric</h1> | ||
</header> | ||
<main> | ||
<nav> | ||
<a href="second.html" id="secondPageLink">Go to Second Page</a> | ||
</nav> | ||
<section> | ||
<button onclick="greet()" id="callPythonButton"> | ||
Call Python Backend | ||
</button> | ||
</section> | ||
</main> | ||
|
||
<script> | ||
document.querySelector("button").addEventListener("click", () => { | ||
invoke("command", { args: { hello: "world1" } }); | ||
}); | ||
async function greet() { | ||
const {message} = await invoke('Hello from JavaScript!') | ||
alert(message) | ||
} | ||
</script> | ||
</body> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
Second page | ||
</head> | ||
<body> | ||
<a href="javascript:void(0);" onclick="history.back()">Go back</a> | ||
|
||
<button onclick="history.back()">back</button> | ||
</body> | ||
</html> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
line-height: 1.6; | ||
margin: 20px; | ||
background-color: #f9f9f9; | ||
color: #333; | ||
} | ||
header { | ||
text-align: center; | ||
margin-bottom: 20px; | ||
} | ||
a, button { | ||
display: inline-block; | ||
margin: 10px 5px; | ||
padding: 10px 15px; | ||
text-decoration: none; | ||
font-size: 16px; | ||
color: #fff; | ||
background-color: #007BFF; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
transition: background-color 0.3s ease; | ||
} | ||
a:hover, button:hover { | ||
background-color: #0056b3; | ||
} | ||
button { | ||
font-weight: bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
{ | ||
"$schema": "../gen/schemas/capabilities.json", | ||
"identifier": "main", | ||
"permissions": [], | ||
"windows": [ | ||
"*" | ||
], | ||
"remote": { | ||
"urls": [ | ||
"http://*", | ||
"https://*" | ||
] | ||
} | ||
"$schema": "../gen/schemas/capabilities.json", | ||
"identifier": "main", | ||
"permissions": [ | ||
"dialog:default" | ||
], | ||
"windows": [ | ||
"*" | ||
], | ||
"remote": { | ||
"urls": [ | ||
"http://*", | ||
"https://*" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,33 @@ | ||
use std::{env, ffi::CString, ptr::null}; | ||
use std::{env, ffi::{c_char, CStr, CString}, path::PathBuf, ptr::null}; | ||
|
||
use serde_json::Value; | ||
use tauric; | ||
|
||
extern "C" fn ready_callback() { | ||
println!("Ready callback called!"); | ||
#[no_mangle] | ||
extern "C" fn OnReady() { | ||
let label = CString::new("main").unwrap(); | ||
let title = CString::new("tauric").unwrap(); | ||
let url = CString::new("mounted://index.html").unwrap(); | ||
let cwd = CString::new(env::current_dir().unwrap().to_str().unwrap()).unwrap(); | ||
tauric::mount_frontend(cwd.as_ptr()); | ||
tauric::create_window(label.as_ptr(), title.as_ptr(),url.as_ptr()); | ||
|
||
let url = CString::new("fs://index.html").unwrap(); | ||
tauric::TauricCreateWindow(label.as_ptr(), title.as_ptr(),url.as_ptr()); | ||
} | ||
|
||
#[no_mangle] | ||
extern "C" fn OnCommand(message: *const c_char) -> *const c_char { | ||
let message_c = unsafe { CStr::from_ptr(message) }; | ||
let message = message_c.to_str().unwrap(); | ||
let message: Value = serde_json::from_str(message).unwrap(); | ||
println!("Received: {:?}", message); | ||
null() | ||
} | ||
|
||
|
||
fn main() { | ||
// Register the callback function | ||
tauric::on_ready(Some(ready_callback)); | ||
let manifest_dir = env!("CARGO_MANIFEST_DIR"); | ||
let identifier = CString::new("com.tauric.dev").unwrap(); | ||
let product_name = CString::new("tauric").unwrap(); | ||
tauric::run(identifier.as_ptr(), product_name.as_ptr(), null()); | ||
let dist_dir = PathBuf::from(manifest_dir).join("../examples/dist").canonicalize().unwrap(); | ||
let dist_dir = CString::new(dist_dir.to_str().unwrap().to_owned()).unwrap(); | ||
tauric::TauricMountFrontend(dist_dir.as_ptr()); | ||
tauric::TauricOnCommand(OnCommand); | ||
tauric::TauricRun(identifier.as_ptr(), product_name.as_ptr(), null(), Some(OnReady)); | ||
} |
Oops, something went wrong.