├── .browserslistrc ├── .circleci └── config.yml ├── .eslintignore ├── .eslintrc.js ├── .github └── workflows │ └── release-please.yml ├── .gitignore ├── .gitpod.Dockerfile ├── .gitpod.yml ├── .prettierrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── appveyor.yml ├── arts └── look.png ├── babel.config.js ├── build └── icons │ ├── 32x32.png │ ├── 512x512.png │ ├── icon.icns │ └── icon.ico ├── cypress.json ├── jest.config.js ├── package.json ├── postcss.config.js ├── public ├── favicon.ico └── index.html ├── src ├── App.vue ├── assets │ └── logo.png ├── background.js ├── components │ └── LandingPage.vue ├── main.js ├── main │ ├── menu.js │ └── updater.js └── router │ └── index.js ├── static └── .gitkeep ├── tests ├── e2e │ ├── .eslintrc.js │ ├── plugins │ │ └── index.js │ ├── specs │ │ └── test.js │ └── support │ │ ├── commands.js │ │ └── index.js └── unit │ ├── .eslintrc.js │ ├── electron.spec.js │ └── example.spec.js ├── vue.config.js └── yarn.lock /.browserslistrc: -------------------------------------------------------------------------------- 1 | chrome 80 2 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: electronuserland/builder:wine-chrome 6 | working_directory: ~/repo 7 | 8 | steps: 9 | - checkout 10 | - restore_cache: 11 | keys: 12 | - v1-dependencies-{{ checksum "package.json" }} 13 | - v1-dependencies- 14 | - run: npx envinfo 15 | - run: npm i -g n && n latest 16 | - run: yarn 17 | - run: yarn release --linux 18 | - save_cache: 19 | paths: 20 | - node_modules 21 | key: v1-dependencies-{{ checksum "package.json" }} 22 | 23 | workflows: 24 | version: 2 25 | build: 26 | jobs: 27 | - build 28 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | app/node_modules/** 2 | app/dist/** 3 | test/unit/coverage/** 4 | test/unit/*.js 5 | test/e2e/*.js 6 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ["plugin:vue/essential", "@vue/prettier"], 7 | rules: { 8 | "no-console": process.env.NODE_ENV === "production" ? "warn" : "off", 9 | "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" 10 | }, 11 | parserOptions: { 12 | parser: "babel-eslint" 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /.github/workflows/release-please.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | name: release-please 6 | jobs: 7 | release-please: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: GoogleCloudPlatform/release-please-action@v2 11 | with: 12 | token: ${{ secrets.GITHUB_TOKEN }} 13 | release-type: node 14 | package-name: release-please-action 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .vscode 3 | .DS_Store 4 | app/dist/* 5 | build/* 6 | !build/icons 7 | dist/* 8 | coverage 9 | node_modules/ 10 | npm-debug.log 11 | npm-debug.log.* 12 | thumbs.db 13 | yarn*.log 14 | !.gitkeep 15 | *.log 16 | dist_electron/ 17 | -------------------------------------------------------------------------------- /.gitpod.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gitpod/workspace-full-vnc 2 | 3 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | image: 2 | file: .gitpod.Dockerfile 3 | 4 | tasks: 5 | - init: yarn install 6 | command: yarn electron:serve --no-sandbox 7 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "trailingComma": "es5" 5 | } 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [5.2.0](https://www.github.com/gengjiawen/electron-devdocs/compare/v5.1.0...v5.2.0) (2021-01-07) 4 | 5 | 6 | ### Features 7 | 8 | * refactor ci ([#163](https://www.github.com/gengjiawen/electron-devdocs/issues/163)) ([cfa2a96](https://www.github.com/gengjiawen/electron-devdocs/commit/cfa2a9649b484d68f201504035a5eafe7f22cb7c)) 9 | 10 | ## [5.1.0](https://www.github.com/gengjiawen/electron-devdocs/compare/v5.0.0-beta3...v5.1.0) (2021-01-06) 11 | 12 | 13 | ### ⚠ BREAKING CHANGES 14 | 15 | * bump to electron 11 and other deps 16 | 17 | ### Features 18 | 19 | * add release it ([2488d62](https://www.github.com/gengjiawen/electron-devdocs/commit/2488d629d9ec300de3d32ccfd0f5947169fd1f44)) 20 | * bump to electron 11 and other deps ([8bc1f22](https://www.github.com/gengjiawen/electron-devdocs/commit/8bc1f22514c97bf2e7fb9d1686623c8426d74ac2)) 21 | 22 | 23 | ### Bug Fixes 24 | 25 | * deprecation lib and api ([be681f5](https://www.github.com/gengjiawen/electron-devdocs/commit/be681f5303847ab2d29514c2a76a6f70d0b52ee0)) 26 | * gitpod start issue ([979e9e6](https://www.github.com/gengjiawen/electron-devdocs/commit/979e9e6a261da6ebd3f2d9211cd1f5b6016bdf1c)) 27 | 28 | 29 | ### Reverts 30 | 31 | * Revert "Bump core-js from 2.6.5 to 3.3.6" (#61) ([86f2978](https://www.github.com/gengjiawen/electron-devdocs/commit/86f2978ece1ee77875def655a462610f08ecb17b)), closes [#61](https://www.github.com/gengjiawen/electron-devdocs/issues/61) 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Daniel Geng 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # electron-devdocs 2 | 3 | [![CircleCI](https://circleci.com/gh/gengjiawen/electron-devdocs.svg?style=svg)](https://circleci.com/gh/gengjiawen/electron-devdocs) 4 | [![Build status](https://ci.appveyor.com/api/projects/status/1akkt6sjlnwwa7tu/branch/master?svg=true)](https://ci.appveyor.com/project/gengjiawen/electron-devdocs/branch/master) 5 | [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/gengjiawen/electron-devdocs) 6 | 7 | > An electron-vue project for devdocs 8 | 9 | ## What does it look like 10 | 11 | ![pretty](arts/look.png) 12 | 13 | 14 | ## Feature 15 | * Multi tab 16 | * Auto-Updater 17 | * Inner google search 18 | 19 | ## Build Setup 20 | ```bash 21 | yarn 22 | yarn run electron:serve 23 | ``` 24 | 25 | 26 | ## License 27 | [MIT](http://opensource.org/licenses/MIT) 28 | 29 | Copyright (c) 2017-present, Jiawen (Daniel) Geng 30 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | image: 3 | - Visual Studio 2019 4 | - macOS 5 | 6 | platform: 7 | - x64 8 | for: 9 | - 10 | matrix: 11 | only: 12 | - image: Visual Studio 2019 13 | install: 14 | - ps: Install-Product node stable x64 15 | - yarn 16 | 17 | init: 18 | - git config --global core.autocrlf input 19 | 20 | install: 21 | - npm i -g yarn && yarn 22 | 23 | build_script: 24 | - npx envinfo 25 | - yarn release 26 | 27 | test: off 28 | -------------------------------------------------------------------------------- /arts/look.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gengjiawen/electron-devdocs/03b77b73caeb0fd061730f68575f01dada6e313e/arts/look.png -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@vue/cli-plugin-babel/preset'], 3 | } 4 | -------------------------------------------------------------------------------- /build/icons/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gengjiawen/electron-devdocs/03b77b73caeb0fd061730f68575f01dada6e313e/build/icons/32x32.png -------------------------------------------------------------------------------- /build/icons/512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gengjiawen/electron-devdocs/03b77b73caeb0fd061730f68575f01dada6e313e/build/icons/512x512.png -------------------------------------------------------------------------------- /build/icons/icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gengjiawen/electron-devdocs/03b77b73caeb0fd061730f68575f01dada6e313e/build/icons/icon.icns -------------------------------------------------------------------------------- /build/icons/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gengjiawen/electron-devdocs/03b77b73caeb0fd061730f68575f01dada6e313e/build/icons/icon.ico -------------------------------------------------------------------------------- /cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "pluginsFile": "tests/e2e/plugins/index.js" 3 | } 4 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: '@vue/cli-plugin-unit-jest', 3 | } 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "electron-devdocs", 3 | "version": "5.3.0", 4 | "main": "background.js", 5 | "description": "an electron-vue app for devdocs", 6 | "homepage": "https://github.com/gengjiawen/electron-devdocs", 7 | "scripts": { 8 | "serve": "vue-cli-service serve", 9 | "build": "vue-cli-service build", 10 | "test:unit": "vue-cli-service test:unit", 11 | "test:e2e": "vue-cli-service test:e2e", 12 | "lint": "vue-cli-service lint --fix", 13 | "electron-build": "vue-cli-service electron:build", 14 | "release": "vue-cli-service electron:build", 15 | "electron:serve": "vue-cli-service electron:serve", 16 | "postinstall": "electron-builder install-app-deps", 17 | "postuninstall": "electron-builder install-app-deps" 18 | }, 19 | "author": "Daniel Geng ", 20 | "license": "MIT", 21 | "dependencies": { 22 | "core-js": "3.9.1", 23 | "electron-context-menu": "2.5.0", 24 | "electron-updater": "4.3.8", 25 | "element-ui": "2.15.1", 26 | "vue": "2.6.12", 27 | "vue-router": "3.5.1" 28 | }, 29 | "devDependencies": { 30 | "@vue/cli-plugin-babel": "4.5.11", 31 | "@vue/cli-plugin-eslint": "5.0.8", 32 | "@vue/cli-plugin-unit-jest": "4.5.11", 33 | "@vue/cli-service": "4.5.11", 34 | "@vue/eslint-config-prettier": "6.0.0", 35 | "@vue/test-utils": "1.1.3", 36 | "babel-eslint": "10.1.0", 37 | "electron": "29.4.2", 38 | "electron-devtools-installer": "^3.1.1", 39 | "eslint": "7.21.0", 40 | "eslint-plugin-prettier": "3.3.1", 41 | "eslint-plugin-vue": "7.7.0", 42 | "prettier": "2.2.1", 43 | "vue-cli-plugin-electron-builder": "2.1.1", 44 | "vue-template-compiler": "2.6.12" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {}, 4 | }, 5 | } 6 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gengjiawen/electron-devdocs/03b77b73caeb0fd061730f68575f01dada6e313e/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | electron-devdocs 9 | 14 | 15 | 16 | 19 |
20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | 11 | 32 | -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gengjiawen/electron-devdocs/03b77b73caeb0fd061730f68575f01dada6e313e/src/assets/logo.png -------------------------------------------------------------------------------- /src/background.js: -------------------------------------------------------------------------------- 1 | import { app, protocol, BrowserWindow, Menu, shell } from "electron"; 2 | import { menu } from './main/menu' 3 | import { 4 | createProtocol, 5 | } from 'vue-cli-plugin-electron-builder/lib' 6 | import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer' 7 | import { registerUpdaterTask } from './main/updater' 8 | import electron_context_menu from "electron-context-menu"; 9 | const isDevelopment = process.env.NODE_ENV !== 'production' 10 | 11 | require('electron-context-menu')({}) 12 | 13 | if (isDevelopment) { 14 | // require('electron-debug')({ showDevTools: true }) 15 | } 16 | 17 | // Keep a global reference of the window object, if you don't, the window will 18 | // be closed automatically when the JavaScript object is garbage collected. 19 | let win 20 | 21 | // Scheme must be registered before the app is ready 22 | protocol.registerSchemesAsPrivileged([ 23 | { scheme: 'app', privileges: { secure: true, standard: true } }, 24 | ]) 25 | 26 | function createWindow() { 27 | // Create the browser window. 28 | win = new BrowserWindow({ 29 | width: 800, 30 | height: 600, 31 | webPreferences: { 32 | enableRemoteModule: true, 33 | nodeIntegration: true, 34 | contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION, 35 | webviewTag: true, 36 | }, 37 | }) 38 | 39 | if (process.env.WEBPACK_DEV_SERVER_URL) { 40 | // Load the url of the dev server if in development mode 41 | win.loadURL(process.env.WEBPACK_DEV_SERVER_URL) 42 | if (!process.env.IS_TEST) win.webContents.openDevTools() 43 | } else { 44 | createProtocol('app') 45 | // Load the index.html when not in development 46 | win.loadURL('app://./index.html') 47 | } 48 | 49 | Menu.setApplicationMenu(menu) 50 | 51 | win.on('closed', () => { 52 | win = null 53 | }) 54 | } 55 | 56 | // Quit when all windows are closed. 57 | app.on('window-all-closed', () => { 58 | // On macOS it is common for applications and their menu bar 59 | // to stay active until the user quits explicitly with Cmd + Q 60 | if (process.platform !== 'darwin') { 61 | app.quit() 62 | } 63 | }) 64 | 65 | app.on('activate', () => { 66 | // On macOS it's common to re-create a window in the app when the 67 | // dock icon is clicked and there are no other windows open. 68 | if (win === null) { 69 | createWindow() 70 | } 71 | }) 72 | 73 | // This method will be called when Electron has finished 74 | // initialization and is ready to create browser windows. 75 | // Some APIs can only be used after this event occurs. 76 | app.on('ready', async () => { 77 | if (isDevelopment && !process.env.IS_TEST) { 78 | // Install Vue Devtools 79 | // Devtools extensions are broken in Electron 6.0.0 and greater 80 | // See https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/378 for more info 81 | // Electron will not launch with Devtools extensions installed on Windows 10 with dark mode 82 | // If you are not using Windows 10 dark mode, you may uncomment these lines 83 | // In addition, if the linked issue is closed, you can upgrade electron and uncomment these lines 84 | try { 85 | await installExtension(VUEJS_DEVTOOLS) 86 | } catch (e) { 87 | console.error('Vue Devtools failed to install:', e.toString()) 88 | } 89 | } 90 | if (!isDevelopment) { 91 | registerUpdaterTask() 92 | } 93 | createWindow() 94 | }) 95 | 96 | // Exit cleanly on request from parent process in development mode. 97 | if (isDevelopment) { 98 | if (process.platform === 'win32') { 99 | process.on('message', data => { 100 | if (data === 'graceful-exit') { 101 | app.quit() 102 | } 103 | }) 104 | } else { 105 | process.on('SIGTERM', () => { 106 | app.quit() 107 | }) 108 | } 109 | } 110 | 111 | export function sendStatusToWindow(messageBundle) { 112 | console.log(messageBundle) 113 | win.webContents.send('message', messageBundle) 114 | } 115 | -------------------------------------------------------------------------------- /src/components/LandingPage.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 106 | 107 | 115 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import { ipcRenderer as ipc } from 'electron' 2 | import Vue from 'vue' 3 | import App from './App.vue' 4 | import router from './router' 5 | import ElementUI from 'element-ui' 6 | import 'element-ui/lib/theme-chalk/index.css' 7 | 8 | Vue.use(ElementUI) 9 | Vue.config.debug = true 10 | 11 | ipc.on('message', (event, arg) => { 12 | console.log('got message', arg) 13 | }) 14 | 15 | window.checkUpdate = () => { 16 | ipc.send('checkUpdate', 1) 17 | } 18 | 19 | /* eslint-disable no-new */ 20 | new Vue({ 21 | router, 22 | render: h => h(App), 23 | }).$mount('#app') 24 | -------------------------------------------------------------------------------- /src/main/menu.js: -------------------------------------------------------------------------------- 1 | import { app, Menu, shell, dialog } from 'electron' 2 | 3 | const template = [ 4 | { 5 | label: 'Edit', 6 | submenu: [ 7 | { 8 | role: 'undo', 9 | }, 10 | { 11 | role: 'redo', 12 | }, 13 | { 14 | type: 'separator', 15 | }, 16 | { 17 | role: 'cut', 18 | }, 19 | { 20 | role: 'copy', 21 | }, 22 | { 23 | role: 'paste', 24 | }, 25 | { 26 | role: 'pasteandmatchstyle', 27 | }, 28 | { 29 | role: 'delete', 30 | }, 31 | { 32 | role: 'selectall', 33 | }, 34 | ], 35 | }, 36 | { 37 | label: 'View', 38 | submenu: [ 39 | { 40 | role: 'reload', 41 | }, 42 | { 43 | role: 'forcereload', 44 | }, 45 | { 46 | role: 'toggledevtools', 47 | }, 48 | { 49 | type: 'separator', 50 | }, 51 | { 52 | role: 'resetzoom', 53 | }, 54 | { 55 | role: 'zoomin', 56 | }, 57 | { 58 | role: 'zoomout', 59 | }, 60 | { 61 | type: 'separator', 62 | }, 63 | { 64 | role: 'togglefullscreen', 65 | }, 66 | ], 67 | }, 68 | { 69 | role: 'window', 70 | submenu: [ 71 | { 72 | role: 'minimize', 73 | }, 74 | { 75 | role: 'close', 76 | }, 77 | ], 78 | }, 79 | { 80 | role: 'help', 81 | submenu: [ 82 | { 83 | label: 'About', 84 | click() { 85 | openAboutDialog() 86 | }, 87 | }, 88 | { 89 | label: 'Learn More', 90 | click() { 91 | shell.openExternal('https://github.com/gengjiawen/electron-devdocs') 92 | }, 93 | }, 94 | ], 95 | }, 96 | ] 97 | 98 | function openAboutDialog() { 99 | const info = `Version ${app.getVersion()} 100 | Electron ${process.versions['electron']} 101 | Renderer ${process.versions['chrome']} 102 | Node ${process.versions['node']}` 103 | 104 | dialog.showMessageBox({ 105 | title: 'Electron Devdocs', 106 | type: 'info', 107 | message: `${app.name}`, 108 | detail: info, 109 | noLink: true, 110 | }) 111 | } 112 | 113 | if (process.platform === 'darwin') { 114 | template.unshift({ 115 | label: app.name, 116 | submenu: [ 117 | { 118 | role: 'about', 119 | }, 120 | { 121 | type: 'separator', 122 | }, 123 | { 124 | role: 'services', 125 | submenu: [], 126 | }, 127 | { 128 | type: 'separator', 129 | }, 130 | { 131 | role: 'hide', 132 | }, 133 | { 134 | role: 'hideothers', 135 | }, 136 | { 137 | role: 'unhide', 138 | }, 139 | { 140 | type: 'separator', 141 | }, 142 | { 143 | role: 'quit', 144 | }, 145 | ], 146 | }) 147 | // Edit menu. 148 | template[1].submenu.push( 149 | { 150 | type: 'separator', 151 | }, 152 | { 153 | label: 'Speech', 154 | submenu: [ 155 | { 156 | role: 'startspeaking', 157 | }, 158 | { 159 | role: 'stopspeaking', 160 | }, 161 | ], 162 | } 163 | ) 164 | // Window menu. 165 | template[3].submenu = [ 166 | { 167 | label: 'Close', 168 | accelerator: 'CmdOrCtrl+W', 169 | role: 'close', 170 | }, 171 | { 172 | label: 'Minimize', 173 | accelerator: 'CmdOrCtrl+M', 174 | role: 'minimize', 175 | }, 176 | { 177 | label: 'Zoom', 178 | role: 'zoom', 179 | }, 180 | { 181 | type: 'separator', 182 | }, 183 | { 184 | label: 'Bring All to Front', 185 | role: 'front', 186 | }, 187 | ] 188 | } else { 189 | template.unshift({ 190 | label: 'File', 191 | submenu: [ 192 | { 193 | role: 'quit', 194 | }, 195 | ], 196 | }) 197 | } 198 | 199 | export const menu = Menu.buildFromTemplate(template) 200 | -------------------------------------------------------------------------------- /src/main/updater.js: -------------------------------------------------------------------------------- 1 | import { ipcMain } from 'electron' 2 | import { 3 | autoUpdater, 4 | DOWNLOAD_PROGRESS, 5 | UPDATE_DOWNLOADED, 6 | } from 'electron-updater' 7 | import { sendStatusToWindow } from '../background' 8 | 9 | autoUpdater.on('checking-for-update', () => { 10 | sendStatusToWindow('Checking for update...') 11 | }) 12 | 13 | autoUpdater.on('update-available', info => { 14 | sendStatusToWindow({ key: 'update-available', value: info }) 15 | }) 16 | 17 | autoUpdater.on(DOWNLOAD_PROGRESS, progress => { 18 | sendStatusToWindow({ key: DOWNLOAD_PROGRESS, value: progress }) 19 | }) 20 | 21 | autoUpdater.on(UPDATE_DOWNLOADED, () => { 22 | console.log('update downloaded') 23 | autoUpdater.quitAndInstall() 24 | }) 25 | 26 | autoUpdater.on('error', (ev, err) => { 27 | sendStatusToWindow({ key: 'Error in auto-updater.', value: err }) 28 | }) 29 | 30 | ipcMain.on('checkUpdate', (event, arg) => { 31 | console.log(arg) 32 | checkUpdate() 33 | }) 34 | 35 | export function checkUpdate() { 36 | console.log('start check') 37 | autoUpdater.checkForUpdates().then(a => { 38 | sendStatusToWindow(a) 39 | }) 40 | } 41 | 42 | export function registerUpdaterTask() { 43 | checkUpdate() 44 | setInterval(() => { 45 | checkUpdate() 46 | }, 2 * 60 * 60 * 1000) 47 | } 48 | -------------------------------------------------------------------------------- /src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import LandingPage from '../components/LandingPage' 4 | 5 | Vue.use(Router) 6 | 7 | export default new Router({ 8 | routes: [ 9 | { 10 | path: '/', 11 | name: 'landing-page', 12 | component: LandingPage, 13 | }, 14 | { 15 | path: '*', 16 | redirect: '/', 17 | }, 18 | ], 19 | }) 20 | -------------------------------------------------------------------------------- /static/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gengjiawen/electron-devdocs/03b77b73caeb0fd061730f68575f01dada6e313e/static/.gitkeep -------------------------------------------------------------------------------- /tests/e2e/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: ["cypress"], 3 | env: { 4 | mocha: true, 5 | "cypress/globals": true 6 | }, 7 | rules: { 8 | strict: "off" 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /tests/e2e/plugins/index.js: -------------------------------------------------------------------------------- 1 | // https://docs.cypress.io/guides/guides/plugins-guide.html 2 | 3 | // if you need a custom webpack configuration you can uncomment the following import 4 | // and then use the `file:preprocessor` event 5 | // as explained in the cypress docs 6 | // https://docs.cypress.io/api/plugins/preprocessors-api.html#Examples 7 | 8 | // const webpack = require('@cypress/webpack-preprocessor') 9 | 10 | module.exports = (on, config) => { 11 | // on('file:preprocessor', webpack({ 12 | // webpackOptions: require('@vue/cli-service/webpack.config'), 13 | // watchOptions: {} 14 | // })) 15 | 16 | return Object.assign({}, config, { 17 | fixturesFolder: 'tests/e2e/fixtures', 18 | integrationFolder: 'tests/e2e/specs', 19 | screenshotsFolder: 'tests/e2e/screenshots', 20 | videosFolder: 'tests/e2e/videos', 21 | supportFile: 'tests/e2e/support/index.js', 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /tests/e2e/specs/test.js: -------------------------------------------------------------------------------- 1 | // https://docs.cypress.io/api/introduction/api.html 2 | 3 | describe('My First Test', () => { 4 | it('Visits the app root url', () => { 5 | cy.visit('/') 6 | cy.contains('h1', 'Welcome to Your Vue.js App') 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /tests/e2e/support/commands.js: -------------------------------------------------------------------------------- 1 | // *********************************************** 2 | // This example commands.js shows you how to 3 | // create various custom commands and overwrite 4 | // existing commands. 5 | // 6 | // For more comprehensive examples of custom 7 | // commands please read more here: 8 | // https://on.cypress.io/custom-commands 9 | // *********************************************** 10 | // 11 | // 12 | // -- This is a parent command -- 13 | // Cypress.Commands.add("login", (email, password) => { ... }) 14 | // 15 | // 16 | // -- This is a child command -- 17 | // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) 18 | // 19 | // 20 | // -- This is a dual command -- 21 | // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) 22 | // 23 | // 24 | // -- This is will overwrite an existing command -- 25 | // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) 26 | -------------------------------------------------------------------------------- /tests/e2e/support/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './commands' 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | -------------------------------------------------------------------------------- /tests/unit/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | jest: true 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /tests/unit/electron.spec.js: -------------------------------------------------------------------------------- 1 | const { testWithSpectron } = require('vue-cli-plugin-electron-builder') 2 | jest.setTimeout(50000) 3 | 4 | test('Window Loads Properly', async () => { 5 | // Wait for dev server to start 6 | const { app, stopServe } = await testWithSpectron() 7 | const win = app.browserWindow 8 | const client = app.client 9 | 10 | // Window was created 11 | expect(await client.getWindowCount()).toBe(1) 12 | // It is not minimized 13 | expect(await win.isMinimized()).toBe(false) 14 | // Window is visible 15 | expect(await win.isVisible()).toBe(true) 16 | // Size is correct 17 | const { width, height } = await win.getBounds() 18 | expect(width).toBeGreaterThan(0) 19 | expect(height).toBeGreaterThan(0) 20 | // App is loaded properly 21 | expect( 22 | /Welcome to Your Vue\.js (\+ TypeScript )?App/.test( 23 | await client.getHTML('#app') 24 | ) 25 | ).toBe(true) 26 | 27 | await stopServe() 28 | }) 29 | -------------------------------------------------------------------------------- /tests/unit/example.spec.js: -------------------------------------------------------------------------------- 1 | import { shallowMount } from '@vue/test-utils' 2 | import HelloWorld from '@/components/HelloWorld.vue' 3 | 4 | describe('HelloWorld.vue', () => { 5 | it('renders props.msg when passed', () => { 6 | const msg = 'new message' 7 | const wrapper = shallowMount(HelloWorld, { 8 | propsData: { msg }, 9 | }) 10 | expect(wrapper.text()).toMatch(msg) 11 | }) 12 | }) 13 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | pluginOptions: { 3 | electronBuilder: { 4 | nodeIntegration: true, 5 | builderOptions: { 6 | productName: 'Devdocs', 7 | appId: 'com.gengjiawen.devdocs', 8 | mac: { 9 | icon: 'build/icons/icon.icns', 10 | }, 11 | win: { 12 | icon: 'build/icons/icon.ico', 13 | }, 14 | linux: { 15 | icon: 'build/icons', 16 | category: 'Development', 17 | target: ['AppImage', 'deb'], 18 | }, 19 | }, 20 | }, 21 | }, 22 | } 23 | --------------------------------------------------------------------------------