Private
Public Access
1
0

重构: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>
This commit is contained in:
2026-05-01 11:03:53 +08:00
parent 44847e0d40
commit f54bf1c28d
185 changed files with 7768 additions and 914 deletions

View File

@@ -2,17 +2,15 @@ package api
import (
"context"
"encoding/json"
"u-desk/internal/service"
"time"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
// UpdateAPI 版本更新 API
type UpdateAPI struct {
updateService *service.UpdateService
ctx context.Context
eventEmitter func(name string, data ...any)
}
// NewUpdateAPI 创建版本更新 API
@@ -22,11 +20,23 @@ func NewUpdateAPI(checkURL string) (*UpdateAPI, error) {
}, nil
}
// SetEventEmitter 设置事件发射器(由 App.ServiceStartup 注入)
func (api *UpdateAPI) SetEventEmitter(emitter func(name string, data ...any)) {
api.eventEmitter = emitter
}
// SetContext 设置上下文(用于事件推送)
func (api *UpdateAPI) SetContext(ctx context.Context) {
api.ctx = ctx
}
// emit 发送事件到前端
func (api *UpdateAPI) emit(name string, data ...any) {
if api.eventEmitter != nil {
api.eventEmitter(name, data...)
}
}
// successResponse 构造成功响应
func successResponse(data interface{}) map[string]interface{} {
return map[string]interface{}{"success": true, "data": data}
@@ -108,8 +118,7 @@ func (api *UpdateAPI) DownloadUpdate(downloadURL string) (map[string]interface{}
"downloaded": downloaded,
"total": total,
}
progressJSON, _ := json.Marshal(progressInfo)
runtime.EventsEmit(api.ctx, "download-progress", string(progressJSON))
api.emit("download-progress", progressInfo)
}
time.Sleep(100 * time.Millisecond)
@@ -117,16 +126,14 @@ func (api *UpdateAPI) DownloadUpdate(downloadURL string) (map[string]interface{}
if err != nil {
errorInfo := map[string]interface{}{"error": err.Error()}
errorJSON, _ := json.Marshal(errorInfo)
runtime.EventsEmit(api.ctx, "download-complete", string(errorJSON))
api.emit("download-complete", errorInfo)
} else {
resultInfo := map[string]interface{}{
"success": true,
"file_path": result.FilePath,
"file_size": result.FileSize,
}
resultJSON, _ := json.Marshal(resultInfo)
runtime.EventsEmit(api.ctx, "download-complete", string(resultJSON))
api.emit("download-complete", resultInfo)
}
}()