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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Improved portal visual editor
- Configuration profile import/export

## [1.1.0] - 2026-08-31

### Added
- Window layout snapshots and lock-screen recovery for standard application windows.
- Display-canvas previews with switchable automatic and manually saved layouts.

## [1.0.1] - 2026-07-24

### Fixed
Expand Down
28 changes: 28 additions & 0 deletions MousePortal/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
private var hotkeyService: HotkeyService?
private var portalService: PortalService?
private let permissionService = PermissionService.shared
private let windowLayoutService = WindowLayoutService.shared
private var hotkeyConfigStore = HotkeyConfigStore.shared
private var cancellables: Set<AnyCancellable> = []

Expand Down Expand Up @@ -54,6 +55,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
self?.updateAccessibilityStatusItem()
}
.store(in: &cancellables)

windowLayoutService.$isEnabled
.receive(on: RunLoop.main)
.sink { [weak self] _ in
self?.setupMenu()
}
.store(in: &cancellables)
}

func applicationDidBecomeActive(_ notification: Notification) {
Expand Down Expand Up @@ -121,6 +129,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
portalItem.state = (portalService?.isRunning ?? false) ? .on : .off
menu.addItem(portalItem)

let windowRecoveryItem = NSMenuItem(
title: L("window_recovery.enabled"),
action: #selector(toggleWindowRecovery),
keyEquivalent: ""
)
windowRecoveryItem.state = windowLayoutService.isEnabled ? .on : .off
menu.addItem(windowRecoveryItem)

menu.addItem(NSMenuItem.separator())

let accessibilityItem = NSMenuItem(title: accessibilityStatusTitle, action: nil, keyEquivalent: "")
Expand Down Expand Up @@ -159,6 +175,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {

// 传送门默认启动
portalService?.start()
windowLayoutService.startMonitoring()
}

private func terminateOtherInstancesIfNeeded() {
Expand Down Expand Up @@ -214,6 +231,16 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
setupMenu()
}

@objc private func toggleWindowRecovery() {
if !windowLayoutService.isEnabled && !permissionService.checkAccessibility() {
permissionService.requestAccessibility()
return
}

windowLayoutService.setEnabled(!windowLayoutService.isEnabled)
setupMenu()
}

// 传递 SwiftUI 环境的 openWindow,可用于直接打开特定 Window
var openWindowAction: OpenWindowAction?

Expand Down Expand Up @@ -248,6 +275,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
@objc private func quitApp() {
hotkeyService?.stop()
portalService?.stop()
windowLayoutService.stopMonitoring()
NSApplication.shared.terminate(nil)
}

Expand Down
4 changes: 2 additions & 2 deletions MousePortal/AppVersion.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Foundation

enum AppVersion {
static let current = "1.0.1"
static let build = "2"
static let current = "1.1.0"
static let build = "20"

static var displayVersion: String {
if let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String,
Expand Down
Loading
Loading