lint
This commit is contained in:
1 parent
fc250c54ed
commit
5eec516459
62 files changed
+3912
-3376
No files matched your search
+32
-32
@@ -1,73 +1,73 @@
|
||||
<script setup lang="tsx">
|
||||
import { DefaultLayout } from '@/renderer/components/layout'
|
||||
import GlobalDialog from '@/renderer/components/GlobalDialog.vue'
|
||||
import UpdateDialog from '@/renderer/components/UpdateDialog.vue'
|
||||
import GlobalSnackbar from '@/renderer/components/GlobalSnackbar.vue'
|
||||
import { onMounted } from 'vue'
|
||||
import { useAppStore } from '@/renderer/store/app'
|
||||
import { onMounted } from 'vue';
|
||||
import GlobalDialog from '@/renderer/components/GlobalDialog.vue';
|
||||
import GlobalSnackbar from '@/renderer/components/GlobalSnackbar.vue';
|
||||
import { DefaultLayout } from '@/renderer/components/layout';
|
||||
import UpdateDialog from '@/renderer/components/UpdateDialog.vue';
|
||||
import { useAppStore } from '@/renderer/store/app';
|
||||
|
||||
// 使用应用商店来管理应用状态
|
||||
const appStore = useAppStore()
|
||||
const appStore = useAppStore();
|
||||
|
||||
onMounted(() => {
|
||||
// 在应用启动时检查更新
|
||||
setTimeout(() => {
|
||||
checkForUpdates()
|
||||
}, 3000) // 延迟3秒后检查更新,避免影响应用启动速度
|
||||
checkForUpdates();
|
||||
}, 3000); // 延迟3秒后检查更新,避免影响应用启动速度
|
||||
|
||||
// 监听主进程发来的更新相关事件
|
||||
window.mainApi.on('update-available', (_, info) => {
|
||||
appStore.setUpdateStatus('available', info.version)
|
||||
})
|
||||
appStore.setUpdateStatus('available', info.version);
|
||||
});
|
||||
|
||||
window.mainApi.on('update-not-available', (_, info) => {
|
||||
appStore.setUpdateStatus('not-available', info.version)
|
||||
})
|
||||
appStore.setUpdateStatus('not-available', info.version);
|
||||
});
|
||||
|
||||
window.mainApi.on('update-error', (_, error) => {
|
||||
appStore.setUpdateStatus('error', undefined, error.message || String(error))
|
||||
})
|
||||
appStore.setUpdateStatus('error', undefined, error.message || String(error));
|
||||
});
|
||||
|
||||
window.mainApi.on('update-download-progress', (_, progress) => {
|
||||
// 这个事件通过pinia状态管理,不需要在这里单独处理
|
||||
console.log('下载进度:', progress)
|
||||
})
|
||||
console.log('下载进度:', progress);
|
||||
});
|
||||
|
||||
window.mainApi.on('update-downloaded', (_, info) => {
|
||||
appStore.setUpdateStatus('downloaded')
|
||||
console.log('更新已下载,准备安装:', info)
|
||||
})
|
||||
})
|
||||
appStore.setUpdateStatus('downloaded');
|
||||
console.log('更新已下载,准备安装:', info);
|
||||
});
|
||||
});
|
||||
|
||||
const checkForUpdates = async () => {
|
||||
try {
|
||||
// 显示检查更新状态
|
||||
appStore.setUpdateStatus('checking')
|
||||
appStore.setUpdateStatus('checking');
|
||||
|
||||
// 调用主进程检查更新
|
||||
const result = await window.mainApi.invoke('msgCheckForUpdates')
|
||||
const result = await window.mainApi.invoke('msgCheckForUpdates');
|
||||
|
||||
if (result.error) {
|
||||
console.error('检查更新时出错:', result.error)
|
||||
appStore.setUpdateStatus('error', result.error)
|
||||
return
|
||||
console.error('检查更新时出错:', result.error);
|
||||
appStore.setUpdateStatus('error', result.error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.updateAvailable) {
|
||||
// 发现新版本,显示更新提示
|
||||
appStore.setUpdateStatus('available', result.currentVersion)
|
||||
appStore.setUpdateStatus('available', result.currentVersion);
|
||||
} else {
|
||||
// 当前已是最新版本
|
||||
appStore.setUpdateStatus('not-available', result.currentVersion)
|
||||
appStore.setUpdateStatus('not-available', result.currentVersion);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('检查更新时出错:', error)
|
||||
console.error('检查更新时出错:', error);
|
||||
appStore.setUpdateStatus(
|
||||
'error',
|
||||
error instanceof Error ? error.message : String(error)
|
||||
)
|
||||
error instanceof Error ? error.message : String(error),
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in new issue
Block a user