mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-27 23:52:50 +08:00
✨ open settings with tray
This commit is contained in:
parent
f69bc59130
commit
36b1fd5588
@ -1,7 +1,11 @@
|
||||
<template>
|
||||
<div class="main-container">
|
||||
<div class="slider-bar">
|
||||
<a-menu v-model:selectedKeys="active" mode="horizontal" @select="({key}) => changeMenu(key)">
|
||||
<a-menu
|
||||
v-model:selectedKeys="active"
|
||||
mode="horizontal"
|
||||
@select="({ key }) => changeMenu(key)"
|
||||
>
|
||||
<a-menu-item key="market">
|
||||
<template #icon>
|
||||
<AppstoreOutlined />
|
||||
@ -46,7 +50,7 @@ import {
|
||||
UserOutlined,
|
||||
AppstoreOutlined,
|
||||
SettingOutlined,
|
||||
BugOutlined,
|
||||
BugOutlined
|
||||
} from "@ant-design/icons-vue";
|
||||
import { useStore } from "vuex";
|
||||
const router = useRouter();
|
||||
@ -63,7 +67,6 @@ window.rubick.onPluginEnter(({ code }: { code: string }) => {
|
||||
const store = useStore();
|
||||
const init = () => store.dispatch("init");
|
||||
init();
|
||||
|
||||
</script>
|
||||
<style lang="less">
|
||||
* {
|
||||
@ -74,7 +77,7 @@ init();
|
||||
.main-container {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
background: #F2EFEF;
|
||||
background: #f2efef;
|
||||
flex-direction: column;
|
||||
|
||||
.slider-bar {
|
||||
|
@ -2,10 +2,11 @@ import { dialog, Menu, Tray, app, shell, BrowserWindow } from "electron";
|
||||
import path from "path";
|
||||
import pkg from "../../../package.json";
|
||||
import os from "os";
|
||||
import API from "../common/api";
|
||||
import commonConst from "@/common/utils/commonConst";
|
||||
|
||||
function createTray(window: BrowserWindow): Promise<Tray> {
|
||||
return new Promise((resolve) => {
|
||||
return new Promise(resolve => {
|
||||
let icon;
|
||||
if (commonConst.macOS()) {
|
||||
icon = "./icons/icon@3x.png";
|
||||
@ -24,6 +25,13 @@ function createTray(window: BrowserWindow): Promise<Tray> {
|
||||
return config.perf.shortCut.showAndHidden;
|
||||
};
|
||||
|
||||
const openSettings = () => {
|
||||
window.webContents.executeJavaScript(
|
||||
`window.rubick && window.rubick.openMenu && window.rubick.openMenu({ code: "settings" })`
|
||||
);
|
||||
window.show();
|
||||
};
|
||||
|
||||
const createContextMenu = () =>
|
||||
Menu.buildFromTemplate([
|
||||
{
|
||||
@ -32,7 +40,7 @@ function createTray(window: BrowserWindow): Promise<Tray> {
|
||||
process.nextTick(() => {
|
||||
shell.openExternal("https://github.com/clouDr-f2e/rubick");
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "意见反馈",
|
||||
@ -40,7 +48,7 @@ function createTray(window: BrowserWindow): Promise<Tray> {
|
||||
process.nextTick(() => {
|
||||
shell.openExternal("https://github.com/clouDr-f2e/rubick/issues");
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
@ -48,19 +56,27 @@ function createTray(window: BrowserWindow): Promise<Tray> {
|
||||
accelerator: getShowAndHiddenHotKey(),
|
||||
click() {
|
||||
window.show();
|
||||
},
|
||||
}
|
||||
},
|
||||
{
|
||||
label: "系统设置",
|
||||
click() {
|
||||
openSettings();
|
||||
}
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
role: "quit",
|
||||
label: "退出",
|
||||
label: "退出"
|
||||
},
|
||||
{
|
||||
label: "重启",
|
||||
click() {
|
||||
app.relaunch();
|
||||
app.quit();
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: "关于",
|
||||
@ -68,10 +84,10 @@ function createTray(window: BrowserWindow): Promise<Tray> {
|
||||
dialog.showMessageBox({
|
||||
title: "拉比克",
|
||||
message: "极简、插件化的现代桌面软件",
|
||||
detail: `Version: ${pkg.version}\nAuthor: muwoo`,
|
||||
detail: `Version: ${pkg.version}\nAuthor: muwoo`
|
||||
});
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
]);
|
||||
appIcon.on("click", () => {
|
||||
appIcon.setContextMenu(createContextMenu());
|
||||
|
@ -97,14 +97,17 @@ const changeIndex = index => {
|
||||
currentSelect.value = currentSelect.value + index;
|
||||
};
|
||||
|
||||
const openMenu = () => {
|
||||
const openMenu = (ext) => {
|
||||
openPlugin({
|
||||
...toRaw(menuPluginInfo.value),
|
||||
feature: menuPluginInfo.value.features[0],
|
||||
cmd: "插件市场"
|
||||
cmd: "插件市场",
|
||||
ext
|
||||
});
|
||||
};
|
||||
|
||||
window.rubick.openMenu = openMenu
|
||||
|
||||
const choosePlugin = () => {
|
||||
const currentChoose = options.value[currentSelect.value];
|
||||
currentChoose.click();
|
||||
|
Loading…
x
Reference in New Issue
Block a user