upgrade essentials versions
This commit is contained in:
@@ -35,8 +35,16 @@
|
||||
</div>
|
||||
<p class="description" v-if="software.description">{{ software.description }}</p>
|
||||
<div class="version-info">
|
||||
<span class="version-tag">当前: {{ software.version || '--' }}</span>
|
||||
<span class="version-tag available" v-if="software.available_version">
|
||||
<template v-if="software.status === 'installed'">
|
||||
<span class="version-tag">当前: {{ software.version || '--' }}</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="version-tag recommended">
|
||||
推荐: {{ software.version || '最新版' }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<span class="version-tag available" v-if="software.status !== 'installed' && software.available_version">
|
||||
最新: {{ software.available_version }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -276,7 +284,7 @@ const handleCardClick = () => {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.version-tag.available {
|
||||
.version-tag.available, .version-tag.recommended {
|
||||
color: var(--primary-color);
|
||||
background: rgba(0, 122, 255, 0.08);
|
||||
padding: 0 6px;
|
||||
|
||||
@@ -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