mirror of
https://github.com/black-ant/Ant-Browser.git
synced 2026-07-14 18:48:55 +08:00
chore(build): complete unsigned macOS packaging
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
goruntime "runtime"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
@@ -406,7 +407,7 @@ func DefaultConfig() *Config {
|
||||
},
|
||||
Browser: BrowserConfig{
|
||||
UserDataRoot: "data",
|
||||
DefaultFingerprintArgs: []string{"--fingerprint-brand=Chrome", "--fingerprint-platform=windows"},
|
||||
DefaultFingerprintArgs: defaultFingerprintArgsForOS(goruntime.GOOS),
|
||||
DefaultLaunchArgs: []string{"--disable-sync", "--no-first-run"},
|
||||
DefaultProxy: "",
|
||||
StartReadyTimeoutMs: 3000,
|
||||
@@ -445,6 +446,17 @@ func DefaultConfig() *Config {
|
||||
}
|
||||
}
|
||||
|
||||
func defaultFingerprintArgsForOS(goos string) []string {
|
||||
platform := "windows"
|
||||
switch strings.ToLower(strings.TrimSpace(goos)) {
|
||||
case "darwin":
|
||||
platform = "mac"
|
||||
case "linux":
|
||||
platform = "linux"
|
||||
}
|
||||
return []string{"--fingerprint-brand=Chrome", "--fingerprint-platform=" + platform}
|
||||
}
|
||||
|
||||
// Save 保存配置到文件
|
||||
func (c *Config) Save(configPath string) error {
|
||||
data, err := yaml.Marshal(c)
|
||||
|
||||
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -74,6 +75,42 @@ browser: {}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultFingerprintArgsForOS(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := map[string]string{
|
||||
"windows": "--fingerprint-platform=windows",
|
||||
"linux": "--fingerprint-platform=linux",
|
||||
"darwin": "--fingerprint-platform=mac",
|
||||
"freebsd": "--fingerprint-platform=windows",
|
||||
}
|
||||
|
||||
for goos, want := range tests {
|
||||
got := defaultFingerprintArgsForOS(goos)
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("%s: unexpected args length: got=%v", goos, got)
|
||||
}
|
||||
if got[1] != want {
|
||||
t.Fatalf("%s: platform arg mismatch: got=%q want=%q", goos, got[1], want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultConfigUsesCurrentOSFingerprintPlatform(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cfg := DefaultConfig()
|
||||
want := defaultFingerprintArgsForOS(runtime.GOOS)
|
||||
if len(cfg.Browser.DefaultFingerprintArgs) != len(want) {
|
||||
t.Fatalf("默认指纹参数数量不符: got=%v want=%v", cfg.Browser.DefaultFingerprintArgs, want)
|
||||
}
|
||||
for i := range want {
|
||||
if cfg.Browser.DefaultFingerprintArgs[i] != want[i] {
|
||||
t.Fatalf("默认指纹参数不符: got=%v want=%v", cfg.Browser.DefaultFingerprintArgs, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadPreservesExplicitConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user