wildfirechat / vue-pc-chat

野火IM PC 客户端,支持Windows、MacOS,Linux,支持国产操作系统和国产CPU
Other
134 stars 125 forks source link

web端唤起PC客户端聊天窗口后 要定位到与具体的某人聊天 #128

Closed 2018linwei closed 2 years ago

2018linwei commented 2 years ago

老师 请教下 web端唤起PC客户端聊天窗口后 要定位到与具体的某人聊天 这个要怎么实现

imndx commented 2 years ago

web 端是通过 deeplink 的方式唤起 pc 端,deeplink scheme 是:wfc://,可以将 path 和相应的参数,拼接在其后,组成一个有意义的uri。 当从 web 端点击该uri并跳转到 pc 端的时候(要求已安装 pc 端),pc 端将能收到该 uri,然后,pc 端解析该uri,并执行相应的操作。

接下来,需要在 web 端和 pc 端之间,进行一些约定 比如: wfc://home表示打开主页 wfc://converstaion?target=FireChat&type=1&line=0表示打开targetFireChattype为群会话,line为0的会话。

具体打开某个人的聊天,可以参考如下伪代码:

  1. web 端,参考SettingPage.vue#openPcChaturi配置为wfc://converstaion?target=FireChat&type=1&line=0
  2. pc 端,参考store.js# ipcRenderer.on('deep-link',部分
    
            ipcRenderer.on('deep-link', (event, args) => {
                // 解析出 target,type,line
               let conversation = new Conversation(type, target, line);
               this.setCurrentConversation(conversation);
            })
2018linwei commented 2 years ago

老师 再请教下url的地址 配置成这样子 wfc://converstaion?target=HKHdHd00&type=0&line=0
target=HKHdHd00 个人用户ID|、 type=0 是一对一聊天 还是无法打开单独与某人聊天

wfc://converstaion?target=HKHdHd00&type=0&line=0 这样子地址是不是我组装错了 现在这个地址只能打开野火聊天窗口软件 无法打开具体与某人聊天窗口

imndx commented 2 years ago

不是这样配置,就会自动打开 pc,并切换到该会话的,pc 端需要进行处理的。

可以参考下下面的示例:

pc端:https://github.com/wildfirechat/vue-pc-chat/commit/66b92f9cff48a5dd06c6013d0af5e14b268b6a57 web 端:https://github.com/wildfirechat/vue-chat/commit/e5778951aae82bc9abb6d33c990b15933fd9edc0

2018linwei commented 2 years ago

PC端 是不是要在 store.js 里加入打开相对应某人聊天窗口代码逻辑
image

imndx commented 2 years ago

PC端 是不是要在 store.js 里加入打开相对应某人聊天窗口代码逻辑 image

是的,但上面截图就是 打开相对应某人聊天窗口代码逻辑

2018linwei commented 2 years ago

感谢 老师 !