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` 文件,整合新的认证与存储逻辑,优化路由设置。 这些更改旨在提升项目的可扩展性与用户体验,支持多用户环境下的画布管理与存储。
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package stores
|
|
|
|
import (
|
|
"excalidraw-complete/core"
|
|
"excalidraw-complete/stores/aws"
|
|
"excalidraw-complete/stores/filesystem"
|
|
"excalidraw-complete/stores/memory"
|
|
"excalidraw-complete/stores/sqlite"
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// Store is a union interface that includes all store types.
|
|
type Store interface {
|
|
core.DocumentStore
|
|
core.CanvasStore
|
|
}
|
|
|
|
func GetStore() Store {
|
|
storageType := os.Getenv("STORAGE_TYPE")
|
|
var store Store
|
|
|
|
storageField := logrus.Fields{
|
|
"storageType": storageType,
|
|
}
|
|
|
|
switch storageType {
|
|
case "filesystem":
|
|
basePath := os.Getenv("LOCAL_STORAGE_PATH")
|
|
if basePath == "" {
|
|
basePath = "./data" // Default path
|
|
}
|
|
storageField["basePath"] = basePath
|
|
store = filesystem.NewStore(basePath)
|
|
case "sqlite":
|
|
dataSourceName := os.Getenv("DATA_SOURCE_NAME")
|
|
if dataSourceName == "" {
|
|
dataSourceName = "excalidraw.db" // Default filename
|
|
}
|
|
storageField["dataSourceName"] = dataSourceName
|
|
store = sqlite.NewStore(dataSourceName)
|
|
case "s3":
|
|
bucketName := os.Getenv("S3_BUCKET_NAME")
|
|
if bucketName == "" {
|
|
logrus.Fatal("S3_BUCKET_NAME environment variable must be set for s3 storage type")
|
|
}
|
|
storageField["bucketName"] = bucketName
|
|
store = aws.NewStore(bucketName)
|
|
default:
|
|
store = memory.NewStore()
|
|
storageField["storageType"] = "in-memory"
|
|
}
|
|
logrus.WithFields(storageField).Info("Use storage")
|
|
return store
|
|
}
|