29 lines
694 B
Go
29 lines
694 B
Go
package browser
|
|
|
|
import (
|
|
"context"
|
|
"github.com/go-rod/rod"
|
|
"github.com/go-rod/rod/lib/launcher"
|
|
"github.com/go-rod/rod/lib/launcher/flags"
|
|
)
|
|
|
|
// OpenApp 用APP模式打开网页
|
|
func OpenApp(c context.Context, url string) {
|
|
path, _ := launcher.LookPath()
|
|
l := launcher.NewAppMode(url).
|
|
Delete(flags.Env).
|
|
Set("kiosk").
|
|
Set("hide-scrollbars").
|
|
Set("disable-sync").
|
|
Set("disable-features", "GoogleSignin,IdentityConsistency,OmniboxUIExperimentation,GoogleSearch,Autofill,SafeSearch,SpeechRecognition").
|
|
Delete("disable-site-isolation-trials").
|
|
Bin(path)
|
|
p := l.MustLaunch()
|
|
defer l.Cleanup()
|
|
|
|
b := rod.New().ControlURL(p).MustConnect()
|
|
defer b.MustClose()
|
|
|
|
<-c.Done()
|
|
}
|