v0.3.11: 统一云盘常量到 cloud-constants.ts (图标/标签/颜色)
This commit is contained in:
@@ -1 +1 @@
|
||||
0.3.10
|
||||
0.3.11
|
||||
|
||||
@@ -56,6 +56,7 @@ export const CLOUD_COLORS: Record<CloudType, string> = {
|
||||
* 网盘图标映射 — 使用仓库中的 PNG 图标文件
|
||||
* 图标存储在 public/icons/ 目录下,Vite 构建时自动打包
|
||||
*/
|
||||
/** 与 src/config/cloud-icons.ts 同步 */
|
||||
export const CLOUD_ICONS: Record<string, string> = {
|
||||
baidu: '/icons/baidu.png',
|
||||
aliyun: '/icons/aliyun.png',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Icons synced with src/config/cloud-icons.ts LEGACY_ICONS
|
||||
|
||||
// --- Cloud Config ---
|
||||
var CLOUD_TYPES = [
|
||||
|
||||
@@ -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; }
|
||||
|
||||
5
source_clean/src/config/cloud-constants.ts
Normal file
5
source_clean/src/config/cloud-constants.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// 云盘常量 - 唯一配置源头 (labels/colors/icons)
|
||||
export const CLOUD_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 LEGACY_ICONS: Record<string, string> = {baidu:'/admin/icons/baidu.png',aliyun:'/admin/icons/aliyun.png',quark:'/admin/icons/quark.png','115':'/admin/icons/115.png',tianyi:'/admin/icons/tianyi.png','123pan':'/admin/icons/123pan.png',uc:'/admin/icons/uc.png',xunlei:'/admin/icons/xunlei.png',pikpak:'/admin/icons/pikpak.png',magnet:'/admin/icons/magnet.png',ed2k:'/admin/icons/ed2k.png',others:'/admin/icons/others.png'};
|
||||
export const CLOUD_LABELS: Record<string, string> = {quark:'夸克网盘',baidu:'百度网盘',aliyun:'阿里云盘','115':'115网盘',tianyi:'天翼云盘','123pan':'123云盘',uc:'UC网盘',xunlei:'迅雷云盘',pikpak:'PikPak',magnet:'磁力链接',ed2k:'电驴链接',others:'其他'};
|
||||
export const CLOUD_COLORS: Record<string, string> = {quark:'#07c160',baidu:'#4e6ef2',aliyun:'#ff6a00','115':'#9b59b6',tianyi:'#00a1d6','123pan':'#e74c3c',uc:'#f39c12',xunlei:'#2ecc71',pikpak:'#8e44ad',magnet:'#95a5a6',ed2k:'#7f8c8d',others:'#95a5a6'};
|
||||
@@ -1,56 +1,11 @@
|
||||
/**
|
||||
* Cloud type labels and colors
|
||||
* Shared between backend and frontend-facing routes
|
||||
*/
|
||||
|
||||
/** Cloud domain → type regex mapping (single source of truth) */
|
||||
export { CLOUD_LABELS, CLOUD_COLORS, CLOUD_ICONS } from './cloud-constants';
|
||||
export const CLOUD_DOMAIN_PATTERNS: Array<{regex:RegExp;type:string}> = [
|
||||
{ regex: /pan\.baidu\.com/i, type: 'baidu' },
|
||||
{ regex: /pan\.quark\.cn/i, type: 'quark' },
|
||||
{ regex: /aliyundrive\.com|alipan\.com/i, type: 'aliyun' },
|
||||
{ regex: /115\.com|115cdn\.com/i, type: '115' },
|
||||
{ regex: /cloud\.189\.cn/i, type: 'tianyi' },
|
||||
{ regex: /123pan\.com|123684\.com|123912\.com/i, type: '123pan' },
|
||||
{ regex: /drive\.uc\.cn/i, type: 'uc' },
|
||||
{ regex: /pan\.xunlei\.com/i, type: 'xunlei' },
|
||||
{ regex: /magnet:/i, type: 'magnet' },
|
||||
];
|
||||
|
||||
/** Detect cloud type from a URL string */
|
||||
{regex:/pan\.baidu\.com/i,type:'baidu'},{regex:/pan\.quark\.cn/i,type:'quark'},
|
||||
{regex:/aliyundrive\.com|alipan\.com/i,type:'aliyun'},{regex:/115\.com|115cdn\.com/i,type:'115'},
|
||||
{regex:/cloud\.189\.cn/i,type:'tianyi'},{regex:/123pan\.com|123684\.com|123912\.com/i,type:'123pan'},
|
||||
{regex:/drive\.uc\.cn/i,type:'uc'},{regex:/pan\.xunlei\.com/i,type:'xunlei'},{regex:/magnet:/i,type:'magnet'}];
|
||||
export function detectCloudType(url: string | undefined | null): string {
|
||||
if (!url) return 'others';
|
||||
for (const { regex, type } of CLOUD_DOMAIN_PATTERNS) {
|
||||
if (regex.test(url)) return type;
|
||||
}
|
||||
for (const {regex,type} of CLOUD_DOMAIN_PATTERNS) if (regex.test(url)) return type;
|
||||
return 'others';
|
||||
}
|
||||
|
||||
export const CLOUD_LABELS: Record<string, string> = {
|
||||
quark: '夸克网盘',
|
||||
baidu: '百度网盘',
|
||||
aliyun: '阿里云盘',
|
||||
'115': '115网盘',
|
||||
tianyi: '天翼云盘',
|
||||
'123pan': '123云盘',
|
||||
uc: 'UC网盘',
|
||||
xunlei: '迅雷云盘',
|
||||
pikpak: 'PikPak',
|
||||
magnet: '磁力链接',
|
||||
ed2k: '电驴链接',
|
||||
others: '其他',
|
||||
};
|
||||
|
||||
export const CLOUD_COLORS: Record<string, string> = {
|
||||
quark: '#07c160',
|
||||
baidu: '#4e6ef2',
|
||||
aliyun: '#ff6a00',
|
||||
'115': '#9b59b6',
|
||||
tianyi: '#00a1d6',
|
||||
'123pan': '#e74c3c',
|
||||
uc: '#f39c12',
|
||||
xunlei: '#2ecc71',
|
||||
pikpak: '#8e44ad',
|
||||
magnet: '#95a5a6',
|
||||
ed2k: '#7f8c8d',
|
||||
others: '#95a5a6',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user