1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

added imagecache

This commit is contained in:
Fedor Katurov 2019-11-07 12:13:05 +07:00
parent 80c3a8a4c5
commit 88f50e3348
6 changed files with 29 additions and 6 deletions

View file

@ -2,6 +2,7 @@ import { IFile } from '~/redux/types';
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
import { ru } from 'date-fns/locale';
import Axios from 'axios';
import { PRESETS } from '~/constants/urls';
export const getStyle = (oElm: any, strCssRule: string) => {
if (document.defaultView && document.defaultView.getComputedStyle) {
@ -57,9 +58,15 @@ export const describeArc = (
].join(' ');
};
export const getURL = (file: Partial<IFile>) => {
export const getURL = (file: Partial<IFile>, size?: typeof PRESETS[keyof typeof PRESETS]) => {
if (!file || !file.url) return null;
if (size) {
return file.url
.replace('REMOTE_CURRENT://', `${process.env.REMOTE_CURRENT}/cache/${size}/`)
.replace('REMOTE_OLD://', process.env.REMOTE_OLD);
}
return file.url
.replace('REMOTE_CURRENT://', process.env.REMOTE_CURRENT)
.replace('REMOTE_OLD://', process.env.REMOTE_OLD);