Skip to content

Commit

Permalink
feat: initial updater
Browse files Browse the repository at this point in the history
  • Loading branch information
DrAugus committed Jun 23, 2022
1 parent e63f2f1 commit 684b6a5
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 11 deletions.
22 changes: 22 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tauri-build = { version = "1.0.0", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0", features = ["api-all"] }
tauri = { version = "1.0.0", features = ["api-all", "updater"] }

[features]
# by default Tauri runs in production mode
Expand Down
33 changes: 26 additions & 7 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,31 @@
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]

// fn update() {
// // Initialize updater and check if a new version is available
// // Event: tauri://update
// window.emit("tauri://update".to_string(), None);
// // Listen New Update Available
// // Event: tauri://update-available
// window.listen("tauri://update-available".to_string(), move |msg| {
// println!("New version available: {:?}", msg);
// });
// // Emit Install and Download
// // Event: tauri://update-install
// window.emit("tauri://update-install".to_string(), None);
// // Listen Install Progress
// // Event: tauri://update-status
// window.listen("tauri://update-status".to_string(), move |msg| {
// println!("New status: {:?}", msg);
// })
// }

fn main() {
let context = tauri::generate_context!();
tauri::Builder::default()
.menu(tauri::Menu::os_default(&context.package_info().name))
.run(context)
.expect("error while running tauri application");
let context = tauri::generate_context!();
tauri::Builder::default()
.menu(tauri::Menu::os_default(&context.package_info().name))
.run(context)
.expect("error while running tauri application");
}
9 changes: 7 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "com.tauri.dev",
"identifier": "com.augus.dev",
"longDescription": "",
"macOS": {
"entitlements": null,
Expand All @@ -51,7 +51,12 @@
"csp": null
},
"updater": {
"active": false
"active": true,
"endpoints": [
"https://releases.myapp.com/{{target}}/{{current_version}}"
],
"dialog": false,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDFEMjYzRTMzNEJEN0I1Q0YKUldUUHRkZExNejRtSFZkTno4VUNrejlpUDJuT1V3T0JRKzhHNnhOazdHVlNiZXYvLzBLV1czZWoK"
},
"windows": [
{
Expand Down
4 changes: 4 additions & 0 deletions src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const count = ref(0)

<a href="https://tauri.app/v1/guides/getting-started/setup/vite">TAURI GUIDE</a>

<p>
<a href="https://draugus.github.io/">Blog</a> | <a href="https://draugus.github.io/genshin/">Genshin</a>
</p>

</template>

<style scoped>
Expand Down
18 changes: 17 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
import { createApp } from 'vue'
import {createApp} from 'vue'
import App from './App.vue'

createApp(App).mount('#app')

// update
import {checkUpdate, installUpdate} from '@tauri-apps/api/updater'
import {relaunch} from '@tauri-apps/api/process'

try {
const {shouldUpdate, manifest} = await checkUpdate()
if (shouldUpdate) {
// display dialog
await installUpdate()
// install complete, restart app
await relaunch()
}
} catch (error) {
console.log(error)
}

0 comments on commit 684b6a5

Please sign in to comment.