use own app protocol impl

This commit is contained in:
Alexander Drozdov
2021-04-17 12:49:29 +03:00
parent e222b9f215
commit acffc51117
2 changed files with 7 additions and 2 deletions
-2
View File
@@ -1,7 +1,6 @@
'use strict'
import { app, protocol, ipcMain, screen } from 'electron'
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
import { setupShortcuts } from './main/shortcuts'
import { createTray } from './main/tray'
@@ -54,7 +53,6 @@ app.on('ready', async () => {
}
}
createProtocol('app')
createFileProtocol()
setupConfigEvents()
+7
View File
@@ -1,10 +1,17 @@
import { protocol, app, ipcMain } from 'electron'
import { IMPORT_FILE } from '@/ipc/ipc-event'
import { URL } from 'url'
import path from 'path'
import crypto from 'crypto'
import fs from 'fs'
export function createFileProtocol () {
protocol.registerFileProtocol('app', (req, resp) => {
const url = new URL(req.url)
const pathName = path.join(url.host, url.pathname)
resp({ path: path.join(__dirname, pathName) })
})
protocol.registerFileProtocol('app-file', (req, resp) => {
resp({ path: path.join(app.getPath('userData'), 'apt-data/files', req.url.substr('app-file://'.length)) })
})