From 4e8f304262718148c6a161aac38141f0ac11c86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Thu, 18 Nov 2021 10:28:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B6=E9=83=A8=E8=BE=93=E5=85=A5=E6=A1=86?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Component/Component.scss | 18 ++++++++++++++ src/forge/Component/HeadSearch.jsx | 40 +++++++----------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/forge/Component/Component.scss b/src/forge/Component/Component.scss index 70c30f5af..da292d237 100644 --- a/src/forge/Component/Component.scss +++ b/src/forge/Component/Component.scss @@ -442,3 +442,21 @@ li.ant-menu-item{ border-left: 5px solid #494949; border-bottom: 6px solid transparent } +//头部输入框样式 +.headSerach{ + background: rgba(255, 255, 255, 0.1); + border-radius: 4px; + padding-left: 20px; + //修改antd输入框默认样式 + .ant-input,.ant-input:focus{ + border: none !important; + background-color: rgba(255, 255, 255, 0) !important; + } + &:hover{ + padding: 2px 20px 2px 20px; + background: #FFF; + & i{ + color: #333; + } + } +} diff --git a/src/forge/Component/HeadSearch.jsx b/src/forge/Component/HeadSearch.jsx index 0e44a2cd2..c73e9fd3d 100644 --- a/src/forge/Component/HeadSearch.jsx +++ b/src/forge/Component/HeadSearch.jsx @@ -1,41 +1,19 @@ import React, { useState } from "react"; -import { Input ,notification} from "antd"; +import { Input} from "antd"; +import './Component.scss'; -const { Search } = Input; export default ({history}) => { - const [openSearch, setOpenSearch] = useState(false); + const [searchValue, setSearchValue] = useState(undefined); - function onGlobalSearch(value) { - history.push('/search?value=' + value); - // window.location.href = `search?value=` + value; - // history.push({ - // pathname:'/search', - // state:value - // }) + function onGlobalSearch(e) { + history.push('/search?value=' + e.target.value); } return ( - { - openSearch ? -
{ - setTimeout(() => { - setOpenSearch(false) - }, 500) - }} - > - -
- : - { - setOpenSearch(true) - }} /> - } +
setSearchValue(undefined)}> + onGlobalSearch({target:{value:searchValue}})}> + setSearchValue(value.target.value)} value={searchValue}> +
) };