feat: 优化md渲染组件性能表现
This commit is contained in:
1 parent
c1be93739d
commit
d20dc84d9d
4 files changed
+44
-31
No files matched your search
@@ -0,0 +1,11 @@
|
||||
import useDefaultStore from "~/hooks/pinia/useDefaultStore"
|
||||
|
||||
export default async function cachedPromise<T>(key: string, promise: () =>Promise<T>): Promise<T> {
|
||||
const cache = useDefaultStore().getCache(key)
|
||||
if (cache) {
|
||||
return cache
|
||||
}
|
||||
const res = await promise()
|
||||
useDefaultStore().setCache(key, res)
|
||||
return res
|
||||
}
|
||||
Reference in new issue
Block a user