{"id":14989559,"url":"https://github.com/q956164483/chatroom","last_synced_at":"2025-04-12T00:31:49.381Z","repository":{"id":152040739,"uuid":"132395544","full_name":"Q956164483/chatRoom","owner":"Q956164483","description":"vue2聊天室，图灵机器人，node爬虫","archived":false,"fork":false,"pushed_at":"2018-05-09T02:56:10.000Z","size":3112,"stargazers_count":105,"open_issues_count":2,"forks_count":18,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T20:51:11.296Z","etag":null,"topics":["koa","koa2","socket","socketio","vue"],"latest_commit_sha":null,"homepage":null,"language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Q956164483.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-07T02:18:47.000Z","updated_at":"2024-04-28T15:51:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"3bf250af-ecaa-4918-bab2-a4a06c460ead","html_url":"https://github.com/Q956164483/chatRoom","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"ee366ae23239f884eb6536e863de4f8e073bd987"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Q956164483%2FchatRoom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Q956164483%2FchatRoom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Q956164483%2FchatRoom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Q956164483%2FchatRoom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Q956164483","download_url":"https://codeload.github.com/Q956164483/chatRoom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248501338,"owners_count":21114655,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["koa","koa2","socket","socketio","vue"],"created_at":"2024-09-24T14:18:34.058Z","updated_at":"2025-04-12T00:31:48.932Z","avatar_url":"https://github.com/Q956164483.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"## vue+koa2聊天室，实时推送比特币价格，爬取电影网站\n### 技术栈\nvue+vuex+vue-router+socket.io+koa2+mongodb+pm2自动化部署+图灵机器人+[npm script打包，cdn同步，服务器上传一个命令全搞定]\n### 功能清单\n登陆注册\n\n获取聊天记录（包含前端分页优化）\n\n发送文字，表情，文件消息\n\n创建群组，添加群组，群组搜索\n\n修改个人信息，群组信息\n\n图片裁剪压缩上传\n\n私聊\n\n[图灵机器人接入](http://www.tuling123.com/)\n\n定时任务爬取电影和btc等数字货币的价格并使用socket.io实时推送给所有客户端\n\n前端一键打包同步到七牛cdn并上传到服务器的实现\n\nserver端的pm2自动部署\n\n### [效果演示](http://47.104.24.198/movie-chat/#/)chrome下F12或者手机扫描下面的二维码\n\n\u003cimg src=\"https://q956164483.github.io/chatRoom/resources/phone-code.png\"\u003e\n\n后端的代码暂时不开放出来，因为涉及到很多个人的配置数据，如果实在需要可以加微信 MSC199312 （需要付费0.0！），毕竟这个小项目断断续续也做了几个星期，也还花了些心思，而且涉及的知识点也都还是很广很实用的，还望理解，其实主要原因还是穷[泪奔]\n\n### 部分代码\n客户端 main.js\n```javascript\nimport Vue from 'vue'\nimport App from './App'\nimport router from './router'\nimport VueLazyload from 'vue-lazyload'\nimport store from '@/store'\nimport io from 'socket.io-client'\nimport '@/assets/js/remChange'\nimport '@/assets/js/request'\n// import { wxConfig, updateShare } from '@/assets/js/wxenv'\nimport '@/assets/css/common.scss'\nimport 'swiper/dist/css/swiper.min.css'\nimport config from '@/assets/js/config'\nimport filters from '@/assets/js/filters'\nimport { openToast } from '@/assets/js/tools'\n\nVue.config.productionTip = false\n\n// 初始化全局过滤器\nObject.keys(filters).forEach(item =\u003e {\n  Vue.filter(item, filters[item])\n})\n\n// 懒加载\nVue.use(VueLazyload, {\n  attempt: 1,\n  // preLoad: 1.3,\n  error: require('./assets/images/404.png'),\n  loading: require('./assets/images/loading-img2.gif'),\n  // the default is ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend']\n  listenEvents: [ 'scroll' ]\n})\n\nVue.prototype.$config = config\n\nrouter.beforeEach((to, from, next) =\u003e {\n  // 如果未匹配到路由\n  if (to.matched.length === 0) {\n    // 如果上级也未匹配到路由则跳转登录页面，如果上级能匹配到则转上级路由\n    from.name ? next({ name: from.name }) : next('/')\n  } else {\n    // 路由切换时改变页面标题\n    document.querySelector('title').innerHTML = to.name\n    // 统计代码\n    if (to.path) _czc.push(['_trackPageview', '/#' + to.fullPath], '')\n    next()\n  }\n})\n\n// 路由变化重新配置微信分享\nrouter.afterEach(to =\u003e {\n  // wxConfig(() =\u003e updateShare())\n})\n\n// socket.io 初始化\nconst socket = io.connect(config.socketBase)\nVue.prototype.$socket = socket\nVue.prototype.$socketEmiter = (name, data) =\u003e {\n  store.commit('isLoading', true)\n  return new Promise((resolve) =\u003e {\n    socket.emit(name, data, res =\u003e {\n      console.log(`${name}\u003e\u003e\u003e`, res)\n      store.commit('isLoading', false)\n      if (res.status === 1) {\n        resolve(res.data)\n      } else {\n        openToast({\n          msg: res.message,\n          duration: 1500\n        })\n      }\n    })\n  })\n}\n\n/* eslint-disable no-new */\nconst app = new Vue({\n  el: '#app',\n  router,\n  store,\n  template: '\u003cApp/\u003e',\n  components: { App }\n})\n\n```\nserver端 app.js\n```javascript\nconst Koa = require('koa')\nconst { resolve } = require('path')\nconst glob = require('glob')\nconst { connectDatabase, initAllSchema, initDefaultUser } = require('./database/init')\nconst config = require('./config')\n\nconst useMiddlewares = app =\u003e {\n  glob.sync(resolve(__dirname, './middlewares', '**/*.js')).forEach(item =\u003e {\n    require(item)(app)\n  })\n}\n\n(async () =\u003e {\n\n  console.log('数据库初始化...')\n  await connectDatabase()\n  initAllSchema()\n  await initDefaultUser()\n\n  const app = new Koa()\n\n  console.log('挂载socket.io...')\n  const server = require('http').Server(app.callback())\n  const io = require('socket.io').listen(server)\n  require('./socket')(io)\n\n  // 暴露出io可在其他地方做推送功能\n  module.exports.io = io\n\n  console.log('挂载中间件...')\n  useMiddlewares(app)\n\n  console.log('初始化定时任务...')\n  // 多了进行一下封装？\n  require('./tools/crawlMovie')\n  require('./tools/crawlCoin')\n\n  server.listen(config.server.PORT, () =\u003e {\n    console.log('正在监听' + config.server.PORT + '端口...')\n  })\n\n})()\n```\n\n## 部分运行截图\n\u003cdiv\u003e\n\u003cimg alt=\"主页\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/1.PNG\"/\u003e\n\u003cimg alt=\"聊天\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/2.PNG\"/\u003e\n\u003cimg alt=\"群信息\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/3.PNG\"/\u003e\n\u003cimg alt=\"个人信息\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/4.PNG\"/\u003e\n\u003cimg alt=\"发送表情\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/5.PNG\"/\u003e\n\u003cimg alt=\"发送图片和文件\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/6.PNG\"/\u003e\n\u003cimg alt=\"图片裁剪\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/7.PNG\"/\u003e\n\u003cimg alt=\"菜单\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/8.PNG\"/\u003e\n\u003cimg alt=\"群聊搜索\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/9.PNG\"/\u003e\n\u003cimg alt=\"群信息\" width=\"200\" src=\"https://q956164483.github.io/chatRoom/resources/10.PNG\"/\u003e\n\n### 最后贴上[git地址](https://github.com/Q956164483/chatRoom)欢迎给个star\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fq956164483%2Fchatroom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fq956164483%2Fchatroom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fq956164483%2Fchatroom/lists"}