初始化

This commit is contained in:
李琦
2026-08-11 19:07:05 +08:00
commit d2aeb13a09
94 changed files with 8704 additions and 0 deletions

205
model/models.go Normal file
View File

@@ -0,0 +1,205 @@
// Package model 定义后端服务、SQLite 仓储和 Wails 前端之间共享的数据结构。
// 该包只描述数据,不包含数据库或系统命令逻辑,因此可被各层安全复用。
package model
type Project struct {
ID int64 `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
Description string `json:"description"`
GroupID int64 `json:"groupId"`
GroupName string `json:"groupName"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Stats ProjectStats `json:"stats"`
Languages []LanguageStat `json:"languages"`
}
type ProjectInput struct {
Name string `json:"name"`
Path string `json:"path"`
Description string `json:"description"`
GroupID int64 `json:"groupId"`
}
type ProjectGroup struct {
ID int64 `json:"id"`
Name string `json:"name"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
}
type ProjectStats struct {
TotalLines int64 `json:"totalLines"`
CodeLines int64 `json:"codeLines"`
CommentLines int64 `json:"commentLines"`
BlankLines int64 `json:"blankLines"`
FileCount int64 `json:"fileCount"`
CommitCount int64 `json:"commitCount"`
AddedLines int64 `json:"addedLines"`
DeletedLines int64 `json:"deletedLines"`
ContributorCount int64 `json:"contributorCount"`
LastAnalyzed string `json:"lastAnalyzed"`
}
type LanguageStat struct {
Name string `json:"name"`
Files int64 `json:"files"`
Code int64 `json:"code"`
Comments int64 `json:"comments"`
Blanks int64 `json:"blanks"`
}
type FileEntry struct {
Path string `json:"path"`
Name string `json:"name"`
Extension string `json:"extension"`
Size int64 `json:"size"`
IsDir bool `json:"isDir"`
Parent string `json:"parent"`
}
type StructureStats struct {
Files []FileEntry `json:"files"`
TotalFiles int64 `json:"totalFiles"`
TotalDirs int64 `json:"totalDirs"`
TotalSize int64 `json:"totalSize"`
LargeFiles []FileEntry `json:"largeFiles"`
Folders []FolderStat `json:"folders"`
Extensions []ExtensionStat `json:"extensions"`
}
type FolderStat struct {
Name string `json:"name"`
Files int64 `json:"files"`
Size int64 `json:"size"`
}
type ExtensionStat struct {
Extension string `json:"extension"`
Files int64 `json:"files"`
Size int64 `json:"size"`
}
type GitCommit struct {
Hash string `json:"hash"`
Author string `json:"author"`
Email string `json:"email"`
Message string `json:"message"`
Date string `json:"date"`
Added int64 `json:"added"`
Deleted int64 `json:"deleted"`
}
type GitRef struct {
Name string `json:"name"`
Hash string `json:"hash"`
Kind string `json:"kind"`
Current bool `json:"current"`
}
type Contributor struct {
Name string `json:"name"`
Email string `json:"email"`
Commits int64 `json:"commits"`
Added int64 `json:"added"`
Deleted int64 `json:"deleted"`
}
type HeatDay struct {
Date string `json:"date"`
Count int64 `json:"count"`
}
type GitStats struct {
Available bool `json:"available"`
Error string `json:"error,omitempty"`
CurrentBranch string `json:"currentBranch"`
WorkspaceBranch string `json:"workspaceBranch"`
ViewRef string `json:"viewRef"`
CommitCount int64 `json:"commitCount"`
Added int64 `json:"added"`
Deleted int64 `json:"deleted"`
ContributorCount int64 `json:"contributorCount"`
Commits []GitCommit `json:"commits"`
Refs []GitRef `json:"refs"`
Contributors []Contributor `json:"contributors"`
Heatmap []HeatDay `json:"heatmap"`
}
type GitDiagnostics struct {
Available bool `json:"available"`
ErrorCode string `json:"errorCode,omitempty"`
Detail string `json:"detail,omitempty"`
IsWSL bool `json:"isWsl"`
Distro string `json:"distro,omitempty"`
LinuxPath string `json:"linuxPath,omitempty"`
WorkspaceBranch string `json:"workspaceBranch,omitempty"`
ViewRef string `json:"viewRef,omitempty"`
RefCount int `json:"refCount"`
}
type ProjectInsights struct {
ProjectID int64 `json:"projectId"`
HealthScore int `json:"healthScore"`
GeneratedAt string `json:"generatedAt"`
Summary InsightSummary `json:"summary"`
Issues []InsightIssue `json:"issues"`
}
type InsightSummary struct {
High int `json:"high"`
Medium int `json:"medium"`
Low int `json:"low"`
TodoCount int `json:"todoCount"`
LongFiles int `json:"longFiles"`
LargeFiles int `json:"largeFiles"`
}
type InsightIssue struct {
Severity string `json:"severity"`
Type string `json:"type"`
Title string `json:"title"`
Detail string `json:"detail"`
Path string `json:"path,omitempty"`
Line int `json:"line,omitempty"`
Suggestion string `json:"suggestion"`
Evidence string `json:"evidence,omitempty"`
}
type GitFileChange struct {
Path string `json:"path"`
Status string `json:"status"`
Added int64 `json:"added"`
Deleted int64 `json:"deleted"`
}
type GitCommitDetail struct {
GitCommit
Files []GitFileChange `json:"files"`
}
type CheckoutResult struct {
Branch string `json:"branch"`
Message string `json:"message"`
}
type ExclusionRule struct {
ID int64 `json:"id"`
Pattern string `json:"pattern"`
Category string `json:"category"`
Builtin bool `json:"builtin"`
}
type LogEntry struct {
ID int64 `json:"id"`
Level string `json:"level"`
Category string `json:"category"`
Message string `json:"message"`
Detail string `json:"detail"`
CreatedAt string `json:"createdAt"`
}
type AppSettings struct {
Theme string `json:"theme"`
Locale string `json:"locale"`
GitScope string `json:"gitScope"`
DatabasePath string `json:"databasePath"`
AutoRefresh bool `json:"autoRefresh"`
GlassOpacity int `json:"glassOpacity"`
LoadingStyle string `json:"loadingStyle"`
}
type Dashboard struct {
Projects int64 `json:"projects"`
TotalLines int64 `json:"totalLines"`
Commits int64 `json:"commits"`
}
// TaskEvent 只传递稳定消息键,具体中文或英文由前端根据当前语言即时翻译。
type TaskEvent struct {
TaskID string `json:"taskId"`
ProjectID int64 `json:"projectId"`
Stage string `json:"stage"`
Progress int `json:"progress"`
MessageKey string `json:"messageKey"`
Params map[string]any `json:"params,omitempty"`
}