Skip to content

Commit

Permalink
更明确的错误提示
Browse files Browse the repository at this point in the history
  • Loading branch information
IJNKAWAKAZE committed Aug 22, 2024
1 parent d7c8e7c commit 5a9cff9
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 19 deletions.
2 changes: 0 additions & 2 deletions src/core/web/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ func init() {

func Base(r *gin.Engine) {
r.GET("/base", func(c *gin.Context) {
utils.WebC = make(chan error, 10)
defer close(utils.WebC)
r.LoadHTMLFiles("./template/Base.tmpl")
var playerBase PlayerBase
var userAccount account.UserAccount
Expand Down
2 changes: 0 additions & 2 deletions src/core/web/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type Char struct {

func Box(r *gin.Engine) {
r.GET("/box", func(c *gin.Context) {
utils.WebC = make(chan error, 10)
defer close(utils.WebC)
r.LoadHTMLFiles("./template/Box.tmpl")
var box BoxInfo
var userAccount account.UserAccount
Expand Down
2 changes: 0 additions & 2 deletions src/core/web/box_detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ type Equip struct {

func BoxDetail(r *gin.Engine) {
r.GET("/boxDetail", func(c *gin.Context) {
utils.WebC = make(chan error, 10)
defer close(utils.WebC)
r.LoadHTMLFiles("./template/BoxDetail.tmpl")
var detailList []Detail
var userAccount account.UserAccount
Expand Down
2 changes: 0 additions & 2 deletions src/core/web/calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ type CalendarInfo struct {

func Calendar(r *gin.Engine) {
r.GET("/calendar", func(c *gin.Context) {
utils.WebC = make(chan error, 10)
defer close(utils.WebC)
r.LoadHTMLFiles("./template/Calendar.tmpl")
var calendarMap = make(map[string]template.HTML)
resp, err := http.Get(viper.GetString("api.calendar"))
Expand Down
2 changes: 0 additions & 2 deletions src/core/web/card.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ func init() {

func Card(r *gin.Engine) {
r.GET("/card", func(c *gin.Context) {
utils.WebC = make(chan error, 10)
defer close(utils.WebC)
r.LoadHTMLFiles("./template/Card.tmpl")
userId, _ := strconv.ParseInt(c.Query("userId"), 10, 64)
uid := c.Query("uid")
Expand Down
2 changes: 0 additions & 2 deletions src/core/web/depot.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ func init() {

func Depot(r *gin.Engine) {
r.GET("/depot", func(c *gin.Context) {
utils.WebC = make(chan error, 10)
defer close(utils.WebC)
r.LoadHTMLFiles("./template/Depot.tmpl")
var depotItems []DepotItem
var userAccount account.UserAccount
Expand Down
2 changes: 0 additions & 2 deletions src/core/web/missing.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ type MissingChar struct {

func Missing(r *gin.Engine) {
r.GET("/missing", func(c *gin.Context) {
utils.WebC = make(chan error, 10)
defer close(utils.WebC)
r.LoadHTMLFiles("./template/Missing.tmpl")
var missingInfo MissingInfo
param := c.Query("param")
Expand Down
2 changes: 0 additions & 2 deletions src/core/web/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (

func State(r *gin.Engine) {
r.GET("/state", func(c *gin.Context) {
utils.WebC = make(chan error, 10)
defer close(utils.WebC)
r.LoadHTMLFiles("./template/State.tmpl")
var userAccount account.UserAccount
var skAccount skland.Account
Expand Down
7 changes: 4 additions & 3 deletions src/utils/base_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

var ctx = context.Background()

var WebC chan error
var WebC = make(chan error, 10)

var browser playwright.Browser

Expand Down Expand Up @@ -276,8 +276,9 @@ func Screenshot(url string, waitTime float64, scale float64) ([]byte, error) {
page.Goto(url, playwright.PageGotoOptions{
WaitUntil: playwright.WaitUntilStateNetworkidle,
})
e := <-WebC
if e != nil {
if len(WebC) > 0 {
e := <-WebC
close(WebC)
return nil, e
}
page.WaitForTimeout(waitTime)
Expand Down

0 comments on commit 5a9cff9

Please sign in to comment.