Private
Public Access
1
0

修复: OSS收藏打开+连接指示器根目录+字段映射+侧边栏重构+文件监听+首屏优化

This commit is contained in:
2026-05-16 17:55:59 +08:00
parent 316e517989
commit d17c20c579
37 changed files with 1667 additions and 1566 deletions

35
main.go
View File

@@ -2,8 +2,9 @@ package main
import (
"embed"
"fmt"
"net/http"
"time"
"os"
"github.com/wailsapp/wails/v3/pkg/application"
"u-desk/internal/hotkey"
@@ -14,8 +15,9 @@ var assets embed.FS
// 标题栏颜色0x00BBGGRR
var (
titleBarLight = uint32(0xF0F0F0) // #F0F0F0 近白
titleBarLight = uint32(0xF0F0F0) // #F0F0F0 近白
titleBarDark = uint32(0x2D2D2D) // #2D2D2D 深灰
noBorder = uint32(0xFFFFFFFE) // DWMWA_COLOR_NONE - Win11 抑制边框绘制
)
func main() {
@@ -24,6 +26,9 @@ func main() {
wailsApp := application.New(application.Options{
Name: "U-Desk",
Description: "桌面文件管理器",
SingleInstance: &application.SingleInstanceOptions{
UniqueID: "top.1216.udesk",
},
Services: []application.Service{
application.NewService(app),
},
@@ -32,7 +37,6 @@ func main() {
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
@@ -67,20 +71,27 @@ func main() {
Height: 900,
MinWidth: 1000,
MinHeight: 600,
BackgroundColour: application.NewRGB(255, 255, 255),
BackgroundColour: application.NewRGB(45, 45, 45),
URL: "/",
Frameless: true,
// 保留 Windows 11 原生装饰(圆角 + Aero 阴影)
Windows: application.WindowsWindow{
Theme: application.SystemDefault,
CustomTheme: application.ThemeSettings{
LightModeActive: &application.WindowTheme{
TitleBarColour: &titleBarLight,
BorderColour: &titleBarLight,
BorderColour: &noBorder,
},
LightModeInactive: &application.WindowTheme{
TitleBarColour: &titleBarLight,
BorderColour: &noBorder,
},
DarkModeActive: &application.WindowTheme{
TitleBarColour: &titleBarDark,
BorderColour: &titleBarDark,
BorderColour: &noBorder,
},
DarkModeInactive: &application.WindowTheme{
TitleBarColour: &titleBarDark,
BorderColour: &noBorder,
},
},
},
@@ -88,15 +99,7 @@ func main() {
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())
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
}
}