Private
Public Access
1
0
Files
u-desk/main.go
绝尘 f54bf1c28d 重构:Wails v3 迁移 + 前端目录规范化 + Sidebar滚动优化
- web/ → frontend/ 目录重命名(Wails v3 标准结构)
- main.go: Middleware 修复 custom.js 404 + DevTools 延迟启动
- Sidebar: 收藏夹内部独立滚动 + 帮助区块固定底部
- useFavorites.ts: longPressTimer const→let 修复 TypeError
- App.vue: Arco Tabs padding-top 覆盖
- build: config.yml / Taskfile.yml 对齐官方模板,devtools build tag
- 新增 v3 bindings、vite.config.js、跨平台构建配置

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 11:03:53 +08:00

87 lines
2.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"embed"
"net/http"
"time"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed all:frontend/dist
var assets embed.FS
// 标题栏颜色0x00BBGGRR
var (
titleBarLight = uint32(0xF0F0F0) // #F0F0F0 近白
titleBarDark = uint32(0x2D2D2D) // #2D2D2D 深灰
)
func main() {
app := NewApp()
wailsApp := application.New(application.Options{
Name: "U-Desk",
Description: "桌面文件管理器",
Services: []application.Service{
application.NewService(app),
},
Assets: application.AssetOptions{
Handler: application.AssetFileServerFS(assets),
Middleware: func(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if req.URL.Path == "/wails/custom.js" {
// custom.js 未使用,返回空响应避免 404 控制台报错
rw.Header().Set("Content-Type", "application/javascript")
rw.WriteHeader(200)
return
}
next.ServeHTTP(rw, req)
})
},
},
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
window := application.Get().Window.NewWithOptions(application.WebviewWindowOptions{
Title: "U-Desk",
Width: 1400,
Height: 900,
MinWidth: 1000,
MinHeight: 600,
BackgroundColour: application.NewRGB(255, 255, 255),
URL: "/",
Frameless: true,
// 保留 Windows 11 原生装饰(圆角 + Aero 阴影)
Windows: application.WindowsWindow{
Theme: application.SystemDefault,
CustomTheme: application.ThemeSettings{
LightModeActive: &application.WindowTheme{
TitleBarColour: &titleBarLight,
BorderColour: &titleBarLight,
},
DarkModeActive: &application.WindowTheme{
TitleBarColour: &titleBarDark,
BorderColour: &titleBarDark,
},
},
},
})
app.SetMainWindow(window)
// production+devtools 模式下 OpenInspectorOnStartup 不生效(需 debugMode=true
// 手动延迟调用 OpenDevTools 弹出 Inspector
// TODO: 替换为 OnDomReady 回调,当前 alpha.80 可能未稳定支持
go func() {
time.Sleep(2 * time.Second)
_ = window.OpenDevTools()
}()
if err := wailsApp.Run(); err != nil {
println("Error:", err.Error())
}
}