-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#1667) * refactor: rename `command` mod to `process`, move restart_application * refactor(api): move `exit`, `relaunch` APIs to `process` module
- Loading branch information
1 parent
5c1fe52
commit b0bb796
Showing
16 changed files
with
144 additions
and
112 deletions.
There are no files selected for viewing
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,5 @@ | ||
--- | ||
"tauri": patch | ||
--- | ||
|
||
Renamed the `command` API module to `process`. |
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,5 @@ | ||
--- | ||
"api": patch | ||
--- | ||
|
||
Move `exit` and `relaunch` APIs from `app` to `process` module. |
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,5 @@ | ||
--- | ||
"tauri": patch | ||
--- | ||
|
||
Move `restart_application` API from `app` module to `process` module. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
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
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
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,37 @@ | ||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use std::process::exit; | ||
|
||
use super::InvokeResponse; | ||
use crate::api::process::restart; | ||
use serde::Deserialize; | ||
|
||
/// The API descriptor. | ||
#[derive(Deserialize)] | ||
#[serde(tag = "cmd", rename_all = "camelCase")] | ||
pub enum Cmd { | ||
/// Relaunch application | ||
Relaunch, | ||
/// Close application with provided exit_code | ||
#[serde(rename_all = "camelCase")] | ||
Exit { exit_code: i32 }, | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(self) -> crate::Result<InvokeResponse> { | ||
match self { | ||
Self::Relaunch => Ok({ | ||
restart(); | ||
().into() | ||
}), | ||
Self::Exit { exit_code } => { | ||
// would be great if we can have a handler inside tauri | ||
// who close all window and emit an event that user can catch | ||
// if they want to process something before closing the app | ||
exit(exit_code); | ||
} | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
import { invokeTauriCommand } from './helpers/tauri' | ||
|
||
/** | ||
* Exits immediately with the given `exitCode`. | ||
* | ||
* @param exitCode The exit code to use | ||
* @returns | ||
*/ | ||
async function exit(exitCode: number = 0): Promise<void> { | ||
return invokeTauriCommand({ | ||
__tauriModule: 'Process', | ||
mainThread: true, | ||
message: { | ||
cmd: 'exit', | ||
exitCode | ||
} | ||
}) | ||
} | ||
|
||
/** | ||
* Exits the current instance of the app then relaunches it. | ||
* | ||
* @returns | ||
*/ | ||
async function relaunch(): Promise<void> { | ||
return invokeTauriCommand({ | ||
__tauriModule: 'Process', | ||
mainThread: true, | ||
message: { | ||
cmd: 'relaunch' | ||
} | ||
}) | ||
} | ||
|
||
export { exit, relaunch } |