@@ -10,13 +10,27 @@ import (
1010 "github.com/yyle88/osexec"
1111)
1212
13+ // FirefoxShow manages Firefox browser automation with webpage output control
14+ // Provides coordinated webpage generation and Firefox opening with timing control
15+ // Handles temporary HTTP service and browser window management
16+ //
17+ // FirefoxShow 管理 Firefox 浏览器自动化与网页输出控制
18+ // 提供协调的网页生成和 Firefox 打开及时间控制
19+ // 处理临时 HTTP 服务和浏览器窗口管理
1320type FirefoxShow struct {
1421 service * gintestpage.Service
1522 command * osexec.OsCommand
1623 showTime time.Time
1724 doneOnce * sync.Once
1825}
1926
27+ // NewFirefoxShow creates Firefox automation instance with custom service and command
28+ // Initializes browser automation using provided HTTP service and OS command configuration
29+ // Returns configured Firefox automation handler for coordinated browser operations
30+ //
31+ // NewFirefoxShow 使用自定义服务和命令创建 Firefox 自动化实例
32+ // 使用提供的 HTTP 服务和操作系统命令配置初始化浏览器自动化
33+ // 返回配置的 Firefox 自动化处理器以实现协调的浏览器操作
2034func NewFirefoxShow (service * gintestpage.Service , command * osexec.OsCommand ) * FirefoxShow {
2135 return & FirefoxShow {
2236 service : service ,
@@ -26,23 +40,55 @@ func NewFirefoxShow(service *gintestpage.Service, command *osexec.OsCommand) *Fi
2640 }
2741}
2842
43+ // NewFirefoxDraw creates Firefox automation with default configuration for development
44+ // Initializes browser automation using default HTTP test service and debug command setup
45+ // Returns ready-to-use Firefox automation handler with optimal development settings
46+ //
47+ // NewFirefoxDraw 使用开发的默认配置创建 Firefox 自动化
48+ // 使用默认 HTTP 测试服务和调试命令设置初始化浏览器自动化
49+ // 返回具有优化开发设置的即用 Firefox 自动化处理器
2950func NewFirefoxDraw () * FirefoxShow {
3051 return NewFirefoxShow (gintestpage .NewService (), osexec .NewOsCommand ().WithDebug ())
3152}
3253
54+ // Close terminates Firefox automation after specified wait time
55+ // Waits for remaining time based on when pages were shown and closes HTTP service
56+ // Uses sync.Once to ensure cleanup happens exactly once
57+ //
58+ // Close 在指定等待时间后终止 Firefox 自动化
59+ // 根据页面显示时间等待剩余时间并关闭 HTTP 服务
60+ // 使用 sync.Once 确保清理操作仅执行一次
3361func (op * FirefoxShow ) Close (waitTime time.Duration ) {
3462 op .doneOnce .Do (func () {
3563 time .Sleep (waitTime - time .Since (op .showTime ))
3664 op .service .Close ()
3765 })
3866}
3967
68+ // ShowInNewWindows displays HTML pages in separate Firefox windows
69+ // Opens each page in its own Firefox window for independent viewing
70+ // Creates temporary URLs and launches Firefox with --new-window option
71+ //
72+ // ShowInNewWindows 在单独的 Firefox 窗口中显示 HTML 页面
73+ // 在独立的 Firefox 窗口中打开每个页面以供独立查看
74+ // 创建临时 URL 并使用 --new-window 选项启动 Firefox
4075func (op * FirefoxShow ) ShowInNewWindows (pages ... string ) {
41- op .Show (pages , "--new-window" ) //打开若干个新窗口以打开若干个网页
76+ op .Open (pages , "--new-window" ) //打开若干个新窗口以打开若干个网页
4277}
4378
79+ // ShowInNewTabs displays HTML pages in new Firefox tabs
80+ // Opens each page in a new tab within existing or new Firefox window
81+ // Creates temporary URLs and launches Firefox with --new-tab option
82+ //
83+ // ShowInNewTabs 在新的 Firefox 标签中显示 HTML 页面
84+ // 在现有或新的 Firefox 窗口的新标签中打开每个页面
85+ // 创建临时 URL 并使用 --new-tab 选项启动 Firefox
4486func (op * FirefoxShow ) ShowInNewTabs (pages ... string ) {
45- op .Show (pages , "--new-tab" ) //打开若干个新标签以打开若干个网页
87+ op .Open (pages , "--new-tab" ) //打开若干个新标签以打开若干个网页
88+ }
89+
90+ func (op * FirefoxShow ) Open (pages []string , openOption string ) {
91+ op .Show (pages , openOption )
4692}
4793
4894func (op * FirefoxShow ) Show (pages []string , openOption string ) {
0 commit comments