Skip to content

Commit

Permalink
【app】fix 在macos更新成功但重启失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tzfun committed Sep 10, 2024
1 parent 51f7b09 commit 6020e3f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/src-tauri/Cargo.lock

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

4 changes: 2 additions & 2 deletions app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "etcd-workbench"
version = "1.0.1"
version = "1.0.0"
description = "Etcd Workbench"
authors = ["beifengtz"]
edition = "2021"
Expand All @@ -13,7 +13,7 @@ tauri-build = { version = "1", features = [] }
# [target.'cfg(target_os = "macos")'.dependencies]

[dependencies]
tauri = { version = "1", features = ["os-all", "shell-open", "window-all", "dialog-open", "dialog-save", "updater", "clipboard-write-text", "macos-private-api"] }
tauri = { version = "1", features = [ "process-relaunch", "os-all", "shell-open", "window-all", "dialog-open", "dialog-save", "updater", "clipboard-write-text", "macos-private-api"] }
#fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
Expand Down
2 changes: 1 addition & 1 deletion app/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"label": "main",
"title": "Etcd Workbench",
"width": 1200,
"height": 900,
"height": 800,
"minWidth": 1000,
"minHeight": 700,
"center": true,
Expand Down
5 changes: 4 additions & 1 deletion app/src-tauri/tauri.macos.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
"dialog": {
"open": true,
"save": true
},
"process": {
"relaunch": true
}
},
"windows": [
{
"label": "main",
"title": "Etcd Workbench",
"width": 1200,
"height": 900,
"height": 800,
"minWidth": 900,
"minHeight": 500,
"center": true,
Expand Down
2 changes: 1 addition & 1 deletion app/src-tauri/tauri.windows.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"label": "main",
"title": "Etcd Workbench",
"width": 1200,
"height": 900,
"height": 800,
"minWidth": 900,
"minHeight": 500,
"center": true,
Expand Down
10 changes: 7 additions & 3 deletions app/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import WindowsSystemBar from "~/components/system-bar/WindowsSystemBar.vue";
import MacSystemBar from "~/components/system-bar/MacSystemBar.vue";
import AppSetting from "~/pages/setting/AppSetting.vue";
import AppMain from "~/pages/main/AppMain.vue";
import {_checkUpdate, _listenLocal, EventName} from "~/common/events.ts";
import {_alertError, _checkUpdate, _listenLocal, EventName} from "~/common/events.ts";
import {_loadSettings, _useSettings, _useUpdateInfo} from "~/common/store.ts";
import {DEFAULT_SETTING_CONFIG} from "~/common/transport/setting.ts";
import {installUpdate} from "@tauri-apps/api/updater";
Expand Down Expand Up @@ -107,9 +107,13 @@ onMounted(async () => {
updateInfo.latestVersion = manifest
if (settings.autoUpdate) {
await installUpdate()
installUpdate().catch(e => {
console.error(e)
_alertError("A new version was found but the update failed. Please update manually or go to GitHub to download the latest version.")
})
}
}).catch(() => {
}).catch(e => {
console.error(e)
updateInfo.valid = false
})
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/common/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,13 @@ export function _checkUpdateAndInstall() {
).then(() => {
_loading(true)
installUpdate().then(async () => {
await relaunch()
relaunch().catch((e:string) => {
console.error(e)
_alertError("Unable to relaunch, please relaunch manually.")
})
}).catch(e => {
console.error(e)
_alertError("Download failed: " + e)
_alertError("Unable to download: " + e)
}).finally(() => {
_loading(false)
})
Expand Down
1 change: 1 addition & 0 deletions scripts/lib/build_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def build_web(bin_name, skip_merge_jar = False):

os.chdir('web')
web_path = os.getcwd()
execute("nvm use 22")
execute("pnpm install")
execute("pnpm run build")

Expand Down

0 comments on commit 6020e3f

Please sign in to comment.