提交 63545a72 编写于 作者: 郭维嘉

fix:添加dick图标

上级 5c334c66
...@@ -64,7 +64,7 @@ function startRenderer () { ...@@ -64,7 +64,7 @@ function startRenderer () {
{ {
contentBase: path.join(__dirname, '../'), contentBase: path.join(__dirname, '../'),
disableHostCheck: true, disableHostCheck: true,
host: 'quicker.csdn.net', host: '127.0.0.1',
quiet: true, quiet: true,
hot: true, hot: true,
before (app, ctx) { before (app, ctx) {
......
{ {
"name": "rubick2", "name": "Quicker",
"version": "0.0.12", "version": "0.0.1",
"author": "muwoo <2424880409@qq.com>", "author": "libai",
"description": "An electron-vue project", "description": "An electron-vue project",
"license": null, "license": null,
"main": "./dist/electron/main.js", "main": "./dist/electron/main.js",
......
...@@ -11,7 +11,7 @@ module.exports = () => { ...@@ -11,7 +11,7 @@ module.exports = () => {
let createWindow = opts => { let createWindow = opts => {
const winURL = const winURL =
process.env.NODE_ENV === "development" process.env.NODE_ENV === "development"
? `http://quicker.csdn.net:5501` ? `http://127.0.0.1:5501`
: `file://${__dirname}/index.html`; : `file://${__dirname}/index.html`;
win = new BrowserWindow({ win = new BrowserWindow({
...@@ -55,7 +55,7 @@ module.exports = () => { ...@@ -55,7 +55,7 @@ module.exports = () => {
win = undefined; win = undefined;
}); });
win.on("blur", () => { win.on("blur", () => {
win.hide(); // win.hide();
}); });
}; };
......
import { dialog, Menu, Tray, app, shell } from "electron";
import path from "path";
import pkg from "../../package.json";
import os from "os";
import { commonConst } from "./common/utils";
function createDock(window) {
return new Promise((resolve, reject) => {
let icon;
if (commonConst.macOS()) {
icon = "./rocket.png";
} else if (commonConst.windows()) {
icon = parseInt(os.release()) < 10 ? "./icon@2x.png" : "./icon.ico";
} else {
icon = "icon@2x.png";
}
const appIcon = path.join(__static, icon);
const dockMenu = Menu.buildFromTemplate([
{
label: "注册",
click() {
shell.openExternal("https://passport.csdn.net/newlogin?code=mobile");
}
},
{
label: "帮助文档",
click: () => {
process.nextTick(() => {
shell.openExternal(
"https://yre5673znb.feishu.cn/docs/doccnMnLv3iZ3epFvjXprnPum3b"
);
});
}
},
{
label: "意见反馈",
click: () => {
process.nextTick(() => {
shell.openExternal("https://www.wenjuan.com/s/UZBZJvmzhg/");
});
}
},
{ type: "separator" },
{
label: "显示窗口",
accelerator: "Alt+R",
click() {
window.show();
}
},
{
label: "偏好设置",
click() {
window.show();
window.webContents.send("tray-setting");
}
},
{
label: "关于",
click() {
dialog.showMessageBox({
title: "Quicker",
message: "即刻",
detail: `Version: ${pkg.version}\nAuthor: libai`
});
}
},
{ type: "separator" },
{
label: "重启",
click() {
app.relaunch();
app.quit();
}
},
{
role: "quit",
label: "退出"
}
]);
// appIcon.on("click", () => {
// appIcon.popUpContextMenu(contextMenu);
// });
// appIcon.setContextMenu(contextMenu);
// resolve(appIcon);
app.dock.setMenu(dockMenu);
app.dock.setIcon(appIcon);
resolve(app);
});
}
export default createDock;
import { app, globalShortcut } from 'electron' import { app, globalShortcut } from "electron";
import init from './common/common' import init from "./common/common";
import { autoUpdate } from './common/autoUpdate' import { autoUpdate } from "./common/autoUpdate";
import createTray from './tray' import createTray from "./tray";
import { commonConst } from './common/utils' import createDock from "./dock";
import pkg from '../../package.json' import { commonConst } from "./common/utils";
import Store from 'electron-store'; import pkg from "../../package.json";
import Store from "electron-store";
Store.initRenderer() Store.initRenderer();
const { main } = require("./browsers")() const { main } = require("./browsers")();
if (commonConst.production()) { if (commonConst.production()) {
global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') global.__static = require("path")
.join(__dirname, "/static")
.replace(/\\/g, "\\\\");
} }
// to fix https://github.com/electron/electron/issues/18397 // to fix https://github.com/electron/electron/issues/18397
app.allowRendererProcessReuse = false app.allowRendererProcessReuse = false;
class initApp { class initApp {
launchApp() { launchApp() {
const gotTheLock = app.requestSingleInstanceLock() const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) { if (!gotTheLock) {
app.quit() app.quit();
} else { } else {
this.beforeReady() this.beforeReady();
this.onReady() this.onReady();
this.onRunning() this.onRunning();
this.onQuit() this.onQuit();
} }
} }
createWindow() { createWindow() {
main.init() main.init();
init(main.getWindow()) init(main.getWindow());
} }
beforeReady() { beforeReady() {
// 系统托盘 // 系统托盘
if (commonConst.macOS()) { if (commonConst.macOS()) {
if (commonConst.production() && !app.isInApplicationsFolder()) { if (commonConst.production() && !app.isInApplicationsFolder()) {
app.moveToApplicationsFolder() app.moveToApplicationsFolder();
} else { } else {
app.dock.hide() // app.dock.hide()
} }
} else { } else {
app.disableHardwareAcceleration() app.moveToApplicationsFolder();
app.disableHardwareAcceleration();
} }
} }
onReady() { onReady() {
const readyFunction = () => { const readyFunction = () => {
this.createWindow() this.createWindow();
createTray(main.getWindow()) createTray(main.getWindow());
autoUpdate() createDock();
} autoUpdate();
};
if (!app.isReady()) { if (!app.isReady()) {
app.on('ready', readyFunction) app.on("ready", readyFunction);
} else { } else {
readyFunction() readyFunction();
} }
} }
onRunning() { onRunning() {
app.on('second-instance', (event, commandLine, workingDirectory) => { app.on("second-instance", (event, commandLine, workingDirectory) => {
// 当运行第二个实例时,将会聚焦到myWindow这个窗口 // 当运行第二个实例时,将会聚焦到myWindow这个窗口
const win = main.getWindow() const win = main.getWindow();
if (win) { if (win) {
if (win.isMinimized()) { if (win.isMinimized()) {
win.restore() win.restore();
} }
win.focus() win.focus();
} }
}) });
app.on('activate', () => { app.on("activate", () => {
if (!main.getWindow()) { if (!main.getWindow()) {
this.createWindow() this.createWindow();
} }
}) });
if (commonConst.windows()) { if (commonConst.windows()) {
app.setAppUserModelId(pkg.build.appId) app.setAppUserModelId(pkg.build.appId);
} }
} }
onQuit() { onQuit() {
app.on('window-all-closed', () => { app.on("window-all-closed", () => {
if (process.platform !== 'darwin') { if (process.platform !== "darwin") {
app.quit() app.quit();
} }
}) });
app.on('will-quit', () => { app.on("will-quit", () => {
globalShortcut.unregisterAll() globalShortcut.unregisterAll();
}) });
// Exit cleanly on request from parent process in development mode. // Exit cleanly on request from parent process in development mode.
if (commonConst.dev()) { if (commonConst.dev()) {
if (process.platform === 'win32') { if (process.platform === "win32") {
process.on('message', data => { process.on("message", data => {
if (data === 'graceful-exit') { if (data === "graceful-exit") {
app.quit() app.quit();
} }
}) });
} else { } else {
process.on('SIGTERM', () => { process.on("SIGTERM", () => {
app.quit() app.quit();
}) });
} }
} }
} }
} }
(new initApp()).launchApp() new initApp().launchApp();
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册