MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / showUpdateDialog

Function showUpdateDialog

src/controller/update/tauriUpdater.ts:69–143  ·  view source on GitHub ↗
(update: UpdateInfo)

Source from the content-addressed store, hash-verified

67}
68
69function showUpdateDialog(update: UpdateInfo) {
70 let downloaded = 0
71 let total = 0
72
73 const content = createUpdateAvailableContent(update.version, update.body)
74
75 updateModal = Modal.confirm({
76 title: t('update_available'),
77 content,
78 okText: t('download_and_install'),
79 cancelText: t('later'),
80 closable: true,
81 maskClosable: false,
82 onOk: async () => {
83 if (isUpdating) return false
84
85 isUpdating = true
86
87 // 更新对话框状态
88 updateModal?.update({
89 okText: t('downloading') + '...',
90 okButtonProps: { loading: true, disabled: true },
91 cancelButtonProps: { disabled: true },
92 closable: false,
93 content: createDownloadingContent(downloaded, total),
94 })
95
96 try {
97 await update.downloadAndInstall(event => {
98 switch (event.event) {
99 case 'Started': {
100 const e = event as Extract<DownloadEvent, { event: 'Started' }>
101 total = e.data.contentLength || 0
102 break
103 }
104 case 'Progress': {
105 const e = event as Extract<DownloadEvent, { event: 'Progress' }>
106 downloaded += e.data.chunkLength
107 updateModal?.update({
108 content: createDownloadingContent(downloaded, total),
109 })
110 break
111 }
112 case 'Finished':
113 updateModal?.update({
114 okText: t('ok'),
115 okButtonProps: { loading: false, disabled: true },
116 cancelButtonProps: { disabled: true },
117 closable: false,
118 content: createDownloadedAndRestartingContent(),
119 })
120 break
121 }
122 })
123
124 // 下载安装完成,重启应用
125 await relaunch()
126 } catch (error) {

Callers 1

checkForUpdateFunction · 0.85

Calls 4

createDownloadingContentFunction · 0.90
updateMethod · 0.80

Tested by

no test coverage detected