来自内容类型的标志性颜色

问题描述

我有一个包含文件浏览器的 Web 应用程序。我有一个小数据库,可以将 FontAwesome 图标与各种内容类型(即图像、word/lowriter 文件、excel/localc 文件、PDF、纯文本、档案等)相关联。为了完整起见,我在此处复制/粘贴(它是用于 React-FontAwesome 的 TypeScript):

const iconClasses: { [key: string]: IconDefinition } = {
      // Media
      "image": faFileImage,"audio": faFileAudio,"video": faFileVideo,// Documents
      "application/pdf": faFilePdf,"application/msword": faFileWord,"application/vnd.ms-word": faFileWord,"application/vnd.oasis.opendocument.text": faFileWord,"application/vnd.openxmlformats-officedocument.wordprocessingml":
      faFileWord,"application/vnd.ms-excel": faFileExcel,"application/vnd.openxmlformats-officedocument.spreadsheetml":
      faFileExcel,"application/vnd.oasis.opendocument.spreadsheet": faFileExcel,"application/vnd.ms-powerpoint": faFilePowerpoint,"application/vnd.openxmlformats-officedocument.presentationml":
      faFilePowerpoint,"application/vnd.oasis.opendocument.presentation": faFilePowerpoint,"text/plain": faFileAlt,"text/html": faFileCode,"application/json": faFileCode,// Archives
      "application/gzip": faFileArchive,"application/zip": faFileArchive
    };
    
    export function getFontAwesomeIconFromMIME(mimeType: string): IconDefinition {
      // List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
    
      const candidate = Object.entries(iconClasses).find(([k]) =>
        mimeType.startsWith(k)
      )
    
      if (candidate === undefined) {
        return faFile;
      } else {
        return candidate[1];
      }
    
    }

但是这些图标是灰色的。我想将“标志性”颜色与图标(RGB 格式)相关联。我不是 UI 专家,但这些颜色似乎有些标准化。例如,PDF 图标是红色的,Word 图标是蓝色的,Excel 图标是绿色的,档案是黄色的,等等。

有这样一组标志性颜色吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...