Skip to content

Commit

Permalink
fix: file name show in message of homepage list
Browse files Browse the repository at this point in the history
  • Loading branch information
aermin committed Apr 5, 2019
1 parent e78ebd9 commit 88ed021
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 55 deletions.
51 changes: 47 additions & 4 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## ghChat(react版)

之所以叫ghChat,是想着以后做一些GitHub的集成,希望让这个即时通讯工具成为chat tool for github.
之所以叫ghChat,是想着以后做一些GitHub的集成,希望让这个即时通讯工具成为chat tool for github

目前只支持github授权登录,和展示github用户公开的信息。

Expand Down Expand Up @@ -119,9 +119,52 @@ Tips: 如何在chrome浏览器中开启对PWA的支持?
![image](https://user-images.githubusercontent.com/24861316/54492876-3ab33d00-4905-11e9-8283-089f2af82399.png)
![image](https://user-images.githubusercontent.com/24861316/54493160-9e3e6a00-4907-11e9-8f26-427c6753e2a4.png)



### 本地跑项目
### 项目结构图

```
├── LICENSE
├── README-zh_CN.md
├── README.md
├── build
├── package-lock.json
├── package.json
├── postcss.config.js
├── secret.js // 放一些非公开的secret
├── server // 后端代码
│   ├── config.js
│   ├── controllers
│   ├── ecosystem.config.js // pm2加生产环境变量的配置文件
│   ├── gulpfile.js
│   ├── index.js
│   ├── init // 初始化mysql
│   ├── middlewares
│   ├── models
│   ├── package-lock.json
│   ├── package.json
│   ├── routes // 后端路由,跟登录注册模块有关
│   ├── socket // 除了登录注册,其他都用socket 来通信
│   ├── utils
│   └── yarn.lock
├── src // 前端代码
│   ├── App.js
│   ├── app.scss
│   ├── assets
│   ├── components
│   ├── containers
│   ├── index.html
│   ├── index.js
│   ├── manifest.json // PWA需要
│   ├── modules
│   ├── redux
│   ├── router
│   ├── service-worker.js // PWA需要
│   └── utils
├── webpack.common.config.js // 通用webpack设置
├── webpack.config.js //生产相关的webpack配置
├── webpack.dev.config.js //开发相关的webpack配置
```

### 本地开发

1. 项目拉到本地
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ And get other technology please follow the package.json file.
- [x] Log in
- [x] Resister
- [x] Log out
- [ ] multiple devices log in at the same time
- [ ] log in multiple devices at the same time

- Integrate with github

Expand Down
4 changes: 1 addition & 3 deletions server/controllers/githubOAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ async function getAccessToken(ctx) {
client_secret: secret.client_secret,
client_id: clientId
};
console.log('oauth body', date);
const options = {
method: 'POST',
uri: 'https://github.com/login/oauth/access_token',
Expand Down Expand Up @@ -59,7 +58,6 @@ module.exports = async (ctx, next) => {
};
const RowDataPacket = await userModel.findGithubUser(id); // judge if this github account exist
let githubUser = JSON.parse(JSON.stringify(RowDataPacket));
console.log('githubUser', githubUser);
if (githubUser.length > 0) {
await userModel.updateGithubUser(data);
} else {
Expand All @@ -68,7 +66,7 @@ module.exports = async (ctx, next) => {
githubUser = JSON.parse(JSON.stringify(RowDataPacket));
}
data.user_id = githubUser[0].id;
console.log('oauth 2333 res', data);
console.log('github res && ctx.body', response, data);
ctx.body = data;
} catch (error) {
throw new Error(error);
Expand Down
2 changes: 1 addition & 1 deletion src/components/GroupChat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class GroupChat extends Component {
name,
github_id,
groupName: this.groupName,
message: inputMsg === '' ? attachments[0].type : `${name}: ${inputMsg}`, // 消息内容
message: inputMsg === '' ? `${name}: [${attachments[0].type || 'file'}]` : `${name}: ${inputMsg}`, // 消息内容
attachments, // 附件
to_group_id: this.chatId,
time: Date.parse(new Date()) / 1000 // 时间
Expand Down
8 changes: 1 addition & 7 deletions src/components/ListItems/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ class ListItems extends Component {
);

const listItems = this.props.dataList && this.props.dataList.map((data, index) => {
let message;
const attachments = (typeof data.attachments === 'string') && JSON.parse(data.attachments);
if (!data.message && attachments.length > 0) {
message = `[${attachments[0].type}]`;
} else {
message = data.message || '暂无消息';
}
const message = data.message || '暂无消息';
const chatFromId = data.to_group_id || (data.user_id && data.user_id.toString());
const isGroupChat = !!data.to_group_id;
let GroupMembers;
Expand Down
2 changes: 1 addition & 1 deletion src/components/PrivateChat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class PrivateChat extends Component {
avatar, // 自己的头像
name,
github_id,
message: inputMsg === '' ? attachments[0].type : `${name}: ${inputMsg}`, // 消息内容
message: inputMsg === '' ? `${name}: [${attachments[0].type || 'file'}]` : `${name}: ${inputMsg}`, // 消息内容
attachments, // 附件
time: Date.parse(new Date()) / 1000 // 时间
};
Expand Down
2 changes: 0 additions & 2 deletions src/modules/InitApp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class InitApp {

_listeningPrivateChatMsg = () => {
window.socket.on('getPrivateMsg', (data) => {
console.log('getPrivateMsg', data);
const { homePageListState, allPrivateChatsState } = store.getState();
const { user_id } = this._userInfo;
// eslint-disable-next-line radix
Expand Down Expand Up @@ -82,7 +81,6 @@ _listeningPrivateChatMsg = () => {

_listeningGroupChatMsg = () => {
window.socket.on('getGroupMsg', (data) => {
console.log('getGroupMsg', data);
const { allGroupChatsState, homePageListState } = store.getState();
// eslint-disable-next-line radix
const chatId = window.location.pathname.split('/').slice(-1)[0];
Expand Down
36 changes: 0 additions & 36 deletions src/router/Bundle.js

This file was deleted.

0 comments on commit 88ed021

Please sign in to comment.