Compare commits

...

2 Commits

Author SHA1 Message Date
potato cbd417fe8d 1233 2024-10-30 16:31:19 +08:00
potato ba0ae9b9ef 123123 2024-10-30 16:30:30 +08:00
16 changed files with 308 additions and 15 deletions

View File

@ -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
);
}
);
},

View File

@ -0,0 +1,5 @@
{
"enablePullDownRefresh": false,
"usingComponents": {
}
}

View File

@ -0,0 +1,13 @@
export default OakComponent({
entity: 'comment',
isList: true,
projection: {
content: 1,
},
formData({ data }) {
return {
list: data,
essayId: this.props.essayId
};
},
});

View File

@ -0,0 +1,3 @@
{
}

View File

@ -0,0 +1,7 @@
.id {
font-size: 18px;
}
.item {
font-size: 18px;
}

View File

@ -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;

View File

@ -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",
@ -328,7 +344,8 @@ const i18ns: I18n[] = [
"userManage": "用户管理",
"relationManage": "关系管理",
"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",
namespace: "domain",

22
src/entities/Comment.ts Normal file
View File

@ -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: '文章',
},
},
},
};

View File

@ -1,3 +1,4 @@
import { message } from 'antd';
import BaseConsole, { Menu } from 'oak-frontend-base/es/features/console';
import { EntityDict } from '@project/oak-app-domain';
import { groupBy } from 'oak-domain/lib/utils/lodash';
@ -38,25 +39,22 @@ const menus: IMenu[] = [
name: 'consoleHome',
icon: 'workbench',
url: '/home',
destEntity: 'userRelation',
destEntity: '',
order: 0,
actions: ['select'],
},
{
name: 'userManage',
icon: 'addpeople',
url: '/userRelation/manage',
parent: 'System',
destEntity: 'userRelation',
actions: ['select'],
destEntity: '',
},
{
name: 'relationManage',
icon: 'share',
url: '/relation/entityList',
parent: 'System',
destEntity: 'userRelation',
actions: ['select'],
destEntity: '',
},
// category
{
@ -64,16 +62,14 @@ const menus: IMenu[] = [
icon: 'stealth',
url: '/category/list',
order: 2,
destEntity: 'userRelation',
actions: ['select'],
destEntity: '',
},
{
name: 'essayManage',
icon: 'barrage',
url: '/essay/list',
order: 3,
destEntity: 'userRelation',
actions: ['select'],
destEntity: '',
},
// 标签关联
{
@ -81,9 +77,16 @@ const menus: IMenu[] = [
icon: 'accessory',
url: '/label/list',
order: 4,
destEntity: 'userRelation',
actions: ['select'],
destEntity: '',
},
//评论管理
{
name: 'commentManage',
icon: 'message',
url:'/comment/list',
destEntity: '',
order:5,
}
];
export default class Console extends BaseConsole<EntityDict, IMenu> {

View File

@ -5,5 +5,6 @@
"userManage": "用户管理",
"relationManage": "关系管理",
"consoleHome" : "控制台首页",
"labelManage": "标签管理"
"labelManage": "标签管理",
"conmmentManage":"评论管理"
}

View File

@ -0,0 +1,5 @@
{
"enablePullDownRefresh": false,
"usingComponents": {
}
}

View File

@ -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'],
});

View File

@ -0,0 +1,3 @@
{
}

View File

@ -0,0 +1,7 @@
.id {
font-size: 18px;
}
.item {
font-size: 18px;
}

View File

@ -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;

View File

@ -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>
</>
)}