Skip to content

Commit

Permalink
Merge pull request trazyn#142 from trazyn/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
trazyn authored Jul 17, 2018
2 parents 998c670 + 52dd1da commit 48eede7
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 66 deletions.
6 changes: 1 addition & 5 deletions config/webpack.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import config from './index';
export default {

module: {
loaders: [
rules: [
{
test: /\.jsx?$/,
loader: ['babel-loader', 'eslint-loader'],
Expand Down Expand Up @@ -58,10 +58,6 @@ export default {
'css-loader',
],
},
{
test: /\.json$/,
loader: 'json-loader',
},
{
test: /\.html/,
loader: 'html-loader',
Expand Down
6 changes: 1 addition & 5 deletions config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default {

...baseConfig,

mode: 'development',
devtool: 'cheap-module-eval-source-map',

entry: [
Expand All @@ -29,11 +30,6 @@ export default {

// https://webpack.github.io/docs/hot-module-replacement-with-webpack.html
new webpack.HotModuleReplacementPlugin(),

// NODE_ENV should be production so that modules do not perform certain development checks
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
}),
],

// https://github.com/chentsulin/webpack-target-electron-renderer#how-this-module-works
Expand Down
7 changes: 1 addition & 6 deletions config/webpack.config.electron.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

import webpack from 'webpack';
import MinifyPlugin from 'babel-minify-webpack-plugin';
import config from './index';
import baseConfig from './webpack.config.base';
Expand All @@ -8,6 +7,7 @@ export default {

...baseConfig,

mode: 'production',
devtool: false,

entry: [
Expand All @@ -23,11 +23,6 @@ export default {
plugins: [
// Minify the output
new MinifyPlugin(),

// NODE_ENV should be production so that modules do not perform certain development checks
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
],

// https://github.com/chentsulin/webpack-target-electron-renderer#how-this-module-works
Expand Down
7 changes: 1 addition & 6 deletions config/webpack.config.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default {

...baseConfig,

mode: 'production',
devtool: false,

entry: [
Expand All @@ -32,12 +33,6 @@ export default {
// https://github.com/webpack/webpack/issues/864
new webpack.optimize.OccurrenceOrderPlugin(),

// NODE_ENV should be production so that modules do not perform certain development checks
new webpack.DefinePlugin({
DEBUG: false,
'process.env.NODE_ENV': JSON.stringify('production')
}),

new CopyWebpackPlugin([
{
from: `${config.assets}/fonts/**/*`,
Expand Down
7 changes: 3 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ async function getIcon(cookies, userid, src) {
responseType: 'arraybuffer',
headers: {
Cookie: cookies,
Host: 'wx.qq.com',
Referer: 'https://wx.qq.com/',
Host: 'wx2.qq.com',
Referer: 'https://wx2.qq.com/',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8',
},
});
Expand Down Expand Up @@ -490,9 +490,8 @@ const createMainWindow = () => {
y: mainWindowState.y,
minWidth: 745,
minHeight: 450,
vibrancy: 'medium-light',
transparent: true,
titleBarStyle: 'hidden-inset',
titleBarStyle: 'hiddenInset',
backgroundColor: 'none',
resizable: false,
webPreferences: {
Expand Down
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@
"dependencies": {
"@exponent/electron-cookies": "^2.0.0",
"auto-launch": "^5.0.1",
"axios": "^0.17.0",
"axios": "^0.18.0",
"browser-md5-file": "^1.0.0",
"classname": "^0.0.0",
"delegate": "^3.1.3",
"electron-context-menu": "^0.9.1",
"electron-context-menu": "^0.10.0",
"electron-json-storage": "^4.0.2",
"electron-window-state": "^4.1.1",
"han": "^0.0.7",
"mobx": "^3.3.1",
"mobx-react": "^4.3.3",
"mobx": "^5.0.3",
"mobx-react": "^5.2.3",
"moment": "^2.19.1",
"play-sound": "^1.1.1",
"prop-types": "^15.6.0",
Expand All @@ -107,7 +107,7 @@
"babel-core": "^6.25.0",
"babel-eslint": "^8.0.1",
"babel-loader": "^7.1.1",
"babel-minify-webpack-plugin": "^0.2.0",
"babel-minify-webpack-plugin": "^0.3.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-react-css-modules": "^3.3.2",
"babel-plugin-transform-async-to-generator": "^6.24.1",
Expand All @@ -122,37 +122,37 @@
"concurrently": "^3.5.0",
"copy-webpack-plugin": "^4.2.0",
"cross-env": "^5.1.1",
"css-loader": "^0.28.4",
"electron": "^1.8.1",
"electron-builder": "^19.42.2",
"electron-updater": "^2.15.0",
"eslint": "^4.10.0",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^5.0.0",
"css-loader": "^1.0.0",
"electron": "^2.0.5",
"electron-builder": "^20.22.0",
"electron-updater": "^3.0.1",
"eslint": "^5.1.0",
"eslint-config-standard": "^11.0.0",
"eslint-config-standard-react": "^6.0.0",
"eslint-formatter-pretty": "^1.1.0",
"eslint-loader": "^1.9.0",
"eslint-loader": "^2.0.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-react": "^7.4.0",
"eslint-plugin-standard": "^3.0.1",
"express": "^4.16.2",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.5",
"html-loader": "^0.5.1",
"html-webpack-plugin": "^2.30.1",
"html-webpack-plugin": "^3.2.0",
"json-loader": "^0.5.4",
"postcss-autoreset": "^2.0.0",
"postcss-cssnext": "^3.0.2",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-modules": "^1.1.0",
"style-loader": "^0.19.0",
"stylelint": "^8.2.0",
"stylelint-config-standard": "^17.0.0",
"url-loader": "^0.6.2",
"webpack": "^3.8.1",
"webpack-dev-middleware": "^1.11.0",
"style-loader": "^0.21.0",
"stylelint": "^9.3.0",
"stylelint-config-standard": "^18.2.0",
"url-loader": "^1.0.1",
"webpack": "^4.16.1",
"webpack-dev-middleware": "^3.1.3",
"webpack-hot-middleware": "^2.20.0"
}
}
2 changes: 1 addition & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import getRoutes from './js/routes';
import stores from './js/stores';

ElectronCookies.enable({
origin: 'https://wx.qq.com',
origin: 'https://wx2.qq.com',
});

class App extends Component {
Expand Down
10 changes: 6 additions & 4 deletions src/js/routes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import React from 'react';
import { withRouter, Route } from 'react-router-dom';
import { withRouter, Route, Switch } from 'react-router-dom';

import { Layout, Settings, Contacts, Home } from './pages';

Expand All @@ -10,9 +10,11 @@ export default () => {
/* eslint-disable */
return (
<Main>
<Route exact path="/" component={Home} />
<Route exact path="/contacts" component={Contacts} />
<Route exact path="/settings" component={Settings} />
<Switch>
<Route exact path="/" component={Home} />
<Route exact path="/contacts" component={Contacts} />
<Route exact path="/settings" component={Settings} />
</Switch>
</Main>
);
/* eslint-enable */
Expand Down
26 changes: 15 additions & 11 deletions src/js/stores/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function resolveMessage(message) {
break;
case 3:
// Image
let image = helper.parseKV(content);
let image = {};
image.src = `${axios.defaults.baseURL}cgi-bin/mmwebwx-bin/webwxgetmsgimg?&msgid=${message.MsgId}&skey=${auth.skey}`;
message.image = image;
break;
Expand Down Expand Up @@ -177,15 +177,19 @@ async function resolveMessage(message) {
function hasUnreadMessage(messages) {
var counter = 0;

messages.keys().map(e => {
var item = messages.get(e);

counter += (item.data.length - item.unread);
});
Array.from(messages.keys()).map(
e => {
var item = messages.get(e);
counter += (item.data.length - item.unread);
}
);

ipcRenderer.send('message-unread', {
counter,
});
ipcRenderer.send(
'message-unread',
{
counter,
}
);
}

async function updateMenus({ conversations = [], contacts = [] }) {
Expand Down Expand Up @@ -524,8 +528,7 @@ class Chat {
FromUserName: message.from,
ToUserName: message.to,
ClientMsgId: message.ClientMsgId,
LocalID: message.LocalID,
MediaId: message.file.mediaId,
LocalID: '',
Type: 3,
},
Scene: isForward ? 2 : 0,
Expand Down Expand Up @@ -692,6 +695,7 @@ class Chat {
return false;
}
} catch (ex) {
console.error('Failed to send message: %o', ex);
return false;
}

Expand Down
9 changes: 6 additions & 3 deletions src/js/stores/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,12 @@ class Session {
}
};

response.data.AddMsgList.map(async e => {
await chat.loadChats(e.StatusNotifyUserName);
});
// Load the rencets chats
response.data.AddMsgList.map(
async e => {
await chat.loadChats(e.StatusNotifyUserName);
}
);

self.loading = false;
self.genSyncKey(response.data.SyncCheckKey.List);
Expand Down

0 comments on commit 48eede7

Please sign in to comment.