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 = {
|
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))
|
Revive: (s:string):ColumnSet=>new ColumnSet(s.split(as))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,19 +14,24 @@ const _defaultColumn:(ColumnInfo| ColumnName)[] = [
|
||||||
]
|
]
|
||||||
export const useStore = defineStore('state', {
|
export const useStore = defineStore('state', {
|
||||||
state: ()=> {
|
state: ()=> {
|
||||||
const last_table = getCookie(nameCookie("last_table"))
|
let store = {
|
||||||
const last_screen = getCookie(nameCookie("last_screen"))
|
|
||||||
const last_columns = getCookie(nameCookie("last_columns"))?.split(",")
|
|
||||||
const last_tags = getCookie(nameCookie("last_tags"))?.split(",")
|
|
||||||
return {
|
|
||||||
invs: new Map() as Map<string,TricksterInventory>,
|
invs: new Map() as Map<string,TricksterInventory>,
|
||||||
accounts: new Set() as Set<string>,
|
accounts: new Set() as Set<string>,
|
||||||
activeTable: last_table ? last_table: "none",
|
activeTable: "none",
|
||||||
screen: last_screen ? last_screen : "default",
|
screen: "default",
|
||||||
columns: last_columns ? new ColumnSet([..._defaultColumn,...last_columns]) : new ColumnSet(_defaultColumn),
|
columns:new ColumnSet(_defaultColumn),
|
||||||
tags: last_tags ? new ColumnSet(last_tags) : new ColumnSet(),
|
tags: new ColumnSet(),
|
||||||
dirty: 0,
|
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