Skip to content

Commit

Permalink
🐛 fix(custom): 修复历史记录重复的问题
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #37
  • Loading branch information
master1lan committed Mar 5, 2023
1 parent 61cb917 commit b9a4795
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/routers/layout/search/pc/modal.tsx

This file was deleted.

8 changes: 6 additions & 2 deletions src/routers/layout/search/pc/searchSuggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ type PCTagSuggestProps = {
const PCTagStorage = new Storage<string[]>("pcTagHistorys");
export const addPCTagHistory = (value: string) => {
const oldHistory = PCTagStorage.getLocalStorage([]);
PCTagStorage.setLocalstorage([value, ...oldHistory.slice(0, 4)]);
PCTagStorage.setLocalstorage(
[value, ...oldHistory.filter((item) => item !== value)].slice(0, 5)
);
};
const usePCTagHistory = () => {
const local_history: renderSuggestItemLists = PCTagStorage.getLocalStorage(
Expand Down Expand Up @@ -101,7 +103,9 @@ export const PCTagSuggest: FC<PCTagSuggestProps> = ({
const PCNameStorage = new Storage<string[]>("pcNameHistorys");
export const addPCNameHistory = (value: string) => {
const oldHistory = PCNameStorage.getLocalStorage([]);
PCNameStorage.setLocalstorage([value, ...oldHistory.slice(0, 4)]);
PCNameStorage.setLocalstorage(
[value, ...oldHistory.filter((item) => item !== value)].slice(0, 5)
);
};
const usePCNameHistory = () => {
const local_history: renderSuggestItemLists = PCNameStorage.getLocalStorage(
Expand Down

0 comments on commit b9a4795

Please sign in to comment.