Browse Source
- 新增 `utils` workspace 包,将广播功能从主进程工具模块迁移至此 - 重构更新器模块的事件类型定义,使用字符串字面量替代枚举类型 - 调整更新进度事件的参数类型,增加详细的进度数据传递 - 修复全局类型定义中的 `IpcRendererEvent` 重复拼写错误 - 清理主页面组件代码,移除未使用的导航栏实现 - 添加应用初始化日志输出,便于调试启动过程 - 修正类型声明文件路径配置,确保 `popup-menu.d.ts` 被正确包含 - 更新依赖项版本,包括 `@intlify/shared` 从 11.1.3 升级到 11.1.5main
21 changed files with 152 additions and 126 deletions
@ -1,7 +1,3 @@ |
|||||
export const enum EventEnum { |
|
||||
UPDATE_PROGRESS = "update-progress", |
|
||||
} |
|
||||
|
|
||||
export type EventMaps = { |
export type EventMaps = { |
||||
[EventEnum.UPDATE_PROGRESS]: () => void |
"update-progress": (data: { percent: number; all: number; now: number }) => void |
||||
} |
} |
||||
|
@ -1,8 +1,6 @@ |
|||||
import { broadcast } from "main/utils" |
import { broadcast } from "utils/main" |
||||
import { EventEnum } from "../common" |
import { EventMaps } from "../common" |
||||
|
|
||||
export { EventEnum } |
export function emit(key: keyof EventMaps, ...args: Parameters<EventMaps[keyof EventMaps]>) { |
||||
|
|
||||
export function emit(key: EventEnum, ...args: any[]) { |
|
||||
broadcast(key, ...args) |
broadcast(key, ...args) |
||||
} |
} |
||||
|
@ -0,0 +1,5 @@ |
|||||
|
import { webContents } from "electron" |
||||
|
|
||||
|
export const broadcast = <T extends Record<string, (...argu: any[]) => void>>(event: keyof T, ...args: Parameters<T[keyof T]>) => { |
||||
|
webContents.getAllWebContents().forEach(browser => browser.send(event as any, ...args)) |
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
{ |
||||
|
"name": "utils", |
||||
|
"version": "1.0.0", |
||||
|
"keywords": [], |
||||
|
"author": "", |
||||
|
"license": "ISC" |
||||
|
} |
@ -0,0 +1,83 @@ |
|||||
|
<script setup lang="ts"> |
||||
|
import { useSnippet } from "common/event/Snippet/hook" |
||||
|
definePage({ |
||||
|
meta: { |
||||
|
home: true, |
||||
|
}, |
||||
|
}) |
||||
|
|
||||
|
const { getTree } = useSnippet() |
||||
|
|
||||
|
const activeLeft = ref<number | null>(null) |
||||
|
function clickActive(e: any) { |
||||
|
const el = e.target as HTMLDivElement |
||||
|
const { x } = el.getBoundingClientRect() |
||||
|
const { width: parentWidth } = el.parentElement!.getBoundingClientRect() |
||||
|
const newLeft = +((x / parentWidth) * 100).toFixed(2) |
||||
|
if (newLeft === activeLeft.value) { |
||||
|
activeLeft.value = null |
||||
|
return |
||||
|
} |
||||
|
activeLeft.value = +((x / parentWidth) * 100).toFixed(2) |
||||
|
} |
||||
|
|
||||
|
async function click() { |
||||
|
console.log(await getTree()) |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<template> |
||||
|
<div h-full flex> |
||||
|
<div border-r-coolGray-200 border-r-1 border-r-solid flex flex-col max-w-300px w="3/10"> |
||||
|
<div class="list"> |
||||
|
<div v-if="activeLeft !== null" class="active" :style="{ left: activeLeft + '%' }"></div> |
||||
|
<div class="item" @click="clickActive"> |
||||
|
<IconHugeiconsInbox class="icon" /> |
||||
|
<span class="text">盒子</span> |
||||
|
</div> |
||||
|
<div class="item" @click="clickActive"> |
||||
|
<IconFluentCollections24Regular class="icon" /> |
||||
|
<span class="text">收藏</span> |
||||
|
</div> |
||||
|
<div class="item" @click="clickActive"> |
||||
|
<IconSolarHome2Outline class="icon" /> |
||||
|
<span class="text">全部</span> |
||||
|
</div> |
||||
|
<div class="item" @click="clickActive"> |
||||
|
<IconMynauiTrash class="icon" /> |
||||
|
<span class="text">废纸篓</span> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div @click="click">文件树</div> |
||||
|
</div> |
||||
|
<div max-w-300px w="3/10" border-r-coolGray-200 border-r-1 border-r-solid>文件树</div> |
||||
|
<div>aa</div> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
.list { |
||||
|
@apply flex border-b-solid border-b-1 border-b-coolGray-200 relative; |
||||
|
.active { |
||||
|
position: absolute; |
||||
|
left: 0; |
||||
|
transition: left 0.5s ease; |
||||
|
width: 25%; |
||||
|
height: 100%; |
||||
|
pointer-events: none; |
||||
|
background-color: rgba(193, 193, 193, 0.2); |
||||
|
z-index: -1; |
||||
|
} |
||||
|
.item { |
||||
|
@apply p-x-3 p-y-2 cursor-pointer flex flex-col gap-1 flex-1 items-center hover:bg-gray-100; |
||||
|
.icon { |
||||
|
@apply w-5 h-5; |
||||
|
pointer-events: none; |
||||
|
} |
||||
|
.text { |
||||
|
@apply text-xs; |
||||
|
pointer-events: none; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
</style> |
@ -1,83 +1,9 @@ |
|||||
<script setup lang="ts"> |
<script setup lang="ts"></script> |
||||
import { useSnippet } from "common/event/Snippet/hook" |
|
||||
definePage({ |
|
||||
meta: { |
|
||||
home: true, |
|
||||
}, |
|
||||
}) |
|
||||
|
|
||||
const { getTree } = useSnippet() |
|
||||
|
|
||||
const activeLeft = ref<number | null>(null) |
|
||||
function clickActive(e: any) { |
|
||||
const el = e.target as HTMLDivElement |
|
||||
const { x } = el.getBoundingClientRect() |
|
||||
const { width: parentWidth } = el.parentElement!.getBoundingClientRect() |
|
||||
const newLeft = +((x / parentWidth) * 100).toFixed(2) |
|
||||
if (newLeft === activeLeft.value) { |
|
||||
activeLeft.value = null |
|
||||
return |
|
||||
} |
|
||||
activeLeft.value = +((x / parentWidth) * 100).toFixed(2) |
|
||||
} |
|
||||
|
|
||||
async function click() { |
|
||||
console.log(await getTree()) |
|
||||
} |
|
||||
</script> |
|
||||
|
|
||||
<template> |
<template> |
||||
<div h-full flex> |
<div h-full flex flex-col> |
||||
<div border-r-coolGray-200 border-r-1 border-r-solid flex flex-col max-w-300px w="3/10"> |
<div v-for="i in 200" :key="i">{{ i }}</div> |
||||
<div class="list"> |
|
||||
<div v-if="activeLeft !== null" class="active" :style="{ left: activeLeft + '%' }"></div> |
|
||||
<div class="item" @click="clickActive"> |
|
||||
<IconHugeiconsInbox class="icon" /> |
|
||||
<span class="text">盒子</span> |
|
||||
</div> |
|
||||
<div class="item" @click="clickActive"> |
|
||||
<IconFluentCollections24Regular class="icon" /> |
|
||||
<span class="text">收藏</span> |
|
||||
</div> |
|
||||
<div class="item" @click="clickActive"> |
|
||||
<IconSolarHome2Outline class="icon" /> |
|
||||
<span class="text">全部</span> |
|
||||
</div> |
|
||||
<div class="item" @click="clickActive"> |
|
||||
<IconMynauiTrash class="icon" /> |
|
||||
<span class="text">废纸篓</span> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div @click="click">文件树</div> |
|
||||
</div> |
|
||||
<div max-w-300px w="3/10" border-r-coolGray-200 border-r-1 border-r-solid>文件树</div> |
|
||||
<div>aa</div> |
|
||||
</div> |
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<style lang="scss" scoped> |
<style lang="scss" scoped></style> |
||||
.list { |
|
||||
@apply flex border-b-solid border-b-1 border-b-coolGray-200 relative; |
|
||||
.active { |
|
||||
position: absolute; |
|
||||
left: 0; |
|
||||
transition: left 0.5s ease; |
|
||||
width: 25%; |
|
||||
height: 100%; |
|
||||
pointer-events: none; |
|
||||
background-color: rgba(193, 193, 193, 0.2); |
|
||||
z-index: -1; |
|
||||
} |
|
||||
.item { |
|
||||
@apply p-x-3 p-y-2 cursor-pointer flex flex-col gap-1 flex-1 items-center hover:bg-gray-100; |
|
||||
.icon { |
|
||||
@apply w-5 h-5; |
|
||||
pointer-events: none; |
|
||||
} |
|
||||
.text { |
|
||||
@apply text-xs; |
|
||||
pointer-events: none; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
</style> |
|
||||
|
Loading…
Reference in new issue