diff --git a/web/src/background.js b/web/src/background.js index 097e9098..1db6f986 100644 --- a/web/src/background.js +++ b/web/src/background.js @@ -65,6 +65,34 @@ app.on('activate', () => { } }) +// Attempt to bind file opening #2 +// https://stackoverflow.com/questions/62420427/how-do-i-make-my-electron-app-the-default-for-opening-files +// https://github.com/rchrd2/example-electron-file-association +// https://www.jianshu.com/p/a32542277b83 +const initOpenFileQueue = [] +app.on('will-finish-launching', () => { + // Event fired When someone drags files onto the icon while your app is running + if (process.platform == 'win32') { + const argv = process.argv + if (argv) { + argv.forEach(filePath => { + if (filePath.indexOf('.apk') >= 0) { + initOpenFileQueue.push(filePath) + } + }) + } + } else { + app.on('open-file', (event, file) => { + if (app.isReady() === false) { + initOpenFileQueue.push(file) + } else { + console.log(file) + } + event.preventDefault() + }) + } +}) + app.on('ready', async () => { createMainWindow() bindEvent() diff --git a/web/vue.config.js b/web/vue.config.js index 5c8065c4..60ddcc24 100644 --- a/web/vue.config.js +++ b/web/vue.config.js @@ -21,86 +21,91 @@ module.exports = { copyright: 'Copyright © 思绪思维导图', // compression: "maximum", // 机器好的可以打开,配置压缩,开启后会让 .AppImage 格式的客户端启动缓慢 asar: true, - fileAssociations: { - ext: 'smm', - icon: './build/icons/icon.ico' - }, + fileAssociations: [ + { + ext: 'smm', + name: 'mind map file', + role: 'Editor', + icon: './build/icons/icon.ico' + } + ], publish: [ { provider: 'github', owner: 'wanglin2', repo: 'mind-map', vPrefixedTagName: true, - releaseType: 'draft', - }, + releaseType: 'draft' + } ], directories: { - output: 'dist_electron', + output: 'dist_electron' }, mac: { target: [ { target: 'dmg', - arch: ['x64', 'arm64', 'universal'], - }, + arch: ['x64', 'arm64', 'universal'] + } ], artifactName: '${productName}-${os}-${version}-${arch}.${ext}', category: 'public.app-category.utilities', - darkModeSupport: true, + darkModeSupport: true }, win: { target: [ { target: 'portable', - arch: ['x64'], + arch: ['x64'] }, { target: 'nsis', - arch: ['x64'], - }, + arch: ['x64'] + } ], publisherName: '思绪思维导图', icon: 'build/icons/icon.ico', - publish: ['github'], + publish: ['github'] }, linux: { target: [ { target: 'AppImage', - arch: ['x64'], + arch: ['x64'] }, { target: 'tar.gz', - arch: ['x64', 'arm64'], + arch: ['x64', 'arm64'] }, { target: 'deb', - arch: ['x64', 'armv7l', 'arm64'], + arch: ['x64', 'armv7l', 'arm64'] }, { target: 'rpm', - arch: ['x64'], + arch: ['x64'] }, { target: 'snap', - arch: ['x64'], + arch: ['x64'] }, { target: 'pacman', - arch: ['x64'], - }, + arch: ['x64'] + } ], category: 'Utilities', - icon: './build/icon.icns', + icon: './build/icon.icns' }, dmg: { - icon: 'build/icons/icon.icns', + icon: 'build/icons/icon.icns' }, nsis: { - oneClick: true, + oneClick: false, + allowToChangeInstallationDirectory: true, perMachine: true, - deleteAppDataOnUninstall: true, - }, + deleteAppDataOnUninstall: true + } }, // 渲染线程的配置文件 chainWebpackRendererProcess: config => {