From bc8e641fdac7691d25b0b3d57fa1593a544a7532 Mon Sep 17 00:00:00 2001 From: Molunerfinn Date: Fri, 20 Dec 2019 18:46:39 +0800 Subject: [PATCH] :bug: Fix: launch error in new structrue --- src/background.ts | 81 ++++-------------------------------- src/renderer/router/index.ts | 1 + vue.config.js | 2 + 3 files changed, 12 insertions(+), 72 deletions(-) diff --git a/src/background.ts b/src/background.ts index 57f3db9..772fe28 100644 --- a/src/background.ts +++ b/src/background.ts @@ -1,74 +1,3 @@ -// 'use strict' - -// import { app, protocol, BrowserWindow } from 'electron' -// import { -// createProtocol, -// installVueDevtools -// } from 'vue-cli-plugin-electron-builder/lib' -// const isDevelopment = process.env.NODE_ENV !== 'production' - -// // Keep a global reference of the window object, if you don't, the window will -// // be closed automatically when the JavaScript object is garbage collected. -// let win: BrowserWindow | null - -// // Scheme must be registered before the app is ready -// protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }]) - -// function createWindow () { -// // Create the browser window. -// win = new BrowserWindow({ width: 800, -// height: 600, -// webPreferences: { -// nodeIntegration: true -// } }) - -// if (process.env.WEBPACK_DEV_SERVER_URL) { -// // Load the url of the dev server if in development mode -// win.loadURL(process.env.WEBPACK_DEV_SERVER_URL as string) -// if (!process.env.IS_TEST) win.webContents.openDevTools() -// } else { -// createProtocol('app') -// // Load the index.html when not in development -// win.loadURL('app://./index.html') -// } - -// win.on('closed', () => { -// win = null -// }) -// } - -// // Quit when all windows are closed. -// app.on('window-all-closed', () => { -// // On macOS it is common for applications and their menu bar -// // to stay active until the user quits explicitly with Cmd + Q -// if (process.platform !== 'darwin') { -// app.quit() -// } -// }) - -// app.on('activate', () => { -// // On macOS it's common to re-create a window in the app when the -// // dock icon is clicked and there are no other windows open. -// if (win === null) { -// createWindow() -// } -// }) - -// // This method will be called when Electron has finished -// // initialization and is ready to create browser windows. -// // Some APIs can only be used after this event occurs. -// app.on('ready', async () => { -// if (isDevelopment && !process.env.IS_TEST) { -// // Install Vue Devtools -// try { -// await installVueDevtools() -// } catch (e) { -// console.error('Vue Devtools failed to install:', e.toString()) -// } -// } -// createWindow() -// }) - 'use strict' import Uploader from '~/main/utils/uploader' @@ -108,8 +37,10 @@ import { shortKeyUpdater, initShortKeyRegister } from '~/main/utils/shortKeyHandler' +import logger from '~/main/utils/logger' + const isDevelopment = process.env.NODE_ENV !== 'production' -protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }]) +protocol.registerSchemesAsPrivileged([{ scheme: 'picgo', privileges: { secure: true, standard: true } }]) if (process.platform === 'darwin') { beforeOpen() @@ -634,6 +565,7 @@ if (process.env.XDG_CURRENT_DESKTOP && process.env.XDG_CURRENT_DESKTOP.includes( } app.on('ready', async () => { + createProtocol('picgo') if (isDevelopment && !process.env.IS_TEST) { // Install Vue Devtools try { @@ -658,6 +590,11 @@ app.on('ready', async () => { if (process.env.NODE_ENV !== 'development') { let files = getUploadFiles() + if (files === null) { + logger.info('get clipboardFile, null') + } else { + logger.info(`get clipboardFile, ${files.toString()}`) + } if (files === null || files.length > 0) { // 如果有文件列表作为参数,说明是命令行启动 if (files === null) { uploadClipboardFiles() diff --git a/src/renderer/router/index.ts b/src/renderer/router/index.ts index 67c13e8..4378a67 100644 --- a/src/renderer/router/index.ts +++ b/src/renderer/router/index.ts @@ -4,6 +4,7 @@ import Router from 'vue-router' Vue.use(Router) export default new Router({ + mode: 'hash', routes: [ { path: '/', diff --git a/vue.config.js b/vue.config.js index d91e023..b60f00e 100644 --- a/vue.config.js +++ b/vue.config.js @@ -12,6 +12,8 @@ module.exports = { }, pluginOptions: { electronBuilder: { + customFileProtocol: 'picgo://./', + externals: ['picgo'], chainWebpackMainProcess: config => { config.resolve.alias .set('@', resolve('src/renderer'))