Skip to content

Commit

Permalink
⚡ feat(custom): pc端搜索提供搜索建议,但是并不完善,up列表需要更新
Browse files Browse the repository at this point in the history
  • Loading branch information
master1lan committed Mar 4, 2023
1 parent 7572267 commit 6911c57
Show file tree
Hide file tree
Showing 13 changed files with 471 additions and 92 deletions.
5 changes: 0 additions & 5 deletions src/routers/layout/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import PCSearch from "./pc";
import PhoneSearch from "./phone";
// todo 增加高级搜索以及手机端的搜索
export default function Search() {
const navigate = useNavigate();
const handlerSubmit = () => {
const value = (document.getElementById("q") as HTMLInputElement).value;
navigate(`/search?tag=${value}`);
};
return (
<>
<div className='visible max-sm:hidden'>
Expand Down
8 changes: 8 additions & 0 deletions src/routers/layout/search/pc/context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createContext, useContext } from "react";
type InputWrapperContextType = {
anchorEl: HTMLElement | null;
};
export const InputWrapperContext = createContext<InputWrapperContextType>({
anchorEl: null,
});
export const useGetInputWrapper = () => useContext(InputWrapperContext);
28 changes: 28 additions & 0 deletions src/routers/layout/search/pc/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { phoneMoreNameAndFaceUrls } from "../phone/url";

export type renderSuggestItemLists = { label: string; value: string }[];

//tag列
export const pcSuggestTagLists: renderSuggestItemLists = [
"莞儿睡不醒",
"露早GOGO",
"米诺高分少女",
"虞莫MOMO",
"柚恩不加糖",
"EOE组合",
"早莞在一起",
"莞柚引力",
"一莞米",
"虞舟唱莞",
"早柚",
"西米露",
"早有虞谋",
"米哈柚",
"虞香柚丝",
"米虞说的道理",
"虞米之乡",
].map((item) => ({ label: item, value: item }));

//up列
export const pcSuggestNameLists: renderSuggestItemLists =
phoneMoreNameAndFaceUrls;
10 changes: 3 additions & 7 deletions src/routers/layout/search/pc/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import React, { useRef } from "react";
import { useSearchFocus } from "@components/proview/searchFocus";
import { FC, useEffect } from "react";
import { useEffect } from "react";
import SelectModeCom from "./selectModeNav";
import Search from "./search";

export default function NormalSearch() {
export default function PCSearch() {
const { focused, bind } = useSearchFocus(),
{ onBlur } = bind;
const contentRef = useRef();
useEffect(() => {
if (focused) {
window.addEventListener("scroll", onBlur, {
once: true,
});
window.addEventListener("scroll", onBlur, { once: true });
}
}, [focused]);
return (
Expand Down
10 changes: 9 additions & 1 deletion src/routers/layout/search/pc/pc.module.less
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
span {
padding-bottom: 2px;
font-size: 14px;
font-weight: 400;
font-weight: 600;
}

span+input {
Expand All @@ -70,4 +70,12 @@
border-radius: 40px;
// transition: all 300ms ease;
}
}

.commonRounded {
border-radius: 40px;
}

.suggestMaxHeight {
max-height: calc(100vh - 200px);
}
Loading

0 comments on commit 6911c57

Please sign in to comment.