Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
bkdev98 committed Feb 13, 2021
0 parents commit b20afc1
Show file tree
Hide file tree
Showing 5 changed files with 1,964 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
polar-web/
dist/
.DS_Store
Binary file added assets/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
const electron = require('electron');
const path = require('path');
const url = require('url');
const { Menu } = electron;
const { app } = electron;
const { BrowserWindow } = electron;

let mainWindow;

const LOAD_URL = url.format({
pathname: path.join(__dirname, '/polar-web/build/index.html'),
protocol: 'file:',
slashes: true,
});

function createWindow() {
mainWindow = new BrowserWindow({
title: 'Polar',
backgroundColor: '#FCF6E5',
titleBarStyle: 'hiddenInset',
webPreferences: {
webSecurity: false,
nativeWindowOpen: true,
nodeIntegration: true,
enableRemoteModule: true,
},
});

mainWindow.webContents.openDevTools();

mainWindow.loadURL(LOAD_URL);

const menu = Menu.buildFromTemplate([
{
label: 'Polar',
submenu: [
{
label: 'Thoát ứng dụng',
role: 'quit',
},
],
},
{
label: 'Edit',
submenu: [
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
{ type: 'separator' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
selector: 'selectAll:',
},
],
},
]);
Menu.setApplicationMenu(menu);

mainWindow.on('closed', () => {
mainWindow = null;
});
}

app.on('ready', () => {
createWindow();
});

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

app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
51 changes: 51 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "polar-desktop",
"version": "1.0.0",
"main": "main.js",
"license": "MIT",
"scripts": {
"react-build": "rm -rf polar-web && git clone https://github.com/polar-write/polar-web.git && cd polar-web && yarn && yarn build && cd ..",
"build": "yarn react-build && yarn dist:mac && yarn dist:win",
"dist:mac": "electron-builder --mac",
"dist:win": "electron-builder --win --x64 --ia32",
"prebuild": "rm -rf ./polar-web/build && rm -rf ./dist",
"postinstall": "electron-builder install-app-deps"
},
"homepage": "./",
"build": {
"appId": "com.quocs.polar",
"productName": "Polar",
"copyright": "Copyright © 2021 Quocs Studio",
"mac": {
"category": "public.app-category.productivity",
"target": "dmg",
"icon": "assets/images/logo.png"
},
"win": {
"target": "nsis",
"icon": "assets/images/logo.png"
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"extends": null,
"files": [
"./polar-web/build/**/*",
"./polar-web/node_modules/**/*",
"./polar-web/src/**/*",
"./polar-web/public/*",
"./assets/images/*",
"./main.js"
],
"directories": {
"buildResources": "public"
}
},
"devDependencies": {
"concurrently": "^5.3.0",
"electron": "^11.2.3",
"electron-builder": "^22.9.1",
"wait-on": "^5.2.1"
}
}
Loading

0 comments on commit b20afc1

Please sign in to comment.