forked from a/lifeto-shop
working persistence in cookie world
This commit is contained in:
parent
f206ce3bb2
commit
e70d407ccb
|
@ -43,7 +43,7 @@ export const StoreStrSet = {
|
|||
}
|
||||
|
||||
export const StoreColSet = {
|
||||
Murder: (s:ColumnSet):string=>Array.from(s).join(as),
|
||||
Murder: (s:ColumnSet):string=>Array.from(s.s.values()).join(as),
|
||||
Revive: (s:string):ColumnSet=>new ColumnSet(s.split(as))
|
||||
}
|
||||
|
||||
|
|
|
@ -14,19 +14,24 @@ const _defaultColumn:(ColumnInfo| ColumnName)[] = [
|
|||
]
|
||||
export const useStore = defineStore('state', {
|
||||
state: ()=> {
|
||||
const last_table = getCookie(nameCookie("last_table"))
|
||||
const last_screen = getCookie(nameCookie("last_screen"))
|
||||
const last_columns = getCookie(nameCookie("last_columns"))?.split(",")
|
||||
const last_tags = getCookie(nameCookie("last_tags"))?.split(",")
|
||||
return {
|
||||
let store = {
|
||||
invs: new Map() as Map<string,TricksterInventory>,
|
||||
accounts: new Set() as Set<string>,
|
||||
activeTable: last_table ? last_table: "none",
|
||||
screen: last_screen ? last_screen : "default",
|
||||
columns: last_columns ? new ColumnSet([..._defaultColumn,...last_columns]) : new ColumnSet(_defaultColumn),
|
||||
tags: last_tags ? new ColumnSet(last_tags) : new ColumnSet(),
|
||||
activeTable: "none",
|
||||
screen: "default",
|
||||
columns:new ColumnSet(_defaultColumn),
|
||||
tags: new ColumnSet(),
|
||||
dirty: 0,
|
||||
}
|
||||
for(const [k, v] of Object.entries(StoreReviver)){
|
||||
const coke = getCookie(nameCookie("last_"+k))
|
||||
if(coke){
|
||||
if((store[k as keyof StoreProps]) != undefined){
|
||||
(store[k as keyof StoreProps] as any) = v.Revive(coke)
|
||||
}
|
||||
}
|
||||
}
|
||||
return store
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue