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

Commit

Permalink
Save work and prepare for pre-release 0.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhongyi Tong committed Feb 18, 2016
1 parent 947424e commit 1133567
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 117 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
/dist
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CHANGELOG

**v0.1 (2016.02.19)**

1. Create the project.
2. Auto resize web content.
3. Drag to send pictures.
4. Open inhibited links without additional redirect.
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,39 @@
# electron-quick-start
# WeChat Electron

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

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.
This is an ***unofficial*** client wrapped with Electron. The web app embedded inside is from the official WeChat team.

A basic Electron application needs just these files:
## Features

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

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

## To Use
## How To Use

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:

```bash
``` bash
# Clone this repository
git clone https://github.com/atom/electron-quick-start
git clone https://github.com/geeeeeeeeek/wechat-electron
# Go into the repository
cd electron-quick-start
cd wechat-electron
# Install dependencies and run the app
npm install && npm start
```

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

#### License [CC0 (Public Domain)](LICENSE.md)
``` bash
electron .
```

#### Download App

If you only cares about the app, you can find it out in the [release](https://github.com/geeeeeeeeek/wechat-electron/releases) section.

#### License [MIT](LICENSE.md)
Binary file added assets/icon.icns
Binary file not shown.
Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"osx" : {
"title": "Wechat Electron",
"background": "icon.png",
"icon": "icon.icns",
"icon-size": 80,
"contents": [
{ "x": 438, "y": 344, "type": "link", "path": "/Applications" },
{ "x": 192, "y": 344, "type": "file" }
]
}
}
51 changes: 0 additions & 51 deletions main.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "wechat-electron",
"version": "0.0.0",
"description": "A Electron application for WeChat",
"main": "main.js",
"main": "src/main.js",
"scripts": {
"start": "electron main.js"
"start": "electron src/main.js"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion index.html → src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<link rel="stylesheet" href="style.css">
</head>
<body>
<webview id="webview" src="https://wx.qq.com/"/>
<webview id="webview" src="https://wx.qq.com/" disablewebsecurity plugins allowpopups/>
</body>
<script src="wechat.js"></script>
</html>
45 changes: 45 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;

let mainWindow;

function createWindow () {
mainWindow = new BrowserWindow({
title: 'WeChat',
width: 800,
height: 600,
resizable: true,
center: true,
show: true,
frame: true,
icon: 'icon.png'
});

mainWindow.loadURL('file://' + __dirname + '/index.html');

mainWindow.webContents.on('will-navigate', ev => {
ev.preventDefault();
});

mainWindow.on('closed', function() {
mainWindow = null;
app.quit();
});
}

app.on('ready', createWindow);

app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', function () {
if (mainWindow === null) {
createWindow();
}
});
File renamed without changes.
89 changes: 89 additions & 0 deletions src/wechat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
"use strict";

const shell = require('electron').shell;

const wechatCSS = `
div.main {
height: 100% !important;
min-height: 0 !important;
padding-top: 0 !important;
}
div.main_inner {
max-width: none !important;
min-width: 0 !important;
}
div.message_empty {
margin-top: 50px;
}
div.img_preview_container div.img_opr_container {
bottom: 50px !important;
}
p.copyright {
display: none !important
}
a.web_wechat_screencut {
display: none !important;
}
* {
-webkit-user-select: none;
}
pre, span, p {
-webkit-user-select: initial;
}
`;

const loginCSS = `
div.login_box {
top: initial;
left: initial;
margin-left: initial;
margin-top: initial;
width: 100%;
height: 100%;
}
div.login {
min-width: 0;
min-height: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
div.lang, div.copyright {
display: none !important
}
`;

let getParameterByName = (url, name) => {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
let regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(url);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

onload = () => {
let webview = document.getElementById("webview");

webview.addEventListener('dom-ready', () => {
webview.insertCSS(wechatCSS);
webview.insertCSS(loginCSS);
webview.executeJavaScript('injectJS.getBadge()');
});

webview.addEventListener('new-window', (e) => {
let url = getParameterByName(e.url, 'requrl');
if (url.length > 1) {
shell.openExternal(url);
} else {
shell.openExternal(e.url);
}
})

webview.addEventListener('new-window', function (e) {
var url = getParameterByName(e.url, 'requrl');
if (url.length > 1) {
shell.openExternal(url);
} else {
shell.openExternal(e.url);
}
})
};
49 changes: 0 additions & 49 deletions wechat.js

This file was deleted.

0 comments on commit 1133567

Please sign in to comment.