mirror of
https://github.com/Dvorinka/excalidraw-full.git
synced 2026-06-03 22:02:57 +00:00
94953a5eac
本次提交包含以下主要更改: 1. 更新 `.gitignore` 文件,添加对 `node_modules` 和环境变量文件的忽略。 2. 修改 `.gitmodules` 文件,替换为新的子模块 `cloudflare-worker`。 3. 新增 `ARCHITECTURE.md` 和 `PROJECT_REFACTOR_PLAN.md` 文档,详细描述项目架构和改造计划。 4. 实现用户认证功能,添加 GitHub OAuth 处理逻辑,支持 JWT 生成与解析。 5. 引入新的存储接口 `CanvasStore`,并实现相应的存储逻辑,支持用户画布的增删改查。 6. 更新 `main.go` 文件,整合新的认证与存储逻辑,优化路由设置。 这些更改旨在提升项目的可扩展性与用户体验,支持多用户环境下的画布管理与存储。
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package core
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type (
|
|
// Canvas represents the metadata and content of a user-saved drawing.
|
|
Canvas struct {
|
|
ID string `json:"id"`
|
|
UserID string `json:"-"` // Not exposed in JSON responses, used internally.
|
|
Name string `json:"name"`
|
|
Data []byte `json:"-"` // The full canvas data, not included in list views.
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
UpdatedAt time.Time `json:"updatedAt"`
|
|
}
|
|
|
|
// CanvasStore defines the persistence layer for user-owned canvases.
|
|
// All operations are scoped to a specific user.
|
|
CanvasStore interface {
|
|
// List returns metadata for all canvases owned by a user.
|
|
// The returned Canvas objects should not contain the `Data` field to keep the response light.
|
|
List(ctx context.Context, userID string) ([]*Canvas, error)
|
|
|
|
// Get returns a single canvas by its ID, ensuring it belongs to the user.
|
|
Get(ctx context.Context, userID, id string) (*Canvas, error)
|
|
|
|
// Save creates or updates a canvas for a user.
|
|
Save(ctx context.Context, canvas *Canvas) error
|
|
|
|
// Delete removes a canvas, ensuring it belongs to the user.
|
|
Delete(ctx context.Context, userID, id string) error
|
|
}
|
|
)
|