mirror of
https://github.com/MatrixSeven/file-transfer-go.git
synced 2026-02-28 02:44:41 +08:00
feat: 删除不再使用的构建脚本和模型文件
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
// WebRTCOffer WebRTC offer 结构
|
||||
type WebRTCOffer struct {
|
||||
SDP string `json:"sdp"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// WebRTCAnswer WebRTC answer 结构
|
||||
type WebRTCAnswer struct {
|
||||
SDP string `json:"sdp"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// WebRTCICECandidate ICE candidate 结构
|
||||
type WebRTCICECandidate struct {
|
||||
Candidate string `json:"candidate"`
|
||||
SDPMLineIndex int `json:"sdpMLineIndex"`
|
||||
SDPMid string `json:"sdpMid"`
|
||||
}
|
||||
|
||||
// VideoMessage 视频消息结构
|
||||
type VideoMessage struct {
|
||||
Type string `json:"type"`
|
||||
Payload interface{} `json:"payload"`
|
||||
}
|
||||
|
||||
// ClientInfo 客户端连接信息
|
||||
type ClientInfo struct {
|
||||
ID string `json:"id"` // 客户端唯一标识
|
||||
Role string `json:"role"` // sender 或 receiver
|
||||
Connection *websocket.Conn `json:"-"` // WebSocket连接(不序列化)
|
||||
JoinedAt time.Time `json:"joined_at"` // 加入时间
|
||||
UserAgent string `json:"user_agent"` // 用户代理
|
||||
}
|
||||
|
||||
// RoomStatus 房间状态信息
|
||||
type RoomStatus struct {
|
||||
Code string `json:"code"`
|
||||
SenderOnline bool `json:"sender_online"`
|
||||
ReceiverOnline bool `json:"receiver_online"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// ErrorResponse 错误响应结构
|
||||
type ErrorResponse struct {
|
||||
Success bool `json:"success"`
|
||||
Message string `json:"message"`
|
||||
Code string `json:"code,omitempty"`
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// 嵌入静态文件
|
||||
//
|
||||
//go:embed all:static
|
||||
var StaticFiles embed.FS
|
||||
|
||||
// StaticFileServer 创建静态文件服务器
|
||||
func StaticFileServer() http.Handler {
|
||||
// 获取嵌入的文件系统
|
||||
staticFS, err := fs.Sub(StaticFiles, "static")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return http.FileServer(http.FS(staticFS))
|
||||
}
|
||||
|
||||
// FrontendFileServer 创建前端文件服务器
|
||||
func FrontendFileServer() http.Handler {
|
||||
return &frontendHandler{}
|
||||
}
|
||||
|
||||
// frontendHandler 处理前端文件请求,支持 SPA 路由
|
||||
type frontendHandler struct{}
|
||||
|
||||
func (h *frontendHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// 返回一个简单的占位页面
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Write([]byte(`
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>文件传输</title>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<h1>文件传输服务</h1>
|
||||
<p>前端文件未嵌入,请先构建前端项目。</p>
|
||||
<p>运行以下命令构建前端:</p>
|
||||
<pre>cd chuan-next && yarn build:ssg</pre>
|
||||
</body>
|
||||
</html>
|
||||
`))
|
||||
}
|
||||
Reference in New Issue
Block a user