Skip to content

Commit

Permalink
🐛 Fix: launch error in new structrue
Browse files Browse the repository at this point in the history
  • Loading branch information
Molunerfinn committed Dec 20, 2019
1 parent 4e3fa28 commit bc8e641
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 72 deletions.
81 changes: 9 additions & 72 deletions src/background.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/renderer/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Router from 'vue-router'
Vue.use(Router)

export default new Router({
mode: 'hash',
routes: [
{
path: '/',
Expand Down
2 changes: 2 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module.exports = {
},
pluginOptions: {
electronBuilder: {
customFileProtocol: 'picgo://./',
externals: ['picgo'],
chainWebpackMainProcess: config => {
config.resolve.alias
.set('@', resolve('src/renderer'))
Expand Down

0 comments on commit bc8e641

Please sign in to comment.