Compare commits
2 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
cbd417fe8d | |
|
|
ba0ae9b9ef |
|
|
@ -88,6 +88,21 @@ const checkers: Checker<EntityDict, 'essay', RuntimeCxt>[] = [
|
||||||
},
|
},
|
||||||
option
|
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": "创建分类"
|
"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",
|
id: "4813a0a3acdfac90d3b3b3cfa37de82c",
|
||||||
namespace: "new-demo-p-console-essay-list",
|
namespace: "new-demo-p-console-essay-list",
|
||||||
|
|
@ -211,6 +219,14 @@ const i18ns: I18n[] = [
|
||||||
position: "src/components/console/switch",
|
position: "src/components/console/switch",
|
||||||
data: {}
|
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",
|
id: "e39f6f508caae16141519422f5b9377c",
|
||||||
namespace: "new-demo-c-frontend-home-categories",
|
namespace: "new-demo-c-frontend-home-categories",
|
||||||
|
|
@ -328,7 +344,8 @@ const i18ns: I18n[] = [
|
||||||
"userManage": "用户管理",
|
"userManage": "用户管理",
|
||||||
"relationManage": "关系管理",
|
"relationManage": "关系管理",
|
||||||
"consoleHome": "控制台首页",
|
"consoleHome": "控制台首页",
|
||||||
"labelManage": "标签管理"
|
"labelManage": "标签管理",
|
||||||
|
"conmmentManage": "评论管理"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -549,6 +566,21 @@ const i18ns: I18n[] = [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: "f70261a2fc23af2a9f459353e5ac1ea3",
|
||||||
|
namespace: "comment",
|
||||||
|
language: "zh-CN",
|
||||||
|
module: "",
|
||||||
|
position: "oak-app-domain/Comment",
|
||||||
|
data: {
|
||||||
|
"name": "评论",
|
||||||
|
"attr": {
|
||||||
|
"creator": "创建者",
|
||||||
|
"content": "内容",
|
||||||
|
"essay": "文章"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: "b06ea1d96db9f0a2d2f3ff3ad966c9c5",
|
id: "b06ea1d96db9f0a2d2f3ff3ad966c9c5",
|
||||||
namespace: "domain",
|
namespace: "domain",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { Schema as Essay } from './Essay';
|
||||||
|
import { EntityDesc, EntityShape } from 'oak-domain/lib/types';
|
||||||
|
import { String } from 'oak-domain/lib/types/DataType';
|
||||||
|
import { Schema as User } from 'oak-general-business/lib/entities/User';
|
||||||
|
//Comment.ToDoIdSubQuery
|
||||||
|
export interface Schema extends EntityShape {
|
||||||
|
creator: User;
|
||||||
|
content: String<1024>;
|
||||||
|
essay: Essay;
|
||||||
|
}
|
||||||
|
export const entityDesc: EntityDesc<Schema> = {
|
||||||
|
locales: {
|
||||||
|
zh_CN: {
|
||||||
|
name: '评论',
|
||||||
|
attr: {
|
||||||
|
creator: '创建者',
|
||||||
|
content: '内容',
|
||||||
|
essay: '文章',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { message } from 'antd';
|
||||||
import BaseConsole, { Menu } from 'oak-frontend-base/es/features/console';
|
import BaseConsole, { Menu } from 'oak-frontend-base/es/features/console';
|
||||||
import { EntityDict } from '@project/oak-app-domain';
|
import { EntityDict } from '@project/oak-app-domain';
|
||||||
import { groupBy } from 'oak-domain/lib/utils/lodash';
|
import { groupBy } from 'oak-domain/lib/utils/lodash';
|
||||||
|
|
@ -38,25 +39,22 @@ const menus: IMenu[] = [
|
||||||
name: 'consoleHome',
|
name: 'consoleHome',
|
||||||
icon: 'workbench',
|
icon: 'workbench',
|
||||||
url: '/home',
|
url: '/home',
|
||||||
destEntity: 'userRelation',
|
destEntity: '',
|
||||||
order: 0,
|
order: 0,
|
||||||
actions: ['select'],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'userManage',
|
name: 'userManage',
|
||||||
icon: 'addpeople',
|
icon: 'addpeople',
|
||||||
url: '/userRelation/manage',
|
url: '/userRelation/manage',
|
||||||
parent: 'System',
|
parent: 'System',
|
||||||
destEntity: 'userRelation',
|
destEntity: '',
|
||||||
actions: ['select'],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'relationManage',
|
name: 'relationManage',
|
||||||
icon: 'share',
|
icon: 'share',
|
||||||
url: '/relation/entityList',
|
url: '/relation/entityList',
|
||||||
parent: 'System',
|
parent: 'System',
|
||||||
destEntity: 'userRelation',
|
destEntity: '',
|
||||||
actions: ['select'],
|
|
||||||
},
|
},
|
||||||
// category
|
// category
|
||||||
{
|
{
|
||||||
|
|
@ -64,16 +62,14 @@ const menus: IMenu[] = [
|
||||||
icon: 'stealth',
|
icon: 'stealth',
|
||||||
url: '/category/list',
|
url: '/category/list',
|
||||||
order: 2,
|
order: 2,
|
||||||
destEntity: 'userRelation',
|
destEntity: '',
|
||||||
actions: ['select'],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'essayManage',
|
name: 'essayManage',
|
||||||
icon: 'barrage',
|
icon: 'barrage',
|
||||||
url: '/essay/list',
|
url: '/essay/list',
|
||||||
order: 3,
|
order: 3,
|
||||||
destEntity: 'userRelation',
|
destEntity: '',
|
||||||
actions: ['select'],
|
|
||||||
},
|
},
|
||||||
// 标签关联
|
// 标签关联
|
||||||
{
|
{
|
||||||
|
|
@ -81,9 +77,16 @@ const menus: IMenu[] = [
|
||||||
icon: 'accessory',
|
icon: 'accessory',
|
||||||
url: '/label/list',
|
url: '/label/list',
|
||||||
order: 4,
|
order: 4,
|
||||||
destEntity: 'userRelation',
|
destEntity: '',
|
||||||
actions: ['select'],
|
|
||||||
},
|
},
|
||||||
|
//评论管理
|
||||||
|
{
|
||||||
|
name: 'commentManage',
|
||||||
|
icon: 'message',
|
||||||
|
url:'/comment/list',
|
||||||
|
destEntity: '',
|
||||||
|
order:5,
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
export default class Console extends BaseConsole<EntityDict, IMenu> {
|
export default class Console extends BaseConsole<EntityDict, IMenu> {
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,6 @@
|
||||||
"userManage": "用户管理",
|
"userManage": "用户管理",
|
||||||
"relationManage": "关系管理",
|
"relationManage": "关系管理",
|
||||||
"consoleHome" : "控制台首页",
|
"consoleHome" : "控制台首页",
|
||||||
"labelManage": "标签管理"
|
"labelManage": "标签管理",
|
||||||
|
"conmmentManage":"评论管理"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 FrontendFooter from '@project/components/frontend/home/FrontendFooter';
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
import { VerticalAlignTopOutlined } from '@ant-design/icons';
|
import { VerticalAlignTopOutlined } from '@ant-design/icons';
|
||||||
|
import List from '@project/components/frontend/comment/list';
|
||||||
const EssayDetails = (
|
const EssayDetails = (
|
||||||
props: WebComponentProps<
|
props: WebComponentProps<
|
||||||
EntityDict,
|
EntityDict,
|
||||||
|
|
@ -18,6 +18,8 @@ const EssayDetails = (
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
) => {
|
) => {
|
||||||
|
const { oakFullpath } = props.data;
|
||||||
|
|
||||||
const { item, cover } = props.data;
|
const { item, cover } = props.data;
|
||||||
const [showScrollTop, setShowScrollTop] = useState(false);
|
const [showScrollTop, setShowScrollTop] = useState(false);
|
||||||
|
|
||||||
|
|
@ -77,6 +79,10 @@ const EssayDetails = (
|
||||||
</div>
|
</div>
|
||||||
<MdViewer md={item.content!} />
|
<MdViewer md={item.content!} />
|
||||||
</div>
|
</div>
|
||||||
|
<List
|
||||||
|
oakPath={`${oakFullpath}.comment$essay`}
|
||||||
|
essayId={item.id}
|
||||||
|
></List>
|
||||||
<div className={Styles.blank}></div>
|
<div className={Styles.blank}></div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue