mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-01 11:13:40 +03:00
fix(tests): update cli.js app fixture (#1469)
This commit is contained in:
parent
5b6c7bb6ee
commit
64d7625b28
@ -20,6 +20,7 @@ function runBuildTest(args) {
|
|||||||
setTimeout(resolve, 2000)
|
setTimeout(resolve, 2000)
|
||||||
})
|
})
|
||||||
process.chdir(appDir)
|
process.chdir(appDir)
|
||||||
|
console.log(server)
|
||||||
await build(args).promise
|
await build(args).promise
|
||||||
|
|
||||||
const artifactFolder = args.debug ? 'debug' : 'release'
|
const artifactFolder = args.debug ? 'debug' : 'release'
|
||||||
|
@ -5,16 +5,13 @@
|
|||||||
function callBackEnd(route, args) {
|
function callBackEnd(route, args) {
|
||||||
console.log(route)
|
console.log(route)
|
||||||
console.log(args)
|
console.log(args)
|
||||||
var xhr = new XMLHttpRequest()
|
window.__TAURI__.http
|
||||||
xhr.onload = function () {
|
.fetch('http://localhost:7000/' + route, {
|
||||||
console.log(route, args, 'done', xhr.status)
|
method: 'POST',
|
||||||
}
|
body: window.__TAURI__.http.Body.json(args),
|
||||||
xhr.onerror = function () {
|
responseType: window.__TAURI__.http.ResponseType.Binary
|
||||||
console.log(route, args, 'error with ' + xhr.status)
|
})
|
||||||
}
|
.catch(console.error)
|
||||||
xhr.open('POST', 'http://localhost:7000/' + route)
|
|
||||||
xhr.setRequestHeader('Content-type', 'application/json')
|
|
||||||
xhr.send(JSON.stringify(args))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function reply(args) {
|
function reply(args) {
|
||||||
@ -136,7 +133,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
window.rpc.notify('exit')
|
window.__TAURI__.invoke('exit')
|
||||||
}, 15000)
|
}, 15000)
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -4,10 +4,9 @@ workspace = { }
|
|||||||
name = "app"
|
name = "app"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "A Tauri App"
|
description = "A Tauri App"
|
||||||
author = [ "Daniel Thompson-Yvetot" ]
|
authors = [ "Daniel Thompson-Yvetot" ]
|
||||||
license = ""
|
license = ""
|
||||||
repository = ""
|
repository = ""
|
||||||
default-run = "app"
|
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[package.metadata.bundle]
|
[package.metadata.bundle]
|
||||||
@ -20,6 +19,9 @@ icon = [
|
|||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
tauri-build = { path = "../../../../../../../core/tauri-build" }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0.64"
|
serde_json = "1.0.64"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
@ -27,8 +29,5 @@ serde_derive = "1.0"
|
|||||||
tauri = { path = "../../../../../../../core/tauri", features =["api-all"]}
|
tauri = { path = "../../../../../../../core/tauri", features =["api-all"]}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
default = [ "custom-protocol" ]
|
||||||
custom-protocol = [ "tauri/custom-protocol" ]
|
custom-protocol = [ "tauri/custom-protocol" ]
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "app"
|
|
||||||
path = "src/main.rs"
|
|
||||||
|
7
tooling/cli.js/test/jest/fixtures/app/src-tauri/build.rs
Normal file
7
tooling/cli.js/test/jest/fixtures/app/src-tauri/build.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
tauri_build::build()
|
||||||
|
}
|
@ -1,26 +1,20 @@
|
|||||||
use tauri::ApplicationDispatcherExt;
|
#[tauri::command(with_window)]
|
||||||
|
fn exit<M: tauri::Params>(window: tauri::Window<M>) {
|
||||||
|
window.close().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.setup(|webview_manager| async move {
|
.on_page_load(|window, _| {
|
||||||
let mut webview_manager_ = webview_manager.clone();
|
let window_ = window.clone();
|
||||||
tauri::event::listen(String::from("hello"), move |_| {
|
window.listen("hello".into(), move |_| {
|
||||||
tauri::event::emit(
|
window_
|
||||||
&webview_manager_,
|
.emit(&"reply".to_string(), Some("{ msg: 'TEST' }".to_string()))
|
||||||
String::from("reply"),
|
.unwrap();
|
||||||
Some("{ msg: 'TEST' }".to_string()),
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
});
|
});
|
||||||
webview_manager
|
window.eval("window.onTauriInit()").unwrap();
|
||||||
.current_webview()
|
|
||||||
.eval("window.onTauriInit && window.onTauriInit()");
|
|
||||||
})
|
|
||||||
.invoke_handler(|webview_manager, command, _arg| async move {
|
|
||||||
if &command == "exit" {
|
|
||||||
webview_manager.close().unwrap();
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
.invoke_handler(tauri::generate_handler![exit])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error encountered while running tauri application");
|
.expect("error encountered while running tauri application");
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"build": {
|
"build": {
|
||||||
"devPath": "http://localhost:4000",
|
"devPath": "../dist",
|
||||||
"distDir": "../dist"
|
"distDir": "../dist",
|
||||||
|
"withGlobalTauri": true
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
@ -19,7 +20,8 @@
|
|||||||
},
|
},
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"title": "Fixture"
|
"title": "Fixture",
|
||||||
|
"visible": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ pub struct PackageConfig {
|
|||||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
pub struct BundleConfig {
|
pub struct BundleConfig {
|
||||||
/// Whether we should build your app with tauri-bundler or plain `cargo build`
|
/// Whether we should build your app with tauri-bundler or plain `cargo build`
|
||||||
|
#[serde(default)]
|
||||||
pub active: bool,
|
pub active: bool,
|
||||||
/// The bundle targets, currently supports ["deb", "app", "msi", "appimage", "dmg"] or "all"
|
/// The bundle targets, currently supports ["deb", "app", "msi", "appimage", "dmg"] or "all"
|
||||||
pub targets: Option<BundleTarget>,
|
pub targets: Option<BundleTarget>,
|
||||||
@ -535,6 +536,7 @@ impl TauriConfig {
|
|||||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||||
pub struct UpdaterConfig {
|
pub struct UpdaterConfig {
|
||||||
/// Whether the updater is active or not.
|
/// Whether the updater is active or not.
|
||||||
|
#[serde(default)]
|
||||||
pub active: bool,
|
pub active: bool,
|
||||||
/// Display built-in dialog or use event system if disabled.
|
/// Display built-in dialog or use event system if disabled.
|
||||||
#[serde(default = "default_dialog")]
|
#[serde(default = "default_dialog")]
|
||||||
|
@ -242,12 +242,10 @@
|
|||||||
},
|
},
|
||||||
"BundleConfig": {
|
"BundleConfig": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
|
||||||
"active"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"active": {
|
"active": {
|
||||||
"description": "Whether we should build your app with tauri-bundler or plain `cargo build`",
|
"description": "Whether we should build your app with tauri-bundler or plain `cargo build`",
|
||||||
|
"default": false,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"category": {
|
"category": {
|
||||||
@ -966,12 +964,10 @@
|
|||||||
},
|
},
|
||||||
"UpdaterConfig": {
|
"UpdaterConfig": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
|
||||||
"active"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"active": {
|
"active": {
|
||||||
"description": "Whether the updater is active or not.",
|
"description": "Whether the updater is active or not.",
|
||||||
|
"default": false,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"dialog": {
|
"dialog": {
|
||||||
|
Loading…
Reference in New Issue
Block a user