dsh-gufa-code 1.3.97 → 1.3.100
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.
- package/README.md +1 -1
- package/client.js +56 -5
- package/desktop/float/GufaFloat.m +68 -3
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/docs/KNOWN-PITFALLS.md +3 -0
- package/host/app-window.js +4 -0
- package/package.json +1 -1
- package/src/client/90-app.js +18 -4
- package/src/client/99-main.js +37 -0
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ dsh plugin add dsh-gufa-code
|
|
|
44
44
|
- **Copilot 风格 Tab 行内补全**:光标停/打字后,基于 Harness 自己的 DeepSeek 模型(默认 `deepseek-flash`,不需要额外 Copilot 订阅)流式生成灰色 ghost text,Tab 接受、Esc 忽略;支持 JS/TS/Python/Java/Go/Rust/C++/C#/JSON/YAML/Shell 等常见语言;
|
|
45
45
|
- 保存走磁盘版本冲突检测 + 原子写;未保存标记;
|
|
46
46
|
- **⌘/Ctrl + 点击跳转定义 / 方法实现**:Python 走 **Pyright 语言服务(LSP)**,JS/TS 走 Monaco 内置 TypeScript 语言服务(点击前会按需把当前文件的 import 依赖加载进 Monaco,跨文件变量/函数由 TS 语言服务解析);其他语言暂用项目级定义搜索兜底;优先走 Monaco 语言服务;目标文件没在 Monaco 里打开、或语言没有内置语言服务时,自动用项目级定义搜索兜底(函数 / 类 / 方法 / const / type 等声明)。兜底会解析 import/require 直接定位来源文件,并跳过压缩产物/大文件;同一个文件里的声明、import 命中的定义、目录距离近的定义直接跳,只有多个真正同名的声明才弹「跳转到定义」列表,点同名属性/变量时不会拿远端无关的 const 来凑数;按住 ⌘/Ctrl 悬停时,可跳转的符号会显示下划线 + 手型光标;
|
|
47
|
-
- **⌘⇧N 新开实例窗口**:用古法编程自带原生 helper 打开一个普通 Harness 窗口(同一 Web GUI
|
|
47
|
+
- **⌘⇧N 新开实例窗口**:用古法编程自带原生 helper 打开一个普通 Harness 窗口(同一 Web GUI、共享登录态),新窗口会**直接进入古法编程**并恢复当前项目/标签页/布局;当前窗口全屏时新窗口也直接全屏;macOS 已支持,Windows/Linux 待 helper 实现 full 模式;
|
|
48
48
|
- **全局搜索 / 替换**(左栏放大镜 / `⌘⇧F`):整个项目的文本搜索,支持区分大小写、正则、包含/排除文件(glob);结果按文件分组、高亮匹配,点击跳转行列;替换栏支持保留大小写(AB)、全部替换(需确认)、按文件替换(悬停文件头铅笔)、按单行匹配替换与忽略(悬停结果行);替换前会自动保存未落盘的编辑器内容;Git 项目用 `git ls-files` 枚举文件(尊重 `.gitignore`、含未跟踪文件),非 Git 项目遍历目录并自动跳过 `node_modules` 等依赖/缓存目录;摸鱼悬浮窗里同样可用;
|
|
49
49
|
- 资源管理器文件/文件夹可直接**拖进右侧输入框**变成 @引用;
|
|
50
50
|
- 资源管理器右键:新建 / 重命名 / 删除 / 复制 / 粘贴 / 打开所在文件夹 / 两文件对比;
|
package/client.js
CHANGED
|
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
|
|
|
16
16
|
const G = {}
|
|
17
17
|
G.NS = GUFA_NS
|
|
18
18
|
/** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
|
|
19
|
-
G.BUILD = '1.3.
|
|
19
|
+
G.BUILD = '1.3.100'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -13949,9 +13949,23 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13949
13949
|
if (next !== undefined) setActivePath(next.path)
|
|
13950
13950
|
},
|
|
13951
13951
|
newWindow: () => {
|
|
13952
|
-
/* Host 用古法编程原生 helper 开一个普通窗口,加载同一个 Web GUI
|
|
13953
|
-
|
|
13954
|
-
|
|
13952
|
+
/* Host 用古法编程原生 helper 开一个普通窗口,加载同一个 Web GUI,
|
|
13953
|
+
并把当前项目/标签页状态与全屏状态带过去;失败才回退浏览器窗口。 */
|
|
13954
|
+
let fullscreen = false
|
|
13955
|
+
try {
|
|
13956
|
+
const coversScreen = window.innerWidth >= (screen.width - 2) && window.innerHeight >= (screen.height - 2)
|
|
13957
|
+
const coversWorkArea = window.innerWidth >= (screen.availWidth - 2) && window.innerHeight >= (screen.availHeight - 2)
|
|
13958
|
+
fullscreen = coversScreen || coversWorkArea
|
|
13959
|
+
} catch {
|
|
13960
|
+
fullscreen = false
|
|
13961
|
+
}
|
|
13962
|
+
let state
|
|
13963
|
+
try {
|
|
13964
|
+
state = buildFloatSnapshot()
|
|
13965
|
+
} catch {
|
|
13966
|
+
state = undefined
|
|
13967
|
+
}
|
|
13968
|
+
void G.api('app.newWindow', { state, fullscreen }).catch((error) => {
|
|
13955
13969
|
let opened = null
|
|
13956
13970
|
try { opened = window.open(location.href, '_blank') } catch { opened = null }
|
|
13957
13971
|
if (opened !== null && opened !== undefined) {
|
|
@@ -13993,7 +14007,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
13993
14007
|
}
|
|
13994
14008
|
setShortcutsOpen((open) => open === false)
|
|
13995
14009
|
},
|
|
13996
|
-
}), [activePath, tabs, ui.terminalOpen, ui.sidebarOpen, saveFile, saveCompareTab, patchUi, closeTabWithConfirm])
|
|
14010
|
+
}), [activePath, tabs, ui.terminalOpen, ui.sidebarOpen, saveFile, saveCompareTab, patchUi, closeTabWithConfirm, buildFloatSnapshot])
|
|
13997
14011
|
G.useIdeShortcuts(ideShortcutHandlers)
|
|
13998
14012
|
|
|
13999
14013
|
/* 原生快捷键服务派发到当前 App 的动作表(IDE 模式内有效)。 */
|
|
@@ -15577,6 +15591,43 @@ const GUFA_PLUGIN = {
|
|
|
15577
15591
|
console.error('[gufa-code] 悬浮模式初始化失败', error)
|
|
15578
15592
|
}
|
|
15579
15593
|
|
|
15594
|
+
/* ── 实例窗口(⌘⇧N 打开的 helper full 窗口):直接进入古法编程 ──
|
|
15595
|
+
helper 已注入项目和编辑器状态;这里在客户端 boot 后反复调 G.enterGufa,
|
|
15596
|
+
直到 IDE 覆盖层真正挂载,避免和 slots 注册时序赛跑。 */
|
|
15597
|
+
try {
|
|
15598
|
+
const instanceMode = /[?&]gufa-instance=1/.test(String(location.search || ''))
|
|
15599
|
+
if (instanceMode && document.documentElement.hasAttribute('data-gufa-float') !== true) {
|
|
15600
|
+
document.documentElement.setAttribute('data-gufa-booting', '1')
|
|
15601
|
+
let attempts = 0
|
|
15602
|
+
let timer = 0
|
|
15603
|
+
const tryEnter = () => {
|
|
15604
|
+
try {
|
|
15605
|
+
if (document.querySelector('.gufa-overlay-root') !== null) {
|
|
15606
|
+
document.documentElement.removeAttribute('data-gufa-booting')
|
|
15607
|
+
if (timer !== 0) window.clearInterval(timer)
|
|
15608
|
+
return
|
|
15609
|
+
}
|
|
15610
|
+
if (typeof G.enterGufa === 'function') G.enterGufa()
|
|
15611
|
+
} catch {
|
|
15612
|
+
/* ignore */
|
|
15613
|
+
}
|
|
15614
|
+
attempts += 1
|
|
15615
|
+
if (attempts > 80 && timer !== 0) {
|
|
15616
|
+
window.clearInterval(timer)
|
|
15617
|
+
document.documentElement.removeAttribute('data-gufa-booting')
|
|
15618
|
+
}
|
|
15619
|
+
}
|
|
15620
|
+
tryEnter()
|
|
15621
|
+
timer = window.setInterval(tryEnter, 200)
|
|
15622
|
+
ctx.effect(() => () => {
|
|
15623
|
+
if (timer !== 0) window.clearInterval(timer)
|
|
15624
|
+
document.documentElement.removeAttribute('data-gufa-booting')
|
|
15625
|
+
}, 'gufa-code: instance boot')
|
|
15626
|
+
}
|
|
15627
|
+
} catch (error) {
|
|
15628
|
+
console.error('[gufa-code] 实例窗口自动进入 IDE 失败', error)
|
|
15629
|
+
}
|
|
15630
|
+
|
|
15580
15631
|
/* HMR 重载时如果仍处于 IDE 模式,重新打上标记(卸载清理会移除它) */
|
|
15581
15632
|
try {
|
|
15582
15633
|
if (typeof G.mode?.get === 'function' && G.mode.get() === true) document.documentElement.setAttribute('data-gufa-ide', '')
|
|
@@ -38,6 +38,23 @@ static void GufaLog(NSString *format, ...) {
|
|
|
38
38
|
[handle closeFile];
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
/* 把任意 JSON 值转成可安全嵌入 JS 的字面量(用于 document-start 注入 localStorage)。 */
|
|
43
|
+
static NSString *GufaJSONLiteralString(id object) {
|
|
44
|
+
if (object == nil || object == [NSNull null]) return @"null";
|
|
45
|
+
/* 顶层字符串/数字是 JSON fragment,必须显式允许,否则会退化成数组字面量。 */
|
|
46
|
+
NSData *data = [NSJSONSerialization dataWithJSONObject:object options:NSJSONWritingFragmentsAllowed error:NULL];
|
|
47
|
+
if (data == nil) {
|
|
48
|
+
NSData *quoted = [NSJSONSerialization dataWithJSONObject:@[object] options:0 error:NULL];
|
|
49
|
+
data = quoted;
|
|
50
|
+
if (data != nil) {
|
|
51
|
+
NSString *arrayLiteral = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
52
|
+
if (arrayLiteral.length >= 2) return [arrayLiteral substringWithRange:NSMakeRange(1, arrayLiteral.length - 2)];
|
|
53
|
+
}
|
|
54
|
+
return @"null";
|
|
55
|
+
}
|
|
56
|
+
return [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
57
|
+
}
|
|
41
58
|
static void GufaEmitJSON(NSDictionary *out);
|
|
42
59
|
|
|
43
60
|
#ifndef GUFA_FLOAT_VERSION
|
|
@@ -120,6 +137,16 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
|
|
|
120
137
|
@property (nonatomic, copy) void (^pendingLoad)(void);
|
|
121
138
|
@end
|
|
122
139
|
|
|
140
|
+
/* 实例窗口要带 ?gufa-instance=1,客户端 boot 据此自动进入古法编程。 */
|
|
141
|
+
static NSURL *GufaInstanceURL(NSString *appUrl) {
|
|
142
|
+
NSURLComponents *components = [NSURLComponents componentsWithString:appUrl ?: @""];
|
|
143
|
+
if (components == nil) return [NSURL URLWithString:appUrl ?: @""];
|
|
144
|
+
NSMutableArray<NSURLQueryItem *> *items = components.queryItems != nil ? [components.queryItems mutableCopy] : [NSMutableArray array];
|
|
145
|
+
[items addObject:[NSURLQueryItem queryItemWithName:@"gufa-instance" value:@"1"]];
|
|
146
|
+
components.queryItems = items;
|
|
147
|
+
return components.URL;
|
|
148
|
+
}
|
|
149
|
+
|
|
123
150
|
@interface GufaAppDelegate : NSObject <NSApplicationDelegate>
|
|
124
151
|
@property (nonatomic, strong) NSWindow *window;
|
|
125
152
|
@property (nonatomic, strong) WKWebView *webView;
|
|
@@ -413,7 +440,38 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
|
|
|
413
440
|
}
|
|
414
441
|
}
|
|
415
442
|
}
|
|
416
|
-
if (
|
|
443
|
+
if (self.fullMode) {
|
|
444
|
+
/* 实例窗口:只注入主窗口的编辑器状态(项目/标签页/UI),让新窗口直接进古法编程并恢复现场。 */
|
|
445
|
+
NSDictionary *fullState = [self.options[@"state"] isKindOfClass:[NSDictionary class]] ? self.options[@"state"] : nil;
|
|
446
|
+
NSMutableString *js = [NSMutableString stringWithString:@"try{"];
|
|
447
|
+
/* 同一个 WKWebView data store 可能还留着上次摸鱼的标记,实例窗口必须先清掉 */
|
|
448
|
+
[js appendString:@"localStorage.removeItem('gufa-code:float');"];
|
|
449
|
+
if (fullState != nil) {
|
|
450
|
+
NSString *projectRoot = [fullState[@"projectRoot"] isKindOfClass:[NSString class]] ? fullState[@"projectRoot"] : @"";
|
|
451
|
+
if (projectRoot.length > 0) {
|
|
452
|
+
/* 客户端用 JSON.parse 读 project,本地存的是 JSON 字符串(带引号),这里用 JSON.stringify 生成 */
|
|
453
|
+
[js appendFormat:@"localStorage.setItem('gufa-code:project', JSON.stringify(%@));", GufaJSONLiteralString(projectRoot)];
|
|
454
|
+
}
|
|
455
|
+
NSString *stateText = GufaJSONLiteralString(fullState);
|
|
456
|
+
if (stateText.length > 0) {
|
|
457
|
+
NSString *escapedState = [stateText stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"];
|
|
458
|
+
escapedState = [escapedState stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
|
|
459
|
+
escapedState = [escapedState stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
|
|
460
|
+
escapedState = [escapedState stringByReplacingOccurrencesOfString:@"\r" withString:@""];
|
|
461
|
+
[js appendFormat:@"localStorage.setItem('gufa-code:float-state','%@');", escapedState];
|
|
462
|
+
}
|
|
463
|
+
NSDictionary *fullUi = [fullState[@"ui"] isKindOfClass:[NSDictionary class]] ? fullState[@"ui"] : nil;
|
|
464
|
+
if (fullUi != nil) {
|
|
465
|
+
NSString *uiText = GufaJSONLiteralString(fullUi);
|
|
466
|
+
NSString *escapedUi = [uiText stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"];
|
|
467
|
+
escapedUi = [escapedUi stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"];
|
|
468
|
+
[js appendFormat:@"localStorage.setItem('gufa-code:ui:v1','%@');", escapedUi];
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
[js appendString:@"}catch(e){}"];
|
|
472
|
+
WKUserScript *stateScript = [[WKUserScript alloc] initWithSource:js injectionTime:WKUserScriptInjectionTimeAtDocumentStart forMainFrameOnly:YES];
|
|
473
|
+
[config.userContentController addUserScript:stateScript];
|
|
474
|
+
} else {
|
|
417
475
|
[bootstrap appendString:@"}catch(e){}"];
|
|
418
476
|
WKUserScript *floatMarker = [[WKUserScript alloc] initWithSource:bootstrap
|
|
419
477
|
injectionTime:WKUserScriptInjectionTimeAtDocumentStart
|
|
@@ -448,6 +506,13 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
|
|
|
448
506
|
}
|
|
449
507
|
[self.window makeKeyAndOrderFront:nil];
|
|
450
508
|
[NSApp activateIgnoringOtherApps:YES];
|
|
509
|
+
if (self.fullMode && [self.options[@"fullscreen"] boolValue]) {
|
|
510
|
+
__weak typeof(self) weakSelf = self;
|
|
511
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
512
|
+
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
513
|
+
if (strongSelf != nil && strongSelf.window != nil && (strongSelf.window.styleMask & NSWindowStyleMaskFullScreen) == 0) [strongSelf.window toggleFullScreen:nil];
|
|
514
|
+
});
|
|
515
|
+
}
|
|
451
516
|
GufaLog(@"window-frame %@ visible=%d level=%ld activeSpace=%d screen=%@ alpha=%.2f", NSStringFromRect(self.window.frame), self.window.isVisible ? 1 : 0, (long)self.window.level, self.window.isOnActiveSpace ? 1 : 0, self.window.screen == nil ? @"nil" : NSStringFromRect(self.window.screen.frame), self.window.alphaValue);
|
|
452
517
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveFrame) name:NSWindowDidEndLiveResizeNotification object:self.window];
|
|
453
518
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveFrame) name:NSWindowDidMoveNotification object:self.window];
|
|
@@ -487,7 +552,7 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
|
|
|
487
552
|
__strong typeof(weakSelf) self = weakSelf;
|
|
488
553
|
if (self == nil) return;
|
|
489
554
|
if (self.fullMode) {
|
|
490
|
-
[self.webView loadRequest:[NSURLRequest requestWithURL:
|
|
555
|
+
[self.webView loadRequest:[NSURLRequest requestWithURL:GufaInstanceURL(appUrl)]];
|
|
491
556
|
return;
|
|
492
557
|
}
|
|
493
558
|
/* 鉴权 cookie 已在 token URL 重定向时写入;这里用 JS 写 localStorage(避开 URL 长度/转义问题),
|
|
@@ -578,7 +643,7 @@ static OSStatus GufaHotKeyHandler(EventHandlerCallRef nextHandler, EventRef even
|
|
|
578
643
|
WKHTTPCookieStore *store = [WKWebsiteDataStore defaultDataStore].httpCookieStore;
|
|
579
644
|
[store setCookie:httpCookie completionHandler:^{
|
|
580
645
|
if (self.fullMode) {
|
|
581
|
-
[self.webView loadRequest:[NSURLRequest requestWithURL:
|
|
646
|
+
[self.webView loadRequest:[NSURLRequest requestWithURL:GufaInstanceURL(self.options[@"appUrl"])]];
|
|
582
647
|
return;
|
|
583
648
|
}
|
|
584
649
|
NSURLComponents *components = [NSURLComponents componentsWithString:self.options[@"appUrl"] ?: @""];
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
8
8
|
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
9
9
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
10
|
-
<key>CFBundleShortVersionString</key><string>1.3.
|
|
11
|
-
<key>CFBundleVersion</key><string>1.3.
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.100</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.100</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
Binary file
|
package/docs/KNOWN-PITFALLS.md
CHANGED
|
@@ -59,6 +59,9 @@
|
|
|
59
59
|
- 实现:复用插件自带的原生 helper(`desktop/float/GufaFloat.m`),payload 传 `{full:true, authUrl, appUrl}` —— helper 建普通标题栏窗口、Regular 激活策略、跳过摸鱼 localStorage/隐藏主窗/吸附,加载同一个 DSH Web GUI;鉴权复用它已有的 `connection.authenticatedUrl()` token 流程。
|
|
60
60
|
- 客户端 ⌘⇧N 必须先调 Host `app.newWindow`,失败才回退 `window.open`(Electron 的 setWindowOpenHandler 会 deny 并用外部浏览器打开 http(s),不是应用内窗口)。
|
|
61
61
|
- 新窗口与 Electron 主窗口共享的是 **同一个 Host/服务端**,但 UI 进程独立(WKWebView,不走 Electron preload);所以别让新窗口依赖 `window.dshDesktop` 之类的 Electron preload API。
|
|
62
|
+
- **自动进入古法编程**:helper full 模式在 document-start 注入 `gufa-code:project` / `gufa-code:float-state` / `gufa-code:ui:v1`;URL 带 `?gufa-instance=1`,客户端 boot 时反复调 `G.enterGufa()` 直到 `.gufa-overlay-root` 挂载。注意 `gufa-code:project` 客户端用 `JSON.parse` 读,注入时必须写 **JSON 字符串**(`JSON.stringify(...)` 生成带引号的值),直接写裸路径会读成 null。
|
|
63
|
+
- helper 的 WKWebView data store 与摸鱼悬浮层共享;full 模式必须 `localStorage.removeItem('gufa-code:float')`,否则新窗口会误进摸鱼 UI。
|
|
64
|
+
- **全屏继承**:客户端用 `innerWidth/innerHeight` 对比 `screen.width/height` 和 `screen.availWidth/availHeight` 判断当前是否全屏,payload 传 `fullscreen:true`,helper 在窗口显示后 `toggleFullScreen`;不要依赖 Electron preload 或 AX 查询(Host 在 Node 模式进程里拿不到 Electron)。
|
|
62
65
|
|
|
63
66
|
## 1. 弹窗/菜单层级:只有一个正确做法(反复踩过多次,最终定案)
|
|
64
67
|
|
package/host/app-window.js
CHANGED
|
@@ -47,8 +47,12 @@ export async function newWindow(body, env) {
|
|
|
47
47
|
}
|
|
48
48
|
const base = `${webServer.protocol}//127.0.0.1:${String(webServer.port)}`
|
|
49
49
|
const authUrl = connection.authenticatedUrl(`${base}/`)
|
|
50
|
+
const state = body !== null && typeof body === 'object' && body.state !== null && typeof body.state === 'object' ? body.state : undefined
|
|
51
|
+
const fullscreen = body !== null && typeof body === 'object' && body.fullscreen === true
|
|
50
52
|
const payload = JSON.stringify({
|
|
51
53
|
full: true,
|
|
54
|
+
fullscreen,
|
|
55
|
+
state,
|
|
52
56
|
authUrl,
|
|
53
57
|
appUrl: `${base}/`,
|
|
54
58
|
title: 'DeepSeek Harness',
|
package/package.json
CHANGED
package/src/client/90-app.js
CHANGED
|
@@ -2108,9 +2108,23 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2108
2108
|
if (next !== undefined) setActivePath(next.path)
|
|
2109
2109
|
},
|
|
2110
2110
|
newWindow: () => {
|
|
2111
|
-
/* Host 用古法编程原生 helper 开一个普通窗口,加载同一个 Web GUI
|
|
2112
|
-
|
|
2113
|
-
|
|
2111
|
+
/* Host 用古法编程原生 helper 开一个普通窗口,加载同一个 Web GUI,
|
|
2112
|
+
并把当前项目/标签页状态与全屏状态带过去;失败才回退浏览器窗口。 */
|
|
2113
|
+
let fullscreen = false
|
|
2114
|
+
try {
|
|
2115
|
+
const coversScreen = window.innerWidth >= (screen.width - 2) && window.innerHeight >= (screen.height - 2)
|
|
2116
|
+
const coversWorkArea = window.innerWidth >= (screen.availWidth - 2) && window.innerHeight >= (screen.availHeight - 2)
|
|
2117
|
+
fullscreen = coversScreen || coversWorkArea
|
|
2118
|
+
} catch {
|
|
2119
|
+
fullscreen = false
|
|
2120
|
+
}
|
|
2121
|
+
let state
|
|
2122
|
+
try {
|
|
2123
|
+
state = buildFloatSnapshot()
|
|
2124
|
+
} catch {
|
|
2125
|
+
state = undefined
|
|
2126
|
+
}
|
|
2127
|
+
void G.api('app.newWindow', { state, fullscreen }).catch((error) => {
|
|
2114
2128
|
let opened = null
|
|
2115
2129
|
try { opened = window.open(location.href, '_blank') } catch { opened = null }
|
|
2116
2130
|
if (opened !== null && opened !== undefined) {
|
|
@@ -2152,7 +2166,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2152
2166
|
}
|
|
2153
2167
|
setShortcutsOpen((open) => open === false)
|
|
2154
2168
|
},
|
|
2155
|
-
}), [activePath, tabs, ui.terminalOpen, ui.sidebarOpen, saveFile, saveCompareTab, patchUi, closeTabWithConfirm])
|
|
2169
|
+
}), [activePath, tabs, ui.terminalOpen, ui.sidebarOpen, saveFile, saveCompareTab, patchUi, closeTabWithConfirm, buildFloatSnapshot])
|
|
2156
2170
|
G.useIdeShortcuts(ideShortcutHandlers)
|
|
2157
2171
|
|
|
2158
2172
|
/* 原生快捷键服务派发到当前 App 的动作表(IDE 模式内有效)。 */
|
package/src/client/99-main.js
CHANGED
|
@@ -429,6 +429,43 @@ const GUFA_PLUGIN = {
|
|
|
429
429
|
console.error('[gufa-code] 悬浮模式初始化失败', error)
|
|
430
430
|
}
|
|
431
431
|
|
|
432
|
+
/* ── 实例窗口(⌘⇧N 打开的 helper full 窗口):直接进入古法编程 ──
|
|
433
|
+
helper 已注入项目和编辑器状态;这里在客户端 boot 后反复调 G.enterGufa,
|
|
434
|
+
直到 IDE 覆盖层真正挂载,避免和 slots 注册时序赛跑。 */
|
|
435
|
+
try {
|
|
436
|
+
const instanceMode = /[?&]gufa-instance=1/.test(String(location.search || ''))
|
|
437
|
+
if (instanceMode && document.documentElement.hasAttribute('data-gufa-float') !== true) {
|
|
438
|
+
document.documentElement.setAttribute('data-gufa-booting', '1')
|
|
439
|
+
let attempts = 0
|
|
440
|
+
let timer = 0
|
|
441
|
+
const tryEnter = () => {
|
|
442
|
+
try {
|
|
443
|
+
if (document.querySelector('.gufa-overlay-root') !== null) {
|
|
444
|
+
document.documentElement.removeAttribute('data-gufa-booting')
|
|
445
|
+
if (timer !== 0) window.clearInterval(timer)
|
|
446
|
+
return
|
|
447
|
+
}
|
|
448
|
+
if (typeof G.enterGufa === 'function') G.enterGufa()
|
|
449
|
+
} catch {
|
|
450
|
+
/* ignore */
|
|
451
|
+
}
|
|
452
|
+
attempts += 1
|
|
453
|
+
if (attempts > 80 && timer !== 0) {
|
|
454
|
+
window.clearInterval(timer)
|
|
455
|
+
document.documentElement.removeAttribute('data-gufa-booting')
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
tryEnter()
|
|
459
|
+
timer = window.setInterval(tryEnter, 200)
|
|
460
|
+
ctx.effect(() => () => {
|
|
461
|
+
if (timer !== 0) window.clearInterval(timer)
|
|
462
|
+
document.documentElement.removeAttribute('data-gufa-booting')
|
|
463
|
+
}, 'gufa-code: instance boot')
|
|
464
|
+
}
|
|
465
|
+
} catch (error) {
|
|
466
|
+
console.error('[gufa-code] 实例窗口自动进入 IDE 失败', error)
|
|
467
|
+
}
|
|
468
|
+
|
|
432
469
|
/* HMR 重载时如果仍处于 IDE 模式,重新打上标记(卸载清理会移除它) */
|
|
433
470
|
try {
|
|
434
471
|
if (typeof G.mode?.get === 'function' && G.mode.get() === true) document.documentElement.setAttribute('data-gufa-ide', '')
|