Skip to content

Commit bc8e641

Browse files
committed
🐛 Fix: launch error in new structrue
1 parent 4e3fa28 commit bc8e641

File tree

3 files changed

+12
-72
lines changed

3 files changed

+12
-72
lines changed

src/background.ts

Lines changed: 9 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,3 @@
1-
// 'use strict'
2-
3-
// import { app, protocol, BrowserWindow } from 'electron'
4-
// import {
5-
// createProtocol,
6-
// installVueDevtools
7-
// } from 'vue-cli-plugin-electron-builder/lib'
8-
// const isDevelopment = process.env.NODE_ENV !== 'production'
9-
10-
// // Keep a global reference of the window object, if you don't, the window will
11-
// // be closed automatically when the JavaScript object is garbage collected.
12-
// let win: BrowserWindow | null
13-
14-
// // Scheme must be registered before the app is ready
15-
// protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }])
16-
17-
// function createWindow () {
18-
// // Create the browser window.
19-
// win = new BrowserWindow({ width: 800,
20-
// height: 600,
21-
// webPreferences: {
22-
// nodeIntegration: true
23-
// } })
24-
25-
// if (process.env.WEBPACK_DEV_SERVER_URL) {
26-
// // Load the url of the dev server if in development mode
27-
// win.loadURL(process.env.WEBPACK_DEV_SERVER_URL as string)
28-
// if (!process.env.IS_TEST) win.webContents.openDevTools()
29-
// } else {
30-
// createProtocol('app')
31-
// // Load the index.html when not in development
32-
// win.loadURL('app://./index.html')
33-
// }
34-
35-
// win.on('closed', () => {
36-
// win = null
37-
// })
38-
// }
39-
40-
// // Quit when all windows are closed.
41-
// app.on('window-all-closed', () => {
42-
// // On macOS it is common for applications and their menu bar
43-
// // to stay active until the user quits explicitly with Cmd + Q
44-
// if (process.platform !== 'darwin') {
45-
// app.quit()
46-
// }
47-
// })
48-
49-
// app.on('activate', () => {
50-
// // On macOS it's common to re-create a window in the app when the
51-
// // dock icon is clicked and there are no other windows open.
52-
// if (win === null) {
53-
// createWindow()
54-
// }
55-
// })
56-
57-
// // This method will be called when Electron has finished
58-
// // initialization and is ready to create browser windows.
59-
// // Some APIs can only be used after this event occurs.
60-
// app.on('ready', async () => {
61-
// if (isDevelopment && !process.env.IS_TEST) {
62-
// // Install Vue Devtools
63-
// try {
64-
// await installVueDevtools()
65-
// } catch (e) {
66-
// console.error('Vue Devtools failed to install:', e.toString())
67-
// }
68-
// }
69-
// createWindow()
70-
// })
71-
721
'use strict'
732

743
import Uploader from '~/main/utils/uploader'
@@ -108,8 +37,10 @@ import {
10837
shortKeyUpdater,
10938
initShortKeyRegister
11039
} from '~/main/utils/shortKeyHandler'
40+
import logger from '~/main/utils/logger'
41+
11142
const isDevelopment = process.env.NODE_ENV !== 'production'
112-
protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }])
43+
protocol.registerSchemesAsPrivileged([{ scheme: 'picgo', privileges: { secure: true, standard: true } }])
11344

11445
if (process.platform === 'darwin') {
11546
beforeOpen()
@@ -634,6 +565,7 @@ if (process.env.XDG_CURRENT_DESKTOP && process.env.XDG_CURRENT_DESKTOP.includes(
634565
}
635566

636567
app.on('ready', async () => {
568+
createProtocol('picgo')
637569
if (isDevelopment && !process.env.IS_TEST) {
638570
// Install Vue Devtools
639571
try {
@@ -658,6 +590,11 @@ app.on('ready', async () => {
658590

659591
if (process.env.NODE_ENV !== 'development') {
660592
let files = getUploadFiles()
593+
if (files === null) {
594+
logger.info('get clipboardFile, null')
595+
} else {
596+
logger.info(`get clipboardFile, ${files.toString()}`)
597+
}
661598
if (files === null || files.length > 0) { // 如果有文件列表作为参数,说明是命令行启动
662599
if (files === null) {
663600
uploadClipboardFiles()

src/renderer/router/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Router from 'vue-router'
44
Vue.use(Router)
55

66
export default new Router({
7+
mode: 'hash',
78
routes: [
89
{
910
path: '/',

vue.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ module.exports = {
1212
},
1313
pluginOptions: {
1414
electronBuilder: {
15+
customFileProtocol: 'picgo://./',
16+
externals: ['picgo'],
1517
chainWebpackMainProcess: config => {
1618
config.resolve.alias
1719
.set('@', resolve('src/renderer'))

0 commit comments

Comments
 (0)