dd8eaef97d
- Reorganize code into cmd/bilidown and internal/ packages - Rename client/ to web/ for frontend source - Remove systray dependency for headless web service - Embed static files into binary using go:embed - Update import paths to use internal/ prefix - Update .gitignore with common patterns Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
24 lines
454 B
Go
24 lines
454 B
Go
package util
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// 统一的 JSON 响应结构
|
|
type Res struct {
|
|
Success bool `json:"success"`
|
|
Message string `json:"message"`
|
|
Data any `json:"data"`
|
|
}
|
|
|
|
// 发送响应
|
|
func (r Res) Write(w http.ResponseWriter) {
|
|
bs, err := json.Marshal(r)
|
|
if err != nil {
|
|
w.Write([]byte(`{"success":false,"message":"系统错误","data":null}`))
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Write(bs)
|
|
}
|