需求:前台壁纸站支持切换到开源壁纸平台,并能展示后台上传的自家图库, 保留原有「浏览器实时生成」能力(扩展而非替换),PC / 移动双端一致。 设计要点(受服务器 5M 出口带宽约束): - 开源平台图片一律走官方 CDN 直链,后端只代理元数据,零带宽消耗。 - 自建图库落盘到 /data/www/wallpaper,由 nginx 的 /wallpaper/ 直出, Go 服务不参与传图;三档尺寸(480 缩略 / 1920 预览 / 原图仅供下载)。 - 内存缓存平台响应(Bing 1h、搜索类 10min),避免撞第三方配额。 内容: - 平台插件:Bing 每日一图、Picsum、Unsplash、Pexels、Wallhaven。 新增平台 = 写一个 provider_xxx.go 并在 allProviders() 加一行, 刻意不用 init() 自注册,避免隐式副作用。所有适配器支持 config.baseUrl 覆盖,用于绕开 DNS 污染(实测 wallhaven.cc 解析到境外无关 IP)。 - 自建图库:上传(MD5 秒传去重 / 尺寸前置校验 / 失败清理孤儿文件)、 元信息编辑、删除、统计;随机取图用「数总数 → 随机偏移」而非 ORDER BY RAND()。 - 接口:open 组 4 个(sources / list / random / download-track), admin 组 8 个(list / upload / save / delete / stats / source.list|save|test)。 全部 POST 且 URL 无参数,符合工作空间接口规范;上传走 multipart 例外。 - 安全:purity 默认锁死 SFW;apiKey 只回传布尔不回传明文; 保存时留空表示保留旧值;open 组错误信息对外脱敏。 - 配置:clientMaxBodySize 提到 64M(gf 默认 8M 会截断 20MB 原图); wallpaper.root / baseUrl 支持环境变量注入并在占位符未替换时兜底。 依赖:golang.org/x/image@v0.23.0(仅用于缩略图缩放,保持 go 1.23.0 不变)。
43 lines
1.5 KiB
Go
43 lines
1.5 KiB
Go
module service.xpcool.com
|
|
|
|
go 1.23.0
|
|
|
|
require (
|
|
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.10.2
|
|
github.com/gogf/gf/v2 v2.10.2
|
|
golang.org/x/image v0.23.0
|
|
)
|
|
|
|
require github.com/go-sql-driver/mysql v1.7.1 // indirect
|
|
|
|
require (
|
|
github.com/BurntSushi/toml v1.5.0 // indirect
|
|
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
|
github.com/emirpasic/gods/v2 v2.0.0-alpha // indirect
|
|
github.com/fatih/color v1.18.0 // indirect
|
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
|
github.com/go-logr/logr v1.4.3 // indirect
|
|
github.com/go-logr/stdr v1.2.2 // indirect
|
|
github.com/google/uuid v1.6.0 // indirect
|
|
github.com/gorilla/websocket v1.5.3 // indirect
|
|
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
|
github.com/magiconair/properties v1.8.10 // indirect
|
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
|
github.com/mattn/go-runewidth v0.0.16 // indirect
|
|
github.com/olekukonko/errors v1.1.0 // indirect
|
|
github.com/olekukonko/ll v0.0.9 // indirect
|
|
github.com/olekukonko/tablewriter v1.1.0 // indirect
|
|
github.com/rivo/uniseg v0.2.0 // indirect
|
|
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
|
go.opentelemetry.io/otel v1.38.0 // indirect
|
|
go.opentelemetry.io/otel/metric v1.38.0 // indirect
|
|
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
|
|
go.opentelemetry.io/otel/trace v1.38.0 // indirect
|
|
golang.org/x/crypto v0.38.0
|
|
golang.org/x/net v0.40.0 // indirect
|
|
golang.org/x/sys v0.35.0 // indirect
|
|
golang.org/x/text v0.25.0 // indirect
|
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
)
|