1233
This commit is contained in:
parent
ba0ae9b9ef
commit
cbd417fe8d
|
|
@ -88,6 +88,21 @@ const checkers: Checker<EntityDict, 'essay', RuntimeCxt>[] = [
|
|||
},
|
||||
option
|
||||
);
|
||||
},
|
||||
() => {
|
||||
//删除相关的comment
|
||||
return context.operate(
|
||||
'comment',
|
||||
{
|
||||
action: 'remove',
|
||||
id: generateNewId(),
|
||||
data: {},
|
||||
filter: {
|
||||
essay: filter,
|
||||
},
|
||||
},
|
||||
option
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"enablePullDownRefresh": false,
|
||||
"usingComponents": {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
export default OakComponent({
|
||||
entity: 'comment',
|
||||
isList: true,
|
||||
projection: {
|
||||
content: 1,
|
||||
},
|
||||
formData({ data }) {
|
||||
return {
|
||||
list: data,
|
||||
essayId: this.props.essayId
|
||||
};
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
.id {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.item {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
import React from 'react';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
|
||||
import Styles from './styles.module.less';
|
||||
import { Input } from 'antd';
|
||||
import { Button } from 'antd';
|
||||
import { Content } from 'antd/es/layout/layout';
|
||||
import useFeatures from '@project/hooks/useFeatures';
|
||||
const { TextArea } = Input;
|
||||
const List = (
|
||||
props: WebComponentProps<
|
||||
EntityDict,
|
||||
'comment',
|
||||
true,
|
||||
{
|
||||
list: RowWithActions<EntityDict, 'comment'>[];
|
||||
essayId: string;
|
||||
}
|
||||
>
|
||||
) => {
|
||||
const { list } = props.data;
|
||||
const features = useFeatures();
|
||||
const { t,execute,addItem} = props.methods;
|
||||
|
||||
const [newCommentText, setNewCommentText] = React.useState('');
|
||||
|
||||
const handleSumit = () => {
|
||||
addItem({
|
||||
content: newCommentText,
|
||||
creatorId: features.token.getUserId(),
|
||||
essayId:props.data.essayId,
|
||||
});
|
||||
execute();
|
||||
//提交后清空输入框
|
||||
setNewCommentText('');
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
This is 评论区
|
||||
{list && (
|
||||
<>
|
||||
{list.map((item) => {
|
||||
return <div key={item.id} className={Styles.item}>{item.id}</div>;
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
{/* textarea */}
|
||||
<textarea
|
||||
value={newCommentText}
|
||||
onChange={(e) => setNewCommentText(e.target.value)}
|
||||
></textarea>
|
||||
{/*button */}
|
||||
<Button
|
||||
onClick={handleSumit}
|
||||
> {t('common::submit')}</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default List;
|
||||
|
|
@ -14,6 +14,14 @@ const i18ns: I18n[] = [
|
|||
"createCategory": "创建分类"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "63f061bd7f1010b396cadb4bb784734f",
|
||||
namespace: "new-demo-p-console-comment-list",
|
||||
language: "zh-CN",
|
||||
module: "new-demo",
|
||||
position: "src/pages/console/comment/list",
|
||||
data: {}
|
||||
},
|
||||
{
|
||||
id: "4813a0a3acdfac90d3b3b3cfa37de82c",
|
||||
namespace: "new-demo-p-console-essay-list",
|
||||
|
|
@ -211,6 +219,14 @@ const i18ns: I18n[] = [
|
|||
position: "src/components/console/switch",
|
||||
data: {}
|
||||
},
|
||||
{
|
||||
id: "cd2859b5ea39b8821f00ceccd2f7cc49",
|
||||
namespace: "new-demo-c-frontend-comment-list",
|
||||
language: "zh-CN",
|
||||
module: "new-demo",
|
||||
position: "src/components/frontend/comment/list",
|
||||
data: {}
|
||||
},
|
||||
{
|
||||
id: "e39f6f508caae16141519422f5b9377c",
|
||||
namespace: "new-demo-c-frontend-home-categories",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"enablePullDownRefresh": false,
|
||||
"usingComponents": {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
export default OakComponent({
|
||||
entity: 'comment',
|
||||
isList: true,
|
||||
projection: {
|
||||
content: 1,
|
||||
essay: {
|
||||
title: 1,
|
||||
},
|
||||
creator: {
|
||||
name: 1,
|
||||
nickname:1,
|
||||
}
|
||||
},
|
||||
formData({ data }) {
|
||||
return {
|
||||
list: data,
|
||||
};
|
||||
},
|
||||
actions:['update','remove'],
|
||||
});
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
.id {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.item {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
import React from 'react';
|
||||
import { EntityDict } from '@project/oak-app-domain';
|
||||
import { RowWithActions, WebComponentProps } from 'oak-frontend-base';
|
||||
import Styles from './styles.module.less';
|
||||
import PageHeader from 'oak-frontend-base/es/components/pageHeader2';
|
||||
import { ListPro } from '@project/components/AbstractComponents';
|
||||
import path from 'path';
|
||||
import { render } from 'nprogress';
|
||||
|
||||
const List = (
|
||||
props: WebComponentProps<
|
||||
EntityDict,
|
||||
'comment',
|
||||
true,
|
||||
{
|
||||
list: RowWithActions<EntityDict, 'comment'>[];
|
||||
}
|
||||
>
|
||||
) => {
|
||||
const { oakFullpath } = props.data;
|
||||
|
||||
const { list } = props.data;
|
||||
const { t, navigateTo, updateItem, execute, addItem, clean, removeItem } =
|
||||
props.methods;
|
||||
const [upsertId, setUpsertId] = React.useState<string | null>(null);
|
||||
const attrs = [
|
||||
{
|
||||
path: 'content',
|
||||
label: t('content'),
|
||||
render: (row: any) => {
|
||||
return row.content;
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'creator',
|
||||
label: t('creator'),
|
||||
render: (row: any) => {
|
||||
return row.creator?.name || row.creator?.nickname || '';
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'essay',
|
||||
label: t('essay'),
|
||||
render: (row :any) => {
|
||||
return row.essay?.title || '';
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const onAction = (row: any, action: string) => {
|
||||
switch (action) {
|
||||
case 'update':
|
||||
setUpsertId(row.id);
|
||||
break;
|
||||
case 'remove':
|
||||
removeItem(row.id);
|
||||
execute();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<PageHeader title={t('pageTitle')}>
|
||||
评论列表页面是我
|
||||
<ListPro
|
||||
entity='category'
|
||||
attributes={attrs}
|
||||
data={list}
|
||||
oakPath={`${oakFullpath}`}
|
||||
onAction={onAction}
|
||||
></ListPro>
|
||||
{list && (
|
||||
<>
|
||||
{list.map((item) => {
|
||||
return (
|
||||
<div key={item.id} className={Styles.item}>
|
||||
{item.id}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
</PageHeader>
|
||||
);
|
||||
};
|
||||
|
||||
export default List;
|
||||
|
|
@ -6,7 +6,7 @@ import MdViewer from '@project/components/common/byteMD/MdViewer';
|
|||
import FrontendFooter from '@project/components/frontend/home/FrontendFooter';
|
||||
import { Button } from 'antd';
|
||||
import { VerticalAlignTopOutlined } from '@ant-design/icons';
|
||||
|
||||
import List from '@project/components/frontend/comment/list';
|
||||
const EssayDetails = (
|
||||
props: WebComponentProps<
|
||||
EntityDict,
|
||||
|
|
@ -18,6 +18,8 @@ const EssayDetails = (
|
|||
}
|
||||
>
|
||||
) => {
|
||||
const { oakFullpath } = props.data;
|
||||
|
||||
const { item, cover } = props.data;
|
||||
const [showScrollTop, setShowScrollTop] = useState(false);
|
||||
|
||||
|
|
@ -77,6 +79,10 @@ const EssayDetails = (
|
|||
</div>
|
||||
<MdViewer md={item.content!} />
|
||||
</div>
|
||||
<List
|
||||
oakPath={`${oakFullpath}.comment$essay`}
|
||||
essayId={item.id}
|
||||
></List>
|
||||
<div className={Styles.blank}></div>
|
||||
</>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue