mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-21 16:34:21 +08:00
✨ feat(native-window): 支持标签页拖出为原生独立窗口
- 支持 SQL、数据和结果标签拖出到跨显示器原生窗口 - 通过受认证 loopback bridge 复用主进程后端与状态 - 支持子窗口继续拆窗、聚焦、关闭、还原与异常退出恢复 - 补充多窗口协议、状态同步和跨平台回归测试
This commit is contained in:
59
internal/nativewindow/process.go
Normal file
59
internal/nativewindow/process.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package nativewindow
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type processSpec struct {
|
||||
Executable string
|
||||
Env []string
|
||||
}
|
||||
|
||||
type childProcess interface {
|
||||
PID() int
|
||||
Wait() error
|
||||
Kill() error
|
||||
}
|
||||
|
||||
type processStarter interface {
|
||||
Start(processSpec) (childProcess, error)
|
||||
}
|
||||
|
||||
type execProcessStarter struct{}
|
||||
|
||||
func (execProcessStarter) Start(spec processSpec) (childProcess, error) {
|
||||
command := exec.Command(spec.Executable, DetachedWindowArgument)
|
||||
command.Env = spec.Env
|
||||
command.Stdout = os.Stdout
|
||||
command.Stderr = os.Stderr
|
||||
if err := command.Start(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &execChildProcess{command: command}, nil
|
||||
}
|
||||
|
||||
type execChildProcess struct {
|
||||
command *exec.Cmd
|
||||
}
|
||||
|
||||
func (p *execChildProcess) PID() int {
|
||||
if p == nil || p.command == nil || p.command.Process == nil {
|
||||
return 0
|
||||
}
|
||||
return p.command.Process.Pid
|
||||
}
|
||||
|
||||
func (p *execChildProcess) Wait() error {
|
||||
if p == nil || p.command == nil {
|
||||
return nil
|
||||
}
|
||||
return p.command.Wait()
|
||||
}
|
||||
|
||||
func (p *execChildProcess) Kill() error {
|
||||
if p == nil || p.command == nil || p.command.Process == nil {
|
||||
return nil
|
||||
}
|
||||
return p.command.Process.Kill()
|
||||
}
|
||||
Reference in New Issue
Block a user