feat(更新): 增强自动更新功能并添加简体中文支持
添加自动更新器变量声明并完善更新状态处理逻辑 修改i18n配置默认使用简体中文 更新对话框现在显示更详细的版本信息
This commit is contained in:
1 parent
709445789a
commit
8ec2e3df18
5 files changed
+15
-8
No files matched your search
@@ -8,6 +8,7 @@ import Constants from './utils/Constants';
|
||||
|
||||
let mainWindow;
|
||||
let errorWindow;
|
||||
let autoUpdater: AutoUpdater | null = null;
|
||||
|
||||
const initializeMainLogger = () => {
|
||||
log.initialize({
|
||||
|
||||
@@ -55,7 +55,8 @@ const checkForUpdates = async () => {
|
||||
|
||||
if (result.updateAvailable) {
|
||||
// 发现新版本,显示更新提示
|
||||
appStore.setUpdateStatus('available', result.currentVersion);
|
||||
appStore.setUpdateStatus('available', result.currentVersion, undefined, result.updateInfo);
|
||||
console.log('发现新版本:', result.updateInfo);
|
||||
} else {
|
||||
// 当前已是最新版本
|
||||
appStore.setUpdateStatus('not-available', result.currentVersion);
|
||||
|
||||
@@ -20,7 +20,7 @@ const dialogVisible = computed({
|
||||
|| (updateStatus.value.status === 'error' && !!updateStatus.value.error);
|
||||
},
|
||||
set: (value: boolean) => {
|
||||
if (value) {
|
||||
if (!value) {
|
||||
appStore.showUpdateDialog();
|
||||
} else {
|
||||
appStore.hideUpdateDialog();
|
||||
@@ -29,8 +29,8 @@ const dialogVisible = computed({
|
||||
});
|
||||
|
||||
const latestVersion = computed(() => {
|
||||
// 这里应该从API获取最新版本号,暂时使用固定值
|
||||
return `v${(updateStatus.value.currentVersion || '1.0.0').replace(/^v?/, '').split('.').map((n, i) =>
|
||||
// 优先使用更新信息中的版本号
|
||||
return updateStatus.value.updateInfo?.version || `v${(updateStatus.value.currentVersion || '1.0.0').replace(/^v?/, '').split('.').map((n, i) =>
|
||||
i === 2 ? (Number.parseInt(n) + 1).toString() : n,
|
||||
).join('.')}`;
|
||||
});
|
||||
|
||||
@@ -13,8 +13,8 @@ import zhHant from '@/renderer/locales/zh-hant.json';
|
||||
import { getCurrentLocale } from '@/renderer/utils';
|
||||
|
||||
export default createI18n({
|
||||
locale: getCurrentLocale(),
|
||||
fallbackLocale: 'en',
|
||||
locale: 'zhHans',
|
||||
fallbackLocale: 'zhHans',
|
||||
globalInjection: true,
|
||||
messages: {
|
||||
en,
|
||||
|
||||
@@ -3,6 +3,11 @@ import { defineStore } from 'pinia';
|
||||
export interface UpdateStatus {
|
||||
status: 'idle' | 'checking' | 'available' | 'not-available' | 'downloading' | 'downloaded' | 'error';
|
||||
currentVersion?: string;
|
||||
updateInfo?: {
|
||||
version: string;
|
||||
releaseName: string;
|
||||
releaseNotes: string;
|
||||
};
|
||||
error?: string;
|
||||
progress?: number;
|
||||
}
|
||||
@@ -23,8 +28,8 @@ export const useAppStore = defineStore('app', {
|
||||
},
|
||||
|
||||
actions: {
|
||||
setUpdateStatus(status: UpdateStatus['status'], currentVersion?: string, error?: string) {
|
||||
this.updateStatus = { status, currentVersion, error };
|
||||
setUpdateStatus(status: UpdateStatus['status'], currentVersion?: string, error?: string, updateInfo?: UpdateStatus['updateInfo']) {
|
||||
this.updateStatus = { status, currentVersion, error, updateInfo };
|
||||
},
|
||||
|
||||
showUpdateDialog() {
|
||||
|
||||
Reference in new issue
Block a user