Skip to content

Commit

Permalink
chore: update lint config in package.json antd fix lint error (#1930)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreammy23 committed Aug 30, 2024
2 parents 371dec1 + 9ecc124 commit cd4048f
Show file tree
Hide file tree
Showing 40 changed files with 535 additions and 442 deletions.
2 changes: 1 addition & 1 deletion web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 12,
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['@typescript-eslint', 'prettier'],
Expand Down
19 changes: 7 additions & 12 deletions web/client/api/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ export const updateApp = (data: CreateAppParams) => {
* 应用列表
*/
export const getAppList = (data: Record<string, any>) => {
return POST<Record<string, any>, AppListResponse>(`/api/v1/app/list?page=${data.page || 1}&page_size=${data.page_size || 12}`, data);
return POST<Record<string, any>, AppListResponse>(
`/api/v1/app/list?page=${data.page || 1}&page_size=${data.page_size || 12}`,
data,
);
};
/**
* 获取创建应用agents
Expand All @@ -52,9 +55,7 @@ export const getAppStrategy = () => {
* 获取资源参数
*/
export const getResource = (data: Record<string, string>) => {
return GET<Record<string, string>, Record<string, any>[]>(
`/api/v1/app/resources/list?type=${data.type}`
);
return GET<Record<string, string>, Record<string, any>[]>(`/api/v1/app/resources/list?type=${data.type}`);
};
/**
* 创建native_app应用
Expand All @@ -80,12 +81,6 @@ export const getAppAdmins = (appCode: string) => {
/**
* 更新应用权限
*/
export const updateAppAdmins = (data: {
app_code: string;
admins: string[];
}) => {
return POST<{ app_code: string; admins: string[] }, null>(
`/api/v1/app/admins/update`,
data
);
export const updateAppAdmins = (data: { app_code: string; admins: string[] }) => {
return POST<{ app_code: string; admins: string[] }, null>(`/api/v1/app/admins/update`, data);
};
5 changes: 4 additions & 1 deletion web/client/api/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ export const cancelFeedback = (data: CancelFeedbackAddParams) => {
* 终止话题
*/
export const stopTopic = (data: StopTopicParams) => {
return POST<StopTopicParams, null>(`/api/v1/chat/topic/terminate?conv_id=${data.conv_id}&round_index=${data.round_index}`, data);
return POST<StopTopicParams, null>(
`/api/v1/chat/topic/terminate?conv_id=${data.conv_id}&round_index=${data.round_index}`,
data,
);
};
26 changes: 15 additions & 11 deletions web/client/api/evaluate/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { getUserId } from '@/utils';
import { GET, POST, DELETE } from '../index';
import type {
getDataSetsRequest,
getEvaluationsRequest,
createEvaluationsRequest,
delDataSetRequest,
delEvaluationRequest,
uploadDataSetsRequest,
createEvaluationsRequest,
downloadEvaluationRequest,
getDataSetsRequest,
getEvaluationsRequest,
getMetricsRequest,
updateDataSetRequest,
downloadEvaluationRequest,
uploadDataSetsRequest,
} from '@/types/evaluate';
import { getUserId } from '@/utils';
import { DELETE, GET, POST } from '../index';

export const getTestAuth = () => {
return GET(`/api/v1/evaluate/test_auth`);
Expand Down Expand Up @@ -100,11 +100,15 @@ export const getMetrics = (data: getMetricsRequest) => {
});
};
export const showEvaluation = (data: Partial<createEvaluationsRequest>) => {
return GET<Partial<createEvaluationsRequest>, Record<string, any>[]>(`/api/v1/evaluate/evaluation/detail/show`, data, {
headers: {
'user-id': userId,
return GET<Partial<createEvaluationsRequest>, Record<string, any>[]>(
`/api/v1/evaluate/evaluation/detail/show`,
data,
{
headers: {
'user-id': userId,
},
},
});
);
};
export const getStorageTypes = () => {
return GET<undefined, Record<string, any>>(`/api/v1/evaluate/storage/types`, undefined, {
Expand Down
34 changes: 23 additions & 11 deletions web/client/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getUserId } from '@/utils';
import { HEADER_USER_ID_KEY } from '@/utils/constants/index';
import axios, { AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';
import axios, { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios';

export type ResponseType<T = any> = {
data: T;
Expand Down Expand Up @@ -38,41 +38,53 @@ const LONG_TIME_API: string[] = [
'/personal/agent/upload',
];

ins.interceptors.request.use((request) => {
const isLongTimeApi = LONG_TIME_API.some((item) => request.url && request.url.indexOf(item) >= 0);
ins.interceptors.request.use(request => {
const isLongTimeApi = LONG_TIME_API.some(item => request.url && request.url.indexOf(item) >= 0);
if (!request.timeout) {
request.timeout = isLongTimeApi ? 60000 : 100000;
}
request.headers.set(HEADER_USER_ID_KEY, getUserId());
return request;
});

export const GET = <Params = any, Response = any, D = any>(url: string, params?: Params, config?: AxiosRequestConfig<D>) => {
export const GET = <Params = any, Response = any, D = any>(
url: string,
params?: Params,
config?: AxiosRequestConfig<D>,
) => {
return ins.get<Params, ApiResponse<Response>>(url, { params, ...config });
};

export const POST = <Data = any, Response = any, D = any>(url: string, data?: Data, config?: AxiosRequestConfig<D>) => {
return ins.post<Data, ApiResponse<Response>>(url, data, config);
};

export const PATCH = <Data = any, Response = any, D = any>(url: string, data?: Data, config?: AxiosRequestConfig<D>) => {
export const PATCH = <Data = any, Response = any, D = any>(
url: string,
data?: Data,
config?: AxiosRequestConfig<D>,
) => {
return ins.patch<Data, ApiResponse<Response>>(url, data, config);
};

export const PUT = <Data = any, Response = any, D = any>(url: string, data?: Data, config?: AxiosRequestConfig<D>) => {
return ins.put<Data, ApiResponse<Response>>(url, data, config);
};

export const DELETE = <Params = any, Response = any, D = any>(url: string, params?: Params, config?: AxiosRequestConfig<D>) => {
export const DELETE = <Params = any, Response = any, D = any>(
url: string,
params?: Params,
config?: AxiosRequestConfig<D>,
) => {
return ins.delete<Params, ApiResponse<Response>>(url, { params, ...config });
};

export * from './tools';
export * from './request';
export * from './app';
export * from './chat';
export * from './evaluate';
export * from './flow';
export * from './app';
export * from './knowledge';
export * from './user';
export * from './prompt';
export * from './evaluate';
export * from './request';
export * from './tools';
export * from './user';
18 changes: 13 additions & 5 deletions web/client/api/knowledge/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { AddYuqueProps, RecallTestChunk, RecallTestProps } from '@/types/knowledge';
import { AddYuqueProps, RecallTestChunk, RecallTestProps, SearchDocumentParams } from '@/types/knowledge';
import { GET, POST } from '../index';
import { SearchDocumentParams } from '@/types/knowledge';

/**
* 知识库编辑搜索
*/
export const searchDocumentList = (spaceName: string, data: SearchDocumentParams) => {
return POST<SearchDocumentParams, { data: string[]; total: number; page: number }>(`/knowledge/${spaceName}/document/list`, data);
return POST<SearchDocumentParams, { data: string[]; total: number; page: number }>(
`/knowledge/${spaceName}/document/list`,
data,
);
};

/**
Expand All @@ -19,8 +21,14 @@ export const addYuque = (data: AddYuqueProps) => {
/**
* 编辑知识库切片
*/
export const editChunk = (knowledgeName: string, data: { questions: string[]; doc_id: string | number; doc_name: string }) => {
return POST<{ questions: string[]; doc_id: string | number; doc_name: string }, null>(`/knowledge/${knowledgeName}/document/edit`, data);
export const editChunk = (
knowledgeName: string,
data: { questions: string[]; doc_id: string | number; doc_name: string },
) => {
return POST<{ questions: string[]; doc_id: string | number; doc_name: string }, null>(
`/knowledge/${knowledgeName}/document/edit`,
data,
);
};
/**
* 召回测试推荐问题
Expand Down
5 changes: 4 additions & 1 deletion web/client/api/prompt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export const deletePrompt = (data: OperatePromptParams) => {
* prompt列表
*/
export const getPromptList = (data: Record<string, any>) => {
return POST<Record<string, any>, PromptListResponse>(`/prompt/query_page?page=${data.page}&page_size=${data.page_size}`, data);
return POST<Record<string, any>, PromptListResponse>(
`/prompt/query_page?page=${data.page}&page_size=${data.page_size}`,
data,
);
};

/**
Expand Down
4 changes: 2 additions & 2 deletions web/genAntdCss.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { extractStyle } from '@ant-design/cssinjs';
import type Entity from '@ant-design/cssinjs/lib/Cache';
import { createHash } from 'crypto';
import fs from 'fs';
import path from 'path';
import { extractStyle } from '@ant-design/cssinjs';
import type Entity from '@ant-design/cssinjs/lib/Cache';

export type DoExtraStyleOptions = {
cache: Entity;
Expand Down
6 changes: 3 additions & 3 deletions web/locales/en/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChatEn } from "./chat";
import { CommonEn } from "./common";
import { FlowEn } from "./flow";
import { ChatEn } from './chat';
import { CommonEn } from './common';
import { FlowEn } from './flow';

const en = {
...ChatEn,
Expand Down
2 changes: 0 additions & 2 deletions web/locales/zh/flow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Select } from 'antd';

export const FlowZn = {
Upload_Data_Successfully: '文件上传成功',
Upload_Data_Failed: '文件上传失败',
Expand Down
6 changes: 3 additions & 3 deletions web/locales/zh/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommonZh } from "./common";
import { ChatZh } from "./chat";
import { FlowZn } from "./flow";
import { ChatZh } from './chat';
import { CommonZh } from './common';
import { FlowZn } from './flow';

const zh = {
...ChatZh,
Expand Down
18 changes: 9 additions & 9 deletions web/new-components/app/AppCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const AppCard: React.FC<{ data: IApp }> = ({ data }) => {
const router = useRouter();
return (
<Card
className="flex h-full flex-col bg-white rounded-lg dark:bg-[#232734] dark:text-white"
className='flex h-full flex-col bg-white rounded-lg dark:bg-[#232734] dark:text-white'
hoverable
bordered={false}
onClick={async () => {
Expand All @@ -34,24 +34,24 @@ const AppCard: React.FC<{ data: IApp }> = ({ data }) => {
}}
>
{/* title & functions */}
<div className="flex items-center justify-between">
<div className="flex items-center ">
<div className='flex items-center justify-between'>
<div className='flex items-center '>
<Image
src={'/icons/node/vis.png'}
width={44}
height={44}
alt={data.app_name}
className="w-11 h-11 rounded-full mr-4 object-contain bg-white"
className='w-11 h-11 rounded-full mr-4 object-contain bg-white'
/>
<div className="flex flex-col">
<div className='flex flex-col'>
<Tooltip title={data?.app_name}>
<span className="font-medium text-[16px] mb-1 line-clamp-1">{data?.app_name}</span>
<span className='font-medium text-[16px] mb-1 line-clamp-1'>{data?.app_name}</span>
</Tooltip>
<div>
<Tag color="default" className="text-xs">
<Tag color='default' className='text-xs'>
{languageMap[data?.language]}
</Tag>
<Tag color="default" className="text-xs">
<Tag color='default' className='text-xs'>
{data?.team_mode}
</Tag>
</div>
Expand All @@ -64,7 +64,7 @@ const AppCard: React.FC<{ data: IApp }> = ({ data }) => {
rows: 2,
tooltip: true,
}}
className="mt-4 text-sm text-gray-500 font-normal h-10"
className='mt-4 text-sm text-gray-500 font-normal h-10'
>
{data?.app_describe}
</Typography.Paragraph>
Expand Down
Loading

0 comments on commit cd4048f

Please sign in to comment.