| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /**
- * 版本管理工具
- * 用于管理更新通知的版本号
- */
- // 当前版本号
- export const CURRENT_VERSION = '1.1.0';
- // 版本历史记录
- export const VERSION_HISTORY = [
- {
- version: '1.1.0',
- date: '2025-12-05',
- description: '应用广场优化、知识库增强、智能问答改进',
- },
-
- ];
- /**
- * 获取当前版本号
- */
- export const getCurrentVersion = (): string => {
- return CURRENT_VERSION;
- };
- /**
- * 比较版本号
- * @param v1
- * @param v2
- * @returns
- */
- export const compareVersions = (v1: string, v2: string): number => {
- const parts1 = v1.split('.').map(Number);
- const parts2 = v2.split('.').map(Number);
-
- for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
- const num1 = parts1[i] || 0;
- const num2 = parts2[i] || 0;
-
- if (num1 > num2) return 1;
- if (num1 < num2) return -1;
- }
-
- return 0;
- };
- /**
- *
- * @param lastViewedVersion
- * @returns true: 需要显示, false: 不需要显示
- */
- export const shouldShowUpdate = (lastViewedVersion: string | null): boolean => {
- if (!lastViewedVersion) return true;
- return compareVersions(CURRENT_VERSION, lastViewedVersion) > 0;
- };
- /**
- * 获取版本历史
- */
- export const getVersionHistory = () => {
- return VERSION_HISTORY;
- };
- /**
- * 重置查看记录
- */
- export const resetViewedVersion = (): void => {
- localStorage.removeItem('lastViewedUpdateVersion');
- };
- /**
- * 强制禁用更新通知
- */
- export const disableUpdateNotification = (): void => {
- localStorage.setItem('disableUpdateNotification', 'true');
- };
- /**
- * 启用更新通知
- */
- export const enableUpdateNotification = (): void => {
- localStorage.removeItem('disableUpdateNotification');
- };
- /**
- * 检查更新通知是否被禁用
- */
- export const isUpdateNotificationDisabled = (): boolean => {
- return localStorage.getItem('disableUpdateNotification') === 'true';
- };
|