mirror of
https://github.com/eyebluecn/tank-front
synced 2024-04-21 12:31:55 +00:00
add some utils
This commit is contained in:
+18
-17
@@ -50,51 +50,52 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.9.0",
|
||||
"@svgr/webpack": "4.3.3",
|
||||
"@types/node": "^12.0.0",
|
||||
"@types/qs": "^6.9.3",
|
||||
"@types/react": "^16.9.0",
|
||||
"@types/react-dom": "^16.9.0",
|
||||
"@types/react-router-dom": "^5.1.5",
|
||||
"@svgr/webpack": "4.3.3",
|
||||
"@typescript-eslint/eslint-plugin": "^2.10.0",
|
||||
"@typescript-eslint/parser": "^2.10.0",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-loader": "8.1.0",
|
||||
"babel-plugin-named-asset-import": "^0.3.6",
|
||||
"babel-preset-react-app": "^9.1.2",
|
||||
"html-webpack-plugin": "4.0.0-beta.11",
|
||||
"mini-css-extract-plugin": "0.9.0",
|
||||
"optimize-css-assets-webpack-plugin": "5.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^2.10.0",
|
||||
"@typescript-eslint/parser": "^2.10.0",
|
||||
"prettier": "^2.0.5",
|
||||
"case-sensitive-paths-webpack-plugin": "2.3.0",
|
||||
"css-loader": "3.4.2",
|
||||
"eslint": "^6.6.0",
|
||||
"eslint-config-react-app": "^5.2.1",
|
||||
"eslint-loader": "3.0.3",
|
||||
"eslint-plugin-flowtype": "4.6.0",
|
||||
"eslint-plugin-import": "2.20.1",
|
||||
"eslint-plugin-jsx-a11y": "6.2.3",
|
||||
"eslint-plugin-prettier": "^3.1.3",
|
||||
"eslint-plugin-react": "7.19.0",
|
||||
"eslint-plugin-react-hooks": "^1.6.1",
|
||||
"file-loader": "4.3.0",
|
||||
"html-webpack-plugin": "4.0.0-beta.11",
|
||||
"less": "^3.11.2",
|
||||
"less-loader": "^6.1.0",
|
||||
"mini-css-extract-plugin": "0.9.0",
|
||||
"optimize-css-assets-webpack-plugin": "5.0.3",
|
||||
"pnp-webpack-plugin": "1.6.4",
|
||||
"postcss-flexbugs-fixes": "4.1.0",
|
||||
"postcss-loader": "3.0.0",
|
||||
"postcss-normalize": "8.0.1",
|
||||
"postcss-preset-env": "6.7.0",
|
||||
"postcss-safe-parser": "4.0.1",
|
||||
"prettier": "^2.0.5",
|
||||
"resolve": "1.15.0",
|
||||
"resolve-url-loader": "3.1.1",
|
||||
"sass-loader": "8.0.2",
|
||||
"css-loader": "3.4.2",
|
||||
"file-loader": "4.3.0",
|
||||
"style-loader": "0.23.1",
|
||||
"terser-webpack-plugin": "2.3.5",
|
||||
"typescript": "~3.7.2",
|
||||
"url-loader": "2.3.0",
|
||||
"webpack": "4.42.0",
|
||||
"webpack-dev-server": "3.10.3",
|
||||
"webpack-manifest-plugin": "2.2.0",
|
||||
"workbox-webpack-plugin": "4.3.1",
|
||||
"style-loader": "0.23.1",
|
||||
"terser-webpack-plugin": "2.3.5",
|
||||
"case-sensitive-paths-webpack-plugin": "2.3.0",
|
||||
"pnp-webpack-plugin": "1.6.4",
|
||||
"resolve": "1.15.0",
|
||||
"resolve-url-loader": "3.1.1",
|
||||
"typescript": "~3.7.2"
|
||||
"workbox-webpack-plugin": "4.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +1,151 @@
|
||||
import BaseEntity from '../base/BaseEntity';
|
||||
import Filter from '../base/filter/Filter';
|
||||
import InputFilter from '../base/filter/InputFilter';
|
||||
|
||||
import BaseEntity from "../base/BaseEntity";
|
||||
import Filter from "../base/filter/Filter";
|
||||
import FileUtil from "../../util/FileUtil";
|
||||
import ImageUtil from "../../util/ImageUtil";
|
||||
import EnvUtil from "../../util/EnvUtil";
|
||||
import InputFilter from "../base/filter/InputFilter";
|
||||
import CheckFilter from "../base/filter/CheckFilter";
|
||||
import SortFilter from "../base/filter/SortFilter";
|
||||
|
||||
export default class Matter extends BaseEntity {
|
||||
|
||||
puuid: string | null = null;
|
||||
userUuid: string | null = null;
|
||||
title: string | null = null;
|
||||
dir: boolean = false;
|
||||
alien: boolean = false;
|
||||
name: string | null = null;
|
||||
md5: string | null = null;
|
||||
size: number = 0;
|
||||
privacy: boolean = true;
|
||||
path: string | null = null;
|
||||
tags: string | null = null;
|
||||
posterTankUuid: string | null = null;
|
||||
posterUrl: string | null = null;
|
||||
author: string | null = null;
|
||||
digest: string | null = null;
|
||||
isMarkdown: boolean = true;
|
||||
html: string | null = null;
|
||||
privacy: boolean = false;
|
||||
top: boolean = false;
|
||||
agree: number = 0;
|
||||
words: number = 0;
|
||||
hit: number = 0;
|
||||
commentNum: number = 0;
|
||||
times: number = 0;
|
||||
parent: string | null = null;
|
||||
|
||||
/*
|
||||
这部分是辅助UI的字段信息
|
||||
*/
|
||||
//作为勾选变量
|
||||
check: boolean = false;
|
||||
|
||||
//允许用户选择的文件类型
|
||||
filter: string = "*";
|
||||
//本地字段
|
||||
//给用户的提示文字
|
||||
uploadHint: string | null = null;
|
||||
//浏览器中选择好的原生file,未作任何处理。
|
||||
file: string | null = null;
|
||||
//当前上传进度的数值 0-1之间
|
||||
progress: number = 0;
|
||||
//实时上传速度 byte/s
|
||||
speed: number = 0;
|
||||
|
||||
static URL_MATTER_CREATE_DIRECTORY = "/api/matter/create/directory";
|
||||
static URL_MATTER_DELETE = "/api/matter/delete";
|
||||
static URL_MATTER_DELETE_BATCH = "/api/matter/delete/batch";
|
||||
static URL_MATTER_RENAME = "/api/matter/rename";
|
||||
static URL_CHANGE_PRIVACY = "/api/matter/change/privacy";
|
||||
static URL_MATTER_MOVE = "/api/matter/move";
|
||||
static URL_MATTER_DOWNLOAD = "/api/matter/download";
|
||||
static URL_MATTER_UPLOAD = "/api/matter/upload";
|
||||
static URL_MATTER_ZIP = "/api/matter/zip";
|
||||
|
||||
static MATTER_ROOT = "root";
|
||||
|
||||
constructor(reactComponent?: React.Component) {
|
||||
|
||||
super(reactComponent);
|
||||
|
||||
}
|
||||
|
||||
assign(obj: any) {
|
||||
super.assign(obj);
|
||||
|
||||
|
||||
super.assignList("parent", Matter);
|
||||
}
|
||||
|
||||
getForm(): any {
|
||||
return {
|
||||
title: this.title,
|
||||
path: this.path,
|
||||
author: this.author,
|
||||
html: this.html,
|
||||
userUuid: this.userUuid,
|
||||
puuid: this.puuid,
|
||||
uuid: this.uuid ? this.uuid : null,
|
||||
dir: this.dir,
|
||||
alien: this.alien,
|
||||
name: this.name,
|
||||
md5: this.md5,
|
||||
size: this.size,
|
||||
privacy: this.privacy,
|
||||
path: this.path,
|
||||
times: this.times,
|
||||
parent: this.parent,
|
||||
};
|
||||
}
|
||||
|
||||
getFilters(): Filter[] {
|
||||
return [
|
||||
...super.getFilters(),
|
||||
new InputFilter('标题', 'title'),
|
||||
new InputFilter('路径', 'path'),
|
||||
new InputFilter('作者', 'author'),
|
||||
new InputFilter("父级菜单uuid", "puuid", null, false),
|
||||
new InputFilter("用户", "userUuid", null, false),
|
||||
new InputFilter("关键字", "name"),
|
||||
new CheckFilter("文件夹", "dir"),
|
||||
new CheckFilter("应用数据", "alien"),
|
||||
new SortFilter("文件夹", "orderDir"),
|
||||
new SortFilter("下载次数", "orderTimes"),
|
||||
new SortFilter("大小", "orderSize"),
|
||||
new SortFilter("名称", "orderName"),
|
||||
new InputFilter("后缀名", "extensions"),
|
||||
new InputFilter("分享uuid", "shareUuid"),
|
||||
new InputFilter("提取码", "shareCode"),
|
||||
new InputFilter("分享根目录", "shareRootUuid"),
|
||||
];
|
||||
}
|
||||
|
||||
getUrlPrefix() {
|
||||
return "/api/matter"
|
||||
}
|
||||
|
||||
isImage() {
|
||||
return FileUtil.isImage(this.name)
|
||||
}
|
||||
|
||||
|
||||
isPdf() {
|
||||
return FileUtil.isPdf(this.name)
|
||||
}
|
||||
|
||||
isText() {
|
||||
return FileUtil.isText(this.name)
|
||||
}
|
||||
|
||||
isDoc() {
|
||||
return FileUtil.isDoc(this.name)
|
||||
}
|
||||
|
||||
isPpt() {
|
||||
return FileUtil.isPpt(this.name)
|
||||
}
|
||||
|
||||
isXls() {
|
||||
return FileUtil.isXls(this.name)
|
||||
}
|
||||
|
||||
isAudio() {
|
||||
return FileUtil.isAudio(this.name)
|
||||
}
|
||||
|
||||
isVideo() {
|
||||
return FileUtil.isVideo(this.name)
|
||||
}
|
||||
|
||||
isPsd() {
|
||||
return FileUtil.isPsd(this.name)
|
||||
}
|
||||
|
||||
getIcon() {
|
||||
if (FileUtil.isImage(this.name)) {
|
||||
return ImageUtil.handleImageUrl(this.getPreviewUrl(), false, 100, 100)
|
||||
} else {
|
||||
return FileUtil.getIcon(this.name, this.dir)
|
||||
}
|
||||
}
|
||||
|
||||
getPreviewUrl(downloadTokenUuid = null) {
|
||||
return EnvUtil.currentHost() + '/api/alien/preview/' + this.uuid + '/' + this.name + (downloadTokenUuid ? '?downloadTokenUuid=' + downloadTokenUuid : '')
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export default class EnvUtil {
|
||||
static currentHost() {
|
||||
return window.location.protocol + "//" + window.location.host;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
import MimeUtil from "./MimeUtil";
|
||||
import StringUtil from "./StringUtil";
|
||||
|
||||
export default class FileUtil {
|
||||
static isImage(name: string | null) {
|
||||
let mimeType = MimeUtil.getMimeType(name);
|
||||
return StringUtil.startWith(mimeType, "image");
|
||||
}
|
||||
|
||||
static isPdf(name: string | null) {
|
||||
let mimeType = MimeUtil.getMimeType(name);
|
||||
return StringUtil.startWith(mimeType, "application/pdf");
|
||||
}
|
||||
|
||||
static isText(name: string | null) {
|
||||
let mimeType = MimeUtil.getMimeType(name);
|
||||
return StringUtil.startWith(mimeType, "text");
|
||||
}
|
||||
|
||||
static isDoc(name: string | null) {
|
||||
let mimeType = MimeUtil.getMimeType(name);
|
||||
return (
|
||||
StringUtil.startWith(mimeType, "application/msword") ||
|
||||
StringUtil.startWith(
|
||||
mimeType,
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static isPpt(name: string | null) {
|
||||
let mimeType = MimeUtil.getMimeType(name);
|
||||
return (
|
||||
StringUtil.startWith(mimeType, "application/vnd.ms-powerpoint") ||
|
||||
StringUtil.startWith(
|
||||
mimeType,
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static isXls(name: string | null) {
|
||||
let mimeType = MimeUtil.getMimeType(name);
|
||||
return (
|
||||
StringUtil.startWith(mimeType, "application/vnd.ms-excel") ||
|
||||
StringUtil.startWith(
|
||||
mimeType,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
static isAudio(name: string | null) {
|
||||
let mimeType = MimeUtil.getMimeType(name);
|
||||
return StringUtil.startWith(mimeType, "audio");
|
||||
}
|
||||
|
||||
static isVideo(name: string | null) {
|
||||
let mimeType = MimeUtil.getMimeType(name);
|
||||
return StringUtil.startWith(mimeType, "video");
|
||||
}
|
||||
|
||||
static isPsd(name: string | null) {
|
||||
let extension = MimeUtil.getExtension(name);
|
||||
return extension === ".psd";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据名字获取对应的图标。imageIcon传值了,那么图片格式采用imageIcon
|
||||
* @param name
|
||||
* @param idDir
|
||||
*/
|
||||
static getIcon(name: string | null, idDir: boolean = false) {
|
||||
if (idDir) {
|
||||
return require("../../assets/img/file/folder.svg");
|
||||
}
|
||||
|
||||
if (FileUtil.isPdf(name)) {
|
||||
return require("../../assets/img/file/pdf.svg");
|
||||
} else if (FileUtil.isDoc(name)) {
|
||||
return require("../../assets/img/file/doc.svg");
|
||||
} else if (FileUtil.isPpt(name)) {
|
||||
return require("../../assets/img/file/ppt.svg");
|
||||
} else if (FileUtil.isXls(name)) {
|
||||
return require("../../assets/img/file/xls.svg");
|
||||
} else if (FileUtil.isAudio(name)) {
|
||||
return require("../../assets/img/file/audio.svg");
|
||||
} else if (
|
||||
FileUtil.isVideo(name) ||
|
||||
MimeUtil.getExtension(name) === ".mkv"
|
||||
) {
|
||||
return require("../../assets/img/file/video.svg");
|
||||
} else if (FileUtil.isText(name)) {
|
||||
return require("../../assets/img/file/text.svg");
|
||||
} else if (FileUtil.isPsd(name)) {
|
||||
return require("../../assets/img/file/psd.svg");
|
||||
} else if (FileUtil.isImage(name)) {
|
||||
return require("../../assets/img/file/image.svg");
|
||||
} else if (
|
||||
StringUtil.endWith(name, "zip") ||
|
||||
StringUtil.endWith(name, "rar") ||
|
||||
StringUtil.endWith(name, "7z") ||
|
||||
StringUtil.endWith(name, "tar") ||
|
||||
StringUtil.endWith(name, "tar") ||
|
||||
StringUtil.endWith(name, "gz")
|
||||
) {
|
||||
return require("../../assets/img/file/archive.svg");
|
||||
} else {
|
||||
return require("../../assets/img/file/file.svg");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
//应用的占位图片,到处都要用到。 生成网址:http://png-pixel.com/
|
||||
//rgb(240,240,240)
|
||||
import NumberUtil from "./NumberUtil";
|
||||
import MimeUtil from "./MimeUtil";
|
||||
|
||||
export default class ImageUtil {
|
||||
static IMAGE_PLACEHOLDER_10_10 =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAEUlEQVR42mP88J8BAzAOZUEAoc4TYb5Mv7IAAAAASUVORK5CYII=";
|
||||
static IMAGE_PLACEHOLDER_20_7 =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAQAAACiwqWzAAAAEklEQVR42mP88J+BKMA4IhUCAJ1VDZFobOQaAAAAAElFTkSuQmCC";
|
||||
static IMAGE_PLACEHOLDER_4_3 =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAQAAAAe/WZNAAAAEElEQVR42mP88J8BDBgxGABf8QXRk11CBwAAAABJRU5ErkJggg==";
|
||||
static IMAGE_PLACEHOLDER_16_9 =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAJCAQAAACRI2S5AAAAEklEQVR42mP88J8BL2AcVQAGACSgEXHKPyH/AAAAAElFTkSuQmCC";
|
||||
static IMAGE_PLACEHOLDER_2_1 =
|
||||
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAQAAAAeXLZtAAAAE0lEQVR42mP88J+BKMA4qpC+CgH2ThNhpeSxLAAAAABJRU5ErkJggg==";
|
||||
|
||||
/**
|
||||
* 统一处理图片url。
|
||||
* @param url 原图片路径
|
||||
* @param origin 是否使用原图,一般在查看图片详情的时候使用
|
||||
* @param width 如果origin=false 裁剪的宽度
|
||||
* @param height 如果origin=false 裁剪的高度
|
||||
* @returns
|
||||
*/
|
||||
static handleImageUrl(
|
||||
url: string | null = null,
|
||||
origin: boolean = false,
|
||||
width: number = 200,
|
||||
height: number = 200
|
||||
) {
|
||||
if (url) {
|
||||
if (origin) {
|
||||
return url;
|
||||
} else {
|
||||
//目前支持这几种格式的处理。 jpg jpeg png tif tiff bmp gif
|
||||
let supportExtensions = [
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".png",
|
||||
".tif",
|
||||
".tiff",
|
||||
".bmp",
|
||||
".gif",
|
||||
];
|
||||
let extension = MimeUtil.getExtension(url);
|
||||
if (supportExtensions.indexOf(extension) === -1) {
|
||||
return url;
|
||||
} else {
|
||||
return url + "?ir=fill_" + width + "_" + height;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (NumberUtil.fractionEqual(1, 1, width, height)) {
|
||||
return ImageUtil.IMAGE_PLACEHOLDER_10_10;
|
||||
} else if (NumberUtil.fractionEqual(20, 7, width, height)) {
|
||||
return ImageUtil.IMAGE_PLACEHOLDER_20_7;
|
||||
} else if (NumberUtil.fractionEqual(4, 3, width, height)) {
|
||||
return ImageUtil.IMAGE_PLACEHOLDER_4_3;
|
||||
} else if (NumberUtil.fractionEqual(16, 9, width, height)) {
|
||||
return ImageUtil.IMAGE_PLACEHOLDER_16_9;
|
||||
} else if (NumberUtil.fractionEqual(2, 1, width, height)) {
|
||||
return ImageUtil.IMAGE_PLACEHOLDER_2_1;
|
||||
} else {
|
||||
return ImageUtil.IMAGE_PLACEHOLDER_10_10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,646 @@
|
||||
export default class MimeUtil {
|
||||
static MIMES: any = {
|
||||
".323": "text/h323",
|
||||
".3g2": "video/3gpp2",
|
||||
".3gp": "video/3gpp",
|
||||
".3gp2": "video/3gpp2",
|
||||
".3gpp": "video/3gpp",
|
||||
".7z": "application/x-7z-compressed",
|
||||
".aa": "audio/audible",
|
||||
".AAC": "audio/aac",
|
||||
".aaf": "application/octet-stream",
|
||||
".aax": "audio/vnd.audible.aax",
|
||||
".ac3": "audio/ac3",
|
||||
".aca": "application/octet-stream",
|
||||
".accda": "application/msaccess.addin",
|
||||
".accdb": "application/msaccess",
|
||||
".accdc": "application/msaccess.cab",
|
||||
".accde": "application/msaccess",
|
||||
".accdr": "application/msaccess.runtime",
|
||||
".accdt": "application/msaccess",
|
||||
".accdw": "application/msaccess.webapplication",
|
||||
".accft": "application/msaccess.ftemplate",
|
||||
".acx": "application/internet-property-stream",
|
||||
".AddIn": "text/xml",
|
||||
".ade": "application/msaccess",
|
||||
".adobebridge": "application/x-bridge-url",
|
||||
".adp": "application/msaccess",
|
||||
".ADT": "audio/vnd.dlna.adts",
|
||||
".ADTS": "audio/aac",
|
||||
".afm": "application/octet-stream",
|
||||
".ai": "application/postscript",
|
||||
".aif": "audio/aiff",
|
||||
".aifc": "audio/aiff",
|
||||
".aiff": "audio/aiff",
|
||||
".air": "application/vnd.adobe.air-application-installer-package+zip",
|
||||
".amc": "application/mpeg",
|
||||
".anx": "application/annodex",
|
||||
".apk": "application/vnd.android.package-archive",
|
||||
".application": "application/x-ms-application",
|
||||
".art": "image/x-jg",
|
||||
".asa": "application/xml",
|
||||
".asax": "application/xml",
|
||||
".ascx": "application/xml",
|
||||
".asd": "application/octet-stream",
|
||||
".asf": "video/x-ms-asf",
|
||||
".ashx": "application/xml",
|
||||
".asi": "application/octet-stream",
|
||||
".asm": "text/plain",
|
||||
".asmx": "application/xml",
|
||||
".aspx": "application/xml",
|
||||
".asr": "video/x-ms-asf",
|
||||
".asx": "video/x-ms-asf",
|
||||
".atom": "application/atom+xml",
|
||||
".au": "audio/basic",
|
||||
".avi": "video/x-msvideo",
|
||||
".axa": "audio/annodex",
|
||||
".axs": "application/olescript",
|
||||
".axv": "video/annodex",
|
||||
".bas": "text/plain",
|
||||
".bat": "text/plain",
|
||||
".bcpio": "application/x-bcpio",
|
||||
".bin": "application/octet-stream",
|
||||
".bmp": "image/bmp",
|
||||
".c": "text/plain",
|
||||
".cab": "application/octet-stream",
|
||||
".caf": "audio/x-caf",
|
||||
".calx": "application/vnd.ms-office.calx",
|
||||
".cat": "application/vnd.ms-pki.seccat",
|
||||
".cc": "text/plain",
|
||||
".cd": "text/plain",
|
||||
".cdda": "audio/aiff",
|
||||
".cdf": "application/x-cdf",
|
||||
".cer": "application/x-x509-ca-cert",
|
||||
".cfg": "text/plain",
|
||||
".chm": "application/octet-stream",
|
||||
".class": "application/x-java-applet",
|
||||
".clp": "application/x-msclip",
|
||||
".cmd": "text/plain",
|
||||
".cmx": "image/x-cmx",
|
||||
".cnf": "text/plain",
|
||||
".cod": "image/cis-cod",
|
||||
".config": "application/xml",
|
||||
".contact": "text/x-ms-contact",
|
||||
".coverage": "application/xml",
|
||||
".cpio": "application/x-cpio",
|
||||
".cpp": "text/plain",
|
||||
".crd": "application/x-mscardfile",
|
||||
".crl": "application/pkix-crl",
|
||||
".crt": "application/x-x509-ca-cert",
|
||||
".cs": "text/plain",
|
||||
".csdproj": "text/plain",
|
||||
".csh": "application/x-csh",
|
||||
".csproj": "text/plain",
|
||||
".css": "text/css",
|
||||
".csv": "application/csv",
|
||||
".cur": "application/octet-stream",
|
||||
".cxx": "text/plain",
|
||||
".dat": "application/octet-stream",
|
||||
".datasource": "application/xml",
|
||||
".dbproj": "text/plain",
|
||||
".dcr": "application/x-director",
|
||||
".def": "text/plain",
|
||||
".deploy": "application/octet-stream",
|
||||
".der": "application/x-x509-ca-cert",
|
||||
".dgml": "application/xml",
|
||||
".dib": "image/bmp",
|
||||
".dif": "video/x-dv",
|
||||
".dir": "application/x-director",
|
||||
".disco": "text/xml",
|
||||
".divx": "video/divx",
|
||||
".dll": "application/x-msdownload",
|
||||
".dll.config": "text/xml",
|
||||
".dlm": "text/dlm",
|
||||
".doc": "application/msword",
|
||||
".docm": "application/vnd.ms-word.document.macroEnabled.12",
|
||||
".docx":
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
".dot": "application/msword",
|
||||
".dotm": "application/vnd.ms-word.template.macroEnabled.12",
|
||||
".dotx":
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
||||
".dsp": "application/octet-stream",
|
||||
".dsw": "text/plain",
|
||||
".dtd": "text/xml",
|
||||
".dtsConfig": "text/xml",
|
||||
".dv": "video/x-dv",
|
||||
".dvi": "application/x-dvi",
|
||||
".dwf": "drawing/x-dwf",
|
||||
".dwg": "application/acad",
|
||||
".dwp": "application/octet-stream",
|
||||
".dxf": "application/x-dxf",
|
||||
".dxr": "application/x-director",
|
||||
".eml": "message/rfc822",
|
||||
".emz": "application/octet-stream",
|
||||
".eot": "application/vnd.ms-fontobject",
|
||||
".eps": "application/postscript",
|
||||
".etl": "application/etl",
|
||||
".etx": "text/x-setext",
|
||||
".evy": "application/envoy",
|
||||
".exe": "application/octet-stream",
|
||||
".exe.config": "text/xml",
|
||||
".fdf": "application/vnd.fdf",
|
||||
".fif": "application/fractals",
|
||||
".filters": "application/xml",
|
||||
".fla": "application/octet-stream",
|
||||
".flac": "audio/flac",
|
||||
".flr": "x-world/x-vrml",
|
||||
".flv": "video/x-flv",
|
||||
".fsscript": "application/fsharp-script",
|
||||
".fsx": "application/fsharp-script",
|
||||
".generictest": "application/xml",
|
||||
".gif": "image/gif",
|
||||
".gpx": "application/gpx+xml",
|
||||
".group": "text/x-ms-group",
|
||||
".gradle": "text/plain",
|
||||
".gsm": "audio/x-gsm",
|
||||
".gtar": "application/x-gtar",
|
||||
".gz": "application/x-gzip",
|
||||
".h": "text/plain",
|
||||
".hdf": "application/x-hdf",
|
||||
".hdml": "text/x-hdml",
|
||||
".hhc": "application/x-oleobject",
|
||||
".hhk": "application/octet-stream",
|
||||
".hhp": "application/octet-stream",
|
||||
".hlp": "application/winhlp",
|
||||
".hpp": "text/plain",
|
||||
".hqx": "application/mac-binhex40",
|
||||
".hta": "application/hta",
|
||||
".htc": "text/x-component",
|
||||
".htm": "text/html",
|
||||
".html": "text/html",
|
||||
".htt": "text/webviewhtml",
|
||||
".hxa": "application/xml",
|
||||
".hxc": "application/xml",
|
||||
".hxd": "application/octet-stream",
|
||||
".hxe": "application/xml",
|
||||
".hxf": "application/xml",
|
||||
".hxh": "application/octet-stream",
|
||||
".hxi": "application/octet-stream",
|
||||
".hxk": "application/xml",
|
||||
".hxq": "application/octet-stream",
|
||||
".hxr": "application/octet-stream",
|
||||
".hxs": "application/octet-stream",
|
||||
".hxt": "text/html",
|
||||
".hxv": "application/xml",
|
||||
".hxw": "application/octet-stream",
|
||||
".hxx": "text/plain",
|
||||
".i": "text/plain",
|
||||
".ico": "image/x-icon",
|
||||
".ics": "application/octet-stream",
|
||||
".idl": "text/plain",
|
||||
".ief": "image/ief",
|
||||
".iii": "application/x-iphone",
|
||||
".inc": "text/plain",
|
||||
".inf": "application/octet-stream",
|
||||
".ini": "text/plain",
|
||||
".inl": "text/plain",
|
||||
".ins": "application/x-internet-signup",
|
||||
".ipa": "application/x-itunes-ipa",
|
||||
".ipg": "application/x-itunes-ipg",
|
||||
".ipproj": "text/plain",
|
||||
".ipsw": "application/x-itunes-ipsw",
|
||||
".iqy": "text/x-ms-iqy",
|
||||
".isp": "application/x-internet-signup",
|
||||
".ite": "application/x-itunes-ite",
|
||||
".itlp": "application/x-itunes-itlp",
|
||||
".itms": "application/x-itunes-itms",
|
||||
".itpc": "application/x-itunes-itpc",
|
||||
".IVF": "video/x-ivf",
|
||||
".jar": "application/java-archive",
|
||||
".java": "text/plain",
|
||||
".jck": "application/liquidmotion",
|
||||
".jcz": "application/liquidmotion",
|
||||
".jfif": "image/pjpeg",
|
||||
".jnlp": "application/x-java-jnlp-file",
|
||||
".jpb": "application/octet-stream",
|
||||
".jpe": "image/jpeg",
|
||||
".jpeg": "image/jpeg",
|
||||
".jpg": "image/jpeg",
|
||||
".js": "text/plain",
|
||||
".json": "application/json",
|
||||
".jsx": "text/jscript",
|
||||
".jsxbin": "text/plain",
|
||||
".latex": "application/x-latex",
|
||||
".less": "text/plain",
|
||||
".library-ms": "application/windows-library+xml",
|
||||
".lit": "application/x-ms-reader",
|
||||
".loadtest": "application/xml",
|
||||
".lpk": "application/octet-stream",
|
||||
".lsf": "video/x-la-asf",
|
||||
".lst": "text/plain",
|
||||
".lsx": "video/x-la-asf",
|
||||
".lzh": "application/octet-stream",
|
||||
".m13": "application/x-msmediaview",
|
||||
".m14": "application/x-msmediaview",
|
||||
".m1v": "video/mpeg",
|
||||
".m2t": "video/vnd.dlna.mpeg-tts",
|
||||
".m2ts": "video/vnd.dlna.mpeg-tts",
|
||||
".m2v": "video/mpeg",
|
||||
".m3u": "audio/x-mpegurl",
|
||||
".m3u8": "audio/x-mpegurl",
|
||||
".m4a": "audio/m4a",
|
||||
".m4b": "audio/m4b",
|
||||
".m4p": "audio/m4p",
|
||||
".m4r": "audio/x-m4r",
|
||||
".m4v": "video/x-m4v",
|
||||
".mac": "image/x-macpaint",
|
||||
".mak": "text/plain",
|
||||
".man": "application/x-troff-man",
|
||||
".manifest": "application/x-ms-manifest",
|
||||
".map": "text/plain",
|
||||
".master": "application/xml",
|
||||
".mbox": "application/mbox",
|
||||
".md": "text/plain",
|
||||
".mda": "application/msaccess",
|
||||
".mdb": "application/x-msaccess",
|
||||
".mde": "application/msaccess",
|
||||
".mdp": "application/octet-stream",
|
||||
".me": "application/x-troff-me",
|
||||
".mfp": "application/x-shockwave-flash",
|
||||
".mht": "message/rfc822",
|
||||
".mhtml": "message/rfc822",
|
||||
".mid": "audio/mid",
|
||||
".midi": "audio/mid",
|
||||
".mix": "application/octet-stream",
|
||||
".mk": "text/plain",
|
||||
".mmf": "application/x-smaf",
|
||||
".mno": "text/xml",
|
||||
".mny": "application/x-msmoney",
|
||||
".mod": "video/mpeg",
|
||||
".mov": "video/quicktime",
|
||||
".movie": "video/x-sgi-movie",
|
||||
".mp2": "video/mpeg",
|
||||
".mp2v": "video/mpeg",
|
||||
".mp3": "audio/mpeg",
|
||||
".mp4": "video/mp4",
|
||||
".mp4v": "video/mp4",
|
||||
".mpa": "video/mpeg",
|
||||
".mpe": "video/mpeg",
|
||||
".mpeg": "video/mpeg",
|
||||
".mpf": "application/vnd.ms-mediapackage",
|
||||
".mpg": "video/mpeg",
|
||||
".mpp": "application/vnd.ms-project",
|
||||
".mpv2": "video/mpeg",
|
||||
".mqv": "video/quicktime",
|
||||
".ms": "application/x-troff-ms",
|
||||
".msg": "application/vnd.ms-outlook",
|
||||
".msi": "application/octet-stream",
|
||||
".mso": "application/octet-stream",
|
||||
".mts": "video/vnd.dlna.mpeg-tts",
|
||||
".mtx": "application/xml",
|
||||
".mvb": "application/x-msmediaview",
|
||||
".mvc": "application/x-miva-compiled",
|
||||
".mxp": "application/x-mmxp",
|
||||
".nc": "application/x-netcdf",
|
||||
".nsc": "video/x-ms-asf",
|
||||
".nws": "message/rfc822",
|
||||
".ocx": "application/octet-stream",
|
||||
".oda": "application/oda",
|
||||
".odb": "application/vnd.oasis.opendocument.database",
|
||||
".odc": "application/vnd.oasis.opendocument.chart",
|
||||
".odf": "application/vnd.oasis.opendocument.formula",
|
||||
".odg": "application/vnd.oasis.opendocument.graphics",
|
||||
".odh": "text/plain",
|
||||
".odi": "application/vnd.oasis.opendocument.image",
|
||||
".odl": "text/plain",
|
||||
".odm": "application/vnd.oasis.opendocument.text-master",
|
||||
".odp": "application/vnd.oasis.opendocument.presentation",
|
||||
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
||||
".odt": "application/vnd.oasis.opendocument.text",
|
||||
".oga": "audio/ogg",
|
||||
".ogg": "audio/ogg",
|
||||
".ogv": "video/ogg",
|
||||
".ogx": "application/ogg",
|
||||
".one": "application/onenote",
|
||||
".onea": "application/onenote",
|
||||
".onepkg": "application/onenote",
|
||||
".onetmp": "application/onenote",
|
||||
".onetoc": "application/onenote",
|
||||
".onetoc2": "application/onenote",
|
||||
".opus": "audio/ogg",
|
||||
".orderedtest": "application/xml",
|
||||
".osdx": "application/opensearchdescription+xml",
|
||||
".otf": "application/font-sfnt",
|
||||
".otg": "application/vnd.oasis.opendocument.graphics-template",
|
||||
".oth": "application/vnd.oasis.opendocument.text-web",
|
||||
".otp": "application/vnd.oasis.opendocument.presentation-template",
|
||||
".ots": "application/vnd.oasis.opendocument.spreadsheet-template",
|
||||
".ott": "application/vnd.oasis.opendocument.text-template",
|
||||
".oxt": "application/vnd.openofficeorg.extension",
|
||||
".p10": "application/pkcs10",
|
||||
".p12": "application/x-pkcs12",
|
||||
".p7b": "application/x-pkcs7-certificates",
|
||||
".p7c": "application/pkcs7-mime",
|
||||
".p7m": "application/pkcs7-mime",
|
||||
".p7r": "application/x-pkcs7-certreqresp",
|
||||
".p7s": "application/pkcs7-signature",
|
||||
".pbm": "image/x-portable-bitmap",
|
||||
".pcast": "application/x-podcast",
|
||||
".pct": "image/pict",
|
||||
".pcx": "application/octet-stream",
|
||||
".pcz": "application/octet-stream",
|
||||
".pdf": "application/pdf",
|
||||
".pfb": "application/octet-stream",
|
||||
".pfm": "application/octet-stream",
|
||||
".pfx": "application/x-pkcs12",
|
||||
".pgm": "image/x-portable-graymap",
|
||||
".pic": "image/pict",
|
||||
".pict": "image/pict",
|
||||
".pkgdef": "text/plain",
|
||||
".pkgundef": "text/plain",
|
||||
".pko": "application/vnd.ms-pki.pko",
|
||||
".pls": "audio/scpls",
|
||||
".pma": "application/x-perfmon",
|
||||
".pmc": "application/x-perfmon",
|
||||
".pml": "application/x-perfmon",
|
||||
".pmr": "application/x-perfmon",
|
||||
".pmw": "application/x-perfmon",
|
||||
".png": "image/png",
|
||||
".pnm": "image/x-portable-anymap",
|
||||
".pnt": "image/x-macpaint",
|
||||
".pntg": "image/x-macpaint",
|
||||
".pnz": "image/png",
|
||||
".pot": "application/vnd.ms-powerpoint",
|
||||
".potm": "application/vnd.ms-powerpoint.template.macroEnabled.12",
|
||||
".potx":
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.template",
|
||||
".ppa": "application/vnd.ms-powerpoint",
|
||||
".ppam": "application/vnd.ms-powerpoint.addin.macroEnabled.12",
|
||||
".ppm": "image/x-portable-pixmap",
|
||||
".pps": "application/vnd.ms-powerpoint",
|
||||
".ppsm": "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
|
||||
".ppsx":
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
||||
".ppt": "application/vnd.ms-powerpoint",
|
||||
".pptm": "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
|
||||
".pptx":
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
".prf": "application/pics-rules",
|
||||
".prm": "application/octet-stream",
|
||||
".prx": "application/octet-stream",
|
||||
".ps": "application/postscript",
|
||||
".psc1": "application/PowerShell",
|
||||
".psd": "application/octet-stream",
|
||||
".psess": "application/xml",
|
||||
".psm": "application/octet-stream",
|
||||
".psp": "application/octet-stream",
|
||||
".pst": "application/vnd.ms-outlook",
|
||||
".pub": "application/x-mspublisher",
|
||||
".py": "text/plain",
|
||||
".pwz": "application/vnd.ms-powerpoint",
|
||||
".qht": "text/x-html-insertion",
|
||||
".qhtm": "text/x-html-insertion",
|
||||
".qt": "video/quicktime",
|
||||
".qti": "image/x-quicktime",
|
||||
".qtif": "image/x-quicktime",
|
||||
".qtl": "application/x-quicktimeplayer",
|
||||
".qxd": "application/octet-stream",
|
||||
".ra": "audio/x-pn-realaudio",
|
||||
".ram": "audio/x-pn-realaudio",
|
||||
".rar": "application/x-rar-compressed",
|
||||
".ras": "image/x-cmu-raster",
|
||||
".rat": "application/rat-file",
|
||||
".rc": "text/plain",
|
||||
".rc2": "text/plain",
|
||||
".rct": "text/plain",
|
||||
".rdlc": "application/xml",
|
||||
".reg": "text/plain",
|
||||
".resx": "application/xml",
|
||||
".rf": "image/vnd.rn-realflash",
|
||||
".rgb": "image/x-rgb",
|
||||
".rgs": "text/plain",
|
||||
".rm": "application/vnd.rn-realmedia",
|
||||
".rmi": "audio/mid",
|
||||
".rmp": "application/vnd.rn-rn_music_package",
|
||||
".roff": "application/x-troff",
|
||||
".rpm": "audio/x-pn-realaudio-plugin",
|
||||
".rqy": "text/x-ms-rqy",
|
||||
".rtf": "application/rtf",
|
||||
".rtx": "text/richtext",
|
||||
".rvt": "application/octet-stream",
|
||||
".ruleset": "application/xml",
|
||||
".s": "text/plain",
|
||||
".safariextz": "application/x-safari-safariextz",
|
||||
".scd": "application/x-msschedule",
|
||||
".scr": "text/plain",
|
||||
".sct": "text/scriptlet",
|
||||
".sd2": "audio/x-sd2",
|
||||
".sdp": "application/sdp",
|
||||
".sea": "application/octet-stream",
|
||||
".searchConnector-ms": "application/windows-search-connector+xml",
|
||||
".setpay": "application/set-payment-initiation",
|
||||
".setreg": "application/set-registration-initiation",
|
||||
".settings": "application/xml",
|
||||
".sgimb": "application/x-sgimb",
|
||||
".sgml": "text/sgml",
|
||||
".sh": "text/plain",
|
||||
".shar": "application/x-shar",
|
||||
".shtml": "text/html",
|
||||
".sit": "application/x-stuffit",
|
||||
".sitemap": "application/xml",
|
||||
".skin": "application/xml",
|
||||
".skp": "application/x-koan",
|
||||
".sldm": "application/vnd.ms-powerpoint.slide.macroEnabled.12",
|
||||
".sldx":
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.slide",
|
||||
".slk": "application/vnd.ms-excel",
|
||||
".sln": "text/plain",
|
||||
".slupkg-ms": "application/x-ms-license",
|
||||
".smd": "audio/x-smd",
|
||||
".smi": "application/octet-stream",
|
||||
".smx": "audio/x-smd",
|
||||
".smz": "audio/x-smd",
|
||||
".snd": "audio/basic",
|
||||
".snippet": "application/xml",
|
||||
".snp": "application/octet-stream",
|
||||
".sol": "text/plain",
|
||||
".sor": "text/plain",
|
||||
".spc": "application/x-pkcs7-certificates",
|
||||
".spl": "application/futuresplash",
|
||||
".spx": "audio/ogg",
|
||||
".sql": "text/plain",
|
||||
".src": "application/x-wais-source",
|
||||
".srf": "text/plain",
|
||||
".SSISDeploymentManifest": "text/xml",
|
||||
".ssm": "application/streamingmedia",
|
||||
".sst": "application/vnd.ms-pki.certstore",
|
||||
".stl": "application/vnd.ms-pki.stl",
|
||||
".sv4cpio": "application/x-sv4cpio",
|
||||
".sv4crc": "application/x-sv4crc",
|
||||
".svc": "application/xml",
|
||||
".svg": "image/svg+xml",
|
||||
".swf": "application/x-shockwave-flash",
|
||||
".step": "application/step",
|
||||
".stp": "application/step",
|
||||
".t": "application/x-troff",
|
||||
".tar": "application/x-tar",
|
||||
".tcl": "application/x-tcl",
|
||||
".testrunconfig": "application/xml",
|
||||
".testsettings": "application/xml",
|
||||
".tex": "application/x-tex",
|
||||
".texi": "application/x-texinfo",
|
||||
".texinfo": "application/x-texinfo",
|
||||
".tgz": "application/x-compressed",
|
||||
".thmx": "application/vnd.ms-officetheme",
|
||||
".thn": "application/octet-stream",
|
||||
".tif": "image/tiff",
|
||||
".tiff": "image/tiff",
|
||||
".tlh": "text/plain",
|
||||
".tli": "text/plain",
|
||||
".toc": "application/octet-stream",
|
||||
".tr": "application/x-troff",
|
||||
".trm": "application/x-msterminal",
|
||||
".trx": "application/xml",
|
||||
".ts": "video/vnd.dlna.mpeg-tts",
|
||||
".tsv": "text/tab-separated-values",
|
||||
".ttf": "application/font-sfnt",
|
||||
".tts": "video/vnd.dlna.mpeg-tts",
|
||||
".txt": "text/plain",
|
||||
".u32": "application/octet-stream",
|
||||
".uls": "text/iuls",
|
||||
".user": "text/plain",
|
||||
".ustar": "application/x-ustar",
|
||||
".vb": "text/plain",
|
||||
".vbdproj": "text/plain",
|
||||
".vbk": "video/mpeg",
|
||||
".vbproj": "text/plain",
|
||||
".vbs": "text/vbscript",
|
||||
".vcf": "text/x-vcard",
|
||||
".vcproj": "application/xml",
|
||||
".vcs": "text/plain",
|
||||
".vcxproj": "application/xml",
|
||||
".vddproj": "text/plain",
|
||||
".vdp": "text/plain",
|
||||
".vdproj": "text/plain",
|
||||
".vdx": "application/vnd.ms-visio.viewer",
|
||||
".vml": "text/xml",
|
||||
".vscontent": "application/xml",
|
||||
".vsct": "text/xml",
|
||||
".vsd": "application/vnd.visio",
|
||||
".vsi": "application/ms-vsi",
|
||||
".vsix": "application/vsix",
|
||||
".vsixlangpack": "text/xml",
|
||||
".vsixmanifest": "text/xml",
|
||||
".vsmdi": "application/xml",
|
||||
".vspscc": "text/plain",
|
||||
".vss": "application/vnd.visio",
|
||||
".vsscc": "text/plain",
|
||||
".vssettings": "text/xml",
|
||||
".vssscc": "text/plain",
|
||||
".vst": "application/vnd.visio",
|
||||
".vstemplate": "text/xml",
|
||||
".vsto": "application/x-ms-vsto",
|
||||
".vsw": "application/vnd.visio",
|
||||
".vsx": "application/vnd.visio",
|
||||
".vtx": "application/vnd.visio",
|
||||
".wav": "audio/wav",
|
||||
".wave": "audio/wav",
|
||||
".wax": "audio/x-ms-wax",
|
||||
".wbk": "application/msword",
|
||||
".wbmp": "image/vnd.wap.wbmp",
|
||||
".wcm": "application/vnd.ms-works",
|
||||
".wdb": "application/vnd.ms-works",
|
||||
".wdp": "image/vnd.ms-photo",
|
||||
".webarchive": "application/x-safari-webarchive",
|
||||
".webm": "video/webm",
|
||||
".webp": "image/webp" /* https"://en.wikipedia.org/wiki/WebP */,
|
||||
".webtest": "application/xml",
|
||||
".wiq": "application/xml",
|
||||
".wiz": "application/msword",
|
||||
".wks": "application/vnd.ms-works",
|
||||
".WLMP": "application/wlmoviemaker",
|
||||
".wlpginstall": "application/x-wlpg-detect",
|
||||
".wlpginstall3": "application/x-wlpg3-detect",
|
||||
".wm": "video/x-ms-wm",
|
||||
".wma": "audio/x-ms-wma",
|
||||
".wmd": "application/x-ms-wmd",
|
||||
".wmf": "application/x-msmetafile",
|
||||
".wml": "text/vnd.wap.wml",
|
||||
".wmlc": "application/vnd.wap.wmlc",
|
||||
".wmls": "text/vnd.wap.wmlscript",
|
||||
".wmlsc": "application/vnd.wap.wmlscriptc",
|
||||
".wmp": "video/x-ms-wmp",
|
||||
".wmv": "video/x-ms-wmv",
|
||||
".wmx": "video/x-ms-wmx",
|
||||
".wmz": "application/x-ms-wmz",
|
||||
".woff": "application/font-woff",
|
||||
".wpl": "application/vnd.ms-wpl",
|
||||
".wps": "application/vnd.ms-works",
|
||||
".wri": "application/x-mswrite",
|
||||
".wrl": "x-world/x-vrml",
|
||||
".wrz": "x-world/x-vrml",
|
||||
".wsc": "text/scriptlet",
|
||||
".wsdl": "text/xml",
|
||||
".wvx": "video/x-ms-wvx",
|
||||
".x": "application/directx",
|
||||
".xaf": "x-world/x-vrml",
|
||||
".xaml": "application/xaml+xml",
|
||||
".xap": "application/x-silverlight-app",
|
||||
".xbap": "application/x-ms-xbap",
|
||||
".xbm": "image/x-xbitmap",
|
||||
".xdr": "text/plain",
|
||||
".xht": "application/xhtml+xml",
|
||||
".xhtml": "application/xhtml+xml",
|
||||
".xla": "application/vnd.ms-excel",
|
||||
".xlam": "application/vnd.ms-excel.addin.macroEnabled.12",
|
||||
".xlc": "application/vnd.ms-excel",
|
||||
".xld": "application/vnd.ms-excel",
|
||||
".xlk": "application/vnd.ms-excel",
|
||||
".xll": "application/vnd.ms-excel",
|
||||
".xlm": "application/vnd.ms-excel",
|
||||
".xls": "application/vnd.ms-excel",
|
||||
".xlsb": "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
|
||||
".xlsm": "application/vnd.ms-excel.sheet.macroEnabled.12",
|
||||
".xlsx":
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
".xlt": "application/vnd.ms-excel",
|
||||
".xltm": "application/vnd.ms-excel.template.macroEnabled.12",
|
||||
".xltx":
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
||||
".xlw": "application/vnd.ms-excel",
|
||||
".xml": "text/xml",
|
||||
".xmp": "application/octet-stream",
|
||||
".xmta": "application/xml",
|
||||
".xof": "x-world/x-vrml",
|
||||
".XOML": "text/plain",
|
||||
".xpm": "image/x-xpixmap",
|
||||
".xps": "application/vnd.ms-xpsdocument",
|
||||
".xrm-ms": "text/xml",
|
||||
".xsc": "application/xml",
|
||||
".xsd": "text/xml",
|
||||
".xsf": "text/xml",
|
||||
".xsl": "text/xml",
|
||||
".xslt": "text/xml",
|
||||
".xsn": "application/octet-stream",
|
||||
".xss": "application/xml",
|
||||
".xspf": "application/xspf+xml",
|
||||
".xtp": "application/octet-stream",
|
||||
".xwd": "image/x-xwindowdump",
|
||||
".z": "application/x-compress",
|
||||
".zip": "application/zip",
|
||||
};
|
||||
|
||||
//根据一个文件名,获取其后缀名(一律使用小写),如果没有后缀名,那么返回""
|
||||
static getExtension(filename: string | null) {
|
||||
if (filename == null) {
|
||||
return "";
|
||||
}
|
||||
let dotIndex = filename.lastIndexOf(".");
|
||||
if (dotIndex === -1) {
|
||||
return "";
|
||||
} else {
|
||||
return filename.substring(dotIndex).toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
//根据一个文件名(带后缀的),获取对应的文件类型。
|
||||
static getMimeType(filename: string | null) {
|
||||
let extension = MimeUtil.getExtension(filename);
|
||||
if (MimeUtil.MIMES[extension]) {
|
||||
return MimeUtil.MIMES[extension];
|
||||
} else {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,39 @@
|
||||
export default class NumberUtil {
|
||||
//求最大公约数
|
||||
static gcd(a: number, b: number): number {
|
||||
return b ? NumberUtil.gcd(b, a % b) : a;
|
||||
}
|
||||
|
||||
//约分 numerator:分子 denominator:分母
|
||||
static reduce(numerator: number, denominator: number) {
|
||||
let maxFactor = NumberUtil.gcd(numerator, denominator);
|
||||
return [numerator / maxFactor, denominator / maxFactor];
|
||||
}
|
||||
|
||||
static isInteger(obj: any) {
|
||||
return typeof obj === 'number' && obj % 1 === 0
|
||||
return typeof obj === "number" && obj % 1 === 0;
|
||||
}
|
||||
|
||||
//转换成整型
|
||||
static parseInt(obj: any): number {
|
||||
|
||||
try {
|
||||
return parseInt(obj)
|
||||
return parseInt(obj);
|
||||
} catch (e) {
|
||||
console.error("无法转换成整数", obj)
|
||||
return 0
|
||||
console.error("无法转换成整数", obj);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//比较两个分数是否相等
|
||||
static fractionEqual(
|
||||
numerator1: number,
|
||||
denominator1: number,
|
||||
numerator2: number,
|
||||
denominator2: number
|
||||
) {
|
||||
let fraction1 = NumberUtil.reduce(numerator1, denominator1);
|
||||
let fraction2 = NumberUtil.reduce(numerator2, denominator2);
|
||||
|
||||
return fraction1[0] === fraction2[0] && fraction1[1] === fraction2[1];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user