package main import ( "embed" "os" "github.com/wailsapp/wails/v3/pkg/application" "videoconcat/services" ) //go:embed assets var assets embed.FS // getEmbeddedFFmpeg 在平台特定文件中实现(ffmpeg_darwin.go, ffmpeg_windows.go, ffmpeg_linux.go, ffmpeg_default.go) // 根据编译时的 GOOS 自动选择对应的实现 // 注意:此函数没有在此文件中声明,而是在平台特定文件中声明和实现 func main() { // 检测开发模式并设置日志级别 if os.Getenv("DEV") == "true" { services.SetLogLevel("DEBUG") services.LogInfo("=== 开发模式启动 ===") services.LogDebug("详细日志已启用") } // 初始化 FFmpeg 助手(传递嵌入的文件系统,根据编译平台自动选择) services.InitFFmpegHelper(getEmbeddedFFmpeg()) // 创建服务 services.LogDebug("开始创建服务...") videoService := services.NewVideoService() extractService := services.NewExtractService() authService := services.NewAuthService() fileService := services.NewFileService() services.LogDebug("所有服务创建完成") services.LogDebug("创建 Wails 应用...") app := application.New(application.Options{ Name: "VideoConcat", Description: "视频拼接工具", Assets: application.AssetOptions{Handler: application.AssetFileServerFS(assets)}, Services: []application.Service{ application.NewService(videoService), application.NewService(extractService), application.NewService(authService), application.NewService(fileService), }, Mac: application.MacOptions{ ApplicationShouldTerminateAfterLastWindowClosed: true, }, }) services.LogDebug("Wails 应用创建完成") // 创建窗口 services.LogDebug("创建应用窗口...") window := app.Window.NewWithOptions(application.WebviewWindowOptions{ Title: "视频拼接工具", Width: 1100, Height: 800, MinWidth: 800, MinHeight: 600, }) window.SetURL("index.html") services.LogInfo("应用窗口已创建,URL: index.html") services.LogInfo("=== 应用启动完成,开始运行 ===") if err := app.Run(); err != nil { services.LogErrorf("应用运行错误: %v", err) panic(err) } }