mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-02 12:18:15 +08:00
feat: support for server-sent events (#5418)
* feat: qr code uploader * fix: axios * fix: test error
This commit is contained in:
parent
b4270c7377
commit
156d99c724
@ -62,6 +62,9 @@ export default defineConfig({
|
||||
edge: 79,
|
||||
safari: 12,
|
||||
},
|
||||
jsMinifierOptions: {
|
||||
target: ['chrome80', 'es2020'],
|
||||
},
|
||||
codeSplitting: {
|
||||
jsStrategy: 'depPerChunk'
|
||||
},
|
||||
|
@ -33,7 +33,7 @@
|
||||
"ahooks": "^3.7.2",
|
||||
"antd": "5.12.8",
|
||||
"antd-style": "3.4.5",
|
||||
"axios": "^0.26.1",
|
||||
"axios": "^1.7.0",
|
||||
"bignumber.js": "^9.1.2",
|
||||
"classnames": "^2.3.1",
|
||||
"cronstrue": "^2.11.0",
|
||||
|
@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
import { IResource } from '@nocobase/sdk';
|
||||
import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react';
|
||||
import { isArray } from 'lodash';
|
||||
import React, { FC, ReactNode, createContext, useContext, useMemo } from 'react';
|
||||
import { useAPIClient } from '../../api-client';
|
||||
import { useCollectionManager } from '../collection';
|
||||
import { CollectionRecord } from '../collection-record';
|
||||
|
@ -20,6 +20,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import LightBox from 'react-image-lightbox';
|
||||
import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app
|
||||
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
||||
import { useComponent } from '../../hooks';
|
||||
import { useProps } from '../../hooks/useProps';
|
||||
import {
|
||||
FILE_SIZE_LIMIT_DEFAULT,
|
||||
@ -401,6 +402,8 @@ export function Uploader({ rules, ...props }: UploadProps) {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const QRCodeUploader = useComponent('QRCodeUploader');
|
||||
|
||||
const { mimetype: accept, size } = rules ?? {};
|
||||
const sizeHint = useSizeHint(size);
|
||||
const selectable =
|
||||
@ -441,6 +444,16 @@ export function Uploader({ rules, ...props }: UploadProps) {
|
||||
</AntdUpload>
|
||||
</Tooltip>
|
||||
</div>
|
||||
{selectable && QRCodeUploader && (
|
||||
<QRCodeUploader
|
||||
value={value}
|
||||
onChange={(value) => {
|
||||
// TODO
|
||||
console.log(value);
|
||||
// onChange(value);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -7,5 +7,7 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
export * from './Upload';
|
||||
export { attachmentFileTypes } from './shared';
|
||||
export { useUploadStyles } from './style';
|
||||
|
||||
export * from './Upload';
|
||||
|
@ -113,3 +113,5 @@ export const useStyles = genStyleHook('upload', (token) => {
|
||||
},
|
||||
} as any;
|
||||
});
|
||||
|
||||
export const useUploadStyles = useStyles;
|
||||
|
@ -5,7 +5,7 @@
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@umijs/utils": "3.5.20",
|
||||
"axios": "^0.26.1",
|
||||
"axios": "^1.7.0",
|
||||
"chalk": "^4.1.1",
|
||||
"commander": "^9.2.0",
|
||||
"tar": "6.1.11"
|
||||
|
@ -53,6 +53,15 @@ function getUmiConfig() {
|
||||
target: PROXY_TARGET_URL,
|
||||
changeOrigin: true,
|
||||
pathRewrite: { [`^${API_BASE_PATH}`]: API_BASE_PATH },
|
||||
onProxyRes(proxyRes, req, res) {
|
||||
if (req.headers.accept === 'text/event-stream') {
|
||||
res.writeHead(res.statusCode, {
|
||||
'Content-Type': 'text/event-stream',
|
||||
'Cache-Control': 'no-transform',
|
||||
Connection: 'keep-alive',
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
// for local storage
|
||||
...getLocalStorageProxy(),
|
||||
|
@ -5,7 +5,7 @@
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"dependencies": {
|
||||
"axios": "^0.26.1",
|
||||
"axios": "^1.7.0",
|
||||
"qs": "^6.10.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -7,7 +7,7 @@
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import axios, { AxiosInstance, AxiosRequestConfig, AxiosRequestHeaders, AxiosResponse } from 'axios';
|
||||
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, RawAxiosRequestHeaders } from 'axios';
|
||||
import qs from 'qs';
|
||||
|
||||
export interface ActionParams {
|
||||
@ -347,7 +347,7 @@ export class APIClient {
|
||||
return this.axios.request<T, R, D>(config);
|
||||
}
|
||||
|
||||
resource(name: string, of?: any, headers?: AxiosRequestHeaders, cancel?: boolean): IResource {
|
||||
resource(name: string, of?: any, headers?: RawAxiosRequestHeaders, cancel?: boolean): IResource {
|
||||
const target = {};
|
||||
const handler = {
|
||||
get: (_: any, actionName: string) => {
|
||||
|
@ -26,7 +26,7 @@
|
||||
"@types/ini": "^1.3.31",
|
||||
"@types/koa-send": "^4.1.3",
|
||||
"@types/multer": "^1.4.5",
|
||||
"axios": "^0.26.1",
|
||||
"axios": "^1.7.0",
|
||||
"chalk": "^4.1.1",
|
||||
"commander": "^9.2.0",
|
||||
"cron": "^2.4.4",
|
||||
|
@ -15,7 +15,7 @@ import bodyParser from 'koa-bodyparser';
|
||||
import Database from '@nocobase/database';
|
||||
import { MockServer } from '@nocobase/test';
|
||||
|
||||
import PluginWorkflow, { Processor, EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
|
||||
import PluginWorkflow, { EXECUTION_STATUS, JOB_STATUS, Processor } from '@nocobase/plugin-workflow';
|
||||
import { getApp, sleep } from '@nocobase/plugin-workflow-test';
|
||||
|
||||
import { RequestConfig } from '../MailerInstruction';
|
||||
@ -206,8 +206,8 @@ describe('workflow > instructions > request', () => {
|
||||
|
||||
expect(job.result).toMatchObject({
|
||||
code: 'ECONNABORTED',
|
||||
name: 'Error',
|
||||
status: null,
|
||||
name: 'AxiosError',
|
||||
// status: null,
|
||||
message: 'timeout of 250ms exceeded',
|
||||
});
|
||||
|
||||
@ -235,8 +235,8 @@ describe('workflow > instructions > request', () => {
|
||||
expect(job.status).toBe(JOB_STATUS.RESOLVED);
|
||||
expect(job.result).toMatchObject({
|
||||
code: 'ECONNABORTED',
|
||||
name: 'Error',
|
||||
status: null,
|
||||
name: 'AxiosError',
|
||||
// status: null,
|
||||
message: 'timeout of 250ms exceeded',
|
||||
});
|
||||
});
|
||||
@ -319,7 +319,7 @@ describe('workflow > instructions > request', () => {
|
||||
expect(job.result).toMatchObject({
|
||||
code: 'ECONNRESET',
|
||||
name: 'Error',
|
||||
status: null,
|
||||
// status: null,
|
||||
message: 'socket hang up',
|
||||
});
|
||||
});
|
||||
|
@ -11,7 +11,7 @@
|
||||
"homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow-request",
|
||||
"devDependencies": {
|
||||
"antd": "5.x",
|
||||
"axios": "^0.26.1",
|
||||
"axios": "^1.7.0",
|
||||
"react": "18.x",
|
||||
"react-i18next": "^11.15.1"
|
||||
},
|
||||
|
@ -8,15 +8,15 @@
|
||||
*/
|
||||
|
||||
import { Server } from 'http';
|
||||
import type { AddressInfo } from 'net';
|
||||
import jwt from 'jsonwebtoken';
|
||||
import Koa from 'koa';
|
||||
import bodyParser from 'koa-bodyparser';
|
||||
import type { AddressInfo } from 'net';
|
||||
|
||||
import Database from '@nocobase/database';
|
||||
import { MockServer } from '@nocobase/test';
|
||||
|
||||
import PluginWorkflow, { Processor, EXECUTION_STATUS, JOB_STATUS } from '@nocobase/plugin-workflow';
|
||||
import PluginWorkflow, { EXECUTION_STATUS, JOB_STATUS, Processor } from '@nocobase/plugin-workflow';
|
||||
import { getApp, sleep } from '@nocobase/plugin-workflow-test';
|
||||
|
||||
import { RequestConfig } from '../RequestInstruction';
|
||||
@ -227,8 +227,8 @@ describe('workflow > instructions > request', () => {
|
||||
|
||||
expect(job.result).toMatchObject({
|
||||
code: 'ECONNABORTED',
|
||||
name: 'Error',
|
||||
status: null,
|
||||
name: 'AxiosError',
|
||||
// status: null,
|
||||
message: 'timeout of 250ms exceeded',
|
||||
});
|
||||
|
||||
@ -256,8 +256,8 @@ describe('workflow > instructions > request', () => {
|
||||
expect(job.status).toBe(JOB_STATUS.RESOLVED);
|
||||
expect(job.result).toMatchObject({
|
||||
code: 'ECONNABORTED',
|
||||
name: 'Error',
|
||||
status: null,
|
||||
name: 'AxiosError',
|
||||
// status: null,
|
||||
message: 'timeout of 250ms exceeded',
|
||||
});
|
||||
});
|
||||
@ -340,7 +340,7 @@ describe('workflow > instructions > request', () => {
|
||||
expect(job.result).toMatchObject({
|
||||
code: 'ECONNRESET',
|
||||
name: 'Error',
|
||||
status: null,
|
||||
// status: null,
|
||||
message: 'socket hang up',
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user