@zero-library/common 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +66 -104
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +19 -30
- package/dist/index.d.ts +19 -30
- package/dist/index.esm.js +67 -100
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -3,19 +3,19 @@ import * as react from 'react';
|
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import Decimal from 'decimal.js';
|
|
6
|
-
import {
|
|
6
|
+
import { AxiosRequestConfig } from 'axios';
|
|
7
7
|
import { ThemeConfig } from 'antd/lib';
|
|
8
8
|
|
|
9
9
|
interface Props$a {
|
|
10
10
|
fileUrl: string;
|
|
11
11
|
}
|
|
12
|
-
declare const _default$
|
|
12
|
+
declare const _default$b: ({ fileUrl }: Props$a) => react_jsx_runtime.JSX.Element;
|
|
13
13
|
|
|
14
14
|
interface Props$9 {
|
|
15
15
|
suffix?: string;
|
|
16
16
|
fontSize?: number;
|
|
17
17
|
}
|
|
18
|
-
declare const _default$
|
|
18
|
+
declare const _default$a: ({ suffix, fontSize }: Props$9) => react_jsx_runtime.JSX.Element;
|
|
19
19
|
|
|
20
20
|
interface Props$8 {
|
|
21
21
|
fileUrl: string;
|
|
@@ -31,7 +31,7 @@ interface Props$8 {
|
|
|
31
31
|
fileParams?: ObjectType<string>;
|
|
32
32
|
onSetPassSuccess?: () => void;
|
|
33
33
|
}
|
|
34
|
-
declare const _default$
|
|
34
|
+
declare const _default$9: ({ suffix, fileUrl, pdfParams, password, searchValue }: Props$8) => react_jsx_runtime.JSX.Element;
|
|
35
35
|
|
|
36
36
|
interface Props$7 {
|
|
37
37
|
open: boolean;
|
|
@@ -49,13 +49,13 @@ interface Props$7 {
|
|
|
49
49
|
};
|
|
50
50
|
onSetPassSuccess?: () => void;
|
|
51
51
|
}
|
|
52
|
-
declare const _default$
|
|
52
|
+
declare const _default$8: ({ open, fileUrl, suffix, title, onClose, password, fileParams, pdfParams, onSetPassSuccess }: Props$7) => react_jsx_runtime.JSX.Element;
|
|
53
53
|
|
|
54
54
|
interface Props$6 {
|
|
55
55
|
fileUrl: string;
|
|
56
56
|
searchValue?: string;
|
|
57
57
|
}
|
|
58
|
-
declare const _default$
|
|
58
|
+
declare const _default$7: ({ fileUrl, searchValue }: Props$6) => react_jsx_runtime.JSX.Element;
|
|
59
59
|
|
|
60
60
|
interface Props$5 {
|
|
61
61
|
fileUrl: string;
|
|
@@ -66,12 +66,12 @@ interface Props$5 {
|
|
|
66
66
|
onSetPassword?: (password: string) => void;
|
|
67
67
|
onSetPageNo?: (pageNo: number) => void;
|
|
68
68
|
}
|
|
69
|
-
declare const _default$
|
|
69
|
+
declare const _default$6: ({ password, fileUrl, pageNo, scale, isHasThumbnails, onSetPassword, onSetPageNo }: Props$5) => react_jsx_runtime.JSX.Element;
|
|
70
70
|
|
|
71
71
|
interface Props$4 {
|
|
72
72
|
fileUrl: string;
|
|
73
73
|
}
|
|
74
|
-
declare const _default$
|
|
74
|
+
declare const _default$5: ({ fileUrl }: Props$4) => react_jsx_runtime.JSX.Element;
|
|
75
75
|
|
|
76
76
|
interface IframeProps {
|
|
77
77
|
id?: string;
|
|
@@ -79,7 +79,7 @@ interface IframeProps {
|
|
|
79
79
|
className?: string;
|
|
80
80
|
onLoad?: () => void;
|
|
81
81
|
}
|
|
82
|
-
declare const _default$
|
|
82
|
+
declare const _default$4: react.ForwardRefExoticComponent<IframeProps & react.RefAttributes<HTMLIFrameElement>>;
|
|
83
83
|
|
|
84
84
|
type ComponentMapType = Record<string, () => Promise<{
|
|
85
85
|
default: React.ComponentType<any>;
|
|
@@ -89,7 +89,7 @@ type Props$3 = {
|
|
|
89
89
|
customComponents?: ComponentMapType;
|
|
90
90
|
[key: string]: any;
|
|
91
91
|
};
|
|
92
|
-
declare const _default$
|
|
92
|
+
declare const _default$3: ({ type, customComponents, ...rest }: Props$3) => react_jsx_runtime.JSX.Element;
|
|
93
93
|
|
|
94
94
|
interface Props$2 {
|
|
95
95
|
disabled?: boolean;
|
|
@@ -102,7 +102,7 @@ interface Props$2 {
|
|
|
102
102
|
onQuote?: (text: string) => void;
|
|
103
103
|
onDownloadFile?: (fileContent: string, targetFormat?: string) => Promise<void>;
|
|
104
104
|
}
|
|
105
|
-
declare const _default$
|
|
105
|
+
declare const _default$2: ({ value, onChange, onScrollPage, searchValue, disabled, extraNav, showToolbar, onQuote, onDownloadFile }: Props$2) => react_jsx_runtime.JSX.Element;
|
|
106
106
|
|
|
107
107
|
interface Props$1 {
|
|
108
108
|
content?: string;
|
|
@@ -111,7 +111,7 @@ interface Props$1 {
|
|
|
111
111
|
onChange?: (value: string) => void;
|
|
112
112
|
onPartialChange?: (oldValue: string, newValue: string) => void;
|
|
113
113
|
}
|
|
114
|
-
declare const _default$
|
|
114
|
+
declare const _default$1: ({ content, searchValue, customComponents, onChange, onPartialChange }: Props$1) => react_jsx_runtime.JSX.Element;
|
|
115
115
|
|
|
116
116
|
type RenderControlObj<C, P = ObjectType<any>> = {
|
|
117
117
|
visible?: boolean;
|
|
@@ -135,7 +135,7 @@ interface Props {
|
|
|
135
135
|
userName?: string;
|
|
136
136
|
size?: number;
|
|
137
137
|
}
|
|
138
|
-
declare const _default
|
|
138
|
+
declare const _default: ({ size, avatarSrc, userName }: Props) => react_jsx_runtime.JSX.Element;
|
|
139
139
|
|
|
140
140
|
type Params = Record<string, any>;
|
|
141
141
|
/**
|
|
@@ -352,23 +352,12 @@ declare const MISSING_PARAMETER = 400;
|
|
|
352
352
|
declare const UNAUTHORIZED = 401;
|
|
353
353
|
declare const FORBIDDEN = 403;
|
|
354
354
|
declare const NOT_FOUND = 404;
|
|
355
|
-
declare const ILLEGAL_PARAMETER = 901;
|
|
356
355
|
declare const PERMISSION_DENIED = 13001;
|
|
357
|
-
declare
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
reqType?: 'json' | 'form';
|
|
363
|
-
timeout?: number;
|
|
364
|
-
responseType?: ResponseType;
|
|
365
|
-
showError?: boolean;
|
|
366
|
-
}
|
|
367
|
-
declare const _default: {
|
|
368
|
-
get: (url: string, params?: any, options?: Options) => Promise<any>;
|
|
369
|
-
post: (url: string, data?: any, options?: Options) => Promise<any>;
|
|
370
|
-
put: (url: string, data?: any, options?: Options) => Promise<any>;
|
|
371
|
-
delete: (url: string, data?: any, options?: Options) => Promise<any>;
|
|
356
|
+
declare function createRequest(baseURL?: string): {
|
|
357
|
+
get: (url: string, params?: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
358
|
+
post: (url: string, data?: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
359
|
+
put: (url: string, data?: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
360
|
+
delete: (url: string, data?: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
372
361
|
};
|
|
373
362
|
|
|
374
363
|
declare const TOKEN_KEY = "NS-TOKEN";
|
|
@@ -381,4 +370,4 @@ declare function getSignPath(): string;
|
|
|
381
370
|
declare const LgPrimaryColor: string;
|
|
382
371
|
declare const themeConfig: ThemeConfig;
|
|
383
372
|
|
|
384
|
-
export { _default$
|
|
373
|
+
export { _default$b as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, _default$a as FileIcon, _default$9 as FilePreview, _default$8 as FilePreviewDrawer, _default$4 as Iframe, _default$3 as LazyComponent, LgPrimaryColor, MISSING_PARAMETER, _default$2 as MarkdownEditor, _default$7 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, PERMISSION_DENIED, type Params, _default$6 as PdfPreview, type RenderControl, type RenderControlObj, _default$1 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default as UserAvatar, type UserInfo, _default$5 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, createRequest, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useCreateValtioContext, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,19 +3,19 @@ import * as react from 'react';
|
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
4
|
import dayjs from 'dayjs';
|
|
5
5
|
import Decimal from 'decimal.js';
|
|
6
|
-
import {
|
|
6
|
+
import { AxiosRequestConfig } from 'axios';
|
|
7
7
|
import { ThemeConfig } from 'antd/lib';
|
|
8
8
|
|
|
9
9
|
interface Props$a {
|
|
10
10
|
fileUrl: string;
|
|
11
11
|
}
|
|
12
|
-
declare const _default$
|
|
12
|
+
declare const _default$b: ({ fileUrl }: Props$a) => react_jsx_runtime.JSX.Element;
|
|
13
13
|
|
|
14
14
|
interface Props$9 {
|
|
15
15
|
suffix?: string;
|
|
16
16
|
fontSize?: number;
|
|
17
17
|
}
|
|
18
|
-
declare const _default$
|
|
18
|
+
declare const _default$a: ({ suffix, fontSize }: Props$9) => react_jsx_runtime.JSX.Element;
|
|
19
19
|
|
|
20
20
|
interface Props$8 {
|
|
21
21
|
fileUrl: string;
|
|
@@ -31,7 +31,7 @@ interface Props$8 {
|
|
|
31
31
|
fileParams?: ObjectType<string>;
|
|
32
32
|
onSetPassSuccess?: () => void;
|
|
33
33
|
}
|
|
34
|
-
declare const _default$
|
|
34
|
+
declare const _default$9: ({ suffix, fileUrl, pdfParams, password, searchValue }: Props$8) => react_jsx_runtime.JSX.Element;
|
|
35
35
|
|
|
36
36
|
interface Props$7 {
|
|
37
37
|
open: boolean;
|
|
@@ -49,13 +49,13 @@ interface Props$7 {
|
|
|
49
49
|
};
|
|
50
50
|
onSetPassSuccess?: () => void;
|
|
51
51
|
}
|
|
52
|
-
declare const _default$
|
|
52
|
+
declare const _default$8: ({ open, fileUrl, suffix, title, onClose, password, fileParams, pdfParams, onSetPassSuccess }: Props$7) => react_jsx_runtime.JSX.Element;
|
|
53
53
|
|
|
54
54
|
interface Props$6 {
|
|
55
55
|
fileUrl: string;
|
|
56
56
|
searchValue?: string;
|
|
57
57
|
}
|
|
58
|
-
declare const _default$
|
|
58
|
+
declare const _default$7: ({ fileUrl, searchValue }: Props$6) => react_jsx_runtime.JSX.Element;
|
|
59
59
|
|
|
60
60
|
interface Props$5 {
|
|
61
61
|
fileUrl: string;
|
|
@@ -66,12 +66,12 @@ interface Props$5 {
|
|
|
66
66
|
onSetPassword?: (password: string) => void;
|
|
67
67
|
onSetPageNo?: (pageNo: number) => void;
|
|
68
68
|
}
|
|
69
|
-
declare const _default$
|
|
69
|
+
declare const _default$6: ({ password, fileUrl, pageNo, scale, isHasThumbnails, onSetPassword, onSetPageNo }: Props$5) => react_jsx_runtime.JSX.Element;
|
|
70
70
|
|
|
71
71
|
interface Props$4 {
|
|
72
72
|
fileUrl: string;
|
|
73
73
|
}
|
|
74
|
-
declare const _default$
|
|
74
|
+
declare const _default$5: ({ fileUrl }: Props$4) => react_jsx_runtime.JSX.Element;
|
|
75
75
|
|
|
76
76
|
interface IframeProps {
|
|
77
77
|
id?: string;
|
|
@@ -79,7 +79,7 @@ interface IframeProps {
|
|
|
79
79
|
className?: string;
|
|
80
80
|
onLoad?: () => void;
|
|
81
81
|
}
|
|
82
|
-
declare const _default$
|
|
82
|
+
declare const _default$4: react.ForwardRefExoticComponent<IframeProps & react.RefAttributes<HTMLIFrameElement>>;
|
|
83
83
|
|
|
84
84
|
type ComponentMapType = Record<string, () => Promise<{
|
|
85
85
|
default: React.ComponentType<any>;
|
|
@@ -89,7 +89,7 @@ type Props$3 = {
|
|
|
89
89
|
customComponents?: ComponentMapType;
|
|
90
90
|
[key: string]: any;
|
|
91
91
|
};
|
|
92
|
-
declare const _default$
|
|
92
|
+
declare const _default$3: ({ type, customComponents, ...rest }: Props$3) => react_jsx_runtime.JSX.Element;
|
|
93
93
|
|
|
94
94
|
interface Props$2 {
|
|
95
95
|
disabled?: boolean;
|
|
@@ -102,7 +102,7 @@ interface Props$2 {
|
|
|
102
102
|
onQuote?: (text: string) => void;
|
|
103
103
|
onDownloadFile?: (fileContent: string, targetFormat?: string) => Promise<void>;
|
|
104
104
|
}
|
|
105
|
-
declare const _default$
|
|
105
|
+
declare const _default$2: ({ value, onChange, onScrollPage, searchValue, disabled, extraNav, showToolbar, onQuote, onDownloadFile }: Props$2) => react_jsx_runtime.JSX.Element;
|
|
106
106
|
|
|
107
107
|
interface Props$1 {
|
|
108
108
|
content?: string;
|
|
@@ -111,7 +111,7 @@ interface Props$1 {
|
|
|
111
111
|
onChange?: (value: string) => void;
|
|
112
112
|
onPartialChange?: (oldValue: string, newValue: string) => void;
|
|
113
113
|
}
|
|
114
|
-
declare const _default$
|
|
114
|
+
declare const _default$1: ({ content, searchValue, customComponents, onChange, onPartialChange }: Props$1) => react_jsx_runtime.JSX.Element;
|
|
115
115
|
|
|
116
116
|
type RenderControlObj<C, P = ObjectType<any>> = {
|
|
117
117
|
visible?: boolean;
|
|
@@ -135,7 +135,7 @@ interface Props {
|
|
|
135
135
|
userName?: string;
|
|
136
136
|
size?: number;
|
|
137
137
|
}
|
|
138
|
-
declare const _default
|
|
138
|
+
declare const _default: ({ size, avatarSrc, userName }: Props) => react_jsx_runtime.JSX.Element;
|
|
139
139
|
|
|
140
140
|
type Params = Record<string, any>;
|
|
141
141
|
/**
|
|
@@ -352,23 +352,12 @@ declare const MISSING_PARAMETER = 400;
|
|
|
352
352
|
declare const UNAUTHORIZED = 401;
|
|
353
353
|
declare const FORBIDDEN = 403;
|
|
354
354
|
declare const NOT_FOUND = 404;
|
|
355
|
-
declare const ILLEGAL_PARAMETER = 901;
|
|
356
355
|
declare const PERMISSION_DENIED = 13001;
|
|
357
|
-
declare
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
reqType?: 'json' | 'form';
|
|
363
|
-
timeout?: number;
|
|
364
|
-
responseType?: ResponseType;
|
|
365
|
-
showError?: boolean;
|
|
366
|
-
}
|
|
367
|
-
declare const _default: {
|
|
368
|
-
get: (url: string, params?: any, options?: Options) => Promise<any>;
|
|
369
|
-
post: (url: string, data?: any, options?: Options) => Promise<any>;
|
|
370
|
-
put: (url: string, data?: any, options?: Options) => Promise<any>;
|
|
371
|
-
delete: (url: string, data?: any, options?: Options) => Promise<any>;
|
|
356
|
+
declare function createRequest(baseURL?: string): {
|
|
357
|
+
get: (url: string, params?: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
358
|
+
post: (url: string, data?: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
359
|
+
put: (url: string, data?: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
360
|
+
delete: (url: string, data?: any, options?: AxiosRequestConfig) => Promise<any>;
|
|
372
361
|
};
|
|
373
362
|
|
|
374
363
|
declare const TOKEN_KEY = "NS-TOKEN";
|
|
@@ -381,4 +370,4 @@ declare function getSignPath(): string;
|
|
|
381
370
|
declare const LgPrimaryColor: string;
|
|
382
371
|
declare const themeConfig: ThemeConfig;
|
|
383
372
|
|
|
384
|
-
export { _default$
|
|
373
|
+
export { _default$b as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, _default$a as FileIcon, _default$9 as FilePreview, _default$8 as FilePreviewDrawer, _default$4 as Iframe, _default$3 as LazyComponent, LgPrimaryColor, MISSING_PARAMETER, _default$2 as MarkdownEditor, _default$7 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, PERMISSION_DENIED, type Params, _default$6 as PdfPreview, type RenderControl, type RenderControlObj, _default$1 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default as UserAvatar, type UserInfo, _default$5 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, createRequest, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useCreateValtioContext, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket };
|
package/dist/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { FileUnknownOutlined, FileZipOutlined, FileMarkdownOutlined, FileGifOutlined, FileImageOutlined, FileJpgOutlined, NotificationOutlined, VideoCameraOutlined, FilePptOutlined, FileExcelOutlined, FileWordOutlined, FilePdfOutlined, FileTextOutlined } from '@ant-design/icons';
|
|
3
3
|
import * as React16 from 'react';
|
|
4
4
|
import { forwardRef, useState, useMemo, useEffect, lazy, Suspense, useRef, createContext, useCallback, useContext } from 'react';
|
|
5
|
-
import { Spin,
|
|
5
|
+
import { Spin, Result, Splitter, Empty, Image, Flex, Drawer, Tag, Avatar, Alert, notification, Modal, Form, Input, Button } from 'antd';
|
|
6
6
|
import parse from 'html-react-parser';
|
|
7
7
|
import { jsonrepair } from 'jsonrepair';
|
|
8
8
|
import markdownit from 'markdown-it';
|
|
@@ -955,112 +955,78 @@ var MISSING_PARAMETER = 400;
|
|
|
955
955
|
var UNAUTHORIZED = 401;
|
|
956
956
|
var FORBIDDEN = 403;
|
|
957
957
|
var NOT_FOUND = 404;
|
|
958
|
-
var ILLEGAL_PARAMETER = 901;
|
|
959
958
|
var PERMISSION_DENIED = 13001;
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
function(config) {
|
|
976
|
-
config.headers[TOKEN_KEY] = getToken();
|
|
977
|
-
if (config.url && !config.url.startsWith("/api/")) {
|
|
978
|
-
config.baseURL = "/api";
|
|
959
|
+
function createRequest(baseURL = "/api") {
|
|
960
|
+
const redirectUrl = () => {
|
|
961
|
+
emit("jumpLink", { url: `/uc${getSignPath()}` });
|
|
962
|
+
};
|
|
963
|
+
const instance = axios.create({
|
|
964
|
+
baseURL,
|
|
965
|
+
timeout: 6e4
|
|
966
|
+
});
|
|
967
|
+
instance.interceptors.request.use(
|
|
968
|
+
function(config) {
|
|
969
|
+
config.headers[TOKEN_KEY] = getToken();
|
|
970
|
+
return config;
|
|
971
|
+
},
|
|
972
|
+
function(error) {
|
|
973
|
+
return Promise.reject(error);
|
|
979
974
|
}
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
)
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
975
|
+
);
|
|
976
|
+
instance.interceptors.response.use(
|
|
977
|
+
function(response) {
|
|
978
|
+
if (isBlob(response.data)) return response;
|
|
979
|
+
if (response.data?.code !== OK) {
|
|
980
|
+
const isPermission = response.data?.code === PERMISSION_DENIED;
|
|
981
|
+
if (response.config?.showError !== false) {
|
|
982
|
+
showMessage({
|
|
983
|
+
title: isPermission ? "" : void 0,
|
|
984
|
+
content: response.data.message,
|
|
985
|
+
duration: isPermission ? 0 : 3
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
return Promise.reject(response.data);
|
|
989
|
+
}
|
|
990
990
|
return response;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
const
|
|
994
|
-
if (response
|
|
995
|
-
showMessage({
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
991
|
+
},
|
|
992
|
+
function(err) {
|
|
993
|
+
const showError = err?.config?.showError !== false;
|
|
994
|
+
if (!err.response) {
|
|
995
|
+
if (showError) showMessage({ content: "\u7F51\u7EDC\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC", type: "error" });
|
|
996
|
+
} else {
|
|
997
|
+
switch (err.response?.status) {
|
|
998
|
+
case UNAUTHORIZED:
|
|
999
|
+
if (showError) showMessage({ content: err.response?.data.message, type: "error" });
|
|
1000
|
+
redirectUrl();
|
|
1001
|
+
break;
|
|
1002
|
+
default:
|
|
1003
|
+
if (showError) showMessage({ content: err.response?.data.message || "\u8BF7\u6C42\u9519\u8BEF\uFF01", type: "error" });
|
|
1004
|
+
}
|
|
1000
1005
|
}
|
|
1001
|
-
return Promise.reject(
|
|
1006
|
+
return Promise.reject(err);
|
|
1002
1007
|
}
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
if (showError) showMessage({ content: err.response?.data.message, type: "error" });
|
|
1021
|
-
break;
|
|
1022
|
-
default:
|
|
1023
|
-
if (showError) showMessage({ content: "\u8BF7\u6C42\u6570\u636E\u53D1\u751F\u9519\u8BEF\uFF01", type: "info" });
|
|
1024
|
-
}
|
|
1008
|
+
);
|
|
1009
|
+
return {
|
|
1010
|
+
get: async (url, params, options) => {
|
|
1011
|
+
const res = await instance({ method: "get", url, params, ...options });
|
|
1012
|
+
return res.data;
|
|
1013
|
+
},
|
|
1014
|
+
post: async (url, data, options) => {
|
|
1015
|
+
const res = await instance({ method: "post", url, data, ...options });
|
|
1016
|
+
return res.data;
|
|
1017
|
+
},
|
|
1018
|
+
put: async (url, data, options) => {
|
|
1019
|
+
const res = await instance({ method: "put", url, data, ...options });
|
|
1020
|
+
return res.data;
|
|
1021
|
+
},
|
|
1022
|
+
delete: async (url, data, options) => {
|
|
1023
|
+
const res = await instance({ method: "delete", url, data, ...options });
|
|
1024
|
+
return res.data;
|
|
1025
1025
|
}
|
|
1026
|
-
return Promise.reject(err);
|
|
1027
|
-
}
|
|
1028
|
-
);
|
|
1029
|
-
var get = async (url, params, options) => {
|
|
1030
|
-
const res = await axios({ method: "get", url, params, ...options });
|
|
1031
|
-
return res.data;
|
|
1032
|
-
};
|
|
1033
|
-
var post = async (url, data, options) => {
|
|
1034
|
-
const res = await axios({
|
|
1035
|
-
method: "post",
|
|
1036
|
-
url,
|
|
1037
|
-
data,
|
|
1038
|
-
...parseOptions(options)
|
|
1039
|
-
});
|
|
1040
|
-
return res.data;
|
|
1041
|
-
};
|
|
1042
|
-
var put = async (url, data, options) => {
|
|
1043
|
-
const res = await axios({ method: "put", url, data, ...parseOptions(options) });
|
|
1044
|
-
return res.data;
|
|
1045
|
-
};
|
|
1046
|
-
var del = async (url, data, options) => {
|
|
1047
|
-
const reqConfig = {
|
|
1048
|
-
method: "delete",
|
|
1049
|
-
url,
|
|
1050
|
-
...parseOptions(options)
|
|
1051
1026
|
};
|
|
1052
|
-
|
|
1053
|
-
const res = await axios({ ...reqConfig, ...params });
|
|
1054
|
-
return res.data;
|
|
1055
|
-
};
|
|
1056
|
-
var request_default = {
|
|
1057
|
-
get,
|
|
1058
|
-
post,
|
|
1059
|
-
put,
|
|
1060
|
-
delete: del
|
|
1061
|
-
};
|
|
1027
|
+
}
|
|
1062
1028
|
|
|
1063
|
-
// src/hooks/useWebSocket.ts
|
|
1029
|
+
// src/hooks/webSocket/useWebSocket.ts
|
|
1064
1030
|
var useWebSocket = ({
|
|
1065
1031
|
url,
|
|
1066
1032
|
onMessage,
|
|
@@ -1169,6 +1135,7 @@ var useWebSocket = ({
|
|
|
1169
1135
|
}
|
|
1170
1136
|
};
|
|
1171
1137
|
useEffect(() => {
|
|
1138
|
+
if (!url) return;
|
|
1172
1139
|
isDestroy.current = false;
|
|
1173
1140
|
createAndListenWebSocket();
|
|
1174
1141
|
window.addEventListener("visibilitychange", handleVisibilityChange);
|
|
@@ -5220,6 +5187,6 @@ var UserAvatar_default = ({ size, avatarSrc, userName }) => {
|
|
|
5220
5187
|
return avatarSrc ? /* @__PURE__ */ jsx(Avatar, { size, src: avatarSrc }) : /* @__PURE__ */ jsx(Avatar, { size, className: "cursor-pointer", style: { backgroundColor: LgPrimaryColor }, children: userName?.slice(0, 1)?.toLocaleUpperCase() });
|
|
5221
5188
|
};
|
|
5222
5189
|
|
|
5223
|
-
export { AudioPlayer_default as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN,
|
|
5190
|
+
export { AudioPlayer_default as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, Iframe_default as Iframe, LazyComponent_default as LazyComponent, LgPrimaryColor, MISSING_PARAMETER, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, NOT_FOUND, OK, PERMISSION_DENIED, PdfPreview_default as PdfPreview, RenderMarkdown_default as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, createRequest, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useCreateValtioContext, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket_default as useWebSocket };
|
|
5224
5191
|
//# sourceMappingURL=index.esm.js.map
|
|
5225
5192
|
//# sourceMappingURL=index.esm.js.map
|