Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Commit

Permalink
build: experimental elctron desktop app (windows), release v0.6.0.beta
Browse files Browse the repository at this point in the history
  • Loading branch information
soulsam480 committed Jan 18, 2021
1 parent 45b9ed2 commit a93c074
Show file tree
Hide file tree
Showing 19 changed files with 2,286 additions and 68 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ pnpm-debug.log*
*.sw?
deploy.sh
src/firebase/cred.ts
src/miscred/prelink.ts
src/miscred/prelink.ts
#Electron-builder output
/dist_electron
Binary file added build/icons/1024x1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/icons/icon.icns
Binary file not shown.
Binary file added build/icons/icon.ico
Binary file not shown.
24 changes: 21 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
{
"name": "noter",
"version": "0.1.0",
"version": "0.5.0",
"private": true,
"author": "soulsam480",
"author": {
"email": "[email protected]",
"name": "soulsam480",
"url": "https://sambitsahoo.com"
},
"description": "Noter is a collaborative note-taking platform built for simplicity and productivity. It's free fast and open source.",
"homepage": "https://noter.sambitsahoo.com",
"repository": "https://github.com/soulsam480/noter",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
"lint": "vue-cli-service lint",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve --no-sandbox",
"electron:generate-icons": "electron-icon-builder --input=./public/icon.png --output=build --flatten",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps"
},
"main": "background.js",
"dependencies": {
"@editorjs/checklist": "^1.1.0",
"@editorjs/code": "^2.5.0",
Expand Down Expand Up @@ -40,6 +53,7 @@
"devDependencies": {
"@types/bootstrap": "^4.5.0",
"@types/core-js": "^2.5.4",
"@types/electron-devtools-installer": "^2.2.0",
"@types/eslint": "^6.8.1",
"@types/eslint-plugin-prettier": "^3.1.0",
"@types/jquery": "^3.5.1",
Expand All @@ -58,6 +72,9 @@
"@vue/eslint-config-typescript": "^5.0.2",
"@vue/runtime-dom": "^3.0.2",
"babel-eslint": "^10.1.0",
"electron": "^9.0.0",
"electron-devtools-installer": "^3.1.0",
"electron-icon-builder": "^2.0.1",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^6.2.2",
Expand All @@ -66,6 +83,7 @@
"sass-loader": "^8.0.2",
"typescript": "~3.9.3",
"typesync": "^0.7.0",
"vue-cli-plugin-electron-builder": "~2.0.0-rc.5",
"vue-template-compiler": "^2.6.11"
}
}
Binary file added public/icon.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 src/background.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
'use strict';
/* global __static */
import { app, protocol, BrowserWindow } from 'electron';
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib';
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer';
const isDevelopment = process.env.NODE_ENV !== 'production';
import path from 'path';
// Scheme must be registered before the app is ready
protocol.registerSchemesAsPrivileged([
{ scheme: 'app', privileges: { secure: true, standard: true } },
]);

async function createWindow() {
// Create the browser window.
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
// Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
nodeIntegration: (process.env
.ELECTRON_NODE_INTEGRATION as unknown) as boolean,
}, //@ts-ignore
icon: path.join(__static, 'icon.png'),
});

if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL as string);
if (!process.env.IS_TEST) win.webContents.openDevTools();
} else {
createProtocol('app');
// Load the index.html when not in development
win.loadURL('app://./index.html');
}
}

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', async () => {
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
try {
await installExtension(VUEJS_DEVTOOLS);
} catch (e) {
console.error('Vue Devtools failed to install:', e.toString());
}
}
createWindow();
});

// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {
if (process.platform === 'win32') {
process.on('message', (data) => {
if (data === 'graceful-exit') {
app.quit();
}
});
} else {
process.on('SIGTERM', () => {
app.quit();
});
}
}
2 changes: 1 addition & 1 deletion src/views/Board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const SimpleImage = require("@editorjs/simple-image");
interface Data {
editor: null | EditorJS;
isSaved: boolean;
timeout: null | number;
timeout: any;
upStatus: string;
dat: object;
isTooltip: boolean;
Expand Down
28 changes: 15 additions & 13 deletions sw.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,47 @@
/* eslint-disable */

// service-worker.js
workbox.core.setCacheNameDetails({ prefix: "d4" });
workbox.core.setCacheNameDetails({ prefix: 'd4' });
//Change this value every time before you build
const LATEST_VERSION = "v2.0.12";
self.addEventListener("activate", (event) => {
console.log(`%c ${LATEST_VERSION} `, "background: #ddd; color: #0000ff");
const LATEST_VERSION = 'v2.0.12';
self.addEventListener('activate', (event) => {
console.log(`%c ${LATEST_VERSION} `, 'background: #ddd; color: #0000ff');
if (caches) {
caches.keys().then((arr) => {
arr.forEach((key) => {
if (key.indexOf("d4-precache") < -1) {
if (key.indexOf('d4-precache') < -1) {
caches
.delete(key)
.then(() =>
console.log(
`%c Cleared ${key}`,
"background: #333; color: #ff0000"
)
'background: #333; color: #ff0000',
),
);
} else {
caches.open(key).then((cache) => {
cache.match("version").then((res) => {
cache.match('version').then((res) => {
if (!res) {
cache.put(
"version",
'version',
new Response(LATEST_VERSION, {
status: 200,
statusText: LATEST_VERSION,
})
}),
);
} else if (res.statusText !== LATEST_VERSION) {
caches
.delete(key)
.then(() =>
console.log(
`%c Cleared Cache ${LATEST_VERSION}`,
"background: #333; color: #ff0000"
)
'background: #333; color: #ff0000',
),
);
} else
console.log(
`%c Great you have the latest version ${LATEST_VERSION}`,
"background: #333; color: #00ff00"
'background: #333; color: #00ff00',
);
});
});
Expand Down
24 changes: 24 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,28 @@ module.exports = {
},
},
},
pluginOptions: {
electronBuilder: {
builderOptions: {
// name: 'Noter',
// description:
// "Noter is a collaborative note-taking platform built for simplicity and productivity. It's free fast and open source.",
// homepage: 'https://noter.sambitsahoo.com',
// author: {
// name: 'sambit Sahoo',
// email: '[email protected]',
// },
// repository: 'https://github.com/soulsam480/noter',
// build: {
appId: 'com.sambitsahoo.noter',
productName: 'Noter',
copyright: 'Copyright © 2021 Sambit Sahoo',
buildVersion: '0.5.0',
nsis: {
oneClick: false,
},
// },
},
},
},
};
Loading

0 comments on commit a93c074

Please sign in to comment.