feat(react-web-next): 新增.editorconfig和.prettierrc配置文件,添加public/.gitkeep占位文件

This commit is contained in:
2025-09-23 10:32:35 +08:00
parent 10ddfd6f75
commit 408b500b6a
199 changed files with 16850 additions and 34874 deletions
@@ -0,0 +1,20 @@
import React, { useEffect, useState } from 'react';
import { Button, Modal } from 'antd';
import { searchApi } from '@/services/search';
interface Props { indexName?: string; open: boolean; onCancel: () => void }
const IndexView: React.FC<Props> = ({ indexName, open, onCancel }) => {
const [json, setJson] = useState<any>({});
useEffect(() => { (async () => { if (indexName) setJson(await searchApi.index(indexName)); })(); }, [indexName]);
return (
<Modal title="查看索引" width={800} open={open} onCancel={onCancel} footer={<Button type="primary" onClick={onCancel}>关闭</Button>}>
<pre style={{ maxHeight: 520, overflow: 'auto', background: '#fafafa', padding: 12 }}>
{JSON.stringify(json, null, 2)}
</pre>
</Modal>
);
};
export default IndexView;
@@ -0,0 +1,64 @@
import React, { useState } from 'react';
import { ModalForm, PageContainer, ProFormText, ProFormTextArea, ProTable } from '@ant-design/pro-components';
import { Space, Typography, message } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { ActionBar, GradientButton, SearchBarPlus } from '@/components/ui';
import { searchApi } from '@/services/search';
import IndexView from './components/IndexView';
const { Link } = Typography;
const IndexPage: React.FC = () => {
const [params, setParams] = useState<Record<string, any>>({});
const [open, setOpen] = useState(false);
const [indexView, setIndexView] = useState<{ open: boolean; indexName?: string }>({ open: false });
const columns: any[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '集群健康', dataIndex: 'health' },
{ title: '集群状态', dataIndex: 'status' },
{ title: '索引名', dataIndex: 'index' },
{ title: '文档数', dataIndex: 'docsCount' },
{ title: '删除文档数', dataIndex: 'docsDeleted' },
{ title: '存储大小', dataIndex: 'storeSize' },
{ title: '操作', key: 'action', render: (_: any, record: any) => (
<Space>
<Link onClick={() => setIndexView({ open: true, indexName: record.index })}>查看</Link>
<Link onClick={() => message.info('演示环境不支持此操作')}>删除</Link>
</Space>
) },
];
return (
<PageContainer header={{ title: '索引管理' }}>
<SearchBarPlus defaultCollapsed split span={12} onTenantChanged={() => { /* 租户切换后统一生效 */ }} onFinish={async (values) => setParams(values)}>
<ProFormText name="queryStr" label="查询" placeholder="支持关键字;通配需用*" />
</SearchBarPlus>
<ActionBar left={<GradientButton size="middle" key="add" type="primary" onClick={() => setOpen(true)}><PlusOutlined /> 新增</GradientButton>} />
<ProTable<any>
rowKey="index"
headerTitle="索引列表"
request={(p) => searchApi.indice({ ...p, ...params })}
columns={columns}
search={false}
pagination={false}
toolBarRender={false}
/>
<ModalForm title="创建索引" width={800} open={open} onOpenChange={setOpen} onFinish={async () => { message.info('演示环境不支持此操作'); return true; }}>
<ProFormText name="index" label="索引名" placeholder="请输入索引名" rules={[{ required: true, message: '索引名不能为空' }]} width="md" />
<ProFormText name="numberOfShards" label="分片数" placeholder="请输入分片数" rules={[{ required: true, message: '分片数不能为空' }]} width="md" />
<ProFormText name="numberOfReplicas" label="副本数" placeholder="请输入副本数" rules={[{ required: true, message: '副本数不能为空' }]} width="md" />
<ProFormText name="type" label="类型" placeholder="请输入类型" rules={[{ required: true, message: '类型不能为空' }]} width="md" />
<ProFormTextArea name="mappingsSource" label="mappings" placeholder="请输入 mappings 的 JSON 内容" rules={[{ required: true, message: 'mappings 不能为空' }]} width="xl" />
</ModalForm>
<IndexView open={indexView.open} indexName={indexView.indexName} onCancel={() => setIndexView({ open: false })} />
</PageContainer>
);
};
export default IndexPage;
@@ -0,0 +1,50 @@
import React, { useRef, useState } from 'react';
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
import type { ProColumns, ActionType } from '@ant-design/pro-components';
import { systemApi } from '@/services/system';
import { ActionBar, SearchBarPlus } from '@/components/ui';
const UserSearchPage: React.FC = () => {
const [params, setParams] = useState<Record<string, any>>({});
const actionRef = useRef<ActionType>();
const columns: ProColumns<any>[] = [
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
{ title: '用户ID', dataIndex: 'id', width: 100 },
{ title: '账号', dataIndex: 'username', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.username || '' }} /> },
{ title: '用户昵称', dataIndex: 'nickname', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.nickname || '' }} /> },
{ title: '手机号', dataIndex: 'mobile', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.mobile || '' }} /> },
{ title: '性别', dataIndex: 'sex', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.sex || '' }} /> },
{ title: '类型', dataIndex: 'type', render: (_, r) => <span dangerouslySetInnerHTML={{ __html: r.type || '' }} /> },
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime', width: 180 },
];
return (
<PageContainer header={{ title: '用户检索' }}>
<SearchBarPlus defaultCollapsed split onTenantChanged={() => actionRef.current?.reload?.()} onFinish={async (values) => {
const { searchKey, searchValue } = values as any;
let queryStr = '';
if (searchKey && searchValue) queryStr = searchKey === 'none' ? searchValue : `${searchKey}:${searchValue}`;
setParams({ ...params, queryStr });
}}>
<ProFormSelect name="searchKey" label="检索" valueEnum={{ none: '全文检索', id: 'ID', username: '账号', nickname: '用户昵称', mobile: '手机号', sex: '性别', type: '用户类型' }} />
<ProFormText name="searchValue" placeholder="请输入关键字" />
</SearchBarPlus>
<ActionBar />
<ProTable<any>
actionRef={actionRef}
rowKey="id"
headerTitle="用户检索"
request={(p) => systemApi.searchUsers({ ...p, ...params })}
columns={columns}
search={false}
pagination={{ showSizeChanger: true, showQuickJumper: true }}
/>
</PageContainer>
);
};
export default UserSearchPage;