feat: add git information display in update modals and enhance version check functionality

This commit is contained in:
Will Miao
2025-06-20 15:22:07 +08:00
parent 2ff11a16c4
commit 1b2a02cb1a
5 changed files with 109 additions and 7 deletions

View File

@@ -95,7 +95,7 @@
flex: 1;
}
.version-info {
.version-content .version-info {
display: flex;
flex-wrap: wrap;
flex-direction: row !important;
@@ -104,7 +104,7 @@
font-size: 0.9em;
}
.version-info .base-model {
.version-content .version-info .base-model {
background: oklch(var(--lora-accent) / 0.1);
color: var(--lora-accent);
padding: 2px 8px;

View File

@@ -37,13 +37,11 @@
display: flex;
justify-content: space-between;
align-items: center;
background: rgba(0, 0, 0, 0.02); /* 轻微的灰色背景 */
border: 1px solid rgba(0, 0, 0, 0.08); /* 更明显的边框 */
border-radius: var(--border-radius-sm);
padding: var(--space-3);
}
.version-info {
.update-info .version-info {
display: flex;
flex-direction: column;
gap: 8px;
@@ -70,6 +68,15 @@
color: var(--lora-accent);
}
/* Add styling for git info display */
.git-info {
font-size: 0.85em;
opacity: 0.7;
margin-top: 4px;
font-family: monospace;
color: var(--text-color);
}
.update-link {
display: flex;
align-items: center;

View File

@@ -8,6 +8,11 @@ export class UpdateService {
this.latestVersion = "v0.0.0"; // Initialize with default values
this.updateInfo = null;
this.updateAvailable = false;
this.gitInfo = {
short_hash: "unknown",
branch: "unknown",
commit_date: "unknown"
};
this.updateNotificationsEnabled = getStorageItem('show_update_notifications');
this.lastCheckTime = parseInt(getStorageItem('last_update_check') || '0');
}
@@ -62,6 +67,7 @@ export class UpdateService {
this.currentVersion = data.current_version || "v0.0.0";
this.latestVersion = data.latest_version || "v0.0.0";
this.updateInfo = data;
this.gitInfo = data.git_info || this.gitInfo;
// Explicitly set update availability based on version comparison
this.updateAvailable = this.isNewerVersion(this.latestVersion, this.currentVersion);
@@ -77,7 +83,8 @@ export class UpdateService {
console.log("Update check complete:", {
currentVersion: this.currentVersion,
latestVersion: this.latestVersion,
updateAvailable: this.updateAvailable
updateAvailable: this.updateAvailable,
gitInfo: this.gitInfo
});
}
} catch (error) {
@@ -152,6 +159,21 @@ export class UpdateService {
if (currentVersionEl) currentVersionEl.textContent = this.currentVersion;
if (newVersionEl) newVersionEl.textContent = this.latestVersion;
// Update git info
const gitInfoEl = modal.querySelector('.git-info');
if (gitInfoEl && this.gitInfo) {
if (this.gitInfo.short_hash !== 'unknown') {
let gitText = `Commit: ${this.gitInfo.short_hash}`;
if (this.gitInfo.commit_date !== 'unknown') {
gitText += ` - Date: ${this.gitInfo.commit_date}`;
}
gitInfoEl.textContent = gitText;
gitInfoEl.style.display = 'block';
} else {
gitInfoEl.style.display = 'none';
}
}
// Update changelog content if available
if (this.updateInfo && this.updateInfo.changelog) {
const changelogContent = modal.querySelector('.changelog-content');