v0.1
This commit is contained in:
commit
4aaaf23d2f
2411 files changed
+1248679
No files matched your search
+37
@@ -0,0 +1,37 @@
|
||||
import { useCookie, useRuntimeConfig } from "#app";
|
||||
function cookies(options) {
|
||||
return {
|
||||
getItem: (key) => useCookie(
|
||||
key,
|
||||
{
|
||||
...options ?? useRuntimeConfig().public.piniaPluginPersistedstate.cookieOptions ?? {},
|
||||
decode: options?.decode ?? decodeURIComponent,
|
||||
readonly: true
|
||||
}
|
||||
).value,
|
||||
setItem: (key, value) => useCookie(
|
||||
key,
|
||||
{
|
||||
...options ?? useRuntimeConfig().public.piniaPluginPersistedstate.cookieOptions ?? {},
|
||||
encode: options?.encode ?? encodeURIComponent
|
||||
}
|
||||
).value = value
|
||||
};
|
||||
}
|
||||
function localStorage() {
|
||||
return {
|
||||
getItem: (key) => import.meta.client ? window.localStorage.getItem(key) : null,
|
||||
setItem: (key, value) => import.meta.client ? window.localStorage.setItem(key, value) : null
|
||||
};
|
||||
}
|
||||
function sessionStorage() {
|
||||
return {
|
||||
getItem: (key) => import.meta.client ? window.sessionStorage.getItem(key) : null,
|
||||
setItem: (key, value) => import.meta.client ? window.sessionStorage.setItem(key, value) : null
|
||||
};
|
||||
}
|
||||
export const storages = {
|
||||
cookies,
|
||||
localStorage,
|
||||
sessionStorage
|
||||
};
|
||||
Reference in new issue
Block a user