chore: cleanup deps
This commit is contained in:
parent
e767710f3d
commit
06667ee0af
4 changed files with 0 additions and 80 deletions
|
@ -1,11 +0,0 @@
|
|||
import SanitizeHTML from 'sanitize-html'
|
||||
|
||||
export function sanitize(text: string) {
|
||||
return SanitizeHTML(text, {
|
||||
allowedAttributes: {
|
||||
a: ['href', 'name', 'target', 'class'],
|
||||
span: ['class'],
|
||||
img: ['src', 'srcset', 'alt', 'title', 'width', 'height', 'loading'],
|
||||
},
|
||||
})
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
export function useCacheStorage<T>(
|
||||
key: string,
|
||||
getter: () => T | Promise<T>,
|
||||
TTL = 1000 * 60 * 60 * 12, // 12 hours
|
||||
) {
|
||||
const storage = useLocalStorage(key, {
|
||||
time: 0,
|
||||
value: null as T | null,
|
||||
})
|
||||
|
||||
if (storage.value.time + TTL < Date.now()) {
|
||||
Promise.resolve(getter()).then((v) => {
|
||||
storage.value = {
|
||||
time: Date.now(),
|
||||
value: v,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return computed({
|
||||
get() {
|
||||
return storage.value.value
|
||||
},
|
||||
set(v) {
|
||||
storage.value.value = v
|
||||
},
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue