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

fix:添加dick图标

上级 5c334c66
......@@ -64,7 +64,7 @@ function startRenderer () {
{
contentBase: path.join(__dirname, '../'),
disableHostCheck: true,
host: 'quicker.csdn.net',
host: '127.0.0.1',
quiet: true,
hot: true,
before (app, ctx) {
......
{
"name": "rubick2",
"version": "0.0.12",
"author": "muwoo <2424880409@qq.com>",
"name": "Quicker",
"version": "0.0.1",
"author": "libai",
"description": "An electron-vue project",
"license": null,
"main": "./dist/electron/main.js",
......
......@@ -11,7 +11,7 @@ module.exports = () => {
let createWindow = opts => {
const winURL =
process.env.NODE_ENV === "development"
? `http://quicker.csdn.net:5501`
? `http://127.0.0.1:5501`
: `file://${__dirname}/index.html`;
win = new BrowserWindow({
......@@ -55,7 +55,7 @@ module.exports = () => {
win = undefined;
});
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 init from './common/common'
import { autoUpdate } from './common/autoUpdate'
import createTray from './tray'
import { commonConst } from './common/utils'
import pkg from '../../package.json'
import Store from 'electron-store';
import { app, globalShortcut } from "electron";
import init from "./common/common";
import { autoUpdate } from "./common/autoUpdate";
import createTray from "./tray";
import createDock from "./dock";
import { commonConst } from "./common/utils";
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()) {
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
app.allowRendererProcessReuse = false
app.allowRendererProcessReuse = false;
class initApp {
launchApp() {
const gotTheLock = app.requestSingleInstanceLock()
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit()
app.quit();
} else {
this.beforeReady()
this.onReady()
this.onRunning()
this.onQuit()
this.beforeReady();
this.onReady();
this.onRunning();
this.onQuit();
}
}
createWindow() {
main.init()
init(main.getWindow())
main.init();
init(main.getWindow());
}
beforeReady() {
// 系统托盘
if (commonConst.macOS()) {
if (commonConst.production() && !app.isInApplicationsFolder()) {
app.moveToApplicationsFolder()
app.moveToApplicationsFolder();
} else {
app.dock.hide()
// app.dock.hide()
}
} else {
app.disableHardwareAcceleration()
app.moveToApplicationsFolder();
app.disableHardwareAcceleration();
}
}
onReady() {
const readyFunction = () => {
this.createWindow()
createTray(main.getWindow())
autoUpdate()
}
this.createWindow();
createTray(main.getWindow());
createDock();
autoUpdate();
};
if (!app.isReady()) {
app.on('ready', readyFunction)
app.on("ready", readyFunction);
} else {
readyFunction()
readyFunction();
}
}
onRunning() {
app.on('second-instance', (event, commandLine, workingDirectory) => {
app.on("second-instance", (event, commandLine, workingDirectory) => {
// 当运行第二个实例时,将会聚焦到myWindow这个窗口
const win = main.getWindow()
const win = main.getWindow();
if (win) {
if (win.isMinimized()) {
win.restore()
win.restore();
}
win.focus()
win.focus();
}
})
app.on('activate', () => {
});
app.on("activate", () => {
if (!main.getWindow()) {
this.createWindow()
this.createWindow();
}
})
});
if (commonConst.windows()) {
app.setAppUserModelId(pkg.build.appId)
app.setAppUserModelId(pkg.build.appId);
}
}
onQuit() {
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
})
});
app.on('will-quit', () => {
globalShortcut.unregisterAll()
})
app.on("will-quit", () => {
globalShortcut.unregisterAll();
});
// Exit cleanly on request from parent process in development mode.
if (commonConst.dev()) {
if (process.platform === 'win32') {
process.on('message', data => {
if (data === 'graceful-exit') {
app.quit()
if (process.platform === "win32") {
process.on("message", data => {
if (data === "graceful-exit") {
app.quit();
}
})
});
} else {
process.on('SIGTERM', () => {
app.quit()
})
process.on("SIGTERM", () => {
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.
先完成此消息的编辑!
想要评论请 注册