feat(panel): surface dev-build version in UI, bot, and CLI

A dev build now shows its `dev+<commit>` identity instead of a misleading stable-looking version in the sidebar badge, dashboard card, update modal, Telegram status report, startup log, and `x-ui -v`. Adds a shared formatPanelVersion helper (single v prefix; dev labels shown verbatim) and fixes the mobile-tag double-v.

Renames the version getters for clarity: config.GetVersion to GetBaseVersion (raw embedded version), config.GetReportedVersion to GetPanelVersion (advertised/displayed), and the xray process GetVersion to GetXrayVersion.
This commit is contained in:
MHSanaei
2026-06-25 02:36:41 +02:00
parent 2adb59bd64
commit e4b881e58a
14 changed files with 75 additions and 36 deletions
+24 -1
View File
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { isPanelUpdateAvailable } from '@/lib/panel-version';
import { formatPanelVersion, isPanelUpdateAvailable } from '@/lib/panel-version';
// Parity with web/service/panel.go isNewerVersion.
describe('isPanelUpdateAvailable', () => {
@@ -31,3 +31,26 @@ describe('isPanelUpdateAvailable', () => {
expect(isPanelUpdateAvailable('nightly-1', 'nightly-1')).toBe(false);
});
});
describe('formatPanelVersion', () => {
it('adds a single v prefix to bare semantic versions', () => {
expect(formatPanelVersion('3.4.0')).toBe('v3.4.0');
expect(formatPanelVersion('2.6.5')).toBe('v2.6.5');
});
it('does not double up the v on already-prefixed tags', () => {
expect(formatPanelVersion('v3.4.0')).toBe('v3.4.0');
expect(formatPanelVersion('V3.4.0')).toBe('v3.4.0');
});
it('shows dev builds verbatim without a v prefix', () => {
expect(formatPanelVersion('dev+1a2b3c4d')).toBe('dev+1a2b3c4d');
expect(formatPanelVersion('dev')).toBe('dev');
});
it('returns empty for blank input and leaves unknown markers untouched', () => {
expect(formatPanelVersion('')).toBe('');
expect(formatPanelVersion(undefined)).toBe('');
expect(formatPanelVersion('?')).toBe('?');
});
});