2025-08-19 14:56:38 +08:00
|
|
|
<template>
|
2025-08-19 16:59:58 +08:00
|
|
|
<n-config-provider
|
|
|
|
|
:config-provider-props="configProviderProps"
|
|
|
|
|
class="w-full h-full pos-relative"
|
|
|
|
|
>
|
2025-08-22 15:49:10 +08:00
|
|
|
<div class="desktop-root" @contextmenu="onContextMenu">
|
2025-08-25 16:42:07 +08:00
|
|
|
<div class="desktop-bg">
|
2025-08-28 08:05:16 +08:00
|
|
|
<div class="desktop-icons-container"
|
2025-08-22 15:49:10 +08:00
|
|
|
:style="gridStyle">
|
|
|
|
|
<AppIcon v-for="(appIcon, i) in appIconsRef" :key="i"
|
2025-08-28 08:05:16 +08:00
|
|
|
:iconInfo="appIcon" :gridTemplate="gridTemplate"
|
|
|
|
|
@dblclick="runApp(appIcon)"
|
|
|
|
|
/>
|
2025-08-22 15:49:10 +08:00
|
|
|
</div>
|
2025-08-19 14:56:38 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="task-bar"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</n-config-provider>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { DesktopProcess } from '@/core/desktop/DesktopProcess.ts'
|
|
|
|
|
import XSystem from '@/core/XSystem.ts'
|
|
|
|
|
import { notificationApi } from '@/core/common/naive-ui/discrete-api.ts'
|
|
|
|
|
import { configProviderProps } from '@/core/common/naive-ui/theme.ts'
|
2025-08-25 16:42:07 +08:00
|
|
|
import { useDesktopInit } from '@/core/desktop/ui/hooks/useDesktopInit.ts'
|
2025-08-21 16:57:42 +08:00
|
|
|
import AppIcon from '@/core/desktop/ui/components/AppIcon.vue'
|
2025-08-28 08:05:16 +08:00
|
|
|
import type { IDesktopAppIcon } from '@/core/desktop/types/IDesktopAppIcon.ts'
|
2025-08-29 14:22:20 +08:00
|
|
|
import { eventManager } from '@/core/events/EventManager.ts'
|
2025-08-19 14:56:38 +08:00
|
|
|
|
2025-08-19 16:59:58 +08:00
|
|
|
const props = defineProps<{ process: DesktopProcess }>()
|
|
|
|
|
|
2025-08-28 08:05:16 +08:00
|
|
|
const { appIconsRef, gridStyle, gridTemplate } = useDesktopInit('.desktop-icons-container')
|
2025-08-19 14:56:38 +08:00
|
|
|
|
2025-08-29 14:22:20 +08:00
|
|
|
eventManager.addEventListener('onDesktopRootDomResize',
|
2025-08-19 16:59:58 +08:00
|
|
|
(width, height) => {
|
|
|
|
|
console.log(width, height)
|
|
|
|
|
notificationApi.create({
|
|
|
|
|
title: '桌面通知',
|
|
|
|
|
content: `桌面尺寸变化${width}x${height}}`,
|
|
|
|
|
duration: 2000,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
)
|
2025-08-19 14:56:38 +08:00
|
|
|
|
2025-08-22 15:49:10 +08:00
|
|
|
const onContextMenu = (e: MouseEvent) => {
|
|
|
|
|
e.preventDefault()
|
2025-08-19 14:56:38 +08:00
|
|
|
}
|
2025-08-28 08:05:16 +08:00
|
|
|
|
|
|
|
|
const runApp = (appIcon: IDesktopAppIcon) => {
|
|
|
|
|
XSystem.instance.run(appIcon.name)
|
|
|
|
|
}
|
2025-08-19 14:56:38 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2025-08-25 16:42:07 +08:00
|
|
|
$taskBarHeight: 40px;
|
2025-08-19 14:56:38 +08:00
|
|
|
.desktop-root {
|
|
|
|
|
@apply w-full h-full flex flex-col;
|
|
|
|
|
|
2025-08-25 16:42:07 +08:00
|
|
|
.desktop-bg {
|
|
|
|
|
@apply w-full h-full flex-1 p-2 pos-relative;
|
|
|
|
|
background-image: url("imgs/desktop-bg-2.jpeg");
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-size: cover;
|
|
|
|
|
height: calc(100% - #{$taskBarHeight});
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 08:05:16 +08:00
|
|
|
.desktop-icons-container {
|
2025-08-22 15:49:10 +08:00
|
|
|
@apply w-full h-full flex-1 grid grid-auto-flow-col pos-relative;
|
2025-08-19 14:56:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.task-bar {
|
2025-08-25 16:42:07 +08:00
|
|
|
@apply w-full bg-gray-200;
|
|
|
|
|
height: $taskBarHeight;
|
2025-08-20 09:59:19 +08:00
|
|
|
flex-shrink: 0;
|
2025-08-19 14:56:38 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|