mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
made tags panel
This commit is contained in:
parent
f2289f4530
commit
c4f60f3d81
31 changed files with 552 additions and 75 deletions
|
@ -23,15 +23,12 @@ export const HTTP_RESPONSES = {
|
|||
TOO_MANY_REQUESTS: 429,
|
||||
};
|
||||
|
||||
export const resultMiddleware = <T extends {}>({
|
||||
export const resultMiddleware = <T extends any>({ status, data }: { status; data: T }) => ({
|
||||
status,
|
||||
data,
|
||||
}: {
|
||||
status: number;
|
||||
data: T;
|
||||
}): { status: number; data: T } => ({ status, data });
|
||||
});
|
||||
|
||||
export const errorMiddleware = <T extends any>(debug): IResultWithStatus<T> =>
|
||||
export const errorMiddleware = <T extends any = any>(debug): IResultWithStatus<T> =>
|
||||
debug && debug.response
|
||||
? {
|
||||
status: debug.response.status,
|
||||
|
@ -41,7 +38,7 @@ export const errorMiddleware = <T extends any>(debug): IResultWithStatus<T> =>
|
|||
}
|
||||
: {
|
||||
status: HTTP_RESPONSES.CONNECTION_REFUSED,
|
||||
data: {} as T & IApiErrorResult,
|
||||
data: {} as T & IApiErrorResult & any,
|
||||
debug,
|
||||
error: 'Ошибка сети',
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ import differenceInMinutes from 'date-fns/differenceInMinutes';
|
|||
import ru from 'date-fns/locale/ru';
|
||||
import Axios from 'axios';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
import { ICommentBlock, COMMENT_BLOCK_DETECTORS, COMMENT_BLOCK_TYPES } from '~/constants/comment';
|
||||
import { COMMENT_BLOCK_DETECTORS, COMMENT_BLOCK_TYPES, ICommentBlock } from '~/constants/comment';
|
||||
import format from 'date-fns/format';
|
||||
|
||||
export const getStyle = (oElm: any, strCssRule: string) => {
|
||||
|
@ -63,20 +63,25 @@ export const describeArc = (
|
|||
].join(' ');
|
||||
};
|
||||
|
||||
export const getURL = (file: Partial<IFile>, size?: typeof PRESETS[keyof typeof PRESETS]) => {
|
||||
if (!file || !file.url) return null;
|
||||
|
||||
export const getURLFromString = (
|
||||
url: string,
|
||||
size?: typeof PRESETS[keyof typeof PRESETS]
|
||||
): string => {
|
||||
if (size) {
|
||||
return file.url
|
||||
return url
|
||||
.replace('REMOTE_CURRENT://', `${process.env.REMOTE_CURRENT}cache/${size}/`)
|
||||
.replace('REMOTE_OLD://', process.env.REMOTE_OLD);
|
||||
}
|
||||
|
||||
return file.url
|
||||
return url
|
||||
.replace('REMOTE_CURRENT://', process.env.REMOTE_CURRENT)
|
||||
.replace('REMOTE_OLD://', process.env.REMOTE_OLD);
|
||||
};
|
||||
|
||||
export const getURL = (file: Partial<IFile>, size?: typeof PRESETS[keyof typeof PRESETS]) => {
|
||||
return file?.url ? getURLFromString(file.url, size) : null;
|
||||
};
|
||||
|
||||
export const formatText = (text: string): string =>
|
||||
!text
|
||||
? ''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue