Skip to content

Commit

Permalink
fix: 🐛 修复一些bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rojer95 committed Mar 6, 2022
1 parent 8184e5c commit 473aba1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"dependencies": {
"antd": "^3.19.5",
"axios": "^0.19.1",
"electron-localshortcut": "^3.2.1",
"mobx": "^5.15.2",
"mobx-react": "^6.1.5",
"react": "^16.8.6",
Expand Down Expand Up @@ -64,6 +65,7 @@
]
},
"mac": {
"identity": null,
"icon": "./src/favicon.icns"
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/apis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export const getSid = () => {
});
};
export const lrc = (url, title) => {
if (url && url.indexOf('file') >= 0) {
console.log('url', url);
return request(url);
}
return request('/lrc', {
baseURL: API,
params: { title },
Expand Down
24 changes: 23 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Modules to control application life and create native browser window
const { app, BrowserWindow, Menu, ipcMain, Tray } = require('electron');
const path = require('path');
const localShortcut = require('electron-localshortcut');

// 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.
Expand All @@ -22,7 +23,6 @@ function createWindow() {
mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
});

Menu.setApplicationMenu(null);
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1000,
Expand All @@ -45,6 +45,28 @@ function createWindow() {
}
// and load the index.html of the app.

if (process.platform === 'darwin') {
console.log('process.platform', process.platform);
let contents = mainWindow.webContents;
localShortcut.register(mainWindow, 'CommandOrControl+A', () => {
contents.selectAll();
});

localShortcut.register(mainWindow, 'CommandOrControl+C', () => {
contents.copy();
});

localShortcut.register(mainWindow, 'CommandOrControl+V', () => {
contents.paste();
});

localShortcut.register(mainWindow, 'CommandOrControl+X', () => {
contents.cut();
});
}

Menu.setApplicationMenu(Menu.buildFromTemplate([]));

// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
Expand Down
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5829,6 +5829,21 @@ electron-download@^3.0.1:
semver "^5.3.0"
sumchecker "^1.2.0"

electron-is-accelerator@^0.1.0:
version "0.1.2"
resolved "https://registry.npmmirror.com/electron-is-accelerator/-/electron-is-accelerator-0.1.2.tgz#509e510c26a56b55e17f863a4b04e111846ab27b"
integrity sha512-fLGSAjXZtdn1sbtZxx52+krefmtNuVwnJCV2gNiVt735/ARUboMl8jnNC9fZEqQdlAv2ZrETfmBUsoQci5evJA==

electron-localshortcut@^3.2.1:
version "3.2.1"
resolved "https://registry.npmmirror.com/electron-localshortcut/-/electron-localshortcut-3.2.1.tgz#cfc83a3eff5e28faf98ddcc87f80a2ce4f623cd3"
integrity sha512-DWvhKv36GsdXKnaFFhEiK8kZZA+24/yFLgtTwJJHc7AFgDjNRIBJZ/jq62Y/dWv9E4ypYwrVWN2bVrCYw1uv7Q==
dependencies:
debug "^4.0.1"
electron-is-accelerator "^0.1.0"
keyboardevent-from-electron-accelerator "^2.0.0"
keyboardevents-areequal "^0.2.1"

electron-osx-sign@0.4.11:
version "0.4.11"
resolved "https://registry.npm.taobao.org/electron-osx-sign/download/electron-osx-sign-0.4.11.tgz#8377732fe7b207969f264b67582ee47029ce092f"
Expand Down Expand Up @@ -10438,6 +10453,16 @@ jsx-ast-utils@^2.0.1, jsx-ast-utils@^2.1.0, jsx-ast-utils@^2.4.1:
array-includes "^3.1.1"
object.assign "^4.1.0"

keyboardevent-from-electron-accelerator@^2.0.0:
version "2.0.0"
resolved "https://registry.npmmirror.com/keyboardevent-from-electron-accelerator/-/keyboardevent-from-electron-accelerator-2.0.0.tgz#ace21b1aa4e47148815d160057f9edb66567c50c"
integrity sha512-iQcmNA0M4ETMNi0kG/q0h/43wZk7rMeKYrXP7sqKIJbHkTU8Koowgzv+ieR/vWJbOwxx5nDC3UnudZ0aLSu4VA==

keyboardevents-areequal@^0.2.1:
version "0.2.2"
resolved "https://registry.npmmirror.com/keyboardevents-areequal/-/keyboardevents-areequal-0.2.2.tgz#88191ec738ce9f7591c25e9056de928b40277194"
integrity sha512-Nv+Kr33T0mEjxR500q+I6IWisOQ0lK1GGOncV0kWE6n4KFmpcu7RUX5/2B0EUtX51Cb0HjZ9VJsSY3u4cBa0kw==

keycode@^2.2.0:
version "2.2.1"
resolved "https://registry.npmmirror.com/keycode/download/keycode-2.2.1.tgz#09c23b2be0611d26117ea2501c2c391a01f39eff"
Expand Down

0 comments on commit 473aba1

Please sign in to comment.