Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
floatflower committed Sep 12, 2021
0 parents commit a8d6432
Show file tree
Hide file tree
Showing 5 changed files with 2,801 additions and 0 deletions.
122 changes: 122 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

.idea/*
dist/*
build/*
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
ProtonMail Desktop
===

Developer: FloatFlower.Huang <floatflower@protonmail.com>

### What is this?

This is a desktop version of ProtonMail application, but actually the only thing I did was wrapping the web application by Electron.js
and add some desktop application features, like `minimize application to tray` and `only always-singleton window`.

I never collect personal data or anything else, and I am one of ProtonMail users,
the purpose that I made this application is because I like desktop application more than web application,
so just feel free and use it:)

### Download

Because I don't have machine with MacOS and I havn't built the CI/CD environment yet,
so if you are looking forward to MacOS version,
please wait me a second, I'll release MacOS version after finishing CI/CD with GitHub Action.

Furthermore, I release the pre-built version with Google Chrome link also because of undone CI/CD environment,
once I finish that, I'll change to release application with Github distribution system.

Or, you can [donate me](https://payment.ecpay.com.tw/Broadcaster/Donate/EFA835E253F6CD1AC6D9780E23CC78CB) a mac mini, lol. (just kidding)

#### 1.0.0
+ Windows Portable: [x64](https://drive.google.com/file/d/1sBY6V8rLeWNreeuW093U0XEbT5hqzoup/view?usp=sharing)
+ Windows Installer: [x64](https://drive.google.com/file/d/1o5lksmEaG4HjlVkQQwHpslGYWY2fnPC9/view?usp=sharing)

### Built your own version

If you want to build this application by yourself, you can follow the instructions below, it's pretty simple.
Don't forget to install node.js with version > 14.17.0
```bash
~$ npm install
# Built windows version
~$ npm run dist:windows
```

### Bug Report

Please raise an issue if you encounter any bugs, or mail me if you have any advices on this project.
74 changes: 74 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
const { app, BrowserWindow, Tray, Menu } = require('electron')
const gotTheLock = app.requestSingleInstanceLock();

let window = null;
let tray = null;
let isQuiting = false;
if (!gotTheLock) {
app.quit()
} else {
app.on('second-instance', (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (window !== null) {
restoreHiddenWindow();
}
})
app.on('before-quit', () => {
isQuiting = true;
});
app.whenReady().then(startWindow).then(createTray)
}


function startWindow () {
if (!window) {
window = new BrowserWindow({
webPreferences: {
nativeWindowOpen: true
},
width: 800,
height: 600,
icon: 'build/icon.png'
})
window.setTitle('Protonmail Desktop')
window.setMenuBarVisibility(false);
window.maximize();
window.loadURL('https://mail.protonmail.com/')


window.on('minimize', (event) => {
event.preventDefault();
window.hide();
})

window.on('close', (event) => {
if (!isQuiting) {
event.preventDefault();
window.hide();
event.returnValue = false;
}
})
}
}

function createTray() {
tray = new Tray('build/icon.png');
const contextMenu = Menu.buildFromTemplate([
{ label: 'Restore', click: restoreHiddenWindow },
{ label: 'Quit', click: app.quit }
])

tray.setContextMenu(contextMenu);
tray.setToolTip('Protonmail Desktop');

tray.on('click', () => {
restoreHiddenWindow();
})
}

function restoreHiddenWindow() {
if (!window.visible) window.show();
if (window.isMinimized()) window.restore();

window.focus();
}
Loading

0 comments on commit a8d6432

Please sign in to comment.