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 { useEffect, useRef } from 'react';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { storage } from '@/utils/chromeStorage';
|
import { storageUtil } from '@/utils/chromeStorage';
|
||||||
|
|
||||||
const RoutePersistence = () => {
|
const RoutePersistence = () => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
@@ -13,7 +13,7 @@ const RoutePersistence = () => {
|
|||||||
if (isRestored.current) return;
|
if (isRestored.current) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const lastRoute = await storage.get('app/lastRoute');
|
const lastRoute = await storageUtil.get('app/lastRoute');
|
||||||
|
|
||||||
if (lastRoute && lastRoute !== '/' && location.pathname === '/') {
|
if (lastRoute && lastRoute !== '/' && location.pathname === '/') {
|
||||||
navigate(lastRoute, { replace: true });
|
navigate(lastRoute, { replace: true });
|
||||||
@@ -32,7 +32,7 @@ const RoutePersistence = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const saveRoute = async () => {
|
const saveRoute = async () => {
|
||||||
if (!isRestored.current) return;
|
if (!isRestored.current) return;
|
||||||
await storage.set('app/lastRoute', location.pathname);
|
await storageUtil.set('app/lastRoute', location.pathname);
|
||||||
console.log('保存路由', 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 blob = new Blob([htmlContent], { type: 'text/html' });
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
chrome.downloads.download({
|
chrome.downloads
|
||||||
url: reader.result as string,
|
.download({
|
||||||
filename: `replay-${Date.now()}.html`,
|
url: reader.result as string,
|
||||||
saveAs: true,
|
filename: `replay-${Date.now()}.html`,
|
||||||
}).then(r => console.log(r));
|
saveAs: true,
|
||||||
|
})
|
||||||
|
.then((r) => console.log(r));
|
||||||
};
|
};
|
||||||
reader.readAsDataURL(blob);
|
reader.readAsDataURL(blob);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user