From 2dfcce944da61b42fa87489e7ab0fb2b8096333b Mon Sep 17 00:00:00 2001 From: tangtaoit Date: Mon, 18 Nov 2024 12:51:43 +0800 Subject: [PATCH] fix: fixed many bugs --- packages/tsdaodaobase/src/App.tsx | 42 +- .../src/Components/Conversation/index.tsx | 7 +- .../src/Components/IndexTable/index.tsx | 5 +- .../src/Components/Search/index.tsx | 2 +- .../src/Components/Subscribers/index.tsx | 9 +- packages/tsdaodaobase/src/EndpointCommon.tsx | 16 +- .../tsdaodaobase/src/Pages/Chat/index.css | 332 ++++++------ packages/tsdaodaobase/src/module.tsx | 39 +- packages/tsdaodaocontacts/package.json | 3 +- .../tsdaodaocontacts/src/Contacts/index.tsx | 489 ++++++++---------- .../tsdaodaocontacts/src/FriendAdd/index.tsx | 145 +++--- .../tsdaodaocontacts/src/NewFriend/index.tsx | 174 ++----- .../src/Organizational/GroupNew/index.tsx | 31 +- packages/tsdaodaocontacts/src/module.tsx | 17 +- packages/tsdaodaologin/src/login.tsx | 8 +- 15 files changed, 558 insertions(+), 761 deletions(-) diff --git a/packages/tsdaodaobase/src/App.tsx b/packages/tsdaodaobase/src/App.tsx index aef9d5d..3a0a443 100644 --- a/packages/tsdaodaobase/src/App.tsx +++ b/packages/tsdaodaobase/src/App.tsx @@ -256,12 +256,6 @@ export default class WKApp extends ProviderListener { WKApp.loginInfo.load(); // 加载登录信息 const themeMode = StorageService.shared.getItem("theme-mode"); - const currentSystemThemeModeIsDark = window.matchMedia( - "(prefers-color-scheme: dark)" - ).matches; - if (!themeMode && currentSystemThemeModeIsDark) { - WKApp.config.themeMode = ThemeMode.dark; - } if (themeMode === "1") { WKApp.config.themeMode = ThemeMode.dark; } @@ -380,16 +374,14 @@ export default class WKApp extends ProviderListener { return this.avatarChannel(c); } - avatarOrg(orgID: string) { + avatarOrg(orgID: string){ const baseURl = WKApp.apiClient.config.apiURL; return `${baseURl}organizations/${orgID}/logo`; } // 我的用户头像发送改变 myUserAvatarChange() { - this.changeChannelAvatarTag( - new Channel(WKApp.loginInfo.uid || "", ChannelTypePerson) - ); + this.changeChannelAvatarTag(new Channel(WKApp.loginInfo.uid||"", ChannelTypePerson)); } changeChannelAvatarTag(channel: Channel) { @@ -397,17 +389,17 @@ export default class WKApp extends ProviderListener { if (channel) { myAvatarTag = `channelAvatarTag:${channel.channelType}${channel.channelID}`; } - console.log("changeChannelAvatarTag0----->"); + console.log('changeChannelAvatarTag0----->') const t = new Date().getTime(); WKApp.loginInfo.setStorageItem(myAvatarTag, `${t}`); } - getChannelAvatarTag(channel?: Channel) { + getChannelAvatarTag(channel? :Channel) { let myAvatarTag = "channelAvatarTag"; if (channel) { myAvatarTag = `channelAvatarTag:${channel.channelType}${channel.channelID}`; } const tag = WKApp.loginInfo.getStorageItem(myAvatarTag); - if (!tag) { + if(!tag) { return ""; } return tag; @@ -538,16 +530,13 @@ export default class WKApp extends ProviderListener { return friendApplys; } - public setFriendApplysUnreadCount() { - if (WKApp.loginInfo.isLogined()) { - WKApp.apiClient.get(`/user/reddot/friendApply`).then((res) => { - WKApp.mittBus.emit("friend-applys-unread-count", res.count); - WKApp.loginInfo.setStorageItem( - `${WKApp.loginInfo.uid}-friend-applys-unread-count`, - res.count - ); + public setFriendApplysUnreadCount(){ + if(WKApp.loginInfo.isLogined()){ + WKApp.apiClient.get(`/user/reddot/friendApply`).then(res=>{ + WKApp.mittBus.emit('friend-applys-unread-count', res.count) + WKApp.loginInfo.setStorageItem(`${WKApp.loginInfo.uid}-friend-applys-unread-count`, res.count); WKApp.menus.refresh(); - }); + }) } } @@ -562,9 +551,7 @@ export default class WKApp extends ProviderListener { // } // } if (WKApp.loginInfo.isLogined()) { - const num = WKApp.loginInfo.getStorageItem( - `${WKApp.loginInfo.uid}-friend-applys-unread-count` - ); + const num = WKApp.loginInfo.getStorageItem(`${WKApp.loginInfo.uid}-friend-applys-unread-count`) unreadCount = Number(num); } return unreadCount; @@ -590,10 +577,7 @@ export default class WKApp extends ProviderListener { // WKApp.endpointManager.invokes(EndpointCategory.friendApplyDataChange); // } if (WKApp.loginInfo.isLogined()) { - WKApp.loginInfo.setStorageItem( - `${WKApp.loginInfo.uid}-friend-applys-unread-count`, - "0" - ); + WKApp.loginInfo.setStorageItem(`${WKApp.loginInfo.uid}-friend-applys-unread-count`, '0') } await WKApp.apiClient.delete(`/user/reddot/friendApply`); } diff --git a/packages/tsdaodaobase/src/Components/Conversation/index.tsx b/packages/tsdaodaobase/src/Components/Conversation/index.tsx index 34c70f9..0720c69 100644 --- a/packages/tsdaodaobase/src/Components/Conversation/index.tsx +++ b/packages/tsdaodaobase/src/Components/Conversation/index.tsx @@ -31,7 +31,7 @@ export class Conversation extends Component implements Conver contextMenusContext!: ContextMenusContext avatarMenusContext!: ContextMenusContext // 点击头像弹出的菜单 _messageInputContext!: MessageInputContext - scrollTimer?: NodeJS.Timer + scrollTimer: number | null = null updateBrowseToMessageSeqAndReminderDoneing: boolean = false private _dragFileCallback?: (file: File) => void @@ -249,10 +249,11 @@ export class Conversation extends Component implements Conver handleScroll(e: any) { if (this.scrollTimer) { clearTimeout(this.scrollTimer) + this.scrollTimer = null } - this.scrollTimer = setTimeout(() => { + this.scrollTimer = window.setTimeout(() => { this.handleScrollEnd() - }, 500) + }, 500) this.contextMenusContext.hide() const targetScrollTop = e.target.scrollTop; const scrollOffsetTop = e.target.scrollHeight - (targetScrollTop + e.target.clientHeight); diff --git a/packages/tsdaodaobase/src/Components/IndexTable/index.tsx b/packages/tsdaodaobase/src/Components/IndexTable/index.tsx index 1a42bbd..7852553 100644 --- a/packages/tsdaodaobase/src/Components/IndexTable/index.tsx +++ b/packages/tsdaodaobase/src/Components/IndexTable/index.tsx @@ -1,12 +1,11 @@ -import { Checkbox } from "@douyinfe/semi-ui"; +import { Checkbox } from "@douyinfe/semi-ui/lib/es/checkbox"; import React, { Component } from "react"; import { getPinyin } from "../../Utils/pinYin"; import { toSimplized } from "../../Utils/t2s"; +import "./index.css"; import { IconSearchStroked } from "@douyinfe/semi-icons"; import { animateScroll, scroller } from "react-scroll"; -import "./index.css"; - export class IndexTableItem { id!: string; name!: string; diff --git a/packages/tsdaodaobase/src/Components/Search/index.tsx b/packages/tsdaodaobase/src/Components/Search/index.tsx index 73ebeda..e6db794 100644 --- a/packages/tsdaodaobase/src/Components/Search/index.tsx +++ b/packages/tsdaodaobase/src/Components/Search/index.tsx @@ -1,6 +1,6 @@ import React, { Component } from "react"; import "./index.css" -import { Input } from "@douyinfe/semi-ui"; +import { Input } from "@douyinfe/semi-ui/lib/es/input"; import { IconSearchStroked } from '@douyinfe/semi-icons'; export interface SearchProps { diff --git a/packages/tsdaodaobase/src/Components/Subscribers/index.tsx b/packages/tsdaodaobase/src/Components/Subscribers/index.tsx index 53a813b..1eed61c 100644 --- a/packages/tsdaodaobase/src/Components/Subscribers/index.tsx +++ b/packages/tsdaodaobase/src/Components/Subscribers/index.tsx @@ -3,14 +3,12 @@ import React from "react"; import { Component } from "react"; import Provider from "../../Service/Provider"; import WKApp from "../../App"; +import "./index.css"; import { SubscribersVM } from "./vm"; import IndexTable, { IndexTableItem } from "../IndexTable"; import WKBase, { WKBaseContext } from "../WKBase"; import RouteContext, { RouteContextConfig } from "../../Service/Context"; import { SubscriberList } from "./list"; -import { ChannelSettingRouteData } from "../../Components/ChannelSetting/context"; - -import "./index.css"; export interface SubscribersProps { context: RouteContext; @@ -46,10 +44,6 @@ export class Subscribers extends Component { render() { const { context, onAdd, onRemove, channel } = this.props; - const data = context.routeData() as ChannelSettingRouteData; - const disableSelectList = data.subscribers.map((subscriber) => { - return subscriber.uid; - }); return ( { @@ -86,7 +80,6 @@ export class Subscribers extends Component { {vm.showAdd() ? WKApp.endpoints.organizationalTool( channel, - disableSelectList,
{ WKApp.shared.logout(); }; @@ -227,9 +229,7 @@ export default class BaseModule implements IModule { cmdContent.param.from_name ); } else if (cmdContent.cmd === "groupAvatarUpdate") { - WKApp.shared.changeChannelAvatarTag( - new Channel(param.group_no, ChannelTypeGroup) - ); + WKApp.shared.changeChannelAvatarTag(new Channel(param.group_no, ChannelTypeGroup)); // 群头像更新 WKSDK.shared().channelManager.fetchChannelInfo( new Channel(param.group_no, ChannelTypeGroup) @@ -343,11 +343,8 @@ export default class BaseModule implements IModule { ConversationAction.update ); } - } else if (cmdContent.cmd === "userAvatarUpdate") { - // 用户头像更新 - WKApp.shared.changeChannelAvatarTag( - new Channel(param.uid, ChannelTypePerson) - ); + } else if (cmdContent.cmd === "userAvatarUpdate") { // 用户头像更新 + WKApp.shared.changeChannelAvatarTag(new Channel(param.uid, ChannelTypePerson)); WKApp.dataSource.notifyContactsChange(); } }); @@ -453,16 +450,15 @@ export default class BaseModule implements IModule { return; } if (window.Notification && Notification.permission !== "denied") { - const options = { - body: description, - icon: WKApp.shared.avatarChannel(message.channel), - lang: "zh-CN", - tag: "tag", - renotify: true, - }; const notify = new Notification( channelInfo ? channelInfo.orgData.displayName : "通知", - options + { + body: description, + icon: WKApp.shared.avatarChannel(message.channel), + lang: "zh-CN", + tag: "tag", + // renotify: true, + } ); notify.onclick = () => { @@ -513,7 +509,7 @@ export default class BaseModule implements IModule { icon={require("./assets/toolbars/func_screenshot.svg").default} onClick={() => { if ((window as any).__POWERED_ELECTRON__) { - (window as any).ipc.send("screenshots-start", {}); + (window as any).ipc.send('screenshots-start', {}) } else { window.open("https://www.snipaste.com"); } @@ -536,11 +532,10 @@ export default class BaseModule implements IModule { const isDark = WKApp.config.themeMode === ThemeMode.dark; return { title: "发起群聊", - icon: require(`${ - isDark - ? "./assets/popmenus_startchat_dark.png" - : "./assets/popmenus_startchat.png" - }`), + icon: require(`${isDark + ? "./assets/popmenus_startchat_dark.png" + : "./assets/popmenus_startchat.png" + }`), onClick: () => { const channel: any = { channelID: localStorage.uid, diff --git a/packages/tsdaodaocontacts/package.json b/packages/tsdaodaocontacts/package.json index 010c0c1..ebbf539 100644 --- a/packages/tsdaodaocontacts/package.json +++ b/packages/tsdaodaocontacts/package.json @@ -5,7 +5,6 @@ "dependencies": { "@tsdaodao/base": "*", "axios": "^0.25.0", - "classnames": "^2.3.1", - "react-infinite-scroller": "^1.2.6" + "classnames": "^2.3.1" } } diff --git a/packages/tsdaodaocontacts/src/Contacts/index.tsx b/packages/tsdaodaocontacts/src/Contacts/index.tsx index a5dbb5a..4bebefe 100644 --- a/packages/tsdaodaocontacts/src/Contacts/index.tsx +++ b/packages/tsdaodaocontacts/src/Contacts/index.tsx @@ -1,287 +1,246 @@ import React from "react"; import { Component } from "react"; -import { - Contacts, - ContactsChangeListener, - ContextMenus, - ContextMenusContext, - WKApp, - WKBase, - WKBaseContext, - WKNavMainHeader, - Search, - UserRelation, -} from "@tsdaodao/base"; -import "./index.css"; +import { Contacts, ContactsChangeListener, ContextMenus, ContextMenusContext, WKApp, WKBase, WKBaseContext, WKNavMainHeader, Search, UserRelation } from "@tsdaodao/base" +import "./index.css" import { toSimplized } from "@tsdaodao/base"; import { getPinyin } from "@tsdaodao/base"; import classnames from "classnames"; import { Toast } from "@douyinfe/semi-ui"; -import { - Channel, - ChannelTypePerson, - WKSDK, - ChannelInfoListener, - ChannelInfo, -} from "wukongimjssdk"; +import { Channel, ChannelTypePerson, WKSDK,ChannelInfoListener,ChannelInfo } from "wukongimjssdk"; import { ContactsListManager } from "../Service/ContactsListManager"; import { Card } from "@tsdaodao/base/src/Messages/Card"; import WKAvatar from "@tsdaodao/base/src/Components/WKAvatar"; + + + export class ContactsState { - indexList: string[] = []; - indexItemMap: Map = new Map(); - keyword?: string; - selectedItem?: Contacts; // 被选中的联系人 + indexList: string[] = [] + indexItemMap: Map = new Map() + keyword?: string + selectedItem?: Contacts // 被选中的联系人 } export default class ContactsList extends Component { - contactsChangeListener!: ContactsChangeListener; - channelInfoListener!: ChannelInfoListener; - contextMenusContext!: ContextMenusContext; - baseContext!: WKBaseContext; - constructor(props: any) { - super(props); + contactsChangeListener!: ContactsChangeListener + channelInfoListener!: ChannelInfoListener + contextMenusContext!: ContextMenusContext + baseContext!: WKBaseContext + constructor(props: any) { + super(props) - this.state = { - indexList: [], - indexItemMap: new Map(), - }; - } - componentDidMount() { - this.contactsChangeListener = () => { - this.rebuildIndex(); - }; - - this.channelInfoListener = (channelInfo: ChannelInfo) => { - if (channelInfo.channel.channelType !== ChannelTypePerson) { - return; - } - //是否包含 - let exist = false; - WKApp.dataSource.contactsList.forEach((v) => { - if (v.uid === channelInfo.channel.channelID) { - exist = true; - v.name = channelInfo.title; - v.remark = channelInfo?.orgData.remark; - return; + this.state = { + indexList: [], + indexItemMap: new Map() } - }); - if (exist) { - this.rebuildIndex(); - } - }; - - WKApp.dataSource.addContactsChangeListener(this.contactsChangeListener); - - this.rebuildIndex(); - - WKSDK.shared().channelManager.addListener(this.channelInfoListener); - - ContactsListManager.shared.setRefreshList = () => { - this.setState({}); - }; - } - - componentWillUnmount() { - ContactsListManager.shared.setRefreshList = undefined; - WKApp.dataSource.removeContactsChangeListener(this.contactsChangeListener); - WKSDK.shared().channelManager.removeListener(this.channelInfoListener); - } - - rebuildIndex() { - console.log("rebuildIndex---->"); - this.buildIndex(this.contactsList()); - } - - contactsList() { - const { keyword } = this.state; - return WKApp.dataSource.contactsList.filter((v) => { - if (v.status === UserRelation.blacklist) { - return false; - } - if (v.follow !== 1) { - return false; - } - if (!keyword || keyword === "") { - return true; - } - - if (v.remark && v.remark !== "") { - if (v.remark.indexOf(keyword) !== -1) { - return true; - } - } - - return v.name.indexOf(keyword) !== -1; - }); - } - - buildIndex(contacts: Contacts[]) { - const indexItemMap = new Map(); - let indexList = []; - for (const item of contacts) { - let name = item.name; - if (item.remark && item.remark !== "") { - name = item.remark; - } - - let pinyinNick = getPinyin(toSimplized(name)).toUpperCase(); - let indexName = - !pinyinNick || /[^a-z]/i.test(pinyinNick[0]) ? "#" : pinyinNick[0]; - - let existItems = indexItemMap.get(indexName); - if (!existItems) { - existItems = []; - indexList.push(indexName); - } - existItems.push(item); - indexItemMap.set(indexName, existItems); } - indexList = indexList.sort((a, b) => { - if (a === "#") { - return -1; - } - if (b === "#") { - return 1; - } - return a.localeCompare(b); - }); - this.setState({ - indexList: indexList, - indexItemMap: indexItemMap, - }); - } + componentDidMount() { - _handleContextMenu(item: Contacts, event: React.MouseEvent) { - this.contextMenusContext.show(event); - this.setState({ - selectedItem: item, - }); - } + this.contactsChangeListener = () => { + this.rebuildIndex() + } - sectionUI(indexName: string) { - const { indexItemMap } = this.state; - const { canSelect } = this.props; - const items = indexItemMap.get(indexName); - - return ( -
-
- {items?.map((item, i) => { - let name = item.name; - if (item.remark && item.remark !== "") { - name = item.remark; + this.channelInfoListener = (channelInfo:ChannelInfo)=>{ + if(channelInfo.channel.channelType !== ChannelTypePerson) { + return } - return ( -
{ - const channel = new Channel(item.uid, ChannelTypePerson); - WKApp.endpoints.showConversation(channel); - this.setState({}); - }} - onContextMenu={(e) => { - this._handleContextMenu(item, e); - }} - > -
- {i === 0 ? indexName : ""} -
-
- -
-
{name}
-
- ); - })} -
-
- ); - } - render() { - const { indexList } = this.state; - return ( - { - this.baseContext = baseCtx; - }} - > -
- -
-
- { - this.setState( - { - keyword: v, - }, - () => { - this.rebuildIndex(); - } - ); - }} - > -
-
- {WKApp.endpoints.contactsHeaders().map((view, i) => { - return
{view}
; - })} -
-
- {indexList.map((indexName) => { - return this.sectionUI(indexName); - })} -
-
- { - this.contextMenusContext = context; - }} - menus={[ - { - title: "查看资料", - onClick: () => { - const { selectedItem } = this.state; - this.baseContext.showUserInfo(selectedItem?.uid || ""); - }, - }, - { - title: "分享给朋友...", - onClick: () => { - WKApp.shared.baseContext.showConversationSelect( - (channels: Channel[]) => { - const { selectedItem } = this.state; - if (channels && channels.length > 0) { - for (const channel of channels) { - const card = new Card(); - card.uid = selectedItem?.uid || ""; - card.name = selectedItem?.name || ""; - card.vercode = selectedItem?.vercode || ""; - WKSDK.shared().chatManager.send(card, channel); + //是否包含 + let exist = false + WKApp.dataSource.contactsList.forEach((v)=>{ + if(v.uid === channelInfo.channel.channelID) { + exist = true + v.name = channelInfo.title + v.remark = channelInfo?.orgData.remark + return + } + }) + if(exist) { + this.rebuildIndex() + } + } + + WKApp.dataSource.addContactsChangeListener(this.contactsChangeListener) + + this.rebuildIndex() + + WKSDK.shared().channelManager.addListener(this.channelInfoListener) + + ContactsListManager.shared.setRefreshList = () => { + this.setState({}) + } + } + + componentWillUnmount() { + ContactsListManager.shared.setRefreshList = undefined + WKApp.dataSource.removeContactsChangeListener(this.contactsChangeListener) + WKSDK.shared().channelManager.removeListener(this.channelInfoListener) + } + + + rebuildIndex() { + console.log("rebuildIndex---->") + this.buildIndex(this.contactsList()) + } + + contactsList() { + const { keyword } = this.state + return WKApp.dataSource.contactsList.filter((v) => { + if (v.status === UserRelation.blacklist) { + return false + } + if (v.follow !== 1) { + return false + } + if (!keyword || keyword === "") { + return true + } + + if (v.remark && v.remark !== "") { + if (v.remark.indexOf(keyword) !== -1) { + return true + } + } + + return v.name.indexOf(keyword) !== -1 + }) + } + + + buildIndex(contacts: Contacts[]) { + const indexItemMap = new Map() + let indexList = [] + for (const item of contacts) { + let name = item.name + if (item.remark && item.remark !== "") { + name = item.remark + } + + let pinyinNick = getPinyin(toSimplized(name)).toUpperCase(); + let indexName = !pinyinNick || /[^a-z]/i.test(pinyinNick[0]) ? "#" : pinyinNick[0]; + + let existItems = indexItemMap.get(indexName) + if (!existItems) { + existItems = [] + indexList.push(indexName) + } + existItems.push(item) + indexItemMap.set(indexName, existItems) + } + indexList = indexList.sort((a, b) => { + if (a === "#") { + return -1 + } + if (b === "#") { + return 1 + } + return a.localeCompare(b) + }) + this.setState({ + indexList: indexList, + indexItemMap: indexItemMap, + }) + } + + _handleContextMenu(item: Contacts, event: React.MouseEvent) { + this.contextMenusContext.show(event) + this.setState({ + selectedItem: item, + }) + } + + sectionUI(indexName: string) { + const { indexItemMap } = this.state + const { canSelect } = this.props + const items = indexItemMap.get(indexName) + + return
+
+ { + items?.map((item, i) => { + let name = item.name + if (item.remark && item.remark !== "") { + name = item.remark } - Toast.success("分享成功!"); - } - }, - "分享名片" - ); - }, - }, - ]} - /> + return
{ + const channel = new Channel(item.uid, ChannelTypePerson) + WKApp.endpoints.showConversation(channel) + this.setState({}) + }} onContextMenu={(e) => { + this._handleContextMenu(item, e) + }}> +
+ {i === 0 ? indexName : ""} +
+
+ +
+
+ {name} +
+
+ }) + } +
- - ); - } -} + + } + render() { + const { indexList } = this.state + return { + this.baseContext = baseCtx + }}> +
+ +
+
+ { + this.setState({ + keyword: v + }, () => { + this.rebuildIndex() + }) + }}> +
+
+ { + WKApp.endpoints.contactsHeaders().map((view, i) => { + return
{view}
+ }) + } +
+
+ { + indexList.map((indexName) => { + return this.sectionUI(indexName) + }) + } +
+
+ { + this.contextMenusContext = context + }} menus={[{ + title: "查看资料", onClick: () => { + const { selectedItem } = this.state + this.baseContext.showUserInfo(selectedItem?.uid || "") + } + }, { + title: "分享给朋友...", onClick: () => { + WKApp.shared.baseContext.showConversationSelect((channels: Channel[]) => { + const { selectedItem } = this.state + if (channels && channels.length > 0) { + for (const channel of channels) { + const card = new Card() + card.uid = selectedItem?.uid || "" + card.name = selectedItem?.name || "" + card.vercode = selectedItem?.vercode||"" + WKSDK.shared().chatManager.send(card, channel) + } + Toast.success("分享成功!") + } + }, "分享名片") + } + }]} /> +
+
+ } +} \ No newline at end of file diff --git a/packages/tsdaodaocontacts/src/FriendAdd/index.tsx b/packages/tsdaodaocontacts/src/FriendAdd/index.tsx index 546d1fe..3069c8b 100644 --- a/packages/tsdaodaocontacts/src/FriendAdd/index.tsx +++ b/packages/tsdaodaocontacts/src/FriendAdd/index.tsx @@ -1,98 +1,81 @@ import { WKApp, WKViewQueueHeader, QRCodeMy, Search } from "@tsdaodao/base"; -import { WKBase, WKBaseContext } from "@tsdaodao/base"; +import {WKBase, WKBaseContext } from "@tsdaodao/base"; import React from "react"; import { Component, ReactNode } from "react"; -import { Spin, Toast } from "@douyinfe/semi-ui"; -import "./index.css"; +import { Spin,Toast } from '@douyinfe/semi-ui'; +import "./index.css" export interface FriendAddProps { - onBack?: () => void; + onBack?: () => void } export class FriendAddState { - spinning!: boolean; - keyword?: string; - result?: any; + spinning!:boolean + keyword?:string + result?:any } -export class FriendAdd extends Component { - baseContext!: WKBaseContext; - constructor(props: any) { - super(props); +export class FriendAdd extends Component { + baseContext!:WKBaseContext + constructor(props:any) { + super(props) - this.state = { - spinning: false, - }; - } - - async searchUser() { - const { keyword } = this.state; - if (!keyword) { - return; + this.state = { + spinning: false, + } } - this.setState({ - spinning: true, - }); - const result = await WKApp.dataSource.commonDataSource - .searchUser(keyword) - .catch((err) => { - Toast.error(err.msg); - }); - if (result) { - this.setState({ - result: result, - spinning: false, - }); - if (result.exist !== 1) { - Toast.error("用户不存在!"); - } else { - WKApp.shared.baseContext.showUserInfo( - result.data.uid, - undefined, - result.data.vercode - ); + async searchUser() { + const { keyword } = this.state + if(!keyword) { + return + } + + this.setState({ + spinning: true, + }) + const result = await WKApp.dataSource.commonDataSource.searchUser(keyword).catch((err)=>{ + Toast.error(err.msg) + }) + if(result) { + this.setState({ + result: result, + spinning: false, + }) + if(result.exist !== 1) { + Toast.error("用户不存在!") + }else { + WKApp.shared.baseContext.showUserInfo(result.data.uid,undefined,result.data.vercode) + } } - } - } + } - render(): ReactNode { - const { onBack } = this.props; - const { spinning } = this.state; - return ( - { - this.baseContext = ctx; - }} - > -
- -
- - { - this.setState({ - keyword: v, - }); - }} - onEnterPress={() => { - this.searchUser(); - }} - > - -
- 我的{WKApp.config.appName}号:{WKApp.loginInfo.shortNo}{" "} - { - WKApp.routeLeft.push(); - }} - src={require("./assets/icon_qrcode.png")} - > + + render(): ReactNode { + const { onBack } = this.props + const { spinning } = this.state + return { + this.baseContext = ctx + }}> +
+ +
+ + { + this.setState({ + keyword: v + }) + }} onEnterPress={()=>{ + this.searchUser() + }}> + +
+ 我的{WKApp.config.appName}号:{WKApp.loginInfo.shortNo} { + WKApp.routeLeft.push() + }} src={require("./assets/icon_qrcode.png")}> +
-
- - ); - } -} + + } +} \ No newline at end of file diff --git a/packages/tsdaodaocontacts/src/NewFriend/index.tsx b/packages/tsdaodaocontacts/src/NewFriend/index.tsx index b3d884a..cd1bf84 100644 --- a/packages/tsdaodaocontacts/src/NewFriend/index.tsx +++ b/packages/tsdaodaocontacts/src/NewFriend/index.tsx @@ -1,130 +1,56 @@ -import React from "react"; -import { - FriendApply, - FriendApplyState, - WKApp, - ContextMenus, - ContextMenusContext, - WKViewQueueHeader, - Provider, -} from "@tsdaodao/base"; -import { Component, ReactNode } from "react"; -import { Button } from "@douyinfe/semi-ui"; -import { NewFriendVM } from "./vm"; +import React, { Component, ReactNode } from "react"; +import { Button } from '@douyinfe/semi-ui'; +import { FriendApplyState, WKApp, WKViewQueueHeader, Provider } from "@tsdaodao/base"; import { FriendAdd } from "../FriendAdd"; +import { NewFriendVM } from "./vm"; import "./index.css"; -export class NewFriendState { - selectedItem?: FriendApply; // 被选中的好友 -} +export class NewFriend extends Component { -export class NewFriend extends Component { - contextMenusContext!: ContextMenusContext; + render(): ReactNode { + return { + return new NewFriendVM() + }} render={(vm: NewFriendVM) => { - constructor(props: any) { - super(props); - } - - _handleContextMenu(item: FriendApply, event: React.MouseEvent) { - console.log(item); - this.contextMenusContext.show(event); - this.setState({ - selectedItem: item, - }); - } - render(): ReactNode { - return ( - { - return new NewFriendVM(); - }} - render={(vm: NewFriendVM) => { - return ( -
- { - WKApp.routeLeft.pop(); - }} - action={ -
- -
- } - >
-
-
    - {vm.friendApplys.map((f) => { - return ( -
  • { - this._handleContextMenu(f, e); - }} - > -
    - -
    -
    -
    - {f.to_name} -
    -
    - {f.remark} -
    -
    -
    - -
    -
  • - ); - })} -
-
- { - this.contextMenusContext = context; - }} - menus={[ - { - title: "删除", - onClick: () => { - const { selectedItem } = this.state; - selectedItem && vm.delFriendApply(selectedItem); - }, - }, - ]} - /> + return
+ { + WKApp.routeLeft.pop() + }} action={
+ +
}>
+
+
    + { + vm.friendApplys.map((f) => { + return
  • +
    + +
    +
    +
    + {f.to_name} +
    +
    + {f.remark} +
    +
    +
    + +
    +
  • + }) + } +
+
- ); - }} - > - ); - } -} + }}> + + + } +} \ No newline at end of file diff --git a/packages/tsdaodaocontacts/src/Organizational/GroupNew/index.tsx b/packages/tsdaodaocontacts/src/Organizational/GroupNew/index.tsx index 08db3da..c457df0 100644 --- a/packages/tsdaodaocontacts/src/Organizational/GroupNew/index.tsx +++ b/packages/tsdaodaocontacts/src/Organizational/GroupNew/index.tsx @@ -14,8 +14,6 @@ import { import { BasicTreeNodeData } from "@douyinfe/semi-foundation/lib/cjs/tree/foundation"; import { WKApp, ThemeMode, WKViewQueueHeader } from "@tsdaodao/base"; import WKAvatar from "@tsdaodao/base/src/Components/WKAvatar"; -import { ContactsStatus } from "@tsdaodao/base/src/Service/DataSource/DataSource"; - import "./index.css"; interface IPorpsOrganizationalGroupNew { @@ -23,7 +21,6 @@ interface IPorpsOrganizationalGroupNew { channelID: string; channelType: number; }; - disableSelectList?: string[]; showAdd?: boolean; render?: JSX.Element; remove?: () => void; @@ -188,8 +185,7 @@ export class OrganizationalGroupNew extends Component< } OTree.push({ - label: - employeesNum > 0 ? `${item.name}(${employeesNum})` : `${item.name}`, + label: employeesNum > 0 ? `${item.name}(${employeesNum})` : `${item.name}`, value: item.dept_id, key: item.short_no, icon: ( @@ -295,14 +291,12 @@ export class OrganizationalGroupNew extends Component< getFriendData() { const setFriendData: any[] = []; - WKApp.dataSource.contactsList - .filter((c) => c.status !== ContactsStatus.Blacklist) - .map((item) => { - setFriendData.push({ - name: item.remark || item.name, - uid: item.uid, - }); + WKApp.dataSource.contactsList.map((item) => { + setFriendData.push({ + name: item.name, + uid: item.uid, }); + }); this.setState({ friendData: [...setFriendData], friendSearchData: [...setFriendData], @@ -407,18 +401,6 @@ export class OrganizationalGroupNew extends Component< } } - isDisableItem(id: string) { - const { disableSelectList } = this.props; - if (disableSelectList && disableSelectList.length > 0) { - for (const disableSelect of disableSelectList) { - if (disableSelect === id) { - return true; - } - } - } - return false; - } - render(): ReactNode { const isDark = WKApp.config.themeMode === ThemeMode.dark; const { @@ -549,7 +531,6 @@ export class OrganizationalGroupNew extends Component< { return ( { const channel = param.channel as any; - const disableSelectList = param.disableSelectList as - | string[] - | undefined; return ( - + ); } ); @@ -128,9 +121,6 @@ export default class ContactsModule implements IModule { "contacts.organizational.layer", (param) => { const channel = param.channel as any; - const disableSelectList = param.disableSelectList as - | string[] - | undefined; const div = document.createElement("div"); const ref: any = React.createRef(); document.body.appendChild(div); @@ -145,7 +135,6 @@ export default class ContactsModule implements IModule { , div @@ -155,4 +144,4 @@ export default class ContactsModule implements IModule { } ); } -} +} \ No newline at end of file diff --git a/packages/tsdaodaologin/src/login.tsx b/packages/tsdaodaologin/src/login.tsx index 6e6ae4a..f08b954 100644 --- a/packages/tsdaodaologin/src/login.tsx +++ b/packages/tsdaodaologin/src/login.tsx @@ -7,9 +7,6 @@ import { WKApp, Provider } from "@tsdaodao/base" import { LoginStatus, LoginType, LoginVM } from "./login_vm"; import classNames from "classnames"; - - - type LoginState = { loginStatus: string loginUUID: string @@ -20,6 +17,9 @@ type LoginState = { class Login extends Component { + + + render() { return { @@ -29,7 +29,7 @@ class Login extends Component {
- logo + logo
更愉快的与朋友交流