feat(settings): 新增 DWS 设备登录与目录连接检查
build / build (push) Successful in 1m52s

数据源配置可发起钉钉官方设备授权、重新授权和取消,完成后刷新共享账号状态并独立检查目录权限。
授权会话限定发起的管理员登录会话,令牌由现有 CLI 存储,取消等待子进程退出。

验证:完整 make verify 通过;前端 582 项、Go 1545 项通过,487 项声明的可选集成未运行。
授权处理器与 HTTP 边界通过 race 检查;本人钉钉授权仍由管理员在官方页面完成。
This commit is contained in:
姚章浩
2026-11-17 16:59:47 +08:00
parent 6c10f71c28
commit b2cea6ed84
20 changed files with 1291 additions and 46 deletions
+14 -4
View File
@@ -19,8 +19,8 @@ type ExecRunner struct {
Timeout time.Duration
}
// RunDWS 运行 `dws <args…>` 并返回 stdout。
func (r ExecRunner) RunDWS(ctx context.Context, args ...string) ([]byte, error) {
// command keeps device login and source reads on one credential environment.
func (r ExecRunner) command(ctx context.Context, args ...string) (*exec.Cmd, error) {
binary := r.Binary
if binary == "" {
binary = os.Getenv("DWS_BIN")
@@ -32,14 +32,24 @@ func (r ExecRunner) RunDWS(ctx context.Context, args ...string) ([]byte, error)
}
binary = found
}
command := exec.CommandContext(ctx, binary, args...)
command.Env = dwsEnv()
command.WaitDelay = 2 * time.Second
return command, nil
}
// RunDWS uses the same executable and credential environment as device login.
func (r ExecRunner) RunDWS(ctx context.Context, args ...string) ([]byte, error) {
timeout := r.Timeout
if timeout <= 0 {
timeout = 25 * time.Second
}
runCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
command := exec.CommandContext(runCtx, binary, args...)
command.Env = dwsEnv()
command, err := r.command(runCtx, args...)
if err != nil {
return nil, err
}
var stdout, stderr bytes.Buffer
command.Stdout = &stdout
command.Stderr = &stderr