Skip to content

Commit

Permalink
优化存储
Browse files Browse the repository at this point in the history
  • Loading branch information
baiy committed Jan 8, 2023
1 parent a5497ce commit 0c4924d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ctool-core/src/helper/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {StorageInterface, StorageDataStructureInterface, StorageDataStructure} f
import {version} from './util'
import platform from './platform'
import {isObject} from "lodash";
import {isProxy, toRaw, unref} from "vue";
import dayjs from "dayjs";

const cacheVersion = version.split('.').join('');
Expand All @@ -13,8 +14,9 @@ const addKeyVersion = (key: string, is: boolean = true): string => `${is ? `v_${

const encode = <T>(value: T, expiry: number = 0): StorageDataStructureInterface<T> => {
expiry = expiry ? expiry + timestamp() : 0
value = unref(value)
return {
v: value,
v: isProxy(value) ? toRaw(value) : value,
u: dayjs().format('YYYY-MM-DD HH:mm:ss'),
e: expiry,
es: expiry ? dayjs(expiry * 1000).format('YYYY-MM-DD HH:mm:ss') : "",
Expand Down

0 comments on commit 0c4924d

Please sign in to comment.