mirror of
https://github.com/rubickCenter/rubick
synced 2025-06-28 16:42:47 +08:00
✨ 支持窗口记忆#216;支持本地启动;支持搜索历史记录
This commit is contained in:
parent
c21c08c370
commit
c7eb266002
@ -9,7 +9,10 @@
|
|||||||
</template>
|
</template>
|
||||||
<a-list-item-meta :description="item.desc">
|
<a-list-item-meta :description="item.desc">
|
||||||
<template #title>
|
<template #title>
|
||||||
<div>{{item.name}}</div>
|
<div>
|
||||||
|
<span :class="item.del ? 'del-title' : ''">{{item.name}}</span>
|
||||||
|
<span v-if="item.del" class="has-del">文件不存在</span>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #avatar>
|
<template #avatar>
|
||||||
<a-avatar shape="square" :src="item.icon" />
|
<a-avatar shape="square" :src="item.icon" />
|
||||||
@ -23,19 +26,39 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
const fs = window.require('fs');
|
||||||
|
|
||||||
const dbId = 'rubick-local-start-app';
|
const dbId = 'rubick-local-start-app';
|
||||||
|
|
||||||
const localStartList = ref(window.rubick.dbStorage.getItem(dbId) || []);
|
const localStartList = ref(window.rubick.dbStorage.getItem(dbId) || []);
|
||||||
|
|
||||||
|
const checkFileExists = () => {
|
||||||
|
localStartList.value = localStartList.value.map((plugin) => {
|
||||||
|
if (!fs.existsSync(plugin.desc)) {
|
||||||
|
return {
|
||||||
|
...plugin,
|
||||||
|
del: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return plugin;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
checkFileExists();
|
||||||
|
|
||||||
const dropFile = (e) => {
|
const dropFile = (e) => {
|
||||||
const files = Array.from(e.dataTransfer.files).map((file) => {
|
const files = Array.from(e.dataTransfer.files).map((file) => {
|
||||||
|
const action =
|
||||||
|
process.platform === 'win32'
|
||||||
|
? `start "dummyclient" "${file.path}"`
|
||||||
|
: `open ${file.path.replace(/ /g, '\\ ')}`;
|
||||||
const plugin = {
|
const plugin = {
|
||||||
icon: window.rubick.getFileIcon(file.path),
|
icon: window.rubick.getFileIcon(file.path),
|
||||||
value: 'plugin',
|
value: 'plugin',
|
||||||
desc: file.path,
|
desc: file.path,
|
||||||
pluginType: 'app',
|
pluginType: 'app',
|
||||||
name: file.name,
|
name: file.name,
|
||||||
action: `open ${file.path.replace(/ /g, '\\ ')}`,
|
action,
|
||||||
keyWords: [file.name],
|
keyWords: [file.name],
|
||||||
names: [file.name],
|
names: [file.name],
|
||||||
};
|
};
|
||||||
@ -46,12 +69,20 @@ const dropFile = (e) => {
|
|||||||
...localStartList.value,
|
...localStartList.value,
|
||||||
...files,
|
...files,
|
||||||
];
|
];
|
||||||
window.rubick.dbStorage.setItem(dbId, JSON.parse(JSON.stringify(localStartList.value)));
|
window.rubick.dbStorage.setItem(
|
||||||
|
dbId,
|
||||||
|
JSON.parse(JSON.stringify(localStartList.value))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const remove = (item) => {
|
const remove = (item) => {
|
||||||
localStartList.value = localStartList.value.filter(app => app.desc !== item.desc);
|
localStartList.value = localStartList.value.filter(
|
||||||
window.rubick.dbStorage.setItem(dbId, JSON.parse(JSON.stringify(localStartList.value)));
|
(app) => app.desc !== item.desc
|
||||||
|
);
|
||||||
|
window.rubick.dbStorage.setItem(
|
||||||
|
dbId,
|
||||||
|
JSON.parse(JSON.stringify(localStartList.value))
|
||||||
|
);
|
||||||
window.market.removeLocalStartPlugin(JSON.parse(JSON.stringify(item)));
|
window.market.removeLocalStartPlugin(JSON.parse(JSON.stringify(item)));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,5 +98,14 @@ const checkDrop = (e) => {
|
|||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
background: var(--color-body-bg);
|
background: var(--color-body-bg);
|
||||||
height: calc(~'100vh - 106px');
|
height: calc(~'100vh - 106px');
|
||||||
|
.del-title {
|
||||||
|
text-decoration-line: line-through;
|
||||||
|
text-decoration-color: var(--ant-error-color);
|
||||||
|
}
|
||||||
|
.has-del {
|
||||||
|
color: var(--ant-error-color);
|
||||||
|
font-size: 12px;
|
||||||
|
margin-left: 6px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -9,8 +9,6 @@ import {
|
|||||||
screen,
|
screen,
|
||||||
shell,
|
shell,
|
||||||
} from 'electron';
|
} from 'electron';
|
||||||
import { runner, detach } from '../browsers';
|
|
||||||
import DBInstance from './db';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { screenCapture } from '@/core';
|
import { screenCapture } from '@/core';
|
||||||
import plist from 'plist';
|
import plist from 'plist';
|
||||||
@ -20,6 +18,10 @@ import { DECODE_KEY } from '@/common/constans/main';
|
|||||||
import getCopyFiles from '@/common/utils/getCopyFiles';
|
import getCopyFiles from '@/common/utils/getCopyFiles';
|
||||||
|
|
||||||
import mainInstance from '../index';
|
import mainInstance from '../index';
|
||||||
|
import { runner, detach } from '../browsers';
|
||||||
|
import DBInstance from './db';
|
||||||
|
import getWinPosition from './getWinPosition';
|
||||||
|
|
||||||
const runnerInstance = runner();
|
const runnerInstance = runner();
|
||||||
const detachInstance = detach();
|
const detachInstance = detach();
|
||||||
|
|
||||||
@ -65,6 +67,7 @@ class API extends DBInstance {
|
|||||||
const originWindow = this.getCurrentWindow(window, e);
|
const originWindow = this.getCurrentWindow(window, e);
|
||||||
if (!originWindow) return;
|
if (!originWindow) return;
|
||||||
originWindow.setBounds({ x: x - mouseX, y: y - mouseY, width, height });
|
originWindow.setBounds({ x: x - mouseX, y: y - mouseY, width, height });
|
||||||
|
getWinPosition.setPosition(x - mouseX, y - mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadPlugin({ data: plugin }, window) {
|
public loadPlugin({ data: plugin }, window) {
|
||||||
|
34
src/main/common/getWinPosition.ts
Normal file
34
src/main/common/getWinPosition.ts
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { screen } from 'electron';
|
||||||
|
|
||||||
|
const winPosition = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
id: -1,
|
||||||
|
getPosition(): { x: number; y: number } {
|
||||||
|
const { x, y } = screen.getCursorScreenPoint();
|
||||||
|
const currentDisplay = screen.getDisplayNearestPoint({ x, y });
|
||||||
|
if (winPosition.id !== currentDisplay.id) {
|
||||||
|
winPosition.id = currentDisplay.id;
|
||||||
|
winPosition.x = parseInt(
|
||||||
|
String(
|
||||||
|
currentDisplay.workArea.x + currentDisplay.workArea.width / 2 - 400
|
||||||
|
)
|
||||||
|
);
|
||||||
|
winPosition.y = parseInt(
|
||||||
|
String(
|
||||||
|
currentDisplay.workArea.y + currentDisplay.workArea.height / 2 - 200
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
x: winPosition.x,
|
||||||
|
y: winPosition.y,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
setPosition(x: number, y: number): void {
|
||||||
|
winPosition.x = x;
|
||||||
|
winPosition.y = y;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default winPosition;
|
@ -10,6 +10,7 @@ import {
|
|||||||
} from 'electron';
|
} from 'electron';
|
||||||
import screenCapture from '@/core/screen-capture';
|
import screenCapture from '@/core/screen-capture';
|
||||||
import localConfig from '@/main/common/initLocalConfig';
|
import localConfig from '@/main/common/initLocalConfig';
|
||||||
|
import winPosition from './getWinPosition';
|
||||||
|
|
||||||
const registerHotKey = (mainWindow: BrowserWindow): void => {
|
const registerHotKey = (mainWindow: BrowserWindow): void => {
|
||||||
// 设置开机启动
|
// 设置开机启动
|
||||||
@ -56,20 +57,7 @@ const registerHotKey = (mainWindow: BrowserWindow): void => {
|
|||||||
globalShortcut.register(config.perf.shortCut.showAndHidden, () => {
|
globalShortcut.register(config.perf.shortCut.showAndHidden, () => {
|
||||||
const currentShow = mainWindow.isVisible() && mainWindow.isFocused();
|
const currentShow = mainWindow.isVisible() && mainWindow.isFocused();
|
||||||
if (currentShow) return mainWindow.hide();
|
if (currentShow) return mainWindow.hide();
|
||||||
|
const { x: wx, y: wy } = winPosition.getPosition();
|
||||||
const { x, y } = screen.getCursorScreenPoint();
|
|
||||||
const currentDisplay = screen.getDisplayNearestPoint({ x, y });
|
|
||||||
const wx = parseInt(
|
|
||||||
String(
|
|
||||||
currentDisplay.workArea.x + currentDisplay.workArea.width / 2 - 400
|
|
||||||
)
|
|
||||||
);
|
|
||||||
const wy = parseInt(
|
|
||||||
String(
|
|
||||||
currentDisplay.workArea.y + currentDisplay.workArea.height / 2 - 200
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
mainWindow.setAlwaysOnTop(false);
|
mainWindow.setAlwaysOnTop(false);
|
||||||
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true });
|
||||||
mainWindow.focus();
|
mainWindow.focus();
|
||||||
|
@ -9,6 +9,7 @@ import { execSync } from 'child_process';
|
|||||||
import searchManager from './search';
|
import searchManager from './search';
|
||||||
import optionsManager from './options';
|
import optionsManager from './options';
|
||||||
import { PLUGIN_INSTALL_DIR as baseDir } from '@/common/constans/renderer';
|
import { PLUGIN_INSTALL_DIR as baseDir } from '@/common/constans/renderer';
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
const createPluginManager = (): any => {
|
const createPluginManager = (): any => {
|
||||||
const pluginInstance = new PluginHandler({
|
const pluginInstance = new PluginHandler({
|
||||||
@ -87,7 +88,11 @@ const createPluginManager = (): any => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (plugin.pluginType === 'app') {
|
if (plugin.pluginType === 'app') {
|
||||||
execSync(plugin.action);
|
try {
|
||||||
|
execSync(plugin.action);
|
||||||
|
} catch (e) {
|
||||||
|
message.error('启动应用出错,请确保启动应用存在!');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.initRubick();
|
window.initRubick();
|
||||||
changePluginHistory({
|
changePluginHistory({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user