diff --git a/packages/server/src/socket.js b/packages/server/src/socket.js index 33efb78..890dd27 100644 --- a/packages/server/src/socket.js +++ b/packages/server/src/socket.js @@ -85,8 +85,10 @@ function getContacts(socket) { nickname: contact.NickName, displayName: getDisplayName(contact), signature: contact.Signature, - nameInitial: contact.PYInitial || contact.RemarkPYInitial, - nameQuanPin: contact.PYQuanPin || contact.RemarkPYQuanPin, + nameInitial: contact.RemarkPYInitial, + nickNameInitial: contact.PYInitial, + nameQuanPin: contact.RemarkPYQuanPin, + nickNameQuanPin: contact.PYQuanPin, avatar: `${config.baseUrl}/session/${socketIDToSessionID.get( socket.id )}/avatar/${contact.UserName}`, diff --git a/packages/web/package-lock.json b/packages/web/package-lock.json index cc35444..53cfcbb 100644 --- a/packages/web/package-lock.json +++ b/packages/web/package-lock.json @@ -18,6 +18,7 @@ "dayjs": "^1.10.7", "filesize": "^7.0.0", "linaria": "^2.1.0", + "lodash-es": "^4.17.21", "log4js": "^6.3.0", "multer": "^1.4.3", "normalize.css": "^8.0.1", @@ -60,6 +61,7 @@ "@testing-library/jest-dom": "^4.2.4", "@types/ali-oss": "^6.0.10", "@types/loadable__component": "^5.13.4", + "@types/lodash-es": "^4.17.5", "@types/platform": "^1.3.4", "@types/prismjs": "^1.16.6", "@types/pure-render-decorator": "^0.2.28", @@ -2239,6 +2241,21 @@ "@types/react": "*" } }, + "node_modules/@types/lodash": { + "version": "4.14.177", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.177.tgz", + "integrity": "sha512-0fDwydE2clKe9MNfvXHBHF9WEahRuj+msTuQqOmAApNORFvhMYZKNGGJdCzuhheVjMps/ti0Ak/iJPACMaevvw==", + "dev": true + }, + "node_modules/@types/lodash-es": { + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.5.tgz", + "integrity": "sha512-SHBoI8/0aoMQWAgUHMQ599VM6ZiSKg8sh/0cFqqlQQMyY9uEplc0ULU5yQNzcvdR4ZKa0ey8+vFmahuRbOCT1A==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", @@ -13513,6 +13530,21 @@ "@types/react": "*" } }, + "@types/lodash": { + "version": "4.14.177", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.177.tgz", + "integrity": "sha512-0fDwydE2clKe9MNfvXHBHF9WEahRuj+msTuQqOmAApNORFvhMYZKNGGJdCzuhheVjMps/ti0Ak/iJPACMaevvw==", + "dev": true + }, + "@types/lodash-es": { + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.5.tgz", + "integrity": "sha512-SHBoI8/0aoMQWAgUHMQ599VM6ZiSKg8sh/0cFqqlQQMyY9uEplc0ULU5yQNzcvdR4ZKa0ey8+vFmahuRbOCT1A==", + "dev": true, + "requires": { + "@types/lodash": "*" + } + }, "@types/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", diff --git a/packages/web/package.json b/packages/web/package.json index b78a297..7e5662f 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -17,6 +17,7 @@ "dayjs": "^1.10.7", "filesize": "^7.0.0", "linaria": "^2.1.0", + "lodash-es": "^4.17.21", "log4js": "^6.3.0", "multer": "^1.4.3", "normalize.css": "^8.0.1", @@ -59,6 +60,7 @@ "@testing-library/jest-dom": "^4.2.4", "@types/ali-oss": "^6.0.10", "@types/loadable__component": "^5.13.4", + "@types/lodash-es": "^4.17.5", "@types/platform": "^1.3.4", "@types/prismjs": "^1.16.6", "@types/pure-render-decorator": "^0.2.28", diff --git a/packages/web/src/modules/FunctionBarAndContactList/ContactList.tsx b/packages/web/src/modules/FunctionBarAndContactList/ContactList.tsx index ee775e2..4473e87 100644 --- a/packages/web/src/modules/FunctionBarAndContactList/ContactList.tsx +++ b/packages/web/src/modules/FunctionBarAndContactList/ContactList.tsx @@ -1,11 +1,25 @@ import React from 'react'; +import { uniq } from 'lodash-es'; import { useSelector } from 'react-redux'; import { State } from '../../state/reducer'; import ContactComponent from './Contact'; import Style from './ContactList.less'; -function ContactList() { - const contacts = useSelector((state: State) => state.contacts); +function ContactList({ keyword = '' }) { + let contacts = + useSelector((state: State) => [...state.groups, ...state.contacts]) || + []; + if (keyword) { + keyword = keyword.toLowerCase(); + contacts = [ + ...contacts.filter((c) => c.displayName?.toLowerCase().includes(keyword)), + ...contacts.filter((c) => c.nameQuanPin?.toLowerCase().includes(keyword)), + ...contacts.filter((c) => c.nickname?.toLowerCase().includes(keyword)), + ...contacts.filter((c) => c.nickname?.toLowerCase().includes(keyword)), + ]; + contacts = uniq(contacts); + } + console.log(contacts); return (