diff --git a/src/core/XSystem.ts b/src/core/XSystem.ts index f84db82..5bc4901 100644 --- a/src/core/XSystem.ts +++ b/src/core/XSystem.ts @@ -1,6 +1,5 @@ import ProcessManageImpl from './process/impl/ProcessManageImpl.ts' import ProcessImpl from './process/impl/ProcessImpl.ts' -import type { ProcessInfoImpl } from '@/core/process/impl/ProcessInfoImpl.ts' import { isUndefined } from 'lodash' import { BasicSystemProcess } from '@/core/system/BasicSystemProcess.ts' import { DesktopProcess } from '@/core/desktop/DesktopProcess.ts' @@ -10,12 +9,22 @@ import { EventBuilderImpl } from '@/core/events/impl/EventBuilderImpl.ts' import type { IProcessManage } from '@/core/process/IProcessManage.ts' import type { IProcess } from '@/core/process/IProcess.ts' import type { IProcessInfo } from '@/core/process/IProcessInfo.ts' +import { ObservableWeakRefImpl } from '@/core/state/impl/ObservableWeakRefImpl.ts' +import type { IObservable } from '@/core/state/IObservable.ts' + +interface IGlobalState { + isLogin: boolean +} export default class XSystem { private static _instance: XSystem = new XSystem() private _processManage: IProcessManage = new ProcessManageImpl() private _eventManage: IEventBuilder = new EventBuilderImpl() + private _globalState: IObservable = new ObservableWeakRefImpl({ + isLogin: false + }) + private _desktopRootDom: HTMLElement; constructor() { console.log('XSystem') @@ -30,11 +39,19 @@ export default class XSystem { public get eventManage() { return this._eventManage } + public get globalState() { + return this._globalState + } + public get desktopRootDom() { + return this._desktopRootDom + } public initialization(dom: HTMLDivElement) { + this._desktopRootDom = dom this.run('basic-system', BasicSystemProcess).then(() => { this.run('desktop', DesktopProcess).then((proc) => { proc.mount(dom) + // console.log(dom.querySelector('.desktop-root')) }) }) } diff --git a/src/core/desktop/DesktopProcess.ts b/src/core/desktop/DesktopProcess.ts index 389120b..4dcb7f7 100644 --- a/src/core/desktop/DesktopProcess.ts +++ b/src/core/desktop/DesktopProcess.ts @@ -88,6 +88,7 @@ export class DesktopProcess extends ProcessImpl { dom.style.zIndex = '0'; dom.style.width = `${this._width}px` dom.style.height = `${this._height}px` + dom.style.position = 'relative' this._desktopRootDom = dom const app = createApp(DesktopComponent, { process: this }) diff --git a/src/core/desktop/ui/DesktopComponent.vue b/src/core/desktop/ui/DesktopComponent.vue index 417823e..e7bf7e8 100644 --- a/src/core/desktop/ui/DesktopComponent.vue +++ b/src/core/desktop/ui/DesktopComponent.vue @@ -5,10 +5,13 @@ >
-
+ :iconInfo="appIcon" :gridTemplate="gridTemplate" + @dblclick="runApp(appIcon)" + /> + />
@@ -25,10 +28,11 @@ import { DesktopEventEnum } from '@/core/events/EventTypes.ts' import { useDesktopInit } from '@/core/desktop/ui/hooks/useDesktopInit.ts' import AppIcon from '@/core/desktop/ui/components/AppIcon.vue' import { watch } from 'vue' +import type { IDesktopAppIcon } from '@/core/desktop/types/IDesktopAppIcon.ts' const props = defineProps<{ process: DesktopProcess }>() -const { appIconsRef, gridStyle, gridTemplate } = useDesktopInit('.desktop-container') +const { appIconsRef, gridStyle, gridTemplate } = useDesktopInit('.desktop-icons-container') XSystem.instance.eventManage.addEventListener( DesktopEventEnum.onDesktopRootDomResize, @@ -45,6 +49,10 @@ XSystem.instance.eventManage.addEventListener( const onContextMenu = (e: MouseEvent) => { e.preventDefault() } + +const runApp = (appIcon: IDesktopAppIcon) => { + XSystem.instance.run(appIcon.name) +}