From 842112898ae3e4dbac4b20bbec32349076b4894c Mon Sep 17 00:00:00 2001 From: Blucas <15555602203@163.com> Date: Mon, 4 Dec 2023 15:49:01 +0800 Subject: [PATCH 1/2] feat: search by title --- src/assets/locales/en.json | 3 ++- src/assets/locales/ja.json | 3 ++- src/assets/locales/ko.json | 3 ++- src/assets/locales/zh.json | 3 ++- src/pages/RoomList/index.tsx | 14 ++++++++++++-- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 9e3c681f..590b55f7 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -14,7 +14,8 @@ "os": "OS", "browser": "Browser", "project": "Project", - "debug": "Debug" + "debug": "Debug", + "title": "Title" }, "error": { "oops": "Oops! Errors happened~", diff --git a/src/assets/locales/ja.json b/src/assets/locales/ja.json index 96c765a6..61346443 100644 --- a/src/assets/locales/ja.json +++ b/src/assets/locales/ja.json @@ -14,7 +14,8 @@ "os": "オペレーティング システム", "browser": "ブラウザ", "project": "プロジェクト", - "debug": "デバッグ" + "debug": "デバッグ", + "title": "タイトル" }, "error": { "oops": "おっと!エラーが発生しました。", diff --git a/src/assets/locales/ko.json b/src/assets/locales/ko.json index daf4787e..f3a2c6aa 100644 --- a/src/assets/locales/ko.json +++ b/src/assets/locales/ko.json @@ -14,7 +14,8 @@ "os": "운영 체제", "browser": "브라우저", "project": "프로젝트", - "debug": "디버그" + "debug": "디버그", + "title": "제목" }, "error": { "oops": "이런! 오류가 발생했습니다.", diff --git a/src/assets/locales/zh.json b/src/assets/locales/zh.json index 63e8de95..0bdbe17f 100644 --- a/src/assets/locales/zh.json +++ b/src/assets/locales/zh.json @@ -14,7 +14,8 @@ "os": "系统", "browser": "浏览器", "project": "项目", - "debug": "调试" + "debug": "调试", + "title": "标题" }, "error": { "oops": " 哎呀!发生错误~", diff --git a/src/pages/RoomList/index.tsx b/src/pages/RoomList/index.tsx index fb72c408..7aa750a5 100644 --- a/src/pages/RoomList/index.tsx +++ b/src/pages/RoomList/index.tsx @@ -39,10 +39,14 @@ const sortConnections = (data: I.SpyRoom[]) => { const filterConnections = ( data: I.SpyRoom[], - condition: Record<'address' | 'os' | 'browser', string>, + condition: Record<'title' | 'address' | 'os' | 'browser', string>, ) => { - const { address = '', os = '', browser = '' } = condition; + const { title = '', address = '', os = '', browser = '' } = condition; + const lowerCaseTitle = String(title).trim().toLowerCase(); return data + .filter(({ tags }) => { + return String(tags.title).toLowerCase().includes(lowerCaseTitle); + }) .filter((i) => i.address.slice(0, 4).includes(address || '')) .filter(({ name }) => { const { osName, browserName } = resolveClientInfo(name); @@ -86,6 +90,7 @@ export const RoomList = () => { ); const [conditions, setConditions] = useState({ + title: '', address: '', os: '', browser: '', @@ -221,6 +226,11 @@ export const RoomList = () => { +