upgrade essentials versions
This commit is contained in:
@@ -33,13 +33,16 @@ export const useSoftwareStore = defineStore('software', {
|
||||
// ... (mergedEssentials, sortedUpdates, sortedAllSoftware, isBusy getters stay the same)
|
||||
mergedEssentials: (state) => {
|
||||
return state.essentials.map(item => {
|
||||
const isInstalled = state.allSoftware.some(s => s.id.toLowerCase() === item.id.toLowerCase());
|
||||
const installedInfo = state.allSoftware.find(s => s.id.toLowerCase() === item.id.toLowerCase());
|
||||
const isInstalled = !!installedInfo;
|
||||
const hasUpdate = state.updates.some(s => s.id.toLowerCase() === item.id.toLowerCase());
|
||||
|
||||
let displayStatus = item.status;
|
||||
let actionLabel = '安装';
|
||||
let currentVersion = item.version; // 默认使用清单中的推荐版本
|
||||
|
||||
if (isInstalled) {
|
||||
currentVersion = installedInfo.version; // 如果已安装,显示本地真实版本
|
||||
if (hasUpdate) {
|
||||
actionLabel = '更新';
|
||||
} else if (displayStatus === 'idle') {
|
||||
@@ -47,7 +50,14 @@ export const useSoftwareStore = defineStore('software', {
|
||||
actionLabel = '已安装';
|
||||
}
|
||||
}
|
||||
return { ...item, status: displayStatus, actionLabel };
|
||||
|
||||
return {
|
||||
...item,
|
||||
version: currentVersion,
|
||||
recommended_version: item.version, // 额外保存一个原始推荐版本字段供前端判断
|
||||
status: displayStatus,
|
||||
actionLabel
|
||||
};
|
||||
});
|
||||
},
|
||||
sortedUpdates: (state) => [...state.updates].sort(sortByName),
|
||||
@@ -191,8 +201,10 @@ export const useSoftwareStore = defineStore('software', {
|
||||
},
|
||||
async install(id: string) {
|
||||
const software = this.findSoftware(id)
|
||||
if (software) software.status = 'pending';
|
||||
await invoke('install_software', { id })
|
||||
if (software) {
|
||||
software.status = 'pending';
|
||||
await invoke('install_software', { id, version: software.version })
|
||||
}
|
||||
},
|
||||
findSoftware(id: string) {
|
||||
return this.essentials.find(s => s.id === id) ||
|
||||
|
||||
Reference in New Issue
Block a user