Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Pangea-Agent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gavin-Group
Pangea-Agent
Commits
8bcb1d59
Commit
8bcb1d59
authored
Jan 04, 2026
by
youxiaoji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* [playwright 增加浏览器类型,支持连接远程浏览器]
parent
42060fe1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
14 deletions
+27
-14
PlaywrightConfig.java
...n/java/pangea/hiagent/common/config/PlaywrightConfig.java
+27
-14
No files found.
backend/src/main/java/pangea/hiagent/common/config/PlaywrightConfig.java
View file @
8bcb1d59
...
@@ -4,35 +4,48 @@ import com.microsoft.playwright.Browser;
...
@@ -4,35 +4,48 @@ import com.microsoft.playwright.Browser;
import
com.microsoft.playwright.BrowserType
;
import
com.microsoft.playwright.BrowserType
;
import
com.microsoft.playwright.Playwright
;
import
com.microsoft.playwright.Playwright
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
@Slf4j
@Slf4j
@Configuration
@Configuration
public
class
PlaywrightConfig
{
public
class
PlaywrightConfig
{
@Value
(
"${pangea.browser.url:ws://localhost:3000}"
)
private
String
browserUrl
;
@Value
(
"${pangea.browser.type:local}"
)
private
String
browserType
;
@Bean
@Bean
public
Playwright
playwright
()
{
public
Playwright
playwright
()
{
log
.
info
(
"playwright init success"
);
log
.
info
(
"playwright init success"
);
return
Playwright
.
create
();
return
Playwright
.
create
();
}
}
@Bean
@Bean
public
Browser
browser
(
Playwright
playwright
)
{
public
Browser
browser
(
Playwright
playwright
)
{
Browser
browser
=
null
;
Browser
browser
=
switch
(
browserType
)
{
browser
=
playwright
.
chromium
().
launch
(
new
BrowserType
.
LaunchOptions
()
case
"local"
->
playwright
.
chromium
().
launch
(
new
BrowserType
.
LaunchOptions
()
.
setHeadless
(
true
)
.
setHeadless
(
true
)
.
setArgs
(
java
.
util
.
Arrays
.
asList
(
.
setArgs
(
java
.
util
.
Arrays
.
asList
(
"--no-sandbox"
,
"--no-sandbox"
,
"--disable-dev-shm-usage"
,
"--disable-dev-shm-usage"
,
"--disable-gpu"
,
"--disable-gpu"
,
"--remote-allow-origins=*"
)));
"--remote-allow-origins=*"
)));
case
"remote"
->
playwright
.
chromium
().
connect
(
browserUrl
);
default
->
null
;
};
if
(
browser
!=
null
)
{
browser
.
onDisconnected
((
tmp
)
->
{
browser
.
onDisconnected
((
tmp
)
->
{
log
.
info
(
"浏览器实例已断开连接"
);
log
.
info
(
"浏览器实例已断开连接"
);
// 发送监听事件
// 发送监听事件
tmp
.
close
();
tmp
.
close
();
});
});
}
return
browser
;
return
browser
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment