diff --git a/assets/less/style.less b/assets/less/style.less index 22c9b8f3..a7495fef 100644 --- a/assets/less/style.less +++ b/assets/less/style.less @@ -132,6 +132,7 @@ } + // table @table-cell-padding: 10px; @table-cell-vertical-padding-large: 14px; diff --git a/components/common/TestnetNotice.vue b/components/common/TestnetNotice.vue new file mode 100644 index 00000000..4d75126d --- /dev/null +++ b/components/common/TestnetNotice.vue @@ -0,0 +1,14 @@ + + + diff --git a/desktop/electron-builder-x86.config.js b/desktop/electron-builder-x86.config.js new file mode 100644 index 00000000..49e01a02 --- /dev/null +++ b/desktop/electron-builder-x86.config.js @@ -0,0 +1,6 @@ +const config = require('./electron-builder.config'); + +config.nsis.artifactName = config.nsis.artifactName.replace('x64', 'x86'); +config.win.artifactName = config.win.artifactName.replace('x64', 'x86'); + +module.exports = config; diff --git a/desktop/electron-builder.config.js b/desktop/electron-builder.config.js new file mode 100644 index 00000000..45d330ba --- /dev/null +++ b/desktop/electron-builder.config.js @@ -0,0 +1,56 @@ +const appName = 'minter-console'; + +module.exports = { + "productName": "Minter Console", + "appId": "com.minter.console", + "directories": { + "buildResources": "desktop", + "output": "tmp/electron", + }, + "files": [ + "dist/**/*", + "desktop/electron.js", + // "desktop/electron.dev.js", + // "nuxt.config.js", + ".nuxt/**/*", + ], + "publish": ["github"], + // mac (zip) + "mac": { + "artifactName": `${appName}-\${version}-\${arch}-mac.\${ext}`, + "icon": "desktop/icons/icon.icns", + }, + // mac dmg + "dmg": { + "artifactName": `${appName}-\${version}-\${arch}.\${ext}`, + "contents": [ + { + "x": 410, + "y": 150, + "type": "link", + "path": "/Applications", + }, + { + "x": 130, + "y": 150, + "type": "file", + }, + ], + }, + // win (portable) + "win": { + "artifactName": `${appName}-\${version}-portable-x64.\${ext}`, + "icon": "desktop/icons/icon.ico", + "target": ["portable", "nsis"], + }, + // win setup + "nsis": { + "artifactName": `${appName}-\${version}-setup-x64.\${ext}`, + }, + // linux + "linux": { + "artifactName": `${appName}-\${version}-\${arch}.\${ext}`, + "icon": "desktop/icons", + "category": "Office", + }, +}; diff --git a/desktop/electron.dev.js b/desktop/electron.dev.js new file mode 100644 index 00000000..d841cc47 --- /dev/null +++ b/desktop/electron.dev.js @@ -0,0 +1,24 @@ +/** + * This file is used specifically and only for development. It installs + * `electron-debug` & `vue-devtools`. There shouldn't be any need to + * modify this file, but it can be used to extend your development + * environment. + */ + +/* eslint-disable */ + +// Install `electron-debug` with `devtron` +require('electron-debug/index')({ showDevTools: true }) + +// Install `vue-devtools` +require('electron').app.on('ready', () => { + // let installExtension = require('electron-devtools-installer') + // installExtension.default(installExtension.VUEJS_DEVTOOLS) + // .then(() => {}) + // .catch(err => { + // console.log('Unable to install `vue-devtools`: \n', err) + // }) +}) + +// Require `main` process to boot app +require('./electron') diff --git a/desktop/electron.js b/desktop/electron.js new file mode 100644 index 00000000..154222e5 --- /dev/null +++ b/desktop/electron.js @@ -0,0 +1,179 @@ +/* +** Nuxt +*/ +const path = require('path'); +const argv = require('minimist')(process.argv.slice(2)); + +const HOST_NAME = argv.hostname || 'localhost'; +const PORT = argv.port || 4000; + + + +// const esm = require('esm'); +const {Nuxt} = require('@nuxt/core'); +async function initNuxt() { + let config = {}; //esm(module)('./nuxt.config.js') + if (config.default) { + config = config.default; + } + config.rootDir = path.resolve(__dirname, '..'); + config.dev = false; + config.mode = 'spa'; + config.dir = { + static: 'dist', + }; + config.server = { + host: HOST_NAME, + port: PORT, + }; + /** @type Nuxt */ + let nuxt = new Nuxt(config); + await nuxt.ready(); + await nuxt.server.listen(); +} + +const _NUXT_URL_ = `http://${HOST_NAME}:${PORT}/`; + + + + +/* +** Electron +*/ + +const fs = require('fs'); +const { app, BrowserWindow, Menu } = require('electron'); // eslint-disable-line + +/** + * Set `__static` path to static files in production + * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html + */ +// if (process.env.NODE_ENV !== 'development') { +// global.__static = require('path').join(__dirname, '/dist').replace(/\\/g, '\\\\') // eslint-disable-line +// } + +let mainWindow; + +app.on('ready', async () => { + try { + await initNuxt(); + } catch (e) { + console.log(e); + } + // setTimeout(createWindow, 3000) + createWindow(); + createMenu(); +}); + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit(); + } +}); + +app.on('activate', () => { + if (mainWindow === null) { + createWindow(); + } +}); + +function createWindow() { + /** + * Initial window options + */ + mainWindow = new BrowserWindow({ + width: 1260, + height: 700, + useContentSize: true, + webPreferences: { + nodeIntegration: false, + }, + }); + + mainWindow.loadURL(_NUXT_URL_); + + if (process.env.NODE_ENV === 'development' || process.env.DEBUG === 'electron-builder') { + mainWindow.webContents.openDevTools(); + } + + // clear leveldb log if localStorage is empty + mainWindow.on('close', async () => { + let vuex = await mainWindow.webContents.executeJavaScript(`window.localStorage.getItem('vuex')`); + vuex = vuex && JSON.parse(vuex); + if (!vuex.auth.advanced && !vuex.auth.password) { + const dbPath = path.join(app.getPath('userData'), 'Local Storage/leveldb'); + const logs = findInDir(dbPath, '.log'); + logs.forEach((filePath) => { + fs.unlinkSync(filePath); + }); + } + }); + + mainWindow.on('closed', () => { + mainWindow = null; + }); +} + +function createMenu() { + const template = [{ + label: "Minter Console", + submenu: [ + { label: "About", selector: "orderFrontStandardAboutPanel:" }, + { type: "separator" }, + { label: "Quit", accelerator: "Command+Q", click: function() { app.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.buildFromTemplate(template)); +} + +function findInDir(startPath, filter) { + let result = []; + + if (!fs.existsSync(startPath)) { + return result; + } + + const files = fs.readdirSync(startPath); + for (let i = 0; i < files.length; i++) { + const filename = path.join(startPath, files[i]); + const stat = fs.lstatSync(filename); + if (stat.isDirectory()) { + result = result.concat(findInDir(filename, filter)); //recurse + } else if (filename.indexOf(filter) >= 0) { + result.push(filename); + } + } + + return result; +} + +/** + * Auto Updater + * + * Uncomment the following code below and install `electron-updater` to + * support auto updating. Code Signing with a valid certificate is required. + * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating + */ + +/* +import { autoUpdater } from 'electron-updater' + +autoUpdater.on('update-downloaded', () => { + autoUpdater.quitAndInstall() +}) + +app.on('ready', () => { + if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates() +}) + */ diff --git a/desktop/icons/256x256.png b/desktop/icons/256x256.png new file mode 100644 index 00000000..8ca2aa9c Binary files /dev/null and b/desktop/icons/256x256.png differ diff --git a/desktop/icons/icon.icns b/desktop/icons/icon.icns new file mode 100644 index 00000000..c34f23c6 Binary files /dev/null and b/desktop/icons/icon.icns differ diff --git a/desktop/icons/icon.ico b/desktop/icons/icon.ico new file mode 100644 index 00000000..057fa7fd Binary files /dev/null and b/desktop/icons/icon.ico differ diff --git a/desktop/pkg.js b/desktop/pkg.js new file mode 100644 index 00000000..4659499e --- /dev/null +++ b/desktop/pkg.js @@ -0,0 +1,31 @@ +const HOST_NAME = 'localhost'; +const PORT = 4000; + +const initCli = function() { + const cli = require('@nuxt/cli'); + const path = require('path'); + const _argv = []; + _argv[0] = 'start'; + _argv.push('--spa'); + _argv.push(`--port=${PORT}`); + _argv.push(`--hostname=${HOST_NAME}`); + _argv.push(path.resolve(__dirname, '..')); + cli.run(_argv); +}; + +/* +const initNuxt = async () => { + const {Nuxt} = require('@nuxt/core'); + let config = {}; + config.rootDir = __dirname; + config.dev = false; + config.mode = 'spa'; + /!** @type Nuxt *!/ + let nuxt = new Nuxt(config); + await nuxt.ready(); + await nuxt.server.listen(PORT, HOST_NAME); +}; +*/ + +// initNuxt(); +initCli(); diff --git a/layouts/default.vue b/layouts/default.vue index 04eb6f79..a33070fa 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,12 +1,14 @@