办学质量监测教学评价系统
shenrongliang
2025-06-13 11d86cc6c26bb4f709e407acadf4805c2024e79f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { ss } from '@/utils/storage'
 
 type LumaVideo = {
    url: string;
    width: number;
    height: number;
    thumbnail: string | null;
    download_url?: string;
};
 
 
export type LumaMedia = {
    id: string;
    prompt: string;
    state: string;
    created_at?: string;
    video?: LumaVideo;
    liked?: boolean | null;
    estimate_wait_seconds?: number | null;
    last_feed?:number
};
export class lumaStore{
  //private id: string;
  private localKey='luma-store';
  public save(obj:LumaMedia ){
    if(!obj.id ) throw "id must";
    let arr=  this.getObjs();
    let i= arr.findIndex( v=>v.id==obj.id );
    if(i>-1) arr[i]= obj;
    else arr.push(obj);
     ss.set(this.localKey, arr );
    return this;
  } 
  public findIndex(id:string){ 
    return this.getObjs().findIndex( v=>v.id== id )
  }
 
  public getObjs():LumaMedia[]{
     const obj = ss.get( this.localKey ) as  undefined| LumaMedia[];
     if(!obj) return [];
     return obj;
  }
}