Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/main/ipcBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,27 @@ export function registerIpcOnHandlers() {
await shell.openExternal(externalUrl);
}
});
ipcMain.handle("shell:revealFileInFolder", async (_event, filePath: string) => {
if (!filePath) return false;

try {
const normalizedPath = path.normalize(filePath);
if (fs.existsSync(normalizedPath)) {
shell.showItemInFolder(normalizedPath);
return true;
}

const directoryPath = path.dirname(normalizedPath);
if (!fs.existsSync(directoryPath)) {
return false;
}

const openResult = await shell.openPath(directoryPath);
return openResult === "";
} catch {
return false;
}
});
ipcMain.on("change-save-status", (event, isSavedStatus) => {
const targetWin = BrowserWindow.fromWebContents(event.sender);
if (!targetWin) return;
Expand Down Expand Up @@ -1050,6 +1071,10 @@ export function registerIpcHandleHandlers() {
}
// 无需 win 的 ipc 处理
export function registerGlobalIpcHandlers() {
ipcMain.handle("clipboard:writeText", async (_event, text: string): Promise<boolean> => {
clipboard.writeText(text ?? "");
return true;
});
ipcMain.handle(
"image:openPreview",
async (event, payload: ImagePreviewPayload): Promise<void> => {
Expand Down
3 changes: 3 additions & 0 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ contextBridge.exposeInMainWorld("electronAPI", {
openExternal: (url: string) => ipcRenderer.send("shell:openExternal", url),
openLink: (href: string, currentFilePath?: string | null) =>
ipcRenderer.invoke("shell:openLink", href, currentFilePath),
revealFileInFolder: (filePath: string) =>
ipcRenderer.invoke("shell:revealFileInFolder", filePath),
openImagePreview: (
src: string,
alt?: string,
options?: { items?: Array<{ src: string; alt?: string }>; index?: number }
) => ipcRenderer.invoke("image:openPreview", { src, alt, ...options }),
getFilePathInClipboard: () => ipcRenderer.invoke("clipboard:getFilePath"),
writeTextToClipboard: (text: string) => ipcRenderer.invoke("clipboard:writeText", text),
writeTempImage: (
file: Uint8Array,
targetPath: string,
Expand Down
99 changes: 62 additions & 37 deletions src/renderer/components/menu/MenuDropDown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import emitter from "@/renderer/events";
import MenuBar from "./MenuBar.vue";

const isOpen = ref(false);
function closeMenu() {
isOpen.value = false;
}

// 事件处理器
function handleFileChange() {
isOpen.value = false;
closeMenu();
}

function handleKeydown(event: KeyboardEvent) {
if (event.key === "Escape" && isOpen.value) {
isOpen.value = false;
closeMenu();
}
}

Expand All @@ -29,11 +32,10 @@ onUnmounted(() => {

<template>
<div class="MenuDropDownBox">
<div class="dropdown-header">
<button class="dropdown-header" type="button" @click="isOpen = !isOpen">
<svg
class="logo"
:class="{ active: isOpen }"
@click="isOpen = !isOpen"
width="13"
height="18"
viewBox="13.5 11.5 11 15"
Expand All @@ -54,63 +56,86 @@ onUnmounted(() => {
fill="currentColor"
/>
</svg>
</div>
<Transition name="menu-slide">
<div v-show="isOpen" class="dropdown-content">
<MenuBar />
</div>
</Transition>
</button>
<Teleport to="body">
<Transition name="menu-fade">
<div v-if="isOpen" class="menu-overlay" @click="closeMenu">
<div class="dropdown-content" @click.stop>
<MenuBar />
</div>
</div>
</Transition>
</Teleport>
</div>
</template>

<style lang="less" scoped>
.MenuDropDownBox {
height: 100%;
flex-shrink: 0;

.dropdown-header {
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
justify-content: center;
cursor: pointer;
padding: 0 0 3px 10px;
height: 100%;
-webkit-app-region: no-drag; /* 禁止拖动 */
margin-left: 6px;
padding: 0 10px;
height: 34px;
border: none;
border-radius: 12px;
background: transparent;
-webkit-app-region: no-drag;

&:hover {
background: var(--hover-color);
}

.logo {
display: inline-block;
width: 13px;
height: 18px;
transition: 0.2s;
margin: 4px;
color: var(--primary-color);

&.active {
transform: rotate(180deg);
}
}
}
.dropdown-content {
position: absolute;
top: 40px; /* 与标题栏高度一致 */
left: 0;
background: var(--background-color-1);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
z-index: 1000;
width: 100%;
height: 100%;
border-radius: 4px;
-webkit-app-region: no-drag; /* 禁止拖动 */
white-space: nowrap;
}
}

.menu-slide-enter-active,
.menu-slide-leave-active {
transition:
opacity 0.15s ease,
transform 0.15s ease;
.menu-overlay {
position: fixed;
inset: 0;
z-index: 110000;
padding: 58px 16px 16px;
display: flex;
align-items: flex-start;
justify-content: center;
background: rgba(10, 14, 24, 0.28);
backdrop-filter: blur(12px);
-webkit-app-region: no-drag;
}

.dropdown-content {
width: min(1180px, calc(100vw - 32px));
height: min(760px, calc(100vh - 74px));
border-radius: 22px;
overflow: hidden;
border: 1px solid color-mix(in srgb, var(--border-color-1) 84%, transparent);
background: color-mix(in srgb, var(--background-color-1) 94%, transparent);
box-shadow: 0 28px 72px rgba(0, 0, 0, 0.28);
white-space: nowrap;
}

.menu-fade-enter-active,
.menu-fade-leave-active {
transition: opacity 0.18s ease;
}

.menu-slide-enter-from,
.menu-slide-leave-to {
.menu-fade-enter-from,
.menu-fade-leave-to {
opacity: 0;
transform: translateY(-8px);
}
</style>
Loading
Loading