Feat:支持WebDAV功能

This commit is contained in:
MarSeventh
2025-08-28 16:56:14 +08:00
parent 7663b8e2f5
commit e12dd3f8e6
109 changed files with 353 additions and 516 deletions

View File

@@ -11,15 +11,15 @@ import { D1Database } from './d1Database.js';
* @returns {Object} 数据库适配器实例
*/
export function createDatabaseAdapter(env) {
// 检查是否配置了D1数据库
if (env.img_d1 && typeof env.img_d1.prepare === 'function') {
// 检查是否配置了数据库
if (env.img_url && typeof env.img_url.get === 'function') {
// 使用KV存储
return new KVAdapter(env.img_url);
} else if (env.img_d1 && typeof env.img_d1.prepare === 'function') {
// 使用D1数据库
return new D1Database(env.img_d1);
} else if (env.img_url && typeof env.img_url.get === 'function') {
// 回退到KV存储
return new KVAdapter(env.img_url);
} else {
console.error('No database configured. Please configure either D1 (env.img_d1) or KV (env.img_url)');
console.error('No database configured. Please configure either KV (env.img_url) or D1 (env.img_d1).');
return null;
}
}