diff --git a/Cargo.toml b/Cargo.toml index 188744067..2496b0259 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ members = [ "examples/commands/src-tauri", "examples/splashscreen/src-tauri/", "examples/state/src-tauri/", + "examples/navigation/src-tauri/", # used to build updater artifacts "examples/updater/src-tauri", ] diff --git a/examples/helloworld/src-tauri/src/main.rs b/examples/helloworld/src-tauri/src/main.rs index e5becf91d..5bb7a26f6 100644 --- a/examples/helloworld/src-tauri/src/main.rs +++ b/examples/helloworld/src-tauri/src/main.rs @@ -7,14 +7,8 @@ windows_subsystem = "windows" )] -#[tauri::command] -fn my_custom_command(argument: String) { - println!("{}", argument); -} - fn main() { tauri::Builder::default() - .invoke_handler(tauri::generate_handler![my_custom_command]) .run(tauri::generate_context!()) .expect("error while running tauri application"); } diff --git a/examples/navigation/package.json b/examples/navigation/package.json new file mode 100644 index 000000000..11fdccc56 --- /dev/null +++ b/examples/navigation/package.json @@ -0,0 +1,7 @@ +{ + "name": "navigation", + "version": "1.0.0", + "scripts": { + "tauri": "node ../../tooling/cli.js/bin/tauri" + } +} \ No newline at end of file diff --git a/examples/navigation/public/index.html b/examples/navigation/public/index.html new file mode 100644 index 000000000..93ae54e13 --- /dev/null +++ b/examples/navigation/public/index.html @@ -0,0 +1,23 @@ + + + + + + + + Tauri + + + +

index.html

+ + + Go + + + + diff --git a/examples/navigation/public/index.js b/examples/navigation/public/index.js new file mode 100644 index 000000000..888fd8e2b --- /dev/null +++ b/examples/navigation/public/index.js @@ -0,0 +1,10 @@ +const routeSelect = document.querySelector('#route') +const link = document.querySelector('#link') + +routeSelect.addEventListener('change', (event) => { + link.href = event.target.value +}) + +document.querySelector('#go').addEventListener('click', () => { + window.location.href = (window.location.origin + '/' + routeSelect.value) +}) diff --git a/examples/navigation/public/nested/index.html b/examples/navigation/public/nested/index.html new file mode 100644 index 000000000..d4a035d4e --- /dev/null +++ b/examples/navigation/public/nested/index.html @@ -0,0 +1,17 @@ + + + + + + + + Tauri + + + +

+ + + + + diff --git a/examples/navigation/public/nested/index.js b/examples/navigation/public/nested/index.js new file mode 100644 index 000000000..9d61017bf --- /dev/null +++ b/examples/navigation/public/nested/index.js @@ -0,0 +1 @@ +document.querySelector('h1').innerHTML = 'nested/index.html' diff --git a/examples/navigation/public/nested/secondary.html b/examples/navigation/public/nested/secondary.html new file mode 100644 index 000000000..4fe7031f2 --- /dev/null +++ b/examples/navigation/public/nested/secondary.html @@ -0,0 +1,17 @@ + + + + + + + + Tauri + + + +

+ + + + + diff --git a/examples/navigation/public/nested/secondary.js b/examples/navigation/public/nested/secondary.js new file mode 100644 index 000000000..284288c0d --- /dev/null +++ b/examples/navigation/public/nested/secondary.js @@ -0,0 +1 @@ +document.querySelector('h1').innerHTML = 'nested/secondary.html' diff --git a/examples/navigation/public/secondary.html b/examples/navigation/public/secondary.html new file mode 100644 index 000000000..4fe7031f2 --- /dev/null +++ b/examples/navigation/public/secondary.html @@ -0,0 +1,17 @@ + + + + + + + + Tauri + + + +

+ + + + + diff --git a/examples/navigation/public/secondary.js b/examples/navigation/public/secondary.js new file mode 100644 index 000000000..0d5374eb6 --- /dev/null +++ b/examples/navigation/public/secondary.js @@ -0,0 +1 @@ +document.querySelector('h1').innerHTML = 'secondary.html' diff --git a/examples/navigation/src-tauri/.gitignore b/examples/navigation/src-tauri/.gitignore new file mode 100644 index 000000000..270a92d27 --- /dev/null +++ b/examples/navigation/src-tauri/.gitignore @@ -0,0 +1,10 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +WixTools + +# These are backup files generated by rustfmt +**/*.rs.bk + +config.json +bundle.json diff --git a/examples/navigation/src-tauri/.license_template b/examples/navigation/src-tauri/.license_template new file mode 100644 index 000000000..860f08256 --- /dev/null +++ b/examples/navigation/src-tauri/.license_template @@ -0,0 +1 @@ +../../../.license_template \ No newline at end of file diff --git a/examples/navigation/src-tauri/Cargo.toml b/examples/navigation/src-tauri/Cargo.toml new file mode 100644 index 000000000..8d3b98c74 --- /dev/null +++ b/examples/navigation/src-tauri/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "navigation" +version = "0.1.0" +description = "A very simple Tauri Appplication with navigation" +edition = "2018" + +[build-dependencies] +tauri-build = { path = "../../../core/tauri-build", features = [ "codegen" ] } + +[dependencies] +serde_json = "1.0" +serde = { version = "1.0", features = [ "derive" ] } +tauri = { path = "../../../core/tauri", features = ["api-all"] } + +[features] +default = [ "custom-protocol" ] +custom-protocol = [ "tauri/custom-protocol" ] diff --git a/examples/navigation/src-tauri/build.rs b/examples/navigation/src-tauri/build.rs new file mode 100644 index 000000000..2ad1cb4e6 --- /dev/null +++ b/examples/navigation/src-tauri/build.rs @@ -0,0 +1,14 @@ +// Copyright 2019-2021 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +use tauri_build::{try_build, Attributes, WindowsAttributes}; + +fn main() { + if let Err(error) = try_build( + Attributes::new() + .windows_attributes(WindowsAttributes::new().window_icon_path("../../.icons/icon.ico")), + ) { + panic!("error found during tauri-build: {}", error); + } +} diff --git a/examples/navigation/src-tauri/src/main.rs b/examples/navigation/src-tauri/src/main.rs new file mode 100644 index 000000000..5bb7a26f6 --- /dev/null +++ b/examples/navigation/src-tauri/src/main.rs @@ -0,0 +1,14 @@ +// Copyright 2019-2021 Tauri Programme within The Commons Conservancy +// SPDX-License-Identifier: Apache-2.0 +// SPDX-License-Identifier: MIT + +#![cfg_attr( + all(not(debug_assertions), target_os = "windows"), + windows_subsystem = "windows" +)] + +fn main() { + tauri::Builder::default() + .run(tauri::generate_context!()) + .expect("error while running tauri application"); +} diff --git a/examples/navigation/src-tauri/tauri.conf.json b/examples/navigation/src-tauri/tauri.conf.json new file mode 100644 index 000000000..c00996bfe --- /dev/null +++ b/examples/navigation/src-tauri/tauri.conf.json @@ -0,0 +1,56 @@ +{ + "build": { + "distDir": "../public", + "devPath": "../public", + "beforeDevCommand": "", + "beforeBuildCommand": "" + }, + "tauri": { + "bundle": { + "active": true, + "targets": "all", + "identifier": "com.tauri.dev", + "icon": [ + "../../.icons/32x32.png", + "../../.icons/128x128.png", + "../../.icons/128x128@2x.png", + "../../.icons/icon.icns", + "../../.icons/icon.ico" + ], + "resources": [], + "externalBin": [], + "copyright": "", + "category": "DeveloperTool", + "shortDescription": "", + "longDescription": "", + "deb": { + "depends": [], + "useBootstrapper": false + }, + "macOS": { + "frameworks": [], + "minimumSystemVersion": "", + "useBootstrapper": false, + "exceptionDomain": "" + } + }, + "allowlist": { + "all": true + }, + "windows": [ + { + "title": "Welcome to Tauri!", + "width": 800, + "height": 600, + "resizable": true, + "fullscreen": false + } + ], + "security": { + "csp": "default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'" + }, + "updater": { + "active": false + } + } +}