import { redis } from './redis.ts'; export type AppLoadStatus = { status: 'running' | 'loading' | 'error' | 'not-exist'; message: string; }; export const getAppLoadStatus = async (user: string, app: string): Promise => { const key = 'user:app:status:' + app + ':' + user; const value = await redis.get(key); if (!value) { return { status: 'not-exist', message: 'not-exist', }; // 没有加载过 } try { return JSON.parse(value); } catch (err) { return { status: 'error', message: 'error', }; } }; export const setAppLoadStatus = async (user: string, app: string, status: AppLoadStatus) => { const key = 'user:app:status:' + app + ':' + user; const value = JSON.stringify(status); await redis.set(key, value); };