mirror of
https://github.com/fanchenio/DawnLauncher.git
synced 2025-07-13 21:02:10 +08:00
quick search add delete history.
This commit is contained in:
parent
52847f8629
commit
235f964198
@ -90,6 +90,7 @@ let simplifiedChinese = {
|
||||
deleteClassificationPrompt: "是否删除当前分类?",
|
||||
deleteIcon: "删除图标",
|
||||
deleteItemPrompt: "是否删除当前项目?",
|
||||
deleteHistory: "删除历史记录",
|
||||
description: "描述",
|
||||
display: "显示",
|
||||
displayMainWindow: "显示主界面",
|
||||
@ -397,6 +398,7 @@ let traditionalChinese = {
|
||||
deleteClassificationPrompt: "是否刪除當前分類?",
|
||||
deleteIcon: "刪除圖標",
|
||||
deleteItemPrompt: "是否刪除當前項目?",
|
||||
deleteHistory: "刪除歷史記錄",
|
||||
description: "描述",
|
||||
display: "顯示",
|
||||
displayMainWindow: "顯示主界面",
|
||||
@ -710,6 +712,7 @@ let english = {
|
||||
deleteClassificationPrompt: "Delete current classification?",
|
||||
deleteIcon: "Delete Icon",
|
||||
deleteItemPrompt: "Delete current item?",
|
||||
deleteHistory: "Delete History",
|
||||
description: "Description",
|
||||
display: "Display",
|
||||
displayMainWindow: "Display Main Interface",
|
||||
|
@ -664,6 +664,35 @@ function clearOpenInfo(item: Item) {
|
||||
item.data.quickSearchLastOpen = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除历史记录
|
||||
* @param itemId
|
||||
*/
|
||||
function deleteQuickSearchHistory(itemId: number) {
|
||||
// 查询
|
||||
let item = selectById(itemId);
|
||||
if (item) {
|
||||
// 重置历史记录
|
||||
item.data.quickSearchLastOpen = 0;
|
||||
item.data.quickSearchOpenNumber = 0;
|
||||
// 更新
|
||||
updateData(itemId, item.data);
|
||||
// 通知主页面
|
||||
sendToWebContent("mainWindow", "onUpdateOpenInfo", {
|
||||
id: itemId,
|
||||
quickSearchOpenNumber: item.data.quickSearchOpenNumber,
|
||||
quickSearchLastOpen: item.data.quickSearchLastOpen,
|
||||
type: "quickSearch",
|
||||
});
|
||||
// 通知快速搜索页面
|
||||
sendToWebContent("quickSearchWindow", "onUpdateOpenInfo", {
|
||||
id: itemId,
|
||||
quickSearchOpenNumber: item.data.quickSearchOpenNumber,
|
||||
quickSearchLastOpen: item.data.quickSearchLastOpen,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
createAddEditWindow,
|
||||
createNetworkIconWindow,
|
||||
@ -681,4 +710,5 @@ export {
|
||||
getClipboardImageFile,
|
||||
pasteIcon,
|
||||
checkInvalid,
|
||||
deleteQuickSearchHistory,
|
||||
};
|
||||
|
@ -5,6 +5,7 @@ import {
|
||||
ipcMain,
|
||||
clipboard,
|
||||
MenuItemConstructorOptions,
|
||||
screen,
|
||||
} from "electron";
|
||||
import { getAbsolutePath } from "../../commons/utils";
|
||||
import {
|
||||
@ -22,6 +23,7 @@ import {
|
||||
getClipboardImageFile,
|
||||
pasteIcon,
|
||||
updateOpenInfo,
|
||||
deleteQuickSearchHistory,
|
||||
} from ".";
|
||||
import {
|
||||
getAppxItemList,
|
||||
@ -171,6 +173,8 @@ export default function () {
|
||||
if (!classification) {
|
||||
return;
|
||||
}
|
||||
// 鼠标位置
|
||||
let point = global.addon.getCursorPoint();
|
||||
// 菜单
|
||||
let menuList: Array<MenuItem> = [];
|
||||
// 组装菜单
|
||||
@ -184,7 +188,10 @@ export default function () {
|
||||
}
|
||||
// "打开"菜单
|
||||
let openMenu = false;
|
||||
if (item.type === 0 && ext && (ext === "exe" || ext === "bat")) {
|
||||
if (
|
||||
(item.type === 0 && ext && (ext === "exe" || ext === "bat")) ||
|
||||
item.type === 4
|
||||
) {
|
||||
menuList.push(
|
||||
new MenuItem({
|
||||
label: global.language.runAsAdministrator,
|
||||
@ -233,10 +240,12 @@ export default function () {
|
||||
label: global.language.explorerMenu,
|
||||
click: () => {
|
||||
// 获取当前窗口所在屏幕
|
||||
let screen = getWindowInScreen();
|
||||
let display = getWindowInScreen(
|
||||
type === "main" ? global.mainWindow : global.quickSearchWindow
|
||||
);
|
||||
let scaleFactor = 1;
|
||||
if (screen && screen.length > 0) {
|
||||
scaleFactor = screen[0].scaleFactor;
|
||||
if (display && display.length > 0) {
|
||||
scaleFactor = display[0].scaleFactor;
|
||||
}
|
||||
// 弹出资源管理器菜单
|
||||
sendToWebContent(
|
||||
@ -251,12 +260,17 @@ export default function () {
|
||||
global.addon.disableMouseHook();
|
||||
// 弹出资源管理器菜单
|
||||
global.addon.explorerContextMenu(
|
||||
global.mainWindow.getNativeWindowHandle().readInt32LE(0),
|
||||
(type === "main"
|
||||
? global.mainWindow
|
||||
: global.quickSearchWindow
|
||||
)
|
||||
.getNativeWindowHandle()
|
||||
.readInt32LE(0),
|
||||
item.type === 0 || item.type === 1
|
||||
? getAbsolutePath(item.data.target)
|
||||
: item.data.target,
|
||||
args.x * scaleFactor,
|
||||
args.y * scaleFactor
|
||||
point[0],
|
||||
point[1]
|
||||
);
|
||||
// 开启鼠标HOOK
|
||||
global.addon.enableMouseHook();
|
||||
@ -310,7 +324,7 @@ export default function () {
|
||||
);
|
||||
pathMenu = true;
|
||||
}
|
||||
if (item.type === 0 || item.type === 1 || item.type === 2) {
|
||||
if (item.type === 0 || item.type === 1) {
|
||||
menuList.push(
|
||||
new MenuItem({
|
||||
label: global.language.createShortcut,
|
||||
@ -677,4 +691,8 @@ export default function () {
|
||||
ipcMain.on("updateItemOpenInfo", (event, args) => {
|
||||
updateOpenInfo(args.type, args.id);
|
||||
});
|
||||
// 删除历史记录
|
||||
ipcMain.on("deleteQuickSearchHistory", (event, args) => {
|
||||
deleteQuickSearchHistory(args);
|
||||
});
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ function setShortcutKey(setting: Setting = global.setting) {
|
||||
classification.shortcutKey.replace("Win", "Super"),
|
||||
() => {
|
||||
// 分类
|
||||
showMainWindowBefore(true, classification.id);
|
||||
showMainWindowBefore(true, false, classification.id);
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
|
@ -682,6 +682,10 @@ contextBridge.exposeInMainWorld("item", {
|
||||
updateOpenInfo: (type: string, id: number) => {
|
||||
ipcRenderer.send("updateItemOpenInfo", { type, id });
|
||||
},
|
||||
// 删除历史记录
|
||||
deleteQuickSearchHistory: (id: number) => {
|
||||
ipcRenderer.send("deleteQuickSearchHistory", id);
|
||||
},
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld("setting", {
|
||||
|
@ -183,3 +183,12 @@ fn remove_window_animation(window: i32) {
|
||||
fn get_appx_list() -> Vec<HashMap<String, String>> {
|
||||
windows::get_appx_list()
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前鼠标位置
|
||||
*/
|
||||
#[allow(dead_code)]
|
||||
#[napi]
|
||||
fn get_cursor_point() -> [i32; 2] {
|
||||
windows::get_cursor_point()
|
||||
}
|
||||
|
@ -773,3 +773,14 @@ fn get_foreground_window_class_name() -> String {
|
||||
// 返回
|
||||
u16_to_string(&buffer)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前鼠标位置
|
||||
*/
|
||||
pub fn get_cursor_point() -> [i32; 2] {
|
||||
let mut point = POINT::default();
|
||||
unsafe {
|
||||
GetCursorPos(&mut point);
|
||||
};
|
||||
[point.x, point.y]
|
||||
}
|
||||
|
1
src/index.d.ts
vendored
1
src/index.d.ts
vendored
@ -144,6 +144,7 @@ declare global {
|
||||
onUpdateOpenInfo: (callback: Callback) => Function;
|
||||
onCheckInvalid: (callback: Callback) => Function;
|
||||
updateOpenInfo: (type: string, id: number) => void;
|
||||
deleteQuickSearchHistory: (id: number) => void;
|
||||
};
|
||||
setting: {
|
||||
createWindow: () => void;
|
||||
|
@ -80,6 +80,7 @@
|
||||
getSearchItemClassificationName((item as Item).classificationId)
|
||||
}}</span></span
|
||||
>
|
||||
<!-- 快捷键 -->
|
||||
<template
|
||||
v-if="
|
||||
store.setting.quickSearch.openShortcutKey !== 'none' && index <= 9
|
||||
@ -121,6 +122,20 @@
|
||||
></keyText>
|
||||
</template>
|
||||
</template>
|
||||
<!-- 删除历史记录 -->
|
||||
<Icon
|
||||
v-if="showHistory"
|
||||
class="delete-history-icon text-[10px] p-[2px] ml-[10px] cursor-pointer"
|
||||
style="border-radius: 12px"
|
||||
:style="{
|
||||
color: store.setting.appearance.theme.mainFontColor,
|
||||
backgroundColor:
|
||||
store.setting.appearance.theme.secondBackgroundColor,
|
||||
}"
|
||||
:title="store.language.deleteHistory"
|
||||
>
|
||||
<CloseRound></CloseRound>
|
||||
</Icon>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -159,6 +174,7 @@ import {
|
||||
import keyText from "../../components/KeyText.vue";
|
||||
import { Icon } from "@vicons/utils";
|
||||
import { SearchOutline, TerminalOutline } from "@vicons/ionicons5";
|
||||
import { CloseRound } from "@vicons/material";
|
||||
import { useMainStore } from "../../store";
|
||||
// pinia
|
||||
const store = useMainStore();
|
||||
@ -304,20 +320,31 @@ function getHistory() {
|
||||
}
|
||||
// 父级运行项目
|
||||
function parentRunItem(e: any) {
|
||||
// 找到item
|
||||
let itemElement = getClassElement(e, "item");
|
||||
if (itemElement) {
|
||||
if (mode.value === "search") {
|
||||
// 项目ID
|
||||
let itemId = parseInt(itemElement.getAttribute("item-id"));
|
||||
// 查询项目
|
||||
let item = getItemById(itemId);
|
||||
if (item && item.data) {
|
||||
runItem(item);
|
||||
// 找到delete-history-icon
|
||||
let deleteHistoryElement = getClassElement(e, "delete-history-icon");
|
||||
if (deleteHistoryElement) {
|
||||
// 找到item
|
||||
let itemElement = getClassElement(e, "item");
|
||||
// 项目ID
|
||||
let itemId = parseInt(itemElement.getAttribute("item-id"));
|
||||
// 删除历史记录
|
||||
window.item.deleteQuickSearchHistory(itemId);
|
||||
} else {
|
||||
// 找到item
|
||||
let itemElement = getClassElement(e, "item");
|
||||
if (itemElement) {
|
||||
if (mode.value === "search") {
|
||||
// 项目ID
|
||||
let itemId = parseInt(itemElement.getAttribute("item-id"));
|
||||
// 查询项目
|
||||
let item = getItemById(itemId);
|
||||
if (item && item.data) {
|
||||
runItem(item);
|
||||
}
|
||||
} else if (mode.value === "commandLine") {
|
||||
// 目标
|
||||
commandLineRun(itemElement.getAttribute("target"));
|
||||
}
|
||||
} else if (mode.value === "commandLine") {
|
||||
// 目标
|
||||
commandLineRun(itemElement.getAttribute("target"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -671,12 +698,10 @@ onMounted(() => {
|
||||
// 聚焦文本框
|
||||
searchInput.value.focus();
|
||||
// 刷新DOM完毕执行
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
// 显示窗口
|
||||
window.quickSearch.showWindow();
|
||||
}, 10);
|
||||
});
|
||||
setTimeout(() => {
|
||||
// 显示窗口
|
||||
window.quickSearch.showWindow();
|
||||
}, 10);
|
||||
})
|
||||
);
|
||||
// 清空数据
|
||||
@ -705,6 +730,17 @@ onMounted(() => {
|
||||
}
|
||||
})
|
||||
);
|
||||
// 删除历史记录
|
||||
listens.push(
|
||||
window.item.onUpdateOpenInfo((data) => {
|
||||
let item = getItemById(data.id);
|
||||
if (item) {
|
||||
item.data.quickSearchOpenNumber = data.quickSearchOpenNumber;
|
||||
item.data.quickSearchLastOpen = data.quickSearchLastOpen;
|
||||
}
|
||||
getHistory();
|
||||
})
|
||||
);
|
||||
});
|
||||
// unmounted
|
||||
onUnmounted(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user