add refresh browser cache when client version not match server version

This commit is contained in:
MaysWind
2025-06-30 00:39:28 +08:00
parent 801c0f8572
commit 96b7c69283
29 changed files with 332 additions and 42 deletions
+27 -9
View File
@@ -1,13 +1,17 @@
import type { VersionInfo } from '@/core/version.ts';
import { getBasePath } from './web.ts';
export function isProduction(): boolean {
return __EZBOOKKEEPING_IS_PRODUCTION__;
}
const clientVersionHolder: VersionInfo = {
version: __EZBOOKKEEPING_VERSION__,
commitHash: __EZBOOKKEEPING_BUILD_COMMIT_HASH__,
buildTime: __EZBOOKKEEPING_BUILD_UNIX_TIME__
};
export function getVersion(): string {
const isRelease = !getBuildTime();
const commitHash = __EZBOOKKEEPING_BUILD_COMMIT_HASH__;
let version = __EZBOOKKEEPING_VERSION__;
export function formatDisplayVersion(versionInfo: VersionInfo): string {
const isRelease = !versionInfo.buildTime;
const commitHash = versionInfo.commitHash;
let version = versionInfo.version;
if (version && (!isRelease || !isProduction())) {
version += '-dev';
@@ -15,6 +19,8 @@ export function getVersion(): string {
if (!version) {
version = 'unknown';
} else {
version = 'v' + version;
}
if (commitHash) {
@@ -24,8 +30,20 @@ export function getVersion(): string {
return version;
}
export function getBuildTime(): string {
return __EZBOOKKEEPING_BUILD_UNIX_TIME__;
export function isProduction(): boolean {
return __EZBOOKKEEPING_IS_PRODUCTION__;
}
export function getClientVersionInfo(): VersionInfo {
return clientVersionHolder;
}
export function getClientDisplayVersion(): string {
return formatDisplayVersion(clientVersionHolder);
}
export function getClientBuildTime(): string {
return clientVersionHolder.buildTime || '';
}
export function getMobileVersionPath(): string {