Browse Source

诗词done

master
nili 3 years ago
parent
commit
6d728529b5
  1. 78
      dist/502.219197d7.async.js
  2. 2
      dist/502.7bff7c20.chunk.css
  3. 2
      dist/542.2966846b.chunk.css
  4. 78
      dist/542.3b336652.async.js
  5. 8
      dist/asset-manifest.json
  6. 2
      dist/index.html
  7. 1
      dist/p__PoemPage.2d004d86.async.js
  8. 1
      dist/p__PoemPage.b6e205b0.async.js
  9. 2
      dist/poem/index.html
  10. 6
      dist/umi.2384d341.js
  11. 31
      src/components/AuthorSelect/index.tsx
  12. 12
      src/components/DebunceSelect/index.tsx
  13. 78
      src/pages/PoemPage/components/PoemForm.tsx
  14. 75
      src/pages/PoemPage/index.tsx
  15. 15
      src/services/luigi/author.ts
  16. 12
      src/services/luigi/poem.ts
  17. 17
      src/services/luigi/typings.d.ts

78
dist/502.219197d7.async.js

File diff suppressed because one or more lines are too long

2
dist/502.7bff7c20.chunk.css

File diff suppressed because one or more lines are too long

2
dist/542.2966846b.chunk.css

File diff suppressed because one or more lines are too long

78
dist/542.3b336652.async.js

File diff suppressed because one or more lines are too long

8
dist/asset-manifest.json

@ -1,16 +1,16 @@
{ {
"/umi.css": "/umi.3237de05.css", "/umi.css": "/umi.3237de05.css",
"/umi.js": "/umi.f116c253.js", "/umi.js": "/umi.2384d341.js",
"/t__plugin-layout__Layout.css": "/t__plugin-layout__Layout.44b8ae54.chunk.css", "/t__plugin-layout__Layout.css": "/t__plugin-layout__Layout.44b8ae54.chunk.css",
"/t__plugin-layout__Layout.js": "/t__plugin-layout__Layout.85d3f9bc.async.js", "/t__plugin-layout__Layout.js": "/t__plugin-layout__Layout.85d3f9bc.async.js",
"/p__PoemPage.js": "/p__PoemPage.2d004d86.async.js", "/p__PoemPage.js": "/p__PoemPage.b6e205b0.async.js",
"/p__404.css": "/p__404.572eeed8.chunk.css", "/p__404.css": "/p__404.572eeed8.chunk.css",
"/p__404.js": "/p__404.341bc6c9.async.js", "/p__404.js": "/p__404.341bc6c9.async.js",
"/799.f321cbac.async.js": "/799.f321cbac.async.js", "/799.f321cbac.async.js": "/799.f321cbac.async.js",
"/105.2ed7a7f1.chunk.css": "/105.2ed7a7f1.chunk.css", "/105.2ed7a7f1.chunk.css": "/105.2ed7a7f1.chunk.css",
"/105.a25c9d08.async.js": "/105.a25c9d08.async.js", "/105.a25c9d08.async.js": "/105.a25c9d08.async.js",
"/542.2966846b.chunk.css": "/542.2966846b.chunk.css", "/502.7bff7c20.chunk.css": "/502.7bff7c20.chunk.css",
"/542.3b336652.async.js": "/542.3b336652.async.js", "/502.219197d7.async.js": "/502.219197d7.async.js",
"/icons/icon-512x512.png": "/icons/icon-512x512.png", "/icons/icon-512x512.png": "/icons/icon-512x512.png",
"/favicon.ico": "/favicon.ico", "/favicon.ico": "/favicon.ico",
"/logo.svg": "/logo.svg", "/logo.svg": "/logo.svg",

2
dist/index.html

@ -249,6 +249,6 @@
</div> </div>
</div> </div>
<script src="/umi.f116c253.js"></script> <script src="/umi.2384d341.js"></script>
</body> </body>
</html> </html>

1
dist/p__PoemPage.2d004d86.async.js

@ -1 +0,0 @@
(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[816],{51975:function(q,O,n){"use strict";n.r(O),n.d(O,{default:function(){return L}});var _=n(57663),b=n(71577),v=n(3182),c=n(11849),I=n(93224),C=n(94043),p=n.n(C),R=n(4614);function P(a,r){return y.apply(this,arguments)}function y(){return y=(0,v.Z)(p().mark(function a(r,t){return p().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,R.WY)("/api/luigi/author/seek",(0,c.Z)({method:"GET",params:(0,c.Z)({},r)},t||{})));case 1:case"end":return e.stop()}},a)})),y.apply(this,arguments)}var m=n(67294),ee=n(43358),G=n(34041),te=n(20228),U=n(11382),$=n(57337),A=n(23279),F=n.n(A),h=n(85893);function B(a){var r=a.fetchOptions,t=a.debounceTimeout,u=t===void 0?800:t,e=a.initOption,i=(0,I.Z)(a,["fetchOptions","debounceTimeout","initOption"]),d=m.useState(!1),l=(0,$.Z)(d,2),f=l[0],o=l[1],s=[],g=null;if(e&&typeof e=="string"){var j=JSON.parse(e);s.push(j),g=j.value}var Y=m.useState(s),x=(0,$.Z)(Y,2),w=x[0],E=x[1],Z=m.useRef(0),M=m.useMemo(function(){var H=function(Q){Z.current+=1;var X=Z.current;E([]),o(!0),r(Q).then(function(k){X===Z.current&&(E(k),o(!1))})};return F()(H,u)},[r,u]);return(0,h.jsx)(G.Z,(0,c.Z)((0,c.Z)({showSearch:!0,labelInValue:!0,filterOption:!1,defaultValue:g,onSearch:M,notFoundContent:f?(0,h.jsx)(U.Z,{size:"small"}):null},i),{},{options:w}))}var D=B,z=function(r){return(0,h.jsx)(D,{initOption:r.value,fetchOptions:function(){var t=(0,v.Z)(p().mark(function u(e){var i,d,l;return p().wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,P({name:e});case 2:if(d=o.sent,!((i=d.data)!==null&&i!==void 0&&i.list)){o.next=5;break}return o.abrupt("return",(l=d.data.list)===null||l===void 0?void 0:l.map(function(s){var g={label:s.name,value:s.id,key:s.id};return g}));case 5:return o.abrupt("return",void 0);case 6:case"end":return o.stop()}},u)}));return function(u){return t.apply(this,arguments)}}(),onChange:function(u){r.onChange(u)},style:{width:"100%"}})},W=z;function ne(a,r){return S.apply(this,arguments)}function S(){return S=_asyncToGenerator(_regeneratorRuntime.mark(function a(r,t){return _regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",request("/api/luigi/poem/detail",_objectSpread({method:"GET",params:_objectSpread({},r)},t||{})));case 1:case"end":return e.stop()}},a)})),S.apply(this,arguments)}function N(a,r){return T.apply(this,arguments)}function T(){return T=(0,v.Z)(p().mark(function a(r,t){return p().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,R.WY)("/api/luigi/poem/list",(0,c.Z)({method:"POST",headers:{"Content-Type":"application/json"},data:r},t||{})));case 1:case"end":return e.stop()}},a)})),T.apply(this,arguments)}var V=n(49101),J=n(99542),K=[{dataIndex:"index",valueType:"indexBorder",width:48},{title:"\u6807\u9898",dataIndex:"title",ellipsis:!0,hideInSearch:!0,tip:"\u6807\u9898\u8FC7\u957F\u4F1A\u81EA\u52A8\u6536\u7F29",formItemProps:{rules:[{required:!0,message:"\u6B64\u9879\u4E3A\u5FC5\u586B\u9879"}]}},{title:"\u72B6\u6001",dataIndex:"status",valueType:"select",valueEnum:{0:{text:"\u672A\u6821\u51C6",status:"Error"},1:{text:"\u5DF2\u6821\u51C6",status:"Success"}}},{title:"\u4F5C\u8005",dataIndex:"authorName",hideInSearch:!0},{title:"\u4F5C\u8005",dataIndex:"author",hideInTable:!0,formItemProps:{rules:[{required:!0,message:"\u6B64\u9879\u4E3A\u5FC5\u586B\u9879"}]},renderFormItem:function(r,t){var u=t.type,e=t.defaultRender,i=(0,I.Z)(t,["type","defaultRender"]);return(0,h.jsx)(W,(0,c.Z)({},i))}},{title:"\u9996\u884C",dataIndex:"line",hideInSearch:!0}],L=function(){var a=(0,m.useRef)();return(0,h.jsx)(J.ZP,{columns:K,actionRef:a,cardBordered:!0,request:(0,v.Z)(p().mark(function r(){var t,u,e,i,d,l,f=arguments;return p().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:return e=f.length>0&&f[0]!==void 0?f[0]:{},i=[],e.author&&(d=e.author,typeof e.author=="string"&&(d=JSON.parse(e.author)),i.push({key:"authorId",val:d.value})),e.status&&i.push({key:"status",val:e.status}),s.next=6,N({current:e.current,pageSize:e.pageSize,query:i});case 6:return l=s.sent,s.abrupt("return",{data:(t=l.data)===null||t===void 0?void 0:t.list,total:(u=l.data)===null||u===void 0?void 0:u.total});case 8:case"end":return s.stop()}},r)})),editable:{type:"multiple"},columnsState:{persistenceKey:"pro-table-singe-demos",persistenceType:"localStorage",onChange:function(t){console.log("value: ",t)}},rowKey:"id",search:{labelWidth:"auto"},form:{syncToUrl:function(t,u){return u==="get"?(0,c.Z)((0,c.Z)({},t),{},{created_at:[t.startTime,t.endTime]}):t}},pagination:{pageSize:5},dateFormatter:"string",headerTitle:"\u9AD8\u7EA7\u8868\u683C",toolBarRender:function(){return[(0,h.jsx)(b.Z,{icon:(0,h.jsx)(V.Z,{}),type:"primary",children:"\u65B0\u5EFA"},"button")]}})}}}]);

1
dist/p__PoemPage.b6e205b0.async.js

File diff suppressed because one or more lines are too long

2
dist/poem/index.html

@ -249,6 +249,6 @@
</div> </div>
</div> </div>
<script src="/umi.f116c253.js"></script> <script src="/umi.2384d341.js"></script>
</body> </body>
</html> </html>

6
dist/umi.f116c253.js → dist/umi.2384d341.js

File diff suppressed because one or more lines are too long

31
src/components/AuthorSelect/index.tsx

@ -1,16 +1,35 @@
import { seekUsingGET } from '@/services/luigi/author'; import { getAuthorByIdUsingGET, seekUsingGET } from '@/services/luigi/author';
import React from 'react'; import React from 'react';
import type { ValueType } from '../DebunceSelect'; import type { ValueType } from '../DebunceSelect';
import DebounceSelect from '../DebunceSelect'; import DebounceSelect from '../DebunceSelect';
const AuthorSelect: React.FC<{ const AuthorSelect: React.FC<{
value?: string; value?: number;
onChange: (value: ValueType) => void; onChange?: (value: ValueType) => void;
}> = (props) => { }> = (props) => {
const [initOption, setInitOption] = React.useState();
React.useEffect(() => {
if (!props.value) {
return;
}
const fetch = async () => {
const response = await getAuthorByIdUsingGET({ id: props.value });
const option: ValueType = {
key: response.data?.id,
label: response.data?.name,
value: response.data?.id,
};
setInitOption(option);
};
fetch();
}, [props.value]);
if (props.value && !initOption) {
return null;
}
return ( return (
<DebounceSelect <DebounceSelect
initOption={props.value} initOption={initOption}
fetchOptions={async (query) => { fetchOptions={async (query) => {
const response = await seekUsingGET({ const response = await seekUsingGET({
name: query, name: query,
@ -23,9 +42,7 @@ const AuthorSelect: React.FC<{
} }
return undefined; return undefined;
}} }}
onChange={(newValue) => { onChange={props.onChange}
props.onChange(newValue);
}}
style={{ style={{
width: '100%', width: '100%',
}} }}

12
src/components/DebunceSelect/index.tsx

@ -7,7 +7,7 @@ export interface DebounceSelectProps<ValueType>
extends Omit<SelectProps<ValueType>, 'options' | 'children'> { extends Omit<SelectProps<ValueType>, 'options' | 'children'> {
fetchOptions: (search: string) => Promise<ValueType[] | undefined>; fetchOptions: (search: string) => Promise<ValueType[] | undefined>;
debounceTimeout?: number; debounceTimeout?: number;
initOption?: string; initOption?: ValueType;
} }
export type ValueType = { key?: number; label?: string; value?: number }; export type ValueType = { key?: number; label?: string; value?: number };
@ -19,12 +19,11 @@ function DebounceSelect({
...props ...props
}: DebounceSelectProps<ValueType>) { }: DebounceSelectProps<ValueType>) {
const [fetching, setFetching] = React.useState(false); const [fetching, setFetching] = React.useState(false);
const initOptions = []; const initOptions: ValueType[] = [];
let defaultValue = null; let defaultValue = null;
if (initOption && typeof initOption == 'string') { if (initOption) {
const option = JSON.parse(initOption); initOptions.push(initOption);
initOptions.push(option); defaultValue = initOption.value;
defaultValue = option.value;
} }
const [options, setOptions] = React.useState<ValueType[]>(initOptions); const [options, setOptions] = React.useState<ValueType[]>(initOptions);
@ -52,7 +51,6 @@ function DebounceSelect({
return ( return (
<Select<ValueType> <Select<ValueType>
showSearch showSearch
labelInValue
filterOption={false} filterOption={false}
defaultValue={defaultValue} defaultValue={defaultValue}
onSearch={debounceFetcher} onSearch={debounceFetcher}

78
src/pages/PoemPage/components/PoemForm.tsx

@ -0,0 +1,78 @@
import AuthorSelect from '@/components/AuthorSelect';
import { DrawerForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form';
import { Button, Form, message } from 'antd';
import React, { useRef } from 'react';
import { poemDetailUsingGET, savePoemUsingPOST } from '@/services/luigi/poem';
import type { ProFormInstance } from '@ant-design/pro-form';
const PoemForm: React.FC<{
triggerText: string;
formTitle: string;
poemId?: number;
refresh?: () => void;
}> = (props) => {
const formRef = useRef<ProFormInstance<API.PoemBo>>();
return (
<DrawerForm<API.PoemBo>
title={props.formTitle}
formRef={formRef}
layout="horizontal"
trigger={<Button type="primary">{props.triggerText}</Button>}
autoFocusFirstInput
drawerProps={{
destroyOnClose: true,
}}
onVisibleChange={async (visible: boolean) => {
if (!visible || !props.poemId) {
return;
}
const response = await poemDetailUsingGET({ id: props.poemId });
if (response.data) {
formRef.current?.setFieldsValue(response.data);
}
}}
onFinish={async (values) => {
const rsp = await savePoemUsingPOST({ ...values, id: props.poemId });
if (rsp.code) {
message.success('提交成功');
if (props.refresh) {
props.refresh();
}
return true;
}
return false;
}}
>
<ProFormText width="md" name="title" label="标题" placeholder="请输入" />
<Form.Item style={{ width: '40%' }} label={<span></span>} name="authorId" shouldUpdate>
<AuthorSelect />
</Form.Item>
<ProFormTextArea
fieldProps={{ autoSize: true }}
width="md"
name="content"
label="内容"
placeholder="请输入"
/>
<ProFormText width="md" name="line" label="首行" placeholder="请输入" />
<ProFormTextArea
fieldProps={{ autoSize: true }}
width="md"
name="note"
label="解析"
placeholder="请输入"
/>
<ProFormTextArea
fieldProps={{ autoSize: true }}
width="md"
name="translation"
label="翻译"
placeholder="请输入"
/>
</DrawerForm>
);
};
export default PoemForm;

75
src/pages/PoemPage/index.tsx

@ -1,16 +1,18 @@
import AuthorSelect from '@/components/AuthorSelect'; import AuthorSelect from '@/components/AuthorSelect';
import { poemListUsingPOST } from '@/services/luigi/poem'; import { poemListUsingPOST } from '@/services/luigi/poem';
import { PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
import { Button } from 'antd'; import React, { useRef } from 'react';
import { useRef } from 'react';
import PoemForm from './components/PoemForm';
import type { ProColumns, ActionType } from '@ant-design/pro-table'; import type { ProColumns, ActionType } from '@ant-design/pro-table';
import { Popconfirm } from 'antd';
import { savePoemUsingPOST } from '../../services/luigi/poem';
const columns: ProColumns<API.PoemBo>[] = [ const columns: ProColumns<API.PoemBo>[] = [
{ {
dataIndex: 'index', dataIndex: 'id',
valueType: 'indexBorder', title: 'id',
width: 48, hideInSearch: true,
}, },
{ {
title: '标题', title: '标题',
@ -64,9 +66,42 @@ const columns: ProColumns<API.PoemBo>[] = [
}, },
}, },
{ {
title: '首行', title: '操作',
dataIndex: 'line', valueType: 'option',
hideInSearch: true, key: 'option',
render: (text, record, _, action) => [
<PoemForm
key={record.id}
poemId={record.id}
formTitle={record.title || '编辑'}
triggerText="编辑"
refresh={() => action?.reload()}
/>,
<Popconfirm
title="确定删除吗?"
key={record.id}
onConfirm={async () => {
await savePoemUsingPOST({ id: record.id, status: -1 });
action?.reload();
}}
okText="Yes"
cancelText="No"
>
<a href="#"></a>
</Popconfirm>,
<Popconfirm
title="确定标记吗?"
key={record.id}
onConfirm={async () => {
await savePoemUsingPOST({ id: record.id, status: record.status == 0 ? 1 : 0 });
action?.reload();
}}
okText="Yes"
cancelText="No"
>
<a href="#">{record.status == 0 ? '校准' : '取消校准'}</a>
</Popconfirm>,
],
}, },
]; ];
@ -85,7 +120,7 @@ export default () => {
if (typeof params.author == 'string') { if (typeof params.author == 'string') {
author = JSON.parse(params.author); author = JSON.parse(params.author);
} }
query.push({ key: 'authorId', val: author.value }); query.push({ key: 'authorId', val: author });
} }
if (params.status) { if (params.status) {
query.push({ key: 'status', val: params.status }); query.push({ key: 'status', val: params.status });
@ -97,20 +132,17 @@ export default () => {
}); });
return { data: response.data?.list, total: response.data?.total }; return { data: response.data?.list, total: response.data?.total };
}} }}
editable={{
type: 'multiple',
}}
columnsState={{ columnsState={{
persistenceKey: 'pro-table-singe-demos', persistenceKey: 'pro-table-singe-demos',
persistenceType: 'localStorage', persistenceType: 'localStorage',
onChange(value) {
console.log('value: ', value);
},
}} }}
rowKey="id" rowKey="id"
search={{ search={{
labelWidth: 'auto', labelWidth: 'auto',
}} }}
pagination={{
pageSize: 20,
}}
form={{ form={{
// 由于配置了 transform,提交的参与与定义的不同这里需要转化一下 // 由于配置了 transform,提交的参与与定义的不同这里需要转化一下
syncToUrl: (values, type) => { syncToUrl: (values, type) => {
@ -123,16 +155,9 @@ export default () => {
return values; return values;
}, },
}} }}
pagination={{ headerTitle="列表"
pageSize: 5,
}}
dateFormatter="string" dateFormatter="string"
headerTitle="高级表格" toolBarRender={() => [<PoemForm key="new" triggerText="新建" formTitle="创建" />]}
toolBarRender={() => [
<Button key="button" icon={<PlusOutlined />} type="primary">
</Button>,
]}
/> />
); );
}; };

15
src/services/luigi/author.ts

@ -2,6 +2,21 @@
/* eslint-disable */ /* eslint-disable */
import { request } from 'umi'; import { request } from 'umi';
/** getAuthorById GET /api/luigi/author/get */
export async function getAuthorByIdUsingGET(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.getAuthorByIdUsingGETParams,
options?: { [key: string]: any },
) {
return request<API.ResponseAuthor>('/api/luigi/author/get', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** seek GET /api/luigi/author/seek */ /** seek GET /api/luigi/author/seek */
export async function seekUsingGET( export async function seekUsingGET(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象) // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)

12
src/services/luigi/poem.ts

@ -28,3 +28,15 @@ export async function poemListUsingPOST(body: API.PoemQuery, options?: { [key: s
...(options || {}), ...(options || {}),
}); });
} }
/** savePoem POST /api/luigi/poem/save */
export async function savePoemUsingPOST(body: API.PoemBo, options?: { [key: string]: any }) {
return request<API.Responseint>('/api/luigi/poem/save', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}

17
src/services/luigi/typings.d.ts

@ -45,6 +45,12 @@ declare namespace API {
val?: string; val?: string;
}; };
type ResponseAuthor = {
code?: number;
data?: Author;
message?: string;
};
type ResponseCommonListAuthor = { type ResponseCommonListAuthor = {
code?: number; code?: number;
data?: CommonListAuthor; data?: CommonListAuthor;
@ -69,6 +75,12 @@ declare namespace API {
message?: string; message?: string;
}; };
type Responseint = {
code?: number;
data?: number;
message?: string;
};
type UserBo = { type UserBo = {
avatar?: string; avatar?: string;
id?: number; id?: number;
@ -76,6 +88,11 @@ declare namespace API {
role?: string; role?: string;
}; };
type getAuthorByIdUsingGETParams = {
/** id */
id: number;
};
type seekUsingGETParams = { type seekUsingGETParams = {
/** name */ /** name */
name: string; name: string;

Loading…
Cancel
Save