feat: update WebSocket connection and add system version sending functionality

- Changed WebSocket connection URL to localhost for testing.
- Added a function to send system version to the server upon connection and after a delay.
- Improved logging for received messages.

chore: update package dependencies

- Bump versions for several dependencies including @kevisual/query, lucide-react, vue, and others.
- Update package manager version to pnpm@10.26.1.

fix: adjust app initialization to use sessionStorage

- Modified the app initialization to use a custom sessionStorage implementation backed by an LRU cache.

feat: implement sessionStorage with LRU cache

- Added a new module for sessionStorage that utilizes LRUCache for efficient caching.
This commit is contained in:
2025-12-21 04:20:25 +08:00
parent b3c5e7d68d
commit 36628c8279
16 changed files with 323 additions and 112 deletions

View File

@@ -1,4 +1,4 @@
import { App } from '@kevisual/app/src/app.ts';
import { App } from '@kevisual/app';
import { storage } from '../module/query.ts';
export const app = new App({ token: storage.getItem('token') || '', storage });
import { sessionStorage } from '../module/cache.ts';
export const app = new App({ token: storage.getItem('token') || '', storage: sessionStorage });

21
src/module/cache.ts Normal file
View File

@@ -0,0 +1,21 @@
import { LRUCache } from 'lru-cache'
export const cache = new LRUCache<string, any>({
max: 10000, // 最大缓存数量
ttl: 1000 * 60 * 60 * 24 * 7, // 缓存过期时间单位为毫秒这里设置为7天
});
export const sessionStorage = {
setItem: (key: string, value: any) => {
cache.set(key, value);
},
getItem: (key: string) => {
return cache.get(key);
},
removeItem: (key: string) => {
cache.delete(key);
},
clear: () => {
cache.clear();
}
}