From fdb0ba96463e158e86c8eb6903145df9a21972a0 Mon Sep 17 00:00:00 2001 From: kimorkim Date: Wed, 27 Sep 2017 17:39:35 +0900 Subject: [PATCH] update png file download dialog --- .vscode/launch.json | 20 ++-- package.json | 1 + src/entry_offline.js | 24 ++++ src/renderer/src/sources/util.js | 1 + yarn.lock | 189 ++++++++++++++++++++++++------- 5 files changed, 188 insertions(+), 47 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6984eae6a..5845cc8e9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,19 +7,21 @@ { "type": "node", "request": "launch", - "protocol": "legacy", "name": "Electron Main", + "cwd": "${workspaceRoot}", + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron", + "windows": { + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd" + }, + "args" : ["."] + }, { + "type": "node", + "request": "launch", + "name": "Electron Main2", "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-forge-vscode-nix", "windows": { - "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-forge-vscode-win.cmd" + "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-forge-vscode-win.cmd" }, - // "port": 5858, - // "timeout": 10000, - // // runtimeArgs will be passed directly to your Electron application - // "runtimeArgs": [ - // "--inspect=5858", - // "--debug" - // ], "cwd": "${workspaceRoot}" } ] diff --git a/package.json b/package.json index 4c74232ab..2b5566252 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "productName": "Entry", "scripts": { "clean": "rimraf dist", + "debug": "./node_modules/.bin/electron-forge-vscode-nix --debug=5858", "dist": "build", "comp": "set NODE_ENV=production&&electron-compile ./src", "start": "electron-forge start", diff --git a/src/entry_offline.js b/src/entry_offline.js index ba51b9c52..d7e132126 100644 --- a/src/entry_offline.js +++ b/src/entry_offline.js @@ -14,6 +14,13 @@ addBypassChecker((filePath) => { return filePath.indexOf(app.getAppPath()) === -1 && bypassList.indexOf(ext) > -1; }); +const downloadFilterList = { + 'image/png': [ + { name: 'PNG Image (*.png)', extensions: ['png'] }, + { name: 'All Files (*.*)', extensions: ['*'] } + ], +} + global.sharedObject = { roomId: '', mainWindowId: '', @@ -125,6 +132,23 @@ if (shouldQuit) { mainWindow.show() }); + mainWindow.webContents.session.on('will-download', (event, downloadItem, webContents) => { + const filename = downloadItem.getFilename(); + const option = { + defaultPath: filename, + } + const filters = downloadFilterList[downloadItem.getMimeType()]; + if(filters) { + option.filters = filters; + } + var fileName = dialog.showSaveDialog(option); + if (typeof fileName == "undefined") { + downloadItem.cancel() + } else { + downloadItem.setSavePath(fileName); + } + }); + mainUtils = new MainUtils(mainWindow); mainWindow.webContents.on('crashed', () => { diff --git a/src/renderer/src/sources/util.js b/src/renderer/src/sources/util.js index 49d5de883..d63bf7f66 100644 --- a/src/renderer/src/sources/util.js +++ b/src/renderer/src/sources/util.js @@ -44,6 +44,7 @@ class Util { } static showSaveDialog(option, callback) { + console.log('dasdas?') if(isOsx) { dialog.showSaveDialog(option, callback); } else { diff --git a/yarn.lock b/yarn.lock index 162be70b4..8846f58ed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -33,8 +33,8 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.34.tgz#eed5c95291a9dddff6b9f5a72ca342b1e72f0ba2" "@types/node@^7.0.18": - version "7.0.39" - resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.39.tgz#8aced4196387038113f6f9aa4014ab4c51edab3c" + version "7.0.43" + resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c" abab@^1.0.0: version "1.0.3" @@ -107,6 +107,10 @@ ansi-escapes@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" +ansi-escapes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" + ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -779,7 +783,16 @@ babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015 babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-plugin-transform-es2015-modules-commonjs@^6.0.12, babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1: +babel-plugin-transform-es2015-modules-commonjs@^6.0.12: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a" + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" + +babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" dependencies: @@ -1386,7 +1399,7 @@ chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0: +chalk@^2.0.0, chalk@^2.0.1: version "2.1.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e" dependencies: @@ -1685,7 +1698,7 @@ cross-spawn-async@^2.1.1: lru-cache "^4.0.0" which "^1.2.8" -cross-spawn@^5.0.0: +cross-spawn@^5.0.0, cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" dependencies: @@ -1848,7 +1861,7 @@ de-indent@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/de-indent/-/de-indent-1.0.2.tgz#b2038e846dc33baa5796128d0804b455b8c1e21d" -debug@*, debug@2, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.3.3, debug@^2.5.1, debug@^2.6.3, debug@^2.6.8: +debug@*, debug@2, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.5.1, debug@^2.6.3, debug@^2.6.8: version "2.6.8" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: @@ -1866,6 +1879,12 @@ debug@2.3.3: dependencies: ms "0.7.2" +debug@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + dependencies: + ms "2.0.0" + decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -2015,7 +2034,23 @@ electron-chromedriver@~1.7.1: electron-download "^4.1.0" extract-zip "^1.6.5" -electron-compile@*, electron-compile@^6.1.3: +electron-compile@*: + version "6.4.2" + resolved "https://registry.yarnpkg.com/electron-compile/-/electron-compile-6.4.2.tgz#eb989eeac727646cbf8619217f53eeae8ee708c1" + dependencies: + "@paulcbetts/mime-types" "^2.1.10" + "@types/node" "^7.0.12" + btoa "^1.1.2" + debug "^2.5.1" + lru-cache "^4.0.1" + mkdirp "^0.5.1" + pify "^2.3.0" + rimraf "^2.5.4" + rxjs "^5.1.1" + spawn-rx "^2.0.3" + yargs "^4.8.1" + +electron-compile@^6.1.3: version "6.4.1" resolved "https://registry.yarnpkg.com/electron-compile/-/electron-compile-6.4.1.tgz#3f89918d72f9bd3b8b8e97d792511d69cade0884" dependencies: @@ -2111,15 +2146,15 @@ electron-forge-template-vue@^1.0.2: resolved "https://registry.yarnpkg.com/electron-forge-template-vue/-/electron-forge-template-vue-1.0.2.tgz#c935f5aa96a2798c6ea9b834465e3212e4f71d33" electron-forge@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/electron-forge/-/electron-forge-3.1.1.tgz#3dccfda9987a2ec9b6f6600c41f1adb8c69be472" + version "3.2.0" + resolved "https://registry.yarnpkg.com/electron-forge/-/electron-forge-3.2.0.tgz#0fe4d867554d8ddf85ca38d68f2814cae0928bb3" dependencies: aws-sdk "^2.9.0" babel-register "^6.16.3" bluebird "^3.4.6" colors "^1.1.2" commander "^2.9.0" - debug "^2.3.3" + debug "^3.0.0" electron-forge-template-angular2 "^1.0.3" electron-forge-template-react "^1.0.2" electron-forge-template-react-typescript "^1.0.3" @@ -2127,32 +2162,32 @@ electron-forge@^3.1.1: electron-packager "^8.5.2" electron-rebuild "^1.6.0" form-data "^2.1.4" - fs-extra "^3.0.0" + fs-extra "^4.0.0" github "^9.0.0" glob "^7.1.1" - inquirer "^3.0.1 " + inquirer "^3.0.1" lodash.template "^4.4.0" - log-symbols "^1.0.2" + log-symbols "^2.0.0" node-fetch "^1.6.3" node-gyp "^3.4.0" nugget "^2.0.1" - opn "^4.0.2" + opn "^5.0.0" ora "^1.1.0" - pify "^2.3.0" + pify "^3.0.0" resolve-package "^1.0.1" s3 "^4.4.0" semver "^5.3.0" spawn-rx "^2.0.7" sudo-prompt "^7.0.0" tabtab "^2.2.1" - username "^2.2.2" + username "^3.0.0" yarn-or-npm "^2.0.2" zip-folder "^1.0.0" optionalDependencies: electron-installer-debian "^0.5.0" electron-installer-dmg "^0.2.0" - electron-installer-flatpak "^0.4.0" - electron-installer-redhat "^0.4.0" + electron-installer-flatpak "^0.6.0" + electron-installer-redhat "^0.5.0" electron-windows-store "^0.10.1" electron-winstaller "^2.5.0" @@ -2180,9 +2215,9 @@ electron-installer-dmg@^0.2.0: optionalDependencies: appdmg "^0.4.5" -electron-installer-flatpak@^0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/electron-installer-flatpak/-/electron-installer-flatpak-0.4.1.tgz#b25586fe1a1cf2dd2ac4f4fe8ea7403b618ce62e" +electron-installer-flatpak@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/electron-installer-flatpak/-/electron-installer-flatpak-0.6.0.tgz#dae659345c8affd74188d7c6236efda2484f2657" dependencies: asar "^0.12.0" async "^2.0.0" @@ -2193,9 +2228,9 @@ electron-installer-flatpak@^0.4.0: temp "^0.8.3" yargs "^6.0.0" -electron-installer-redhat@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/electron-installer-redhat/-/electron-installer-redhat-0.4.0.tgz#b21809657c8361c7614cd6fdaa6206b15894e440" +electron-installer-redhat@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/electron-installer-redhat/-/electron-installer-redhat-0.5.0.tgz#09699cd37bc911cf7ff99587ba77aa205e836cd2" dependencies: asar "^0.13.0" async "^2.1.5" @@ -2446,6 +2481,18 @@ execa@^0.4.0: path-key "^1.0.0" strip-eof "^1.0.0" +execa@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-0.7.0.tgz#944becd34cc41ee32a63a9faf27ad5a65fc59777" + dependencies: + cross-spawn "^5.0.1" + get-stream "^3.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + exit-hook@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" @@ -2634,6 +2681,14 @@ fs-extra@^3.0.0, fs-extra@^3.0.1: jsonfile "^3.0.0" universalify "^0.1.0" +fs-extra@^4.0.0: + version "4.0.2" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.2.tgz#f91704c53d1b461f893452b0c307d9997647ab6b" + dependencies: + graceful-fs "^4.1.2" + jsonfile "^4.0.0" + universalify "^0.1.0" + fs-temp@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/fs-temp/-/fs-temp-1.1.2.tgz#cc52f038bbefe510f6bcd09ec592b79d0f69253f" @@ -2733,6 +2788,10 @@ get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" +get-stream@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" + getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" @@ -3064,7 +3123,26 @@ inquirer@^1.0.2: strip-ansi "^3.0.0" through "^2.3.6" -"inquirer@^3.0.1 ", inquirer@^3.0.6: +inquirer@^3.0.1: + version "3.3.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" + dependencies: + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" + cli-width "^2.0.0" + external-editor "^2.0.4" + figures "^2.0.0" + lodash "^4.3.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.1.0" + strip-ansi "^4.0.0" + through "^2.3.6" + +inquirer@^3.0.6: version "3.2.1" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.2.1.tgz#06ceb0f540f45ca548c17d6840959878265fa175" dependencies: @@ -3233,6 +3311,10 @@ is-windows@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-0.2.0.tgz#de1aa6d63ea29dd248737b69f1ff8b8002d2108c" +is-wsl@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" + isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" @@ -3402,6 +3484,12 @@ jsonfile@^3.0.0: optionalDependencies: graceful-fs "^4.1.6" +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + optionalDependencies: + graceful-fs "^4.1.6" + jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" @@ -3605,6 +3693,12 @@ log-symbols@^1.0.2: dependencies: chalk "^1.0.0" +log-symbols@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-2.1.0.tgz#f35fa60e278832b538dc4dddcbb478a45d3e3be6" + dependencies: + chalk "^2.0.1" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -3651,9 +3745,11 @@ math-expression-evaluator@^1.2.14: version "1.2.17" resolved "https://registry.yarnpkg.com/math-expression-evaluator/-/math-expression-evaluator-1.2.17.tgz#de819fdbcd84dccd8fae59c6aeb79615b9d266ac" -mem@^0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/mem/-/mem-0.1.1.tgz#24df988c3102b03c074c1b296239c5b2e6647825" +mem@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" + dependencies: + mimic-fn "^1.0.0" meow@^3.1.0: version "3.7.0" @@ -3914,6 +4010,12 @@ npm-run-path@^1.0.0: dependencies: path-key "^1.0.0" +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + dependencies: + path-key "^2.0.0" + "npmlog@0 || 1 || 2 || 3 || 4": version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" @@ -4005,12 +4107,11 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" -opn@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/opn/-/opn-4.0.2.tgz#7abc22e644dff63b0a96d5ab7f2790c0f01abc95" +opn@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/opn/-/opn-5.1.0.tgz#72ce2306a17dbea58ff1041853352b4a8fc77519" dependencies: - object-assign "^4.0.1" - pinkie-promise "^2.0.0" + is-wsl "^1.1.0" optimist@^0.6.1, optimist@~0.6.1: version "0.6.1" @@ -4074,6 +4175,10 @@ osenv@0: os-homedir "^1.0.0" os-tmpdir "^1.0.0" +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + p-limit@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc" @@ -4150,6 +4255,10 @@ path-key@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/path-key/-/path-key-1.0.0.tgz#5d53d578019646c0d68800db4e146e6bdc2ac7af" +path-key@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + path-parse@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" @@ -4180,6 +4289,10 @@ pify@^2.0.0, pify@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + pinkie-promise@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" @@ -5538,12 +5651,12 @@ url@~0.11.0: punycode "1.3.2" querystring "0.2.0" -username@^2.2.2: - version "2.3.0" - resolved "https://registry.yarnpkg.com/username/-/username-2.3.0.tgz#ba37dd53ac7d6225e77730fdd79244f1fc058e1e" +username@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/username/-/username-3.0.0.tgz#b3dba982a72b4ce59d52f159fa1aeba266af5fc8" dependencies: - execa "^0.4.0" - mem "^0.1.0" + execa "^0.7.0" + mem "^1.1.0" utf8-byte-length@^1.0.1: version "1.0.4"