项目介绍
抹茶聊天是一个IM项目,通过netty实现和前端的websocket连接。内含微信扫描登录,成员列表,消息列表,消息互动,丰富的消息类型,还有很多实用的小轮子列如aop日志,分布式锁注解,频控注解,ip解析归属地等,持续更新中。。。

项目导航
- 快速体验地址:抹茶聊天首页
- 前端项目仓库:MallChatWeb
- 项目视频记录:Bilibili地址 全程分享项目进度,功能选型的思考,同时征集迭代建议。
环境搭建
下载项目
//后端
//gitee 地址
git clone https://gitee.com/zhongzhibinbin/MallChat.git
//github 地址
git clone https://github.com/zongzibinbin/MallChat.git
//前端
//github 地址
git clone https://github.com/Evansy/MallChatWeb.git
后端环境搭建
打开 application.yml 把运行环境改为 test

修改 application-test.properties 中的配置

配置Mysql
Redis密码没配置可以注销掉


RocketMQ的安装
可以看这里:RocketMQ 安装配置全攻略:从环境准备到实战验证(windows/Linux)
内网穿透
这里需要把内网穿透把项目映射到公网让微信进行访问。
我用的是natapp工具,具体操作可以看这篇 NATAPP使用教程(内网穿透)
这里隧道的本地端口必须和后端项目的端口一直,不然映射不出去。

配置微信公众号
注册一个公众号

选择公众平台测试账号


这里URL得内网地址加上 /wx/portal/public ,比如说你的内网地址是这样,URL就是http://t7987867.natappfree.cc http://t7987867.natappfree.cchttp://t7987867.natappfree.cc /wx/portal/public
URL这个接口用于测试,微信测试你的后端是否存在。

aesKey不上线的话不用配置。
然后下滑配置

修改为自己的内网穿透

这一步没做就会出现,微信登录失败这个问题。

配置好这些就可以启动了。
前端环境搭建
下载node版本
查看node版本,出现版本下载成功
node -v
# 查看当前源
npm config get registry
# 换淘宝源
npm config set registry https://registry.npm.taobao.org
下载pnpm
npm install pnpm -g
#查看下载源
pnpm config get registry
#更换下载源
pnpm config set registry https://registry.npmmirror.com/
修改后端访问端口

下载包
pnpm install
运行
pnpm run dev
踩坑
如果前端运行遇到这个报错
failed to load config from D:\a\MallChatWeb-main\config\vite.config.dev.ts
error when starting dev server:
Error [ERR_REQUIRE_ESM]: require() of ES Module D:\a\MallChatWeb-main\node_modules\.pnpm\package-manager-detector@1.5.0\node_modules\package-manager-detector\dist\detect.mjs not supported.
Instead change the require of D:\a\MallChatWeb-main\node_modules\.pnpm\package-manager-detector@1.5.0\node_modules\package-manager-detector\dist\detect.mjs to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (D:\a\MallChatWeb-main\node_modules\.pnpm\@antfu+install-pkg@1.1.0\node_modules\@antfu\install-pkg\dist\index.cjs:41:21)
at _require.extensions.<computed> [as .js] (file:///D:/a/MallChatWeb-main/node_modules/.pnpm/vite@4.4.11_@types+node@18.19.130_sass@1.93.2/node_modules/vite/dist/node/chunks/dep-2b82a1ce.js:66330:17)
ELIFECYCLE Command failed with exit code 1.

package.json 文件加个配置
"type": "module",

然后把 node_modules 删了,重新下载 pnpm install 就好了

抹茶聊天室搭建与避坑指南

1761

被折叠的 条评论
为什么被折叠?



