Skip to content
This repository was archived by the owner on Nov 12, 2018. It is now read-only.

Commit 1133567

Browse files
author
Zhongyi Tong
committed
Save work and prepare for pre-release 0.1.
1 parent 947424e commit 1133567

File tree

13 files changed

+182
-117
lines changed

13 files changed

+182
-117
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
/dist

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CHANGELOG
2+
3+
**v0.1 (2016.02.19)**
4+
5+
1. Create the project.
6+
2. Auto resize web content.
7+
3. Drag to send pictures.
8+
4. Open inhibited links without additional redirect.

README.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,39 @@
1-
# electron-quick-start
1+
# WeChat Electron
22

3-
**Clone and run for a quick way to see an Electron in action.**
3+
**A better WeChat client on Mac OS X.**
44

5-
This is a minimal Electron application based on the [Quick Start Guide](http://electron.atom.io/docs/latest/tutorial/quick-start) within the Electron documentation.
5+
This is an ***unofficial*** client wrapped with Electron. The web app embedded inside is from the official WeChat team.
66

7-
A basic Electron application needs just these files:
7+
## Features
88

9-
- `index.html` - A web page to render.
10-
- `main.js` - Starts the app and creates a browser window to render HTML.
11-
- `package.json` - Points to the app's main file and lists its details and dependencies.
9+
- Modern UI and full features from the Web platform.
10+
- Auto resize window.
11+
- Drag-to-send pictures.
12+
- Open inhibited websites without redirects (including taobao.com, etc).
1213

13-
You can learn more about each of these components within the [Quick Start Guide](http://electron.atom.io/docs/latest/tutorial/quick-start).
14+
![qq20160219-0 2x](https://cloud.githubusercontent.com/assets/7262715/13150473/eae10174-d6a0-11e5-9909-09d3b5854d51.png)
1415

15-
## To Use
16+
## How To Use
1617

1718
To clone and run this repository you'll need [Git](https://git-scm.com) and [Node.js](https://nodejs.org/en/download/) (which comes with [npm](http://npmjs.com)) installed on your computer. From your command line:
1819

19-
```bash
20+
``` bash
2021
# Clone this repository
21-
git clone https://github.com/atom/electron-quick-start
22+
git clone https://github.com/geeeeeeeeek/wechat-electron
2223
# Go into the repository
23-
cd electron-quick-start
24+
cd wechat-electron
2425
# Install dependencies and run the app
2526
npm install && npm start
2627
```
2728

28-
Learn more about Electron and its API in the [documentation](http://electron.atom.io/docs/latest).
29+
**Or**, if electron has already been installed, you can simply type:
2930

30-
#### License [CC0 (Public Domain)](LICENSE.md)
31+
``` bash
32+
electron .
33+
```
34+
35+
#### Download App
36+
37+
If you only cares about the app, you can find it out in the [release](https://github.com/geeeeeeeeek/wechat-electron/releases) section.
38+
39+
#### License [MIT](LICENSE.md)

assets/icon.icns

212 KB
Binary file not shown.

assets/icon.png

109 KB
Loading

config.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"osx" : {
3+
"title": "Wechat Electron",
4+
"background": "icon.png",
5+
"icon": "icon.icns",
6+
"icon-size": 80,
7+
"contents": [
8+
{ "x": 438, "y": 344, "type": "link", "path": "/Applications" },
9+
{ "x": 192, "y": 344, "type": "file" }
10+
]
11+
}
12+
}

main.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"name": "wechat-electron",
33
"version": "0.0.0",
44
"description": "A Electron application for WeChat",
5-
"main": "main.js",
5+
"main": "src/main.js",
66
"scripts": {
7-
"start": "electron main.js"
7+
"start": "electron src/main.js"
88
},
99
"repository": {
1010
"type": "git",

index.html renamed to src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<link rel="stylesheet" href="style.css">
77
</head>
88
<body>
9-
<webview id="webview" src="https://wx.qq.com/"/>
9+
<webview id="webview" src="https://wx.qq.com/" disablewebsecurity plugins allowpopups/>
1010
</body>
1111
<script src="wechat.js"></script>
1212
</html>

src/main.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
'use strict';
2+
3+
const electron = require('electron');
4+
const app = electron.app;
5+
const BrowserWindow = electron.BrowserWindow;
6+
7+
let mainWindow;
8+
9+
function createWindow () {
10+
mainWindow = new BrowserWindow({
11+
title: 'WeChat',
12+
width: 800,
13+
height: 600,
14+
resizable: true,
15+
center: true,
16+
show: true,
17+
frame: true,
18+
icon: 'icon.png'
19+
});
20+
21+
mainWindow.loadURL('file://' + __dirname + '/index.html');
22+
23+
mainWindow.webContents.on('will-navigate', ev => {
24+
ev.preventDefault();
25+
});
26+
27+
mainWindow.on('closed', function() {
28+
mainWindow = null;
29+
app.quit();
30+
});
31+
}
32+
33+
app.on('ready', createWindow);
34+
35+
app.on('window-all-closed', function () {
36+
if (process.platform !== 'darwin') {
37+
app.quit();
38+
}
39+
});
40+
41+
app.on('activate', function () {
42+
if (mainWindow === null) {
43+
createWindow();
44+
}
45+
});

style.css renamed to src/style.css

File renamed without changes.

src/wechat.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
"use strict";
2+
3+
const shell = require('electron').shell;
4+
5+
const wechatCSS = `
6+
div.main {
7+
height: 100% !important;
8+
min-height: 0 !important;
9+
padding-top: 0 !important;
10+
}
11+
div.main_inner {
12+
max-width: none !important;
13+
min-width: 0 !important;
14+
}
15+
div.message_empty {
16+
margin-top: 50px;
17+
}
18+
div.img_preview_container div.img_opr_container {
19+
bottom: 50px !important;
20+
}
21+
p.copyright {
22+
display: none !important
23+
}
24+
a.web_wechat_screencut {
25+
display: none !important;
26+
}
27+
* {
28+
-webkit-user-select: none;
29+
}
30+
pre, span, p {
31+
-webkit-user-select: initial;
32+
}
33+
`;
34+
35+
const loginCSS = `
36+
div.login_box {
37+
top: initial;
38+
left: initial;
39+
margin-left: initial;
40+
margin-top: initial;
41+
width: 100%;
42+
height: 100%;
43+
}
44+
div.login {
45+
min-width: 0;
46+
min-height: 0;
47+
width: 100%;
48+
height: 100%;
49+
overflow: hidden;
50+
}
51+
div.lang, div.copyright {
52+
display: none !important
53+
}
54+
`;
55+
56+
let getParameterByName = (url, name) => {
57+
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
58+
let regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
59+
results = regex.exec(url);
60+
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
61+
}
62+
63+
onload = () => {
64+
let webview = document.getElementById("webview");
65+
66+
webview.addEventListener('dom-ready', () => {
67+
webview.insertCSS(wechatCSS);
68+
webview.insertCSS(loginCSS);
69+
webview.executeJavaScript('injectJS.getBadge()');
70+
});
71+
72+
webview.addEventListener('new-window', (e) => {
73+
let url = getParameterByName(e.url, 'requrl');
74+
if (url.length > 1) {
75+
shell.openExternal(url);
76+
} else {
77+
shell.openExternal(e.url);
78+
}
79+
})
80+
81+
webview.addEventListener('new-window', function (e) {
82+
var url = getParameterByName(e.url, 'requrl');
83+
if (url.length > 1) {
84+
shell.openExternal(url);
85+
} else {
86+
shell.openExternal(e.url);
87+
}
88+
})
89+
};

wechat.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)