feat(image): 新建 knowai-core:1.0.0 镜像并完成推送
Some checks reported errors
continuous-integration/drone/push Build was killed

- 搭建 api、auth、utils 等逻辑模块
- 通过 tsc、eslint、vitest 测试验证

BREAKING CHANGE: 新镜像分支
This commit is contained in:
tobegold574
2025-11-10 20:20:25 +08:00
commit 6a81b7bb13
73 changed files with 10511 additions and 0 deletions

55
auth/storage-adapter.ts Normal file
View File

@@ -0,0 +1,55 @@
/**
* 存储适配器接口
* 提供统一的存储接口,用于非敏感数据的临时存储
* 注意此存储适配器不用于session管理session完全由服务器端控制
*/
import type { StorageAdapter } from './types';
/**
* 内存存储适配器
* 适用于非敏感数据的临时存储如UI状态、用户偏好设置等
*/
export class MemoryStorageAdapter implements StorageAdapter {
private storage: Record<string, string> = {};
getItem(key: string): string | null {
return this.storage[key] || null;
}
setItem(key: string, value: string): void {
this.storage[key] = value;
}
removeItem(key: string): void {
delete this.storage[key];
}
/**
* 清空所有存储项
*/
clear(): void {
this.storage = {};
}
/**
* 获取所有存储键
* @returns 存储键数组
*/
keys(): string[] {
return Object.keys(this.storage);
}
}
/**
* 创建存储适配器
* @param type 存储类型目前只支持memory
* @returns 存储适配器实例
*/
export function createStorageAdapter(type: 'memory' = 'memory'): StorageAdapter {
switch (type) {
case 'memory':
return new MemoryStorageAdapter();
default:
return new MemoryStorageAdapter();
}
}