dsh-gufa-code 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,8 @@
14
14
  #import <CoreGraphics/CoreGraphics.h>
15
15
 
16
16
  @interface GufaDragStrip : NSView
17
+ @property (nonatomic, weak) id doubleClickTarget;
18
+ @property (nonatomic, assign) SEL doubleClickAction;
17
19
  @end
18
20
 
19
21
  @implementation GufaDragStrip
@@ -27,20 +29,33 @@
27
29
  NSFontAttributeName: [NSFont systemFontOfSize:10 weight:NSFontWeightMedium],
28
30
  NSForegroundColorAttributeName: [NSColor colorWithCalibratedWhite:1.0 alpha:0.6],
29
31
  };
30
- NSString *label = @"古法编程 · 悬浮层(拖动这里移动窗口)";
32
+ NSString *label = @"古法编程 · 悬浮层(拖动移动 · 双击穿透 · 右键菜单)";
31
33
  NSSize size = [label sizeWithAttributes:attrs];
32
34
  NSPoint origin = NSMakePoint(floor((self.bounds.size.width - size.width) / 2.0), floor((self.bounds.size.height - size.height) / 2.0));
33
35
  [label drawAtPoint:origin withAttributes:attrs];
34
36
  }
35
37
 
36
- - (void)mouseDown:(NSEvent *)event {
37
- [self.window performWindowDragWithEvent:event];
38
- }
39
-
40
38
  - (void)mouseDragged:(NSEvent *)event {
41
39
  /* performDrag 已接管拖动 */
42
40
  }
43
41
 
42
+ - (void)rightMouseDown:(NSEvent *)event {
43
+ /* 右键直接弹出悬浮层菜单(菜单栏图标太挤时也能用) */
44
+ if (self.menu != nil) {
45
+ [NSMenu popUpContextMenu:self.menu withEvent:event forView:self];
46
+ return;
47
+ }
48
+ [super rightMouseDown:event];
49
+ }
50
+
51
+ - (void)mouseDown:(NSEvent *)event {
52
+ if (event.clickCount == 2 && self.doubleClickTarget != nil && self.doubleClickAction != NULL) {
53
+ [NSApp sendAction:self.doubleClickAction to:self.doubleClickTarget from:self];
54
+ return;
55
+ }
56
+ [self.window performWindowDragWithEvent:event];
57
+ }
58
+
44
59
  - (BOOL)acceptsFirstMouse:(NSEvent *)event { return YES; }
45
60
 
46
61
  @end
@@ -56,6 +71,8 @@
56
71
  @property (nonatomic, strong) NSWindow *window;
57
72
  @property (nonatomic, strong) WKWebView *webView;
58
73
  @property (nonatomic, strong) NSStatusItem *statusItem;
74
+ @property (nonatomic, strong) NSMenu *mainMenu;
75
+ @property (nonatomic, strong) GufaDragStrip *dragStrip;
59
76
  @property (nonatomic, assign) BOOL clickThrough;
60
77
  @property (nonatomic, strong) NSString *frameKey;
61
78
  @property (nonatomic, strong) GufaNavigationDelegate *navigation;
@@ -159,7 +176,11 @@
159
176
  CGFloat stripHeight = 22.0;
160
177
  GufaDragStrip *strip = [[GufaDragStrip alloc] initWithFrame:NSMakeRect(0, frame.size.height - stripHeight, frame.size.width, stripHeight)];
161
178
  strip.autoresizingMask = NSViewWidthSizable | NSViewMinYMargin;
179
+ strip.menu = self.mainMenu;
180
+ strip.doubleClickTarget = self;
181
+ strip.doubleClickAction = @selector(toggleClickThrough:);
162
182
  [container addSubview:strip];
183
+ self.dragStrip = strip;
163
184
 
164
185
  self.window.contentView = container;
165
186
  [self.window makeKeyAndOrderFront:nil];
@@ -180,6 +201,7 @@
180
201
  [menu addItemWithTitle:@"重置窗口位置和大小" action:@selector(resetFrame:) keyEquivalent:@""].target = self;
181
202
  [menu addItem:[NSMenuItem separatorItem]];
182
203
  [menu addItemWithTitle:@"关闭悬浮层" action:@selector(quitApp:) keyEquivalent:@""].target = self;
204
+ self.mainMenu = menu;
183
205
  self.statusItem.menu = menu;
184
206
  }
185
207
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-gufa-code",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
5
5
  "icon": "icon.svg",
6
6
  "keywords": [