feat: 版块图标上传(≤1MB,png/jpg/gif/webp,sha去重,未设置降级首字+哈希色)
This commit is contained in:
@@ -2,14 +2,14 @@ import React from 'react';
|
||||
|
||||
/**
|
||||
* 论坛版块图标(L1/L2 共用):
|
||||
* - cat.icon 非空:http(s) 开头渲染图片;否则按单个 emoji 字符渲染
|
||||
* - cat.icon 非空:http(s) 或 / 开头的相对路径(如 /uploads/icons/xxx.png)渲染图片;否则按单个 emoji 字符渲染
|
||||
* - 无 icon 时取名称首字(大写)
|
||||
* - 底色:icon_color 自定义 hex(自动按亮度选深/浅文字色);
|
||||
* 空则按名称哈希选 12 色 MD3 container/onContainer 对(style.css 的 .tone-N,深浅色自适应)
|
||||
*/
|
||||
export default function ForumIcon({ icon = '', name = '', iconColor = '', size = 40 }) {
|
||||
const raw = String(icon || '').trim();
|
||||
const isUrl = /^https?:\/\//i.test(raw);
|
||||
const isUrl = /^https?:\/\//i.test(raw) || raw.startsWith('/');
|
||||
const isEmoji = !!raw && !isUrl;
|
||||
const letter = (name || '').trim().charAt(0).toUpperCase() || '?';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user