mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-27 23:34:48 +08:00
feat: remove storage type in config
This commit is contained in:
@@ -74,8 +74,3 @@ export function getApiSites(): ApiSite[] {
|
||||
key,
|
||||
}));
|
||||
}
|
||||
|
||||
export function getStorageConfig(): StorageConfig {
|
||||
const config = getConfig();
|
||||
return config.storage || { type: 'localstorage' };
|
||||
}
|
||||
|
||||
@@ -31,10 +31,8 @@ const PLAY_RECORDS_KEY = 'moontv_play_records';
|
||||
|
||||
// ---- 环境变量 ----
|
||||
const STORAGE_TYPE =
|
||||
(process.env.NEXT_PUBLIC_STORAGE_TYPE as
|
||||
| 'localstorage'
|
||||
| 'database'
|
||||
| undefined) || 'localstorage';
|
||||
(process.env.STORAGE_TYPE as 'localstorage' | 'database' | undefined) ||
|
||||
'localstorage';
|
||||
|
||||
// ---------------- 搜索历史相关常量 ----------------
|
||||
const SEARCH_HISTORY_KEY = 'moontv_search_history';
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import { getStorageConfig } from './config';
|
||||
// storage type 常量: 'localstorage' | 'database',默认 'localstorage'
|
||||
const STORAGE_TYPE =
|
||||
(process.env.STORAGE_TYPE as 'localstorage' | 'database' | undefined) ||
|
||||
'localstorage';
|
||||
|
||||
// 播放记录数据结构
|
||||
export interface PlayRecord {
|
||||
@@ -85,9 +88,7 @@ class DatabaseStorage implements IStorage {
|
||||
|
||||
// 创建存储实例
|
||||
function createStorage(): IStorage {
|
||||
const config = getStorageConfig();
|
||||
|
||||
switch (config.type) {
|
||||
switch (STORAGE_TYPE) {
|
||||
case 'database':
|
||||
return new DatabaseStorage();
|
||||
case 'localstorage':
|
||||
|
||||
Reference in New Issue
Block a user