v0.3.11: 统一云盘常量到 cloud-constants.ts (图标/标签/颜色)
This commit is contained in:
@@ -1,59 +1,19 @@
|
||||
import { getSystemConfig } from '../admin/system-config.service';
|
||||
|
||||
export interface CloudTypeInfo {
|
||||
type: string;
|
||||
label: string;
|
||||
icon: string;
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
/** Official brand icons — Baidu via SimpleIcons, Aliyun via SimpleIcons Alibaba Cloud. */
|
||||
|
||||
const ICONS: Record<string, string> = {
|
||||
baidu: '/icons/baidu.png',
|
||||
aliyun: '/icons/aliyun.png',
|
||||
quark: '/icons/quark.png',
|
||||
'115': '/icons/115.png',
|
||||
tianyi: '/icons/tianyi.png',
|
||||
'123pan': '/icons/123pan.png',
|
||||
uc: '/icons/uc.png',
|
||||
xunlei: '/icons/xunlei.png',
|
||||
pikpak: '/icons/pikpak.png',
|
||||
magnet: '/icons/magnet.png',
|
||||
ed2k: '/icons/ed2k.png',
|
||||
others: '/icons/others.png',
|
||||
};
|
||||
|
||||
|
||||
export const ALL_CLOUD_TYPES: { type: string; label: string; icon: string }[] = [
|
||||
{ type: 'quark', label: '夸克网盘', icon: ICONS.quark },
|
||||
{ type: 'baidu', label: '百度网盘', icon: ICONS.baidu },
|
||||
{ type: 'aliyun', label: '阿里云盘', icon: ICONS.aliyun },
|
||||
{ type: '115', label: '115 网盘', icon: ICONS['115'] },
|
||||
{ type: 'tianyi', label: '天翼云盘', icon: ICONS.tianyi },
|
||||
{ type: '123pan', label: '123 云盘', icon: ICONS['123pan'] },
|
||||
{ type: 'uc', label: 'UC 网盘', icon: ICONS.uc },
|
||||
{ type: 'xunlei', label: '迅雷网盘', icon: ICONS.xunlei },
|
||||
{ type: 'pikpak', label: 'PikPak', icon: ICONS.pikpak },
|
||||
{ type: 'magnet', label: '磁力链接', icon: ICONS.magnet },
|
||||
{ type: 'ed2k', label: '电驴链接', icon: ICONS.ed2k },
|
||||
{ type: 'others', label: '其他', icon: ICONS.others },
|
||||
];
|
||||
|
||||
export function isCloudTypeEnabled(type: string): boolean {
|
||||
const val = getSystemConfig(`cloud_type_${type}_enabled`);
|
||||
if (val === null) return type !== 'others';
|
||||
return val === "true" || val === "1";
|
||||
}
|
||||
|
||||
export function getAllCloudTypes(): CloudTypeInfo[] {
|
||||
return ALL_CLOUD_TYPES.map(ct => ({ ...ct, enabled: isCloudTypeEnabled(ct.type) }));
|
||||
}
|
||||
|
||||
export function getEnabledCloudTypeSet(): Set<string> {
|
||||
const enabled = new Set<string>();
|
||||
for (const ct of ALL_CLOUD_TYPES) {
|
||||
if (isCloudTypeEnabled(ct.type)) enabled.add(ct.type);
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
import { CLOUD_ICONS, CLOUD_LABELS } from '../config/cloud-constants';
|
||||
export interface CloudTypeInfo { type: string; label: string; icon: string; enabled: boolean; }
|
||||
export const ALL_CLOUD_TYPES = [
|
||||
{ type:'quark', label:CLOUD_LABELS.quark, icon:CLOUD_ICONS.quark },
|
||||
{ type:'baidu', label:CLOUD_LABELS.baidu, icon:CLOUD_ICONS.baidu },
|
||||
{ type:'aliyun', label:CLOUD_LABELS.aliyun, icon:CLOUD_ICONS.aliyun },
|
||||
{ type:'115', label:CLOUD_LABELS['115'], icon:CLOUD_ICONS['115'] },
|
||||
{ type:'tianyi', label:CLOUD_LABELS.tianyi, icon:CLOUD_ICONS.tianyi },
|
||||
{ type:'123pan', label:CLOUD_LABELS['123pan'], icon:CLOUD_ICONS['123pan'] },
|
||||
{ type:'uc', label:CLOUD_LABELS.uc, icon:CLOUD_ICONS.uc },
|
||||
{ type:'xunlei', label:CLOUD_LABELS.xunlei, icon:CLOUD_ICONS.xunlei },
|
||||
{ type:'pikpak', label:CLOUD_LABELS.pikpak, icon:CLOUD_ICONS.pikpak },
|
||||
{ type:'magnet', label:CLOUD_LABELS.magnet, icon:CLOUD_ICONS.magnet },
|
||||
{ type:'ed2k', label:CLOUD_LABELS.ed2k, icon:CLOUD_ICONS.ed2k },
|
||||
{ type:'others', label:CLOUD_LABELS.others, icon:CLOUD_ICONS.others }];
|
||||
export function isCloudTypeEnabled(type: string): boolean { const v = getSystemConfig('cloud_type_'+type+'_enabled'); return v===null ? type!=='others' : v==='true'||v==='1'; }
|
||||
export function getAllCloudTypes(): CloudTypeInfo[] { return ALL_CLOUD_TYPES.map(ct=>({...ct,enabled:isCloudTypeEnabled(ct.type)})); }
|
||||
export function getEnabledCloudTypeSet(): Set<string> { const s=new Set<string>(); for(const ct of ALL_CLOUD_TYPES) if(isCloudTypeEnabled(ct.type)) s.add(ct.type); return s; }
|
||||
|
||||
Reference in New Issue
Block a user