sqlite支持

This commit is contained in:
mtvpls
2026-04-11 11:28:04 +08:00
parent 0d00fafcb5
commit c7879748f9
6 changed files with 217 additions and 42 deletions
+21
View File
@@ -4,6 +4,27 @@ const { parse } = require('url');
const next = require('next');
const { Server } = require('socket.io');
function shouldInitSQLite() {
const isCloudflare = process.env.CF_PAGES === '1' || process.env.BUILD_TARGET === 'cloudflare';
return process.env.NEXT_PUBLIC_STORAGE_TYPE === 'd1' && !isCloudflare && process.env.MOONTV_LITE !== 'true';
}
function ensureSQLiteReady() {
if (!shouldInitSQLite()) {
return;
}
try {
const { initSQLiteDatabase } = require('./scripts/init-sqlite.js');
initSQLiteDatabase();
} catch (error) {
console.error('❌ Error initializing SQLite database:', error);
throw error;
}
}
ensureSQLiteReady();
const dev = process.env.NODE_ENV !== 'production';
const hostname = process.env.HOSTNAME || '0.0.0.0';
const port = parseInt(process.env.PORT || '3000', 10);