Merge pull request #3 from LingandRX/develop
refactor(storage): 将 storage 工具类导出名重命名为 storageUtil
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { storage } from '@/utils/chromeStorage';
|
||||
import { storageUtil } from '@/utils/chromeStorage';
|
||||
|
||||
const RoutePersistence = () => {
|
||||
const location = useLocation();
|
||||
@@ -13,7 +13,7 @@ const RoutePersistence = () => {
|
||||
if (isRestored.current) return;
|
||||
|
||||
try {
|
||||
const lastRoute = await storage.get('app/lastRoute');
|
||||
const lastRoute = await storageUtil.get('app/lastRoute');
|
||||
|
||||
if (lastRoute && lastRoute !== '/' && location.pathname === '/') {
|
||||
navigate(lastRoute, { replace: true });
|
||||
@@ -32,7 +32,7 @@ const RoutePersistence = () => {
|
||||
useEffect(() => {
|
||||
const saveRoute = async () => {
|
||||
if (!isRestored.current) return;
|
||||
await storage.set('app/lastRoute', location.pathname);
|
||||
await storageUtil.set('app/lastRoute', location.pathname);
|
||||
console.log('保存路由', location.pathname);
|
||||
};
|
||||
|
||||
|
||||
@@ -40,4 +40,4 @@ class StorageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
export const storage = new StorageUtils();
|
||||
export const storageUtil = new StorageUtils();
|
||||
|
||||
@@ -55,11 +55,13 @@ export const downloadHtmlInBackground = (events: unknown[]) => {
|
||||
const blob = new Blob([htmlContent], { type: 'text/html' });
|
||||
const reader = new FileReader();
|
||||
reader.onload = () => {
|
||||
chrome.downloads.download({
|
||||
chrome.downloads
|
||||
.download({
|
||||
url: reader.result as string,
|
||||
filename: `replay-${Date.now()}.html`,
|
||||
saveAs: true,
|
||||
}).then(r => console.log(r));
|
||||
})
|
||||
.then((r) => console.log(r));
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user