balibabu
commited on
Commit
·
15052fd
1
Parent(s):
915c3d2
Make the app name configurable even after the project is built (#731)
Browse files### What problem does this PR solve?
Make the app name configurable even after the project is built #730
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/.umirc.ts +4 -1
- web/src/assets/logo.png +0 -0
- web/src/assets/svg/logo.svg +0 -29
- web/src/conf.json +3 -0
- web/src/hooks/logicHooks.ts +21 -1
- web/src/interfaces/database/file-manager.ts +1 -0
- web/src/layouts/components/header/index.less +1 -0
- web/src/layouts/components/header/index.tsx +4 -3
- web/src/pages/file-manager/action-cell/index.tsx +36 -29
- web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx +6 -2
- web/src/pages/file-manager/file-toolbar.tsx +23 -18
- web/src/utils/commonUtil.ts +5 -0
web/.umirc.ts
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
import { defineConfig } from 'umi';
|
|
|
2 |
import routes from './src/routes';
|
3 |
|
4 |
export default defineConfig({
|
|
|
5 |
outputPath: 'dist',
|
6 |
// alias: { '@': './src' },
|
7 |
npmClient: 'npm',
|
@@ -25,9 +27,10 @@ export default defineConfig({
|
|
25 |
},
|
26 |
},
|
27 |
devtool: 'source-map',
|
|
|
28 |
proxy: {
|
29 |
'/v1': {
|
30 |
-
target: '',
|
31 |
changeOrigin: true,
|
32 |
// pathRewrite: { '^/v1': '/v1' },
|
33 |
},
|
|
|
1 |
import { defineConfig } from 'umi';
|
2 |
+
import { appName } from './src/conf.json';
|
3 |
import routes from './src/routes';
|
4 |
|
5 |
export default defineConfig({
|
6 |
+
title: appName,
|
7 |
outputPath: 'dist',
|
8 |
// alias: { '@': './src' },
|
9 |
npmClient: 'npm',
|
|
|
27 |
},
|
28 |
},
|
29 |
devtool: 'source-map',
|
30 |
+
copy: ['src/conf.json'],
|
31 |
proxy: {
|
32 |
'/v1': {
|
33 |
+
target: 'http://123.60.95.134:9380/',
|
34 |
changeOrigin: true,
|
35 |
// pathRewrite: { '^/v1': '/v1' },
|
36 |
},
|
web/src/assets/logo.png
DELETED
Binary file (12.6 kB)
|
|
web/src/assets/svg/logo.svg
DELETED
web/src/conf.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"appName": "RAGFlow"
|
3 |
+
}
|
web/src/hooks/logicHooks.ts
CHANGED
@@ -3,7 +3,8 @@ import { Pagination } from '@/interfaces/common';
|
|
3 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
4 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
5 |
import { PaginationProps } from 'antd';
|
6 |
-
import
|
|
|
7 |
import { useTranslation } from 'react-i18next';
|
8 |
import { useDispatch } from 'umi';
|
9 |
import { useSetModalState, useTranslate } from './commonHooks';
|
@@ -113,3 +114,22 @@ export const useSetPagination = (namespace: string) => {
|
|
113 |
|
114 |
return setPagination;
|
115 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
4 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
5 |
import { PaginationProps } from 'antd';
|
6 |
+
import axios from 'axios';
|
7 |
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
8 |
import { useTranslation } from 'react-i18next';
|
9 |
import { useDispatch } from 'umi';
|
10 |
import { useSetModalState, useTranslate } from './commonHooks';
|
|
|
114 |
|
115 |
return setPagination;
|
116 |
};
|
117 |
+
|
118 |
+
export interface AppConf {
|
119 |
+
appName: string;
|
120 |
+
}
|
121 |
+
|
122 |
+
export const useFetchAppConf = () => {
|
123 |
+
const [appConf, setAppConf] = useState<AppConf>({} as AppConf);
|
124 |
+
const fetchAppConf = useCallback(async () => {
|
125 |
+
const ret = await axios.get('/conf.json');
|
126 |
+
|
127 |
+
setAppConf(ret.data);
|
128 |
+
}, []);
|
129 |
+
|
130 |
+
useEffect(() => {
|
131 |
+
fetchAppConf();
|
132 |
+
}, [fetchAppConf]);
|
133 |
+
|
134 |
+
return appConf;
|
135 |
+
};
|
web/src/interfaces/database/file-manager.ts
CHANGED
@@ -12,6 +12,7 @@ export interface IFile {
|
|
12 |
type: string;
|
13 |
update_date: string;
|
14 |
update_time: number;
|
|
|
15 |
}
|
16 |
|
17 |
export interface IFolder {
|
|
|
12 |
type: string;
|
13 |
update_date: string;
|
14 |
update_time: number;
|
15 |
+
source_type: string;
|
16 |
}
|
17 |
|
18 |
export interface IFolder {
|
web/src/layouts/components/header/index.less
CHANGED
@@ -18,6 +18,7 @@
|
|
18 |
|
19 |
.appIcon {
|
20 |
vertical-align: middle;
|
|
|
21 |
}
|
22 |
|
23 |
.appName {
|
|
|
18 |
|
19 |
.appIcon {
|
20 |
vertical-align: middle;
|
21 |
+
max-width: 36px;
|
22 |
}
|
23 |
|
24 |
.appName {
|
web/src/layouts/components/header/index.tsx
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import { ReactComponent as StarIon } from '@/assets/svg/chat-star.svg';
|
2 |
import { ReactComponent as FileIcon } from '@/assets/svg/file-management.svg';
|
3 |
import { ReactComponent as KnowledgeBaseIcon } from '@/assets/svg/knowledge-base.svg';
|
4 |
-
import { ReactComponent as Logo } from '@/assets/svg/logo.svg';
|
5 |
import { useTranslate } from '@/hooks/commonHooks';
|
6 |
import { useNavigateWithFromState } from '@/hooks/routeHook';
|
7 |
import { Layout, Radio, Space, theme } from 'antd';
|
@@ -9,6 +8,7 @@ import { useCallback, useMemo } from 'react';
|
|
9 |
import { useLocation } from 'umi';
|
10 |
import Toolbar from '../right-toolbar';
|
11 |
|
|
|
12 |
import styles from './index.less';
|
13 |
|
14 |
const { Header } = Layout;
|
@@ -20,6 +20,7 @@ const RagHeader = () => {
|
|
20 |
const navigate = useNavigateWithFromState();
|
21 |
const { pathname } = useLocation();
|
22 |
const { t } = useTranslate('header');
|
|
|
23 |
|
24 |
const tagsData = useMemo(
|
25 |
() => [
|
@@ -56,8 +57,8 @@ const RagHeader = () => {
|
|
56 |
}}
|
57 |
>
|
58 |
<Space size={12} onClick={handleLogoClick} className={styles.logoWrapper}>
|
59 |
-
<
|
60 |
-
<span className={styles.appName}>
|
61 |
</Space>
|
62 |
<Space size={[0, 8]} wrap>
|
63 |
<Radio.Group
|
|
|
1 |
import { ReactComponent as StarIon } from '@/assets/svg/chat-star.svg';
|
2 |
import { ReactComponent as FileIcon } from '@/assets/svg/file-management.svg';
|
3 |
import { ReactComponent as KnowledgeBaseIcon } from '@/assets/svg/knowledge-base.svg';
|
|
|
4 |
import { useTranslate } from '@/hooks/commonHooks';
|
5 |
import { useNavigateWithFromState } from '@/hooks/routeHook';
|
6 |
import { Layout, Radio, Space, theme } from 'antd';
|
|
|
8 |
import { useLocation } from 'umi';
|
9 |
import Toolbar from '../right-toolbar';
|
10 |
|
11 |
+
import { useFetchAppConf } from '@/hooks/logicHooks';
|
12 |
import styles from './index.less';
|
13 |
|
14 |
const { Header } = Layout;
|
|
|
20 |
const navigate = useNavigateWithFromState();
|
21 |
const { pathname } = useLocation();
|
22 |
const { t } = useTranslate('header');
|
23 |
+
const appConf = useFetchAppConf();
|
24 |
|
25 |
const tagsData = useMemo(
|
26 |
() => [
|
|
|
57 |
}}
|
58 |
>
|
59 |
<Space size={12} onClick={handleLogoClick} className={styles.logoWrapper}>
|
60 |
+
<img src="/logo.svg" alt="" className={styles.appIcon} />
|
61 |
+
<span className={styles.appName}>{appConf.appName}</span>
|
62 |
</Space>
|
63 |
<Space size={[0, 8]} wrap>
|
64 |
<Radio.Group
|
web/src/pages/file-manager/action-cell/index.tsx
CHANGED
@@ -44,6 +44,7 @@ const ActionCell = ({
|
|
44 |
setSelectedRowKeys,
|
45 |
);
|
46 |
const extension = getExtension(record.name);
|
|
|
47 |
|
48 |
const onDownloadDocument = () => {
|
49 |
downloadFile({
|
@@ -67,36 +68,42 @@ const ActionCell = ({
|
|
67 |
|
68 |
return (
|
69 |
<Space size={0}>
|
70 |
-
|
71 |
-
<
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
<
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
100 |
{record.type !== 'folder' && (
|
101 |
<Tooltip title={t('download', { keyPrefix: 'common' })}>
|
102 |
<Button
|
|
|
44 |
setSelectedRowKeys,
|
45 |
);
|
46 |
const extension = getExtension(record.name);
|
47 |
+
const isKnowledgeBase = record.source_type === 'knowledgebase';
|
48 |
|
49 |
const onDownloadDocument = () => {
|
50 |
downloadFile({
|
|
|
68 |
|
69 |
return (
|
70 |
<Space size={0}>
|
71 |
+
{isKnowledgeBase || (
|
72 |
+
<Tooltip title={t('addToKnowledge')}>
|
73 |
+
<Button
|
74 |
+
type="text"
|
75 |
+
className={styles.iconButton}
|
76 |
+
onClick={onShowConnectToKnowledgeModal}
|
77 |
+
>
|
78 |
+
<LinkOutlined size={20} />
|
79 |
+
</Button>
|
80 |
+
</Tooltip>
|
81 |
+
)}
|
82 |
|
83 |
+
{isKnowledgeBase || (
|
84 |
+
<Tooltip title={t('rename', { keyPrefix: 'common' })}>
|
85 |
+
<Button
|
86 |
+
type="text"
|
87 |
+
disabled={beingUsed}
|
88 |
+
onClick={onShowRenameModal}
|
89 |
+
className={styles.iconButton}
|
90 |
+
>
|
91 |
+
<EditOutlined size={20} />
|
92 |
+
</Button>
|
93 |
+
</Tooltip>
|
94 |
+
)}
|
95 |
+
{isKnowledgeBase || (
|
96 |
+
<Tooltip title={t('delete', { keyPrefix: 'common' })}>
|
97 |
+
<Button
|
98 |
+
type="text"
|
99 |
+
disabled={beingUsed}
|
100 |
+
onClick={handleRemoveFile}
|
101 |
+
className={styles.iconButton}
|
102 |
+
>
|
103 |
+
<DeleteOutlined size={20} />
|
104 |
+
</Button>
|
105 |
+
</Tooltip>
|
106 |
+
)}
|
107 |
{record.type !== 'folder' && (
|
108 |
<Tooltip title={t('download', { keyPrefix: 'common' })}>
|
109 |
<Button
|
web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import { useTranslate } from '@/hooks/commonHooks';
|
2 |
import { useFetchKnowledgeList } from '@/hooks/knowledgeHook';
|
3 |
import { IModalProps } from '@/interfaces/common';
|
4 |
-
import {
|
|
|
5 |
import { useEffect } from 'react';
|
6 |
|
7 |
const ConnectToKnowledgeModal = ({
|
@@ -15,7 +16,7 @@ const ConnectToKnowledgeModal = ({
|
|
15 |
const { list, fetchList } = useFetchKnowledgeList();
|
16 |
const { t } = useTranslate('fileManager');
|
17 |
|
18 |
-
const options
|
19 |
label: item.name,
|
20 |
value: item.id,
|
21 |
}));
|
@@ -46,9 +47,12 @@ const ConnectToKnowledgeModal = ({
|
|
46 |
<Select
|
47 |
mode="multiple"
|
48 |
allowClear
|
|
|
49 |
style={{ width: '100%' }}
|
50 |
placeholder={t('pleaseSelect')}
|
51 |
options={options}
|
|
|
|
|
52 |
/>
|
53 |
</Form.Item>
|
54 |
</Form>
|
|
|
1 |
import { useTranslate } from '@/hooks/commonHooks';
|
2 |
import { useFetchKnowledgeList } from '@/hooks/knowledgeHook';
|
3 |
import { IModalProps } from '@/interfaces/common';
|
4 |
+
import { filterOptionsByInput } from '@/utils/commonUtil';
|
5 |
+
import { Form, Modal, Select } from 'antd';
|
6 |
import { useEffect } from 'react';
|
7 |
|
8 |
const ConnectToKnowledgeModal = ({
|
|
|
16 |
const { list, fetchList } = useFetchKnowledgeList();
|
17 |
const { t } = useTranslate('fileManager');
|
18 |
|
19 |
+
const options = list?.map((item) => ({
|
20 |
label: item.name,
|
21 |
value: item.id,
|
22 |
}));
|
|
|
47 |
<Select
|
48 |
mode="multiple"
|
49 |
allowClear
|
50 |
+
showSearch
|
51 |
style={{ width: '100%' }}
|
52 |
placeholder={t('pleaseSelect')}
|
53 |
options={options}
|
54 |
+
optionFilterProp="children"
|
55 |
+
filterOption={filterOptionsByInput}
|
56 |
/>
|
57 |
</Form.Item>
|
58 |
</Form>
|
web/src/pages/file-manager/file-toolbar.tsx
CHANGED
@@ -46,6 +46,7 @@ const FileToolbar = ({
|
|
46 |
const { handleInputChange, searchString } = useHandleSearchChange();
|
47 |
const breadcrumbItems = useSelectBreadcrumbItems();
|
48 |
const { handleBreadcrumbClick } = useHandleBreadcrumbClick();
|
|
|
49 |
|
50 |
const itemRender: BreadcrumbProps['itemRender'] = (
|
51 |
currentRoute,
|
@@ -128,19 +129,21 @@ const FileToolbar = ({
|
|
128 |
<div className={styles.filter}>
|
129 |
<Breadcrumb items={breadcrumbItems} itemRender={itemRender} />
|
130 |
<Space>
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
<
|
139 |
-
<
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
|
|
|
|
144 |
<Input
|
145 |
placeholder={t('searchFiles')}
|
146 |
value={searchString}
|
@@ -150,11 +153,13 @@ const FileToolbar = ({
|
|
150 |
prefix={<SearchOutlined />}
|
151 |
/>
|
152 |
|
153 |
-
|
154 |
-
<
|
155 |
-
{
|
156 |
-
|
157 |
-
|
|
|
|
|
158 |
</Space>
|
159 |
</div>
|
160 |
);
|
|
|
46 |
const { handleInputChange, searchString } = useHandleSearchChange();
|
47 |
const breadcrumbItems = useSelectBreadcrumbItems();
|
48 |
const { handleBreadcrumbClick } = useHandleBreadcrumbClick();
|
49 |
+
const isKnowledgeBase = breadcrumbItems.at(-1)?.title === '.knowledgebase';
|
50 |
|
51 |
const itemRender: BreadcrumbProps['itemRender'] = (
|
52 |
currentRoute,
|
|
|
129 |
<div className={styles.filter}>
|
130 |
<Breadcrumb items={breadcrumbItems} itemRender={itemRender} />
|
131 |
<Space>
|
132 |
+
{isKnowledgeBase || (
|
133 |
+
<Dropdown
|
134 |
+
menu={{ items }}
|
135 |
+
placement="bottom"
|
136 |
+
arrow={false}
|
137 |
+
disabled={disabled}
|
138 |
+
>
|
139 |
+
<Button>
|
140 |
+
<Space>
|
141 |
+
<b> {t('bulk')}</b>
|
142 |
+
<DownOutlined />
|
143 |
+
</Space>
|
144 |
+
</Button>
|
145 |
+
</Dropdown>
|
146 |
+
)}
|
147 |
<Input
|
148 |
placeholder={t('searchFiles')}
|
149 |
value={searchString}
|
|
|
153 |
prefix={<SearchOutlined />}
|
154 |
/>
|
155 |
|
156 |
+
{isKnowledgeBase || (
|
157 |
+
<Dropdown menu={{ items: actionItems }} trigger={['click']}>
|
158 |
+
<Button type="primary" icon={<PlusOutlined />}>
|
159 |
+
{t('addFile')}
|
160 |
+
</Button>
|
161 |
+
</Dropdown>
|
162 |
+
)}
|
163 |
</Space>
|
164 |
</div>
|
165 |
);
|
web/src/utils/commonUtil.ts
CHANGED
@@ -60,3 +60,8 @@ export const sortLLmFactoryListBySpecifiedOrder = (list: IFactory[]) => {
|
|
60 |
|
61 |
return finalList;
|
62 |
};
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
return finalList;
|
62 |
};
|
63 |
+
|
64 |
+
export const filterOptionsByInput = (
|
65 |
+
input: string,
|
66 |
+
option: { label: string; value: string } | undefined,
|
67 |
+
) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase());
|