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 mainWindow;
|
||||||
let errorWindow;
|
let errorWindow;
|
||||||
|
let autoUpdater: AutoUpdater | null = null;
|
||||||
|
|
||||||
const initializeMainLogger = () => {
|
const initializeMainLogger = () => {
|
||||||
log.initialize({
|
log.initialize({
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ const checkForUpdates = async () => {
|
|||||||
|
|
||||||
if (result.updateAvailable) {
|
if (result.updateAvailable) {
|
||||||
// 发现新版本,显示更新提示
|
// 发现新版本,显示更新提示
|
||||||
appStore.setUpdateStatus('available', result.currentVersion);
|
appStore.setUpdateStatus('available', result.currentVersion, undefined, result.updateInfo);
|
||||||
|
console.log('发现新版本:', result.updateInfo);
|
||||||
} else {
|
} else {
|
||||||
// 当前已是最新版本
|
// 当前已是最新版本
|
||||||
appStore.setUpdateStatus('not-available', result.currentVersion);
|
appStore.setUpdateStatus('not-available', result.currentVersion);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const dialogVisible = computed({
|
|||||||
|| (updateStatus.value.status === 'error' && !!updateStatus.value.error);
|
|| (updateStatus.value.status === 'error' && !!updateStatus.value.error);
|
||||||
},
|
},
|
||||||
set: (value: boolean) => {
|
set: (value: boolean) => {
|
||||||
if (value) {
|
if (!value) {
|
||||||
appStore.showUpdateDialog();
|
appStore.showUpdateDialog();
|
||||||
} else {
|
} else {
|
||||||
appStore.hideUpdateDialog();
|
appStore.hideUpdateDialog();
|
||||||
@@ -29,8 +29,8 @@ const dialogVisible = computed({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const latestVersion = 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,
|
i === 2 ? (Number.parseInt(n) + 1).toString() : n,
|
||||||
).join('.')}`;
|
).join('.')}`;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import zhHant from '@/renderer/locales/zh-hant.json';
|
|||||||
import { getCurrentLocale } from '@/renderer/utils';
|
import { getCurrentLocale } from '@/renderer/utils';
|
||||||
|
|
||||||
export default createI18n({
|
export default createI18n({
|
||||||
locale: getCurrentLocale(),
|
locale: 'zhHans',
|
||||||
fallbackLocale: 'en',
|
fallbackLocale: 'zhHans',
|
||||||
globalInjection: true,
|
globalInjection: true,
|
||||||
messages: {
|
messages: {
|
||||||
en,
|
en,
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import { defineStore } from 'pinia';
|
|||||||
export interface UpdateStatus {
|
export interface UpdateStatus {
|
||||||
status: 'idle' | 'checking' | 'available' | 'not-available' | 'downloading' | 'downloaded' | 'error';
|
status: 'idle' | 'checking' | 'available' | 'not-available' | 'downloading' | 'downloaded' | 'error';
|
||||||
currentVersion?: string;
|
currentVersion?: string;
|
||||||
|
updateInfo?: {
|
||||||
|
version: string;
|
||||||
|
releaseName: string;
|
||||||
|
releaseNotes: string;
|
||||||
|
};
|
||||||
error?: string;
|
error?: string;
|
||||||
progress?: number;
|
progress?: number;
|
||||||
}
|
}
|
||||||
@@ -23,8 +28,8 @@ export const useAppStore = defineStore('app', {
|
|||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
setUpdateStatus(status: UpdateStatus['status'], currentVersion?: string, error?: string) {
|
setUpdateStatus(status: UpdateStatus['status'], currentVersion?: string, error?: string, updateInfo?: UpdateStatus['updateInfo']) {
|
||||||
this.updateStatus = { status, currentVersion, error };
|
this.updateStatus = { status, currentVersion, error, updateInfo };
|
||||||
},
|
},
|
||||||
|
|
||||||
showUpdateDialog() {
|
showUpdateDialog() {
|
||||||
|
|||||||
Reference in new issue
Block a user