Skip to content

新增一键清除功能,搜索栏自动填充bug已修复 #40

Merged
merged 3 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

# 1.1.0 (2023-03-05)


### ✨ Features

* **custom**: 添加一键清除历史记录功能 ([51d25cf](https://vlink.dev/EOEFANS/eoefans-web/commits/51d25cf))



## 1.0.5 (2023-03-05)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eoefans-web",
"version": "1.0.5",
"version": "1.1.0",
"type": "module",
"scripts": {
"dev": "vite --config ./config/vite.dev.config.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/routers/layout/search/pc/search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const NormalSearch = () => {
handlerNavigate(value);
},
handerHistorySubmit = (value: string) => {
inputRef.current!.value = value;
handlerNavigate(value);
addPCTagHistory(value);
};
Expand Down Expand Up @@ -152,10 +153,12 @@ const AdvanceSearch = forwardRef(function Advance(props, ref) {
onBlur();
},
handlerTagHistorySubmit = (tag: string) => {
tagRef.current!.value = tag;
handlerNavigate(tag, getNameValue());
addPCTagHistory(tag);
},
handlerNameHistorySubmit = (name: string) => {
nameRef.current!.value = name;
handlerNavigate(getTagValue(), name);
addPCNameHistory(name);
};
Expand Down
35 changes: 23 additions & 12 deletions src/routers/layout/search/pc/searchSuggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import HistoryToggleOffIcon from "@mui/icons-material/HistoryToggleOff";
import TagIcon from "@mui/icons-material/Tag";
import AccessibilityNewIcon from "@mui/icons-material/AccessibilityNew";
import { Popper } from "@mui/material";
import ClearAllIcon from "@mui/icons-material/ClearAll";
import { Storage } from "@routers/layout/tools";
import { useURLParams } from "@utils/hooks/url";
import { FC, ReactElement, useEffect, useMemo, useState } from "react";
Expand All @@ -24,6 +25,7 @@ export const addPCTagHistory = (value: string) => {
[value, ...oldHistory.filter((item) => item !== value)].slice(0, 5)
);
};
const clearPCTagHistory = () => PCTagStorage.clearLocalstorage();
const usePCTagHistory = () => {
const local_history: renderSuggestItemLists = PCTagStorage.getLocalStorage(
[]
Expand Down Expand Up @@ -64,6 +66,24 @@ const useSuggestOption = (open: boolean) => {
return [fixedOpen];
};

const HistoryTitleItem: FC<{ onClear: () => void }> = ({ onClear }) => {
return (
<>
<p>
<HistoryToggleOffIcon fontSize='inherit' />
历史记录
</p>
<p
onClick={onClear}
className='cursor-pointer text-sm text-gray-500 ml-2'
>
<ClearAllIcon fontSize='inherit' />
清除记录
</p>
</>
);
};

export const PCTagSuggest: FC<PCTagSuggestProps> = ({
open,
ClickCallback,
Expand All @@ -74,12 +94,7 @@ export const PCTagSuggest: FC<PCTagSuggestProps> = ({
return (
<SuggestPopper open={fixedOpen}>
<SuggestItem
title={
<>
<HistoryToggleOffIcon fontSize='inherit' />
历史记录
</>
}
title={<HistoryTitleItem onClear={clearPCTagHistory} />}
dataList={history_tag}
feedbackMsg='暂无数据'
clickCallBack={ClickCallback}
Expand Down Expand Up @@ -107,6 +122,7 @@ export const addPCNameHistory = (value: string) => {
[value, ...oldHistory.filter((item) => item !== value)].slice(0, 5)
);
};
const clearPCNameHistory = () => PCNameStorage.clearLocalstorage();
const usePCNameHistory = () => {
const local_history: renderSuggestItemLists = PCNameStorage.getLocalStorage(
[]
Expand All @@ -123,12 +139,7 @@ export const PCNameSuggest: FC<PCTagSuggestProps> = ({
return (
<SuggestPopper open={fixedOpen}>
<SuggestItem
title={
<>
<HistoryToggleOffIcon fontSize='inherit' />
历史记录
</>
}
title={<HistoryTitleItem onClear={clearPCNameHistory} />}
dataList={history_name}
feedbackMsg='暂无数据'
clickCallBack={ClickCallback}
Expand Down