├── .eslintrc.js ├── .gitignore ├── LICENSE ├── README.md ├── makefile.js ├── package-lock.json ├── package.json ├── src ├── assets │ ├── fonts │ │ └── icomoon.woff │ ├── images │ │ └── icon.png │ └── locales │ │ ├── fr-FR.json │ │ ├── zh-CN.json │ │ └── zh-TW.json ├── components │ ├── app-updater.vue │ ├── date-formatter.js │ ├── editable-item.vue │ ├── editable-list.vue │ ├── game-view.vue │ ├── hyper-link.vue │ ├── input-area.vue │ ├── item-icon.vue │ ├── pretty-checkbox.vue │ ├── root.vue │ ├── sheet-stick.vue │ ├── sheet-switcher.vue │ ├── store.js │ ├── super-button.vue │ ├── title-bar.vue │ └── todo-view.vue ├── index.html ├── main.js ├── plugins │ ├── binding.js │ ├── flux.js │ ├── i18n.js │ ├── notifier.js │ ├── schedule.js │ ├── storage.js │ └── variables.js ├── resources │ ├── default │ │ ├── custom.css │ │ ├── custom.js │ │ └── translation.json │ ├── fonts │ │ └── NotoSansCJKsc-Regular.otf_ │ └── visual │ │ ├── tile.png │ │ └── todu.VisualElementsManifest.xml └── style.css ├── webpack.config.js └── window.js /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: ['html'], 3 | parserOptions: { 4 | ecmaVersion: 2018, 5 | sourceType: 'module', 6 | }, 7 | env: { 8 | es6: true, 9 | node: true, 10 | browser: true, 11 | }, 12 | rules: { 13 | /** Possible Errors */ 14 | 'for-direction': 'error', 15 | 'getter-return': 'error', 16 | 'no-await-in-loop': 'error', 17 | 'no-compare-neg-zero': 'error', 18 | 'no-cond-assign': 'error', 19 | // 'no-console': 'off', 20 | 'no-constant-condition': ['error', { checkLoops: false }], 21 | // 'no-control-regex': 'off', 22 | 'no-debugger': 'error', 23 | 'no-dupe-args': 'error', 24 | 'no-dupe-keys': 'error', 25 | 'no-duplicate-case': 'error', 26 | 'no-empty': ['error', { allowEmptyCatch: true }], 27 | 'no-empty-character-class': 'error', 28 | 'no-ex-assign': 'error', 29 | 'no-extra-boolean-cast': 'error', 30 | 'no-extra-parens': ['warn', 'all', { nestedBinaryExpressions: false }], 31 | 'no-extra-semi': 'error', 32 | 'no-func-assign': 'error', 33 | 'no-inner-declarations': 'error', 34 | 'no-invalid-regexp': 'error', 35 | 'no-irregular-whitespace': 'error', 36 | 'no-obj-calls': 'error', 37 | 'no-prototype-builtins': 'warn', 38 | 'no-regex-spaces': 'error', 39 | 'no-sparse-arrays': 'error', 40 | 'no-template-curly-in-string': 'error', 41 | 'no-unexpected-multiline': 'error', 42 | 'no-unreachable': 'error', 43 | 'no-unsafe-finally': 'error', 44 | 'no-unsafe-negation': 'error', 45 | 'use-isnan': 'error', 46 | // 'valid-jsdoc': 'off', 47 | 'valid-typeof': 'error', 48 | 49 | /** Best Practices */ 50 | 'accessor-pairs': 'error', 51 | 'array-callback-return': 'error', 52 | 'block-scoped-var': 'error', 53 | 'class-methods-use-this': 'warn', 54 | 'complexity': ['warn', { max: 20 }], 55 | 'consistent-return': 'warn', 56 | 'curly': ['error', 'multi-line', 'consistent'], 57 | 'default-case': 'warn', 58 | 'dot-location': ['error', 'property'], 59 | 'dot-notation': 'error', 60 | 'eqeqeq': ['error', 'always', { null: 'ignore' }], 61 | 'guard-for-in': 'error', 62 | 'max-classes-per-file': ['error', 1], 63 | 'no-alert': 'warn', 64 | 'no-caller': 'error', 65 | 'no-case-declarations': 'error', 66 | 'no-div-regex': 'error', 67 | 'no-else-return': 'warn', 68 | 'no-empty-function': ['error', { allow: ['arrowFunctions'] }], 69 | 'no-empty-pattern': 'error', 70 | // 'no-eq-null': 'off', 71 | 'no-eval': 'error', 72 | 'no-extend-native': 'warn', 73 | 'no-extra-bind': 'error', 74 | 'no-extra-label': 'error', 75 | 'no-fallthrough': 'error', 76 | 'no-floating-decimal': 'error', 77 | 'no-global-assign': 'error', 78 | 'no-implicit-coercion': 'warn', 79 | 'no-implicit-globals': 'warn', 80 | 'no-implied-eval': 'error', 81 | 'no-invalid-this': 'error', 82 | 'no-iterator': 'error', 83 | 'no-labels': 'warn', 84 | 'no-lone-blocks': 'error', 85 | 'no-loop-func': 'error', 86 | // 'no-magic-numbers': 'off', 87 | 'no-multi-spaces': 'error', 88 | 'no-multi-str': 'error', 89 | // 'no-new': 'off', 90 | 'no-new-func': 'error', 91 | 'no-new-wrappers': 'error', 92 | 'no-octal': 'error', 93 | 'no-octal-escape': 'error', 94 | // 'no-param-reassign': 'off', 95 | 'no-proto': 'error', 96 | 'no-redeclare': 'error', 97 | // 'no-restricted-properties': 'off', 98 | 'no-return-assign': 'warn', 99 | 'no-return-await': 'error', 100 | 'no-script-url': 'warn', 101 | 'no-self-assign': 'error', 102 | 'no-self-compare': 'error', 103 | 'no-sequences': 'error', 104 | 'no-throw-literal': 'error', 105 | 'no-unmodified-loop-condition': 'error', 106 | 'no-unused-expressions': ['error', { allowShortCircuit: true }], 107 | 'no-unused-labels': 'error', 108 | 'no-useless-call': 'error', 109 | 'no-useless-concat': 'error', 110 | 'no-useless-escape': 'warn', 111 | 'no-useless-return': 'warn', 112 | // 'no-void': 'off', 113 | // 'no-warning-comments': 'off', 114 | 'no-with': 'warn', 115 | 'prefer-promise-reject-errors': 'error', 116 | 'radix': 'error', 117 | 'require-await': 'warn', 118 | 'vars-on-top': 'error', 119 | 'wrap-iife': ['error', 'inside'], 120 | 'yoda': 'warn', 121 | 122 | /** Strict Mode */ 123 | // 'strict': 'off', 124 | 125 | /** Variables */ 126 | // 'init-declarations': 'off', 127 | 'no-delete-var': 'error', 128 | 'no-label-var': 'error', 129 | // 'no-restricted-globals': 'off', 130 | 'no-shadow': 'warn', 131 | 'no-shadow-restricted-names': 'error', 132 | 'no-undef': 'error', 133 | 'no-undef-init': 'error', 134 | // 'no-undefined': 'off', 135 | 'no-unused-vars': ['error', { args: 'none' }], 136 | 'no-use-before-define': ['error', 'nofunc'], 137 | 138 | /** Node.js and CommonJS */ 139 | // 'callback-return': 'off', 140 | 'global-require': 'warn', 141 | 'handle-callback-err': 'warn', 142 | 'no-buffer-constructor': 'error', 143 | 'no-mixed-requires': 'error', 144 | 'no-new-require': 'error', 145 | 'no-path-concat': 'warn', 146 | // 'no-process-env': 'off', 147 | 'no-process-exit': 'warn', 148 | // 'no-restricted-modules': 'off', 149 | // 'no-sync': 'off', 150 | 151 | /** Stylistic Issues */ 152 | 'array-bracket-newline': ['error', { multiline: true }], 153 | 'array-bracket-spacing': ['error', 'never'], 154 | // 'array-element-newline': 'off', 155 | // 'block-spacing': 'off', 156 | 'brace-style': ['error', '1tbs', { allowSingleLine: true }], 157 | 'camelcase': 'warn', 158 | // 'capitalized-comments': 'off', 159 | 'comma-dangle': ['error', 'only-multiline'], 160 | 'comma-spacing': ['error', { before: false, after: true }], 161 | 'comma-style': ['error', 'last'], 162 | 'computed-property-spacing': ['error', 'never'], 163 | // 'consistent-this': 'off', 164 | 'eol-last': ['error', 'always'], 165 | 'func-call-spacing': ['error', 'never'], 166 | 'func-name-matching': ['error', 'always'], 167 | // 'func-names': 'off', 168 | 'func-style': ['warn', 'declaration', { allowArrowFunctions: true }], 169 | 'function-paren-newline': ['warn', 'consistent'], 170 | // 'id-blacklist': 'off', 171 | // 'id-length': 'off', 172 | // 'id-match': 'off', 173 | // 'implicit-arrow-linebreak': 'off', 174 | 'indent': ['error', 2, { SwitchCase: 1 }], 175 | 'jsx-quotes': ['error', 'prefer-double'], 176 | 'key-spacing': ['error', { 177 | beforeColon: false, afterColon: true, mode: 'strict' 178 | }], 179 | 'keyword-spacing': ['error', { before: true, after: true }], 180 | // 'line-comment-position': 'off', 181 | 'linebreak-style': ['error', 'unix'], 182 | // 'lines-around-comment': 'off', 183 | // 'lines-between-class-members': 'off', 184 | 'max-depth': ['error', { max: 4 }], 185 | 'max-len': ['error', { 186 | code: 80, ignoreStrings: true, ignoreTemplateLiterals: true, 187 | ignoreRegExpLiterals: true 188 | }], 189 | 'max-lines': ['error', { max: 300 }], 190 | 'max-lines-per-function': ['error', { max: 50 }], 191 | 'max-nested-callbacks': ['error', { max: 4 }], 192 | 'max-params': ['error', { max: 3 }], 193 | // 'max-statements': 'off', 194 | // 'max-statements-per-line': 'off', 195 | // 'multiline-comment-style': 'off', 196 | // 'multiline-ternary': 'off', 197 | 'new-cap': ['error', { capIsNew: false }], 198 | 'new-parens': 'error', 199 | // 'newline-per-chained-call': 'off', 200 | 'no-array-constructor': 'error', 201 | 'no-bitwise': 'warn', 202 | // 'no-continue': 'off', 203 | // 'no-inline-comments': 'off', 204 | 'no-lonely-if': 'warn', 205 | 'no-mixed-operators': 'warn', 206 | 'no-mixed-spaces-and-tabs': 'error', 207 | 'no-multi-assign': 'warn', 208 | 'no-multiple-empty-lines': ['warn', { max: 2, maxEOF: 1, maxBOF: 0 }], 209 | // 'no-negated-condition': 'off', 210 | 'no-nested-ternary': 'warn', 211 | 'no-new-object': 'error', 212 | 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], 213 | // 'no-restricted-syntax': 'off', 214 | 'no-tabs': 'error', 215 | // 'no-ternary': 'off', 216 | 'no-trailing-spaces': 'error', 217 | 'no-underscore-dangle': 'warn', 218 | 'no-unneeded-ternary': 'error', 219 | 'no-whitespace-before-property': 'error', 220 | 'nonblock-statement-body-position': 'off', 221 | 'object-curly-newline': ['error', { consistent: true }], 222 | // 'object-curly-spacing': 'off', 223 | // 'object-property-newline': 'off', 224 | 'one-var': ['error', 'never'], 225 | // 'one-var-declaration-per-line': 'off', 226 | 'operator-assignment': 'warn', 227 | 'operator-linebreak': ['error', 'after'], 228 | // 'padded-blocks': 'off', 229 | // 'padding-line-between-statements': 'off', 230 | 'prefer-object-spread': 'warn', 231 | // 'quote-props': 'off', 232 | 'quotes': ['error', 'single'], 233 | // 'require-jsdoc': 'off', 234 | 'semi': ['error', 'never'], 235 | 'semi-spacing': ['error', { before: false, after: true }], 236 | // 'semi-style': 'off', 237 | // 'sort-keys': 'off', 238 | // 'sort-vars': 'off', 239 | 'space-before-blocks': ['error', 'always'], 240 | 'space-before-function-paren': ['error', { named: 'never' }], 241 | 'space-in-parens': ['error', 'never'], 242 | 'space-infix-ops': 'error', 243 | 'space-unary-ops': ['error', { words: true, nonwords: false }], 244 | 'spaced-comment': ['error', 'always', { markers: ['*'] }], 245 | 'switch-colon-spacing': ['error', { before: false, after: true }], 246 | 'template-tag-spacing': ['error', 'never'], 247 | 'unicode-bom': ['error', 'never'], 248 | // 'wrap-regex': 'off', 249 | 250 | /** ECMAScript 6 */ 251 | 'arrow-body-style': 'off', 252 | 'arrow-parens': ['error', 'as-needed'], 253 | 'arrow-spacing': ['error', { before: true, after: true }], 254 | 'constructor-super': 'error', 255 | 'generator-star-spacing': ['error', { 256 | before: false, after: true, method: 'neither' 257 | }], 258 | 'no-class-assign': 'error', 259 | 'no-confusing-arrow': 'error', 260 | 'no-const-assign': 'error', 261 | 'no-dupe-class-members': 'error', 262 | 'no-duplicate-imports': 'error', 263 | 'no-new-symbol': 'error', 264 | // 'no-restricted-imports': 'off', 265 | 'no-this-before-super': 'error', 266 | 'no-useless-computed-key': 'error', 267 | 'no-useless-constructor': 'error', 268 | 'no-useless-rename': 'error', 269 | 'no-var': 'error', 270 | 'object-shorthand': 'warn', 271 | 'prefer-arrow-callback': 'warn', 272 | 'prefer-const': ['error', { destructuring: 'all' }], 273 | 'prefer-destructuring': 'off', 274 | 'prefer-numeric-literals': 'error', 275 | 'prefer-rest-params': 'error', 276 | 'prefer-spread': 'error', 277 | 'prefer-template': 'warn', 278 | 'require-yield': 'error', 279 | 'rest-spread-spacing': ['error', 'never'], 280 | // 'sort-imports': 'off', 281 | 'symbol-description': 'warn', 282 | // 'template-curly-spacing': 'off', 283 | 'yield-star-spacing': ['error', 'after'], 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /dist 3 | /node_modules 4 | /src/assets/images/*.ico 5 | /src/assets/images/*.icns 6 | /src/build 7 | /src/resources/fonts/*.otf 8 | /src/storage 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 孙翛然 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 | ## TODU 2 | 3 | An awesome, hackable to-do list. 4 | 5 | ![Screenshot](https://user-images.githubusercontent.com/5101076/31648366-ddd86026-b33f-11e7-8a20-35d857514e71.png) 6 | 7 | [Download the latest version here](https://github.com/CyanSalt/todu/releases/latest) 8 | 9 | ### Manage your to-do 10 | 11 | * Type your to-do in editor line, then press `Enter`. 12 | * Every day when you open this app, items that undone will be move to today's list. 13 | * Add your to-do of tomorrow in the same way. 14 | * **Drag and drop** your to-do item between today's list and tomorrow. 15 | * Click the date on the right and look up history. 16 | * Add time in today's list and set an alarm clock *5 min* before it happens. 17 | 18 | ### Use different sheet 19 | 20 | * Click super button with infinity icon to toggle the sheet switcher. 21 | * Add, remove sheet, or change the sheet's title if you like. 22 | * Set it to Cycle mode by clicking the button next to the head 'Today'. 23 | 24 | ### Export your data 25 | 26 | * All of user data are placed in the folder `storage` of the app. 27 | * Edit the `sheets.json` to change the sheets' information. 28 | * Copy the content of `todo.json` or `todo-*.json` to export your data. 29 | 30 | ### HACK IT! 31 | 32 | * The messages in this app is written in English, and will be shown as the language set in your system by default. however, you can use its internal translations or translate it yourself. 33 | * Create file `translation.json` in the `storage` directory. 34 | * Type your configure like `{"@use": "en-US"}`, or customize the translation file yourself (See [All translatable texts](https://github.com/CyanSalt/todu/blob/master/src/resources/default/translation.json)). 35 | 36 | * This app is built with [Electron](https://electronjs.org/) and [VueJS](https://vuejs.org/index.html). If you are familiar with eithor of those, you can add `custom.js` to write your own code whenever the app launched. See the demo at `resources/default/custom.js` 37 | 38 | * As well as script, you can also add `custom.css` to write your stylesheets. 39 | 40 | * For getting the document layout of the app's page, you can press `Control/Cmd+Shift+I` to open the devtools panel, just like you do it in Chrome. 41 | 42 | ### License 43 | 44 | MIT 45 | -------------------------------------------------------------------------------- /makefile.js: -------------------------------------------------------------------------------- 1 | const packager = require('electron-packager') 2 | const png2icons = require('png2icons') 3 | const path = require('path') 4 | const fs = require('fs') 5 | const app = require('./package.json') 6 | 7 | const suffix = process.platform === 'darwin' ? 'icns' : 'ico' 8 | const ICON_PATH = `src/assets/images/icon.${suffix}` 9 | 10 | // Check icon file 11 | try { 12 | fs.accessSync(ICON_PATH) 13 | } catch (error) { 14 | console.log('Generating program icon...') 15 | const folder = path.dirname(ICON_PATH) 16 | const input = fs.readFileSync(`${folder}/icon.png`) 17 | const builder = suffix === 'icns' ? png2icons.createICNS : png2icons.createICO 18 | const output = builder(input, png2icons.BICUBIC, false) 19 | fs.writeFileSync(ICON_PATH, output) 20 | } 21 | 22 | const options = { 23 | dir: '.', 24 | name: app.name, 25 | out: 'dist/', 26 | overwrite: true, 27 | asar: true, 28 | icon: ICON_PATH, 29 | ignore: [ 30 | '^/(?!src|package\\.json|window\\.js)', 31 | '^/src/(components|plugins|resources|storage)($|/)', 32 | '^/src/assets/.*\\.(ico|icns)$', 33 | ], 34 | appVersion: app.executableVersion, 35 | win32metadata: { 36 | FileDescription: app.productName, 37 | OriginalFilename: `${app.name}.exe`, 38 | } 39 | } 40 | 41 | function copy(source, target) { 42 | const basename = path.basename(source) 43 | if (fs.lstatSync(source).isDirectory()) { 44 | target = path.join(target, basename) 45 | try { 46 | fs.mkdirSync(target) 47 | } catch (e) {} 48 | const entries = fs.readdirSync(source) 49 | for (const entry of entries) { 50 | copy(path.join(source, entry), target) 51 | } 52 | } else { 53 | fs.copyFileSync(source, path.join(target, basename)) 54 | } 55 | } 56 | 57 | packager(options).then(appPaths => { 58 | appPaths.forEach(dir => { 59 | copy('src/resources', dir) 60 | if (dir.includes('win32')) { 61 | const manifest = `${app.name}.VisualElementsManifest.xml` 62 | fs.renameSync(`${dir}/resources/visual/${manifest}`, `${dir}/${manifest}`) 63 | } 64 | }) 65 | console.log('Build finished.') 66 | }).catch(e => { 67 | console.error(e) 68 | }) 69 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "todu", 3 | "version": "1.10.2", 4 | "executableVersion": "1.9.0", 5 | "productName": "TODU", 6 | "author": "CyanSalt", 7 | "description": "An awesome todo list", 8 | "main": "window.js", 9 | "scripts": { 10 | "build": "webpack --mode=production && node makefile.js", 11 | "dev": "webpack --mode=development && electron .", 12 | "lint": "eslint --ext .js,.vue --ignore-path .gitignore ." 13 | }, 14 | "repository": { 15 | "type": "git", 16 | "url": "https://github.com/CyanSalt/todu.git" 17 | }, 18 | "license": "MIT", 19 | "engines": { 20 | "node": ">=8.5.0" 21 | }, 22 | "devDependencies": { 23 | "css-loader": "^1.0.1", 24 | "electron": "^3.0.8", 25 | "electron-packager": "^12.2.0", 26 | "mini-css-extract-plugin": "^0.4.4", 27 | "png2icons": "^1.0.1", 28 | "vue": "^2.5.17", 29 | "vue-loader": "^15.4.2", 30 | "vue-style-loader": "^4.1.2", 31 | "vue-template-compiler": "^2.5.17", 32 | "webpack": "^4.25.1", 33 | "webpack-cli": "^3.1.2" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/assets/fonts/icomoon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanSalt/todu/dfbbd4172b82004a180a9a523fa3c38825ae4de3/src/assets/fonts/icomoon.woff -------------------------------------------------------------------------------- /src/assets/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanSalt/todu/dfbbd4172b82004a180a9a523fa3c38825ae4de3/src/assets/images/icon.png -------------------------------------------------------------------------------- /src/assets/locales/fr-FR.json: -------------------------------------------------------------------------------- 1 | { 2 | "Today#!1": "Aujourd'hui", 3 | "Tomorrow#!2": "Demain", 4 | "Sunday#!3": "Dimanche", 5 | "Monday#!4": "Lundi", 6 | "Tuesday#!5": "Mardi", 7 | "Wednesday#!6": "Mercredi", 8 | "Thursday#!7": "Jeudi", 9 | "Friday#!8": "Vendredi", 10 | "Saturday#!9": "Samedi", 11 | "%W, %M.%D#!10": "", 12 | "Add a to-do#!11": "Ajouter une to-do", 13 | "Yesterday#!12": "Hier", 14 | "3 days ago#!13": "Avant hier", 15 | "This %W#!14": "Ce %W", 16 | "Last %W#!15": "%W dernier", 17 | "Sunday#!16": "Dimanche", 18 | "Monday#!17": "Lundi", 19 | "Tuesday#!18": "Mardi", 20 | "Wednesday#!19": "Mercredi", 21 | "Thursday#!20": "Jeudi", 22 | "Friday#!21": "Vendredi", 23 | "Saturday#!22": "Samedi", 24 | "%D days ago#!23": "Il y a %D jours", 25 | "Long ago#!24": "Il y a longtemps", 26 | "TO-DO#!25": "À-FAIRE", 27 | "DONE#!26": "FAIT", 28 | "Previous#!27": "Précédent", 29 | "Next#!28": "Prochaine", 30 | "Upgrade to %V#!29": "Mise à jour %V", 31 | "Downloading %R#!30": "Télécharger %R", 32 | "Pausing %R#!31": "Pause %R", 33 | "Relaunch and upgrade#!32": "Relancer et améliorer", 34 | "%T today#!33": "%T aujourd'hui", 35 | "Before#!34": "Le passé" 36 | } 37 | -------------------------------------------------------------------------------- /src/assets/locales/zh-CN.json: -------------------------------------------------------------------------------- 1 | { 2 | "Today#!1": "今天", 3 | "Tomorrow#!2": "明天", 4 | "Sunday#!3": "星期日", 5 | "Monday#!4": "星期一", 6 | "Tuesday#!5": "星期二", 7 | "Wednesday#!6": "星期三", 8 | "Thursday#!7": "星期四", 9 | "Friday#!8": "星期五", 10 | "Saturday#!9": "星期六", 11 | "%W, %M.%D#!10": "%M月%D日 %W", 12 | "Add a to-do#!11": "添加待办事项", 13 | "Yesterday#!12": "昨天", 14 | "3 days ago#!13": "前天", 15 | "This %W#!14": "本%W", 16 | "Last %W#!15": "上%W", 17 | "Sunday#!16": "周日", 18 | "Monday#!17": "周一", 19 | "Tuesday#!18": "周二", 20 | "Wednesday#!19": "周三", 21 | "Thursday#!20": "周四", 22 | "Friday#!21": "周五", 23 | "Saturday#!22": "周六", 24 | "%D days ago#!23": "%D天前", 25 | "Long ago#!24": "很久以前", 26 | "TO-DO#!25": "待办事项", 27 | "DONE#!26": "已办事项", 28 | "Previous#!27": "上一页", 29 | "Next#!28": "下一页", 30 | "Upgrade to %V#!29": "更新 %V", 31 | "Downloading %R#!30": "下载中 %R", 32 | "Pausing %R#!31": "暂停中 %R", 33 | "Relaunch and upgrade#!32": "重启以更新", 34 | "%T today#!33": "今天 %T", 35 | "Before#!34": "过去" 36 | } 37 | -------------------------------------------------------------------------------- /src/assets/locales/zh-TW.json: -------------------------------------------------------------------------------- 1 | { 2 | "Today#!1": "今天", 3 | "Tomorrow#!2": "明天", 4 | "Sunday#!3": "星期日", 5 | "Monday#!4": "星期一", 6 | "Tuesday#!5": "星期二", 7 | "Wednesday#!6": "星期三", 8 | "Thursday#!7": "星期四", 9 | "Friday#!8": "星期五", 10 | "Saturday#!9": "星期六", 11 | "%W, %M.%D#!10": "%M月%D日 %W", 12 | "Add a to-do#!11": "添加待辦事項", 13 | "Yesterday#!12": "昨天", 14 | "3 days ago#!13": "前天", 15 | "This %W#!14": "本%W", 16 | "Last %W#!15": "上%W", 17 | "Sunday#!16": "周日", 18 | "Monday#!17": "周一", 19 | "Tuesday#!18": "周二", 20 | "Wednesday#!19": "周三", 21 | "Thursday#!20": "周四", 22 | "Friday#!21": "周五", 23 | "Saturday#!22": "周六", 24 | "%D days ago#!23": "%D天前", 25 | "Long ago#!24": "很久以前", 26 | "TO-DO#!25": "待辦事項", 27 | "DONE#!26": "已辦事項", 28 | "Previous#!27": "上一頁", 29 | "Next#!28": "下一頁", 30 | "Upgrade to %V#!29": "更新 %V", 31 | "Downloading %R#!30": "下載中 %R", 32 | "Pausing %R#!31": "暫停中 %R", 33 | "Relaunch and upgrade#!32": "重啓以更新", 34 | "%T today#!33": "今天 %T", 35 | "Before#!34": "過去" 36 | } 37 | -------------------------------------------------------------------------------- /src/components/app-updater.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 185 | 186 | 192 | -------------------------------------------------------------------------------- /src/components/date-formatter.js: -------------------------------------------------------------------------------- 1 | export default { 2 | methods: { 3 | midnight(date) { 4 | // Notice that return value of 'digitdate' might not be ISO-8601 5 | // for example: 2017-11-1 (should be 2017-11-01 in ISO-8601) 6 | // return new Date(`${date}T00:00:00`) 7 | return new Date(`${date} 00:00`) 8 | }, 9 | digitdate(date) { 10 | // return new Date(date).toLocaleDateString() 11 | date = new Date(date) 12 | return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}` 13 | }, 14 | localdate(date) { 15 | date = new Date(date) 16 | const format = this.i18n('%W, %M.%D#!10') 17 | const days = [ 18 | 'Sunday#!3', 'Monday#!4', 'Tuesday#!5', 'Wednesday#!6', 19 | 'Thursday#!7', 'Friday#!8', 'Saturday#!9', 20 | ] 21 | return format.replace(/%[A-Z]+/g, holder => { 22 | switch (holder) { 23 | case '%M': return date.getMonth() + 1 24 | case '%D': return date.getDate() 25 | case '%W': return this.i18n(days[date.getDay()]) 26 | default: return holder 27 | } 28 | }) 29 | }, 30 | localinterval(date) { 31 | // calculate with midnight 32 | date = this.midnight(date) 33 | const today = new Date() 34 | const distance = Math.floor((today - date) / 864e5) 35 | switch (distance) { 36 | case 1: 37 | return this.i18n('Yesterday#!12') 38 | case 2: 39 | return this.i18n('3 days ago#!13') 40 | default: 41 | } 42 | const current = today.getDay() 43 | const target = date.getDay() 44 | const front = target && (target < current || !current) 45 | const days = [ 46 | 'Sunday#!16', 'Monday#!17', 'Tuesday#!18', 'Wednesday#!19', 47 | 'Thursday#!20', 'Friday#!21', 'Saturday#!22', 48 | ] 49 | if (distance < 7 && front) { 50 | return this.i18n('This %W#!14').replace('%W', this.i18n(days[target])) 51 | } else if (distance <= 7 || (distance < 14 && front)) { 52 | return this.i18n('Last %W#!15').replace('%W', this.i18n(days[target])) 53 | } 54 | if (distance < 100) { 55 | return this.i18n('%D days ago#!23').replace('%D', distance) 56 | } 57 | return this.i18n('Long ago#!24') 58 | }, 59 | }, 60 | } 61 | -------------------------------------------------------------------------------- /src/components/editable-item.vue: -------------------------------------------------------------------------------- 1 | 45 | 46 | 305 | 306 | 388 | -------------------------------------------------------------------------------- /src/components/editable-list.vue: -------------------------------------------------------------------------------- 1 | 31 | 32 | 128 | 129 | 222 | -------------------------------------------------------------------------------- /src/components/game-view.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 120 | 121 | 233 | -------------------------------------------------------------------------------- /src/components/hyper-link.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 22 | 23 | 36 | -------------------------------------------------------------------------------- /src/components/input-area.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 41 | 42 | 72 | -------------------------------------------------------------------------------- /src/components/item-icon.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 16 | 17 | 58 | -------------------------------------------------------------------------------- /src/components/pretty-checkbox.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 19 | 20 | 62 | -------------------------------------------------------------------------------- /src/components/root.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 60 | -------------------------------------------------------------------------------- /src/components/sheet-stick.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 74 | 75 | 105 | -------------------------------------------------------------------------------- /src/components/sheet-switcher.vue: -------------------------------------------------------------------------------- 1 | 18 | 19 | 124 | 125 | 215 | -------------------------------------------------------------------------------- /src/components/store.js: -------------------------------------------------------------------------------- 1 | export default { 2 | data: { 3 | 'super-button/selecting': false, 4 | 'game/flag': 0, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/components/super-button.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 59 | 60 | 106 | -------------------------------------------------------------------------------- /src/components/title-bar.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 61 | 62 | 107 | -------------------------------------------------------------------------------- /src/components/todo-view.vue: -------------------------------------------------------------------------------- 1 | 61 | 62 | 255 | 256 | 310 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | TODU 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Flux from './plugins/flux' 3 | import I18N from './plugins/i18n' 4 | import Binding from './plugins/binding' 5 | import Schedule from './plugins/schedule' 6 | import Notifier from './plugins/notifier' 7 | import Variables from './plugins/variables' 8 | import FileStorage from './plugins/storage' 9 | import Root from './components/root' 10 | import Store from './components/store' 11 | 12 | Vue.use(I18N) 13 | Vue.use(Binding) 14 | Vue.use(Schedule) 15 | Vue.use(Notifier) 16 | Vue.use(Variables) 17 | Vue.use(FileStorage) 18 | Vue.use(Flux, Store) 19 | 20 | new Vue(Root) 21 | -------------------------------------------------------------------------------- /src/plugins/binding.js: -------------------------------------------------------------------------------- 1 | const store = {} 2 | const Binding = { 3 | of(key) { 4 | if (!store[key]) { 5 | store[key] = new Map() 6 | } 7 | return store[key] 8 | } 9 | } 10 | 11 | export default { 12 | install(Vue, options) { 13 | Vue.prototype.$binding = Binding 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/plugins/flux.js: -------------------------------------------------------------------------------- 1 | let store = null 2 | 3 | const Flux = { 4 | on(event, handler) { 5 | return store.$on(event, handler) 6 | }, 7 | emit(event, payload) { 8 | return store.$emit(event, payload) 9 | }, 10 | get(key) { 11 | return store[key] 12 | }, 13 | set(key, value) { 14 | store[key] = value 15 | }, 16 | dispatch(method, payload) { 17 | return store[method](payload) 18 | }, 19 | } 20 | 21 | export function state(name) { 22 | return { 23 | get() { 24 | return Flux.get(name) 25 | }, 26 | set(value) { 27 | return Flux.set(name, value) 28 | } 29 | } 30 | } 31 | 32 | export default { 33 | install(Vue, options) { 34 | store = new Vue(options) 35 | Vue.prototype.$flux = Flux 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/plugins/i18n.js: -------------------------------------------------------------------------------- 1 | import {remote} from 'electron' 2 | import {readFileSync} from 'fs' 3 | import {resolve} from 'path' 4 | import {FileStorage} from './storage' 5 | 6 | const translations = [ 7 | { 8 | file: 'fr-FR.json', 9 | locales: ['fr', 'fr-CA', 'fr-CH', 'fr-FR'], 10 | }, 11 | { 12 | file: 'zh-CN.json', 13 | locales: ['zh', 'zh-CN'], 14 | }, 15 | { 16 | file: 'zh-TW.json', 17 | locales: ['zh-TW'], 18 | }, 19 | ] 20 | 21 | function load(file) { 22 | const path = resolve(__dirname, 'assets/locales', file) 23 | try { 24 | return JSON.parse(readFileSync(path)) 25 | } catch (e) { 26 | return null 27 | } 28 | } 29 | 30 | export default { 31 | install(Vue, options) { 32 | let locale = remote.app.getLocale() 33 | const custom = FileStorage.loadSync('translation.json') || {} 34 | if (custom['@use']) locale = custom['@use'] 35 | // Load translation data 36 | const translation = translations 37 | .find(({locales}) => locales.includes(locale)) 38 | const dictionary = (translation && load(translation.file)) || {} 39 | // Merge user defined translation data 40 | for (const [key, value] of Object.entries(custom)) { 41 | if (value) dictionary[key] = value 42 | } 43 | Vue.prototype.i18n = function (message) { 44 | return dictionary[message] || message.split('#!')[0] 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/plugins/notifier.js: -------------------------------------------------------------------------------- 1 | import {remote} from 'electron' 2 | 3 | const Notifier = { 4 | send(options) { 5 | const {title, body} = options 6 | const icon = 'assets/images/icon.png' 7 | const frame = remote.getCurrentWindow() 8 | frame.flashFrame(true) 9 | const notification = new Notification(title, {body, icon}) 10 | notification.onclick = () => { 11 | if (frame.isMinimized()) { 12 | frame.restore() 13 | } 14 | frame.focus() 15 | } 16 | return notification 17 | } 18 | } 19 | 20 | export default { 21 | install(Vue, options) { 22 | Vue.prototype.$notifier = Notifier 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/plugins/schedule.js: -------------------------------------------------------------------------------- 1 | const store = {} 2 | const Schedule = { 3 | register(time, handler) { 4 | time = new Date(time) 5 | const timeout = time - Date.now() 6 | if (timeout < 1) { 7 | return false 8 | } 9 | const id = setTimeout(handler, timeout) 10 | store[id] = {time, handler} 11 | return id 12 | }, 13 | unregister(id) { 14 | clearTimeout(id) 15 | const data = store[id] 16 | delete store[id] 17 | return data 18 | }, 19 | } 20 | 21 | export default { 22 | install(Vue, options) { 23 | Vue.prototype.$schedule = Schedule 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/plugins/storage.js: -------------------------------------------------------------------------------- 1 | import { 2 | readFile, readFileSync, 3 | writeFile, writeFileSync, 4 | unlink, unlinkSync, 5 | mkdir, mkdirSync, 6 | access, accessSync, 7 | } from 'fs' 8 | import {dirname, resolve} from 'path' 9 | 10 | const NOOP = () => {} 11 | const PATH = process.env.NODE_ENV === 'production' ? 12 | dirname(process.execPath) : __dirname 13 | 14 | export const FileStorage = { 15 | fetch(key, initial, callback) { 16 | return this.load(key, (err, data) => { 17 | if (!err || !initial) { 18 | return callback(err, data) 19 | } 20 | this.save(key, initial) 21 | return initial 22 | }) 23 | }, 24 | fetchSync(key, initial) { 25 | const data = this.loadSync(key) 26 | if (data !== null || !initial) { 27 | return data 28 | } 29 | this.save(key, initial) 30 | return initial 31 | }, 32 | load(key, callback = NOOP) { 33 | return readFile(this.filename(key), (err, data) => { 34 | if (!err && data) { 35 | try { 36 | data = JSON.parse(data) 37 | } catch (e) { 38 | callback(e, null) 39 | return 40 | } 41 | } 42 | callback(err, data) 43 | }) 44 | }, 45 | loadSync(key) { 46 | try { 47 | return JSON.parse(readFileSync(this.filename(key))) 48 | } catch (e) { 49 | return null 50 | } 51 | }, 52 | delete(key, callback = NOOP) { 53 | return unlink(this.filename(key), (...args) => { 54 | callback(...args) 55 | }) 56 | }, 57 | deleteSync(key) { 58 | try { 59 | unlinkSync(this.filename(key)) 60 | } catch (e) {} 61 | }, 62 | save(key, data, callback = NOOP) { 63 | const filename = this.filename(key) 64 | return mkdir(dirname(filename), () => { 65 | writeFile(filename, this.stringify(data), callback) 66 | }) 67 | }, 68 | saveSync(key, data) { 69 | const filename = this.filename(key) 70 | try { 71 | mkdirSync(dirname(filename)) 72 | } catch (e) { 73 | return 74 | } 75 | writeFileSync(filename, this.stringify(data)) 76 | }, 77 | require(key, callback) { 78 | const filename = this.filename(key) 79 | access(filename, err => { 80 | if (err) return 81 | callback(global.require(filename)) 82 | }) 83 | }, 84 | requireSync(key) { 85 | const filename = this.filename(key) 86 | try { 87 | accessSync(filename) 88 | return global.require(filename) 89 | } catch (e) { 90 | return null 91 | } 92 | }, 93 | rawdata(key, suffix, callback) { 94 | return readFile(this.filename(key), (err, data) => { 95 | if (err) return 96 | callback(data) 97 | }) 98 | }, 99 | rawdataSync(key, suffix) { 100 | try { 101 | return readFileSync(this.filename(key)) 102 | } catch (e) { 103 | return null 104 | } 105 | }, 106 | 107 | stringify(data) { 108 | return JSON.stringify(data, null, 2) 109 | }, 110 | filename(basename) { 111 | return resolve(PATH, 'storage', basename) 112 | }, 113 | } 114 | 115 | export default { 116 | install(Vue, options) { 117 | Vue.prototype.$storage = FileStorage 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/plugins/variables.js: -------------------------------------------------------------------------------- 1 | const store = {} 2 | const Variables = { 3 | get(key) { 4 | return store[key] 5 | }, 6 | set(key, value) { 7 | store[key] = value 8 | }, 9 | pop(key) { 10 | const value = store[key] 11 | store[key] = null 12 | return value 13 | } 14 | } 15 | 16 | export default { 17 | install(Vue, options) { 18 | Vue.prototype.$vars = Variables 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/resources/default/custom.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Your Stylesheet 3 | */ 4 | 5 | /* an example to customize your software */ 6 | /* 7 | body { 8 | background: #fff 9 | } 10 | .list-group.today { 11 | order: 1; 12 | } 13 | */ 14 | -------------------------------------------------------------------------------- /src/resources/default/custom.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Your init script 3 | * @param {Vue} vm ViewModal for root element of Vue.js 4 | * @return {void} 5 | */ 6 | module.exports = function (vm) { 7 | 8 | // an example to hack your software 9 | // vm.title = 'Have a nice day!' 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/resources/default/translation.json: -------------------------------------------------------------------------------- 1 | { 2 | "@use": "", 3 | "Today#!1": "", 4 | "Tomorrow#!2": "", 5 | "Sunday#!3": "", 6 | "Monday#!4": "", 7 | "Tuesday#!5": "", 8 | "Wednesday#!6": "", 9 | "Thursday#!7": "", 10 | "Friday#!8": "", 11 | "Saturday#!9": "", 12 | "%W, %M.%D#!10": "", 13 | "Add a to-do#!11": "", 14 | "Yesterday#!12": "", 15 | "3 days ago#!13": "", 16 | "This %W#!14": "", 17 | "Last %W#!15": "", 18 | "Sunday#!16": "", 19 | "Monday#!17": "", 20 | "Tuesday#!18": "", 21 | "Wednesday#!19": "", 22 | "Thursday#!20": "", 23 | "Friday#!21": "", 24 | "Saturday#!22": "", 25 | "%D days ago#!23": "", 26 | "Long ago#!24": "", 27 | "TO-DO#!25": "", 28 | "DONE#!26": "", 29 | "Previous#!27": "", 30 | "Next#!28": "", 31 | "Upgrade to %V#!29": "", 32 | "Downloading %R#!30": "", 33 | "Pausing %R#!31": "", 34 | "Relaunch and upgrade#!32": "", 35 | "%T today#!33": "", 36 | "Before#!34": "" 37 | } 38 | -------------------------------------------------------------------------------- /src/resources/fonts/NotoSansCJKsc-Regular.otf_: -------------------------------------------------------------------------------- 1 | https://github.com/googlei18n/noto-cjk/raw/master/NotoSansCJKsc-Regular.otf 2 | -------------------------------------------------------------------------------- /src/resources/visual/tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanSalt/todu/dfbbd4172b82004a180a9a523fa3c38825ae4de3/src/resources/visual/tile.png -------------------------------------------------------------------------------- /src/resources/visual/todu.VisualElementsManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | -------------------------------------------------------------------------------- /src/style.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-style: normal; 3 | font-family: 'TODU UI'; 4 | src: local('Noto Sans CJK SC'), local('PingFang SC'), 5 | url("../../fonts/NotoSansCJKsc-Regular.otf") 6 | } 7 | 8 | body { 9 | margin: 0; 10 | font-family: 'TODU UI'; 11 | background: #fcfcfc; 12 | color: #343d46; 13 | user-select: none; 14 | -webkit-tap-highlight-color: transparent; 15 | } 16 | ::-webkit-scrollbar { 17 | background: inherit; 18 | width: 6px; 19 | } 20 | ::-webkit-scrollbar-thumb { 21 | background: rgba(170, 170, 170, 0.5); 22 | } 23 | 24 | @font-face { 25 | font-family: 'icomoon'; 26 | font-weight: normal; 27 | font-style: normal; 28 | src: url('./assets/fonts/icomoon.woff') format('woff'); 29 | } 30 | .icon-trash, 31 | .icon-plus, 32 | .icon-arrow-left, 33 | .icon-infinite, 34 | .icon-cycle, 35 | .icon-unmaximize, 36 | .icon-minimize, 37 | .icon-maximize, 38 | .icon-close, 39 | .icon-more, 40 | .icon-link, 41 | .icon-clock, 42 | .icon-chevron-up, 43 | .icon-hash, 44 | .icon-bookmark { 45 | font-family: 'icomoon'; 46 | } 47 | .icon-trash:before { 48 | content: "\e900"; 49 | } 50 | .icon-plus:before { 51 | content: "\e901"; 52 | } 53 | .icon-arrow-left:before { 54 | content: "\e902"; 55 | } 56 | .icon-infinite:before { 57 | content: "\e903"; 58 | } 59 | .icon-cycle:before { 60 | content: "\e904"; 61 | } 62 | .icon-unmaximize:before { 63 | content: "\e905"; 64 | } 65 | .icon-minimize:before { 66 | content: "\e906"; 67 | } 68 | .icon-maximize:before { 69 | content: "\e907"; 70 | } 71 | .icon-close:before { 72 | content: "\e908"; 73 | } 74 | .icon-more:before { 75 | content: "\e909"; 76 | } 77 | .icon-link:before { 78 | content: "\e90a"; 79 | } 80 | .icon-clock:before { 81 | content: "\e90b"; 82 | } 83 | .icon-chevron-up:before { 84 | content: "\e90c"; 85 | } 86 | .icon-hash:before { 87 | content: "\e90d"; 88 | } 89 | .icon-bookmark:before { 90 | content: "\e90e"; 91 | } 92 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const webpack = require('webpack') 3 | const MiniCSSExtractPlugin = require('mini-css-extract-plugin') 4 | const VueLoaderPlugin = require('vue-loader/lib/plugin') 5 | 6 | module.exports = { 7 | target: 'electron-renderer', 8 | devtool: 'source-map', 9 | stats: { 10 | modules: false, 11 | entrypoints: false, 12 | }, 13 | node: { 14 | __dirname: false, 15 | }, 16 | entry: { 17 | main: path.resolve(__dirname, 'src/main.js') 18 | }, 19 | output: { 20 | path: path.resolve(__dirname, 'src/build/'), 21 | filename: 'bundle.js' 22 | }, 23 | externals: { 24 | 'original-fs': 'require("original-fs")', 25 | }, 26 | resolve: { 27 | extensions: ['.js', '.vue'], 28 | alias: { 29 | vue: 'vue/dist/vue.esm.js' 30 | } 31 | }, 32 | module: { 33 | rules: [ 34 | { 35 | test: /\.vue$/, 36 | loader: 'vue-loader', 37 | }, 38 | { 39 | test: /\.css$/, 40 | use: [ 41 | 'vue-style-loader', 42 | MiniCSSExtractPlugin.loader, 43 | 'css-loader', 44 | ] 45 | } 46 | ] 47 | }, 48 | plugins: [ 49 | new MiniCSSExtractPlugin({ 50 | filename: 'bundle.css', 51 | }), 52 | new webpack.ProgressPlugin(), 53 | new VueLoaderPlugin(), 54 | ], 55 | } 56 | -------------------------------------------------------------------------------- /window.js: -------------------------------------------------------------------------------- 1 | const {app, BrowserWindow, Menu} = require('electron') 2 | const path = require('path') 3 | 4 | let frame = null 5 | 6 | function init() { 7 | frame = new BrowserWindow({ 8 | title: 'TODU', 9 | width: 900, 10 | height: 700, 11 | minWidth: 450, 12 | frame: false, 13 | webPreferences: { 14 | experimentalFeatures: true, 15 | }, 16 | }) 17 | frame.loadURL(`file://${__dirname}/src/index.html`) 18 | frame.on('closed', () => { 19 | frame = null 20 | }) 21 | const menu = createMenu() 22 | if (process.platform === 'darwin') { 23 | Menu.setApplicationMenu(menu) 24 | } else { 25 | frame.setMenu(menu) 26 | frame.setMenuBarVisibility(false) 27 | } 28 | // these handler must be binded in main process 29 | transferEvents() 30 | } 31 | 32 | function createMenu() { 33 | return Menu.buildFromTemplate([ 34 | { 35 | label: app.getName(), 36 | submenu: [ 37 | {role: 'toggledevtools'}, 38 | { 39 | label: 'Print', 40 | accelerator: 'CommandOrControl+P', 41 | click() { 42 | frame && frame.webContents.print() 43 | } 44 | } 45 | ] 46 | } 47 | ]) 48 | } 49 | 50 | function transferEvents() { 51 | frame.on('maximize', () => { 52 | frame.webContents.send('maximize') 53 | }) 54 | frame.on('unmaximize', () => { 55 | frame.webContents.send('unmaximize') 56 | }) 57 | global.downloads = new Map() 58 | frame.webContents.session.on('will-download', (e, item, webContents) => { 59 | const target = path.join( 60 | process.resourcesPath, 61 | `${item.getFilename()}.download`, 62 | ) 63 | item.setSavePath(target) 64 | global.downloads.set(target, item) 65 | webContents.send('will-download', target) 66 | }) 67 | } 68 | 69 | const second = app.makeSingleInstance((argv, directory) => { 70 | if (frame) { 71 | if (frame.isMinimized()) { 72 | frame.restore() 73 | } 74 | frame.focus() 75 | } 76 | return true 77 | }) 78 | 79 | if (second) { 80 | app.quit() 81 | } 82 | 83 | app.on('ready', init) 84 | 85 | app.on('activate', () => { 86 | if (frame === null) { 87 | init() 88 | } 89 | }) 90 | 91 | app.on('window-all-closed', () => { 92 | app.quit() 93 | }) 94 | --------------------------------------------------------------------------------