1
This commit is contained in:
@@ -94,7 +94,7 @@ export interface WindowConfig {
|
||||
/**
|
||||
* 窗体实例接口
|
||||
*/
|
||||
export interface WindowInstance {
|
||||
export interface WindowFormInstance {
|
||||
/**
|
||||
* 窗体唯一标识符
|
||||
*/
|
||||
@@ -156,7 +156,7 @@ export interface WindowEvents extends IEventMap {
|
||||
* 窗体管理服务类
|
||||
*/
|
||||
export class WindowFormService {
|
||||
private windowsForm = reactive(new Map<string, WindowInstance>())
|
||||
private windowsForm = reactive(new Map<string, WindowFormInstance>())
|
||||
private activeWindowId = ref<string | null>(null)
|
||||
private nextZIndex = 1000
|
||||
private eventBus: IEventBuilder<WindowEvents>
|
||||
@@ -169,11 +169,11 @@ export class WindowFormService {
|
||||
/**
|
||||
* 创建新窗体
|
||||
*/
|
||||
async createWindow(appId: string, config: WindowConfig): Promise<WindowInstance> {
|
||||
async createWindow(appId: string, config: WindowConfig): Promise<WindowFormInstance> {
|
||||
const windowId = uuidv4()
|
||||
const now = new Date()
|
||||
|
||||
const windowInstance: WindowInstance = {
|
||||
const windowInstance: WindowFormInstance = {
|
||||
id: windowId,
|
||||
appId,
|
||||
config,
|
||||
@@ -220,6 +220,9 @@ export class WindowFormService {
|
||||
if (window.element) {
|
||||
window.element.remove()
|
||||
}
|
||||
if (window.iframe) {
|
||||
window.iframe.remove()
|
||||
}
|
||||
|
||||
// 从集合中移除
|
||||
this.windowsForm.delete(windowId)
|
||||
@@ -405,14 +408,14 @@ export class WindowFormService {
|
||||
/**
|
||||
* 获取窗体实例
|
||||
*/
|
||||
getWindow(windowId: string): WindowInstance | undefined {
|
||||
getWindow(windowId: string): WindowFormInstance | undefined {
|
||||
return this.windowsForm.get(windowId)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有窗体
|
||||
*/
|
||||
getAllWindows(): WindowInstance[] {
|
||||
getAllWindows(): WindowFormInstance[] {
|
||||
return Array.from(this.windowsForm.values())
|
||||
}
|
||||
|
||||
@@ -448,7 +451,7 @@ export class WindowFormService {
|
||||
/**
|
||||
* 创建窗体DOM元素
|
||||
*/
|
||||
private async createWindowElement(windowInstance: WindowInstance): Promise<void> {
|
||||
private async createWindowElement(windowInstance: WindowFormInstance): Promise<void> {
|
||||
const { id, config, appId } = windowInstance
|
||||
|
||||
// 创建窗体容器
|
||||
@@ -549,7 +552,7 @@ export class WindowFormService {
|
||||
/**
|
||||
* 创建窗体标题栏
|
||||
*/
|
||||
private createTitleBar(windowInstance: WindowInstance): HTMLElement {
|
||||
private createTitleBar(windowInstance: WindowFormInstance): HTMLElement {
|
||||
const titleBar = document.createElement('div')
|
||||
titleBar.className = 'window-title-bar'
|
||||
titleBar.style.cssText = `
|
||||
@@ -659,7 +662,7 @@ export class WindowFormService {
|
||||
/**
|
||||
* 添加窗体拖拽功能
|
||||
*/
|
||||
private addDragFunctionality(titleBar: HTMLElement, windowInstance: WindowInstance): void {
|
||||
private addDragFunctionality(titleBar: HTMLElement, windowInstance: WindowFormInstance): void {
|
||||
let isDragging = false
|
||||
let startX = 0
|
||||
let startY = 0
|
||||
@@ -744,7 +747,10 @@ export class WindowFormService {
|
||||
/**
|
||||
* 添加窗体调整尺寸功能
|
||||
*/
|
||||
private addResizeFunctionality(windowElement: HTMLElement, windowInstance: WindowInstance): void {
|
||||
private addResizeFunctionality(
|
||||
windowElement: HTMLElement,
|
||||
windowInstance: WindowFormInstance
|
||||
): void {
|
||||
// 初始化调整尺寸状态
|
||||
windowInstance.resizeState = {
|
||||
isResizing: false,
|
||||
@@ -873,7 +879,7 @@ export class WindowFormService {
|
||||
private addResizeHandleEvents(
|
||||
handle: HTMLElement,
|
||||
windowElement: HTMLElement,
|
||||
windowInstance: WindowInstance
|
||||
windowInstance: WindowFormInstance
|
||||
): void {
|
||||
const direction = handle.className
|
||||
.split(' ')
|
||||
@@ -930,7 +936,7 @@ export class WindowFormService {
|
||||
private updateCursorForResize(
|
||||
e: MouseEvent,
|
||||
windowElement: HTMLElement,
|
||||
windowInstance: WindowInstance
|
||||
windowInstance: WindowFormInstance
|
||||
): void {
|
||||
if (!windowInstance.resizeState) return
|
||||
|
||||
@@ -1150,7 +1156,7 @@ export class WindowFormService {
|
||||
/**
|
||||
* 加载应用
|
||||
*/
|
||||
private async loadApplication(windowInstance: WindowInstance): Promise<void> {
|
||||
private async loadApplication(windowInstance: WindowFormInstance): Promise<void> {
|
||||
// 动态导入 AppRegistry 检查是否为内置应用
|
||||
try {
|
||||
// 如果是内置应用,直接返回,不需要等待
|
||||
|
||||
Reference in New Issue
Block a user