Compare commits
3 Commits
e800982c05
...
073fdd10d3
| Author | SHA1 | Date |
|---|---|---|
|
|
073fdd10d3 | |
|
|
d12360839d | |
|
|
779b62d739 |
|
|
@ -14,24 +14,24 @@ const checkers: Checker<EntityDict, 'essay', RuntimeCxt>[] = [
|
|||
$or: [{ iState: 'unpublished' }, { iState: 'withdrawn' }],
|
||||
},
|
||||
},
|
||||
// settop的时候只能是isTop为false的
|
||||
{
|
||||
entity: 'essay',
|
||||
action: 'setTop',
|
||||
type: 'row',
|
||||
filter: {
|
||||
isTop: false,
|
||||
},
|
||||
},
|
||||
// cancelTop的时候只能是isTop为true的
|
||||
{
|
||||
entity: 'essay',
|
||||
action: 'cancelTop',
|
||||
type: 'row',
|
||||
filter: {
|
||||
isTop: true,
|
||||
},
|
||||
},
|
||||
// // settop的时候只能是isTop为false的
|
||||
// {
|
||||
// entity: 'essay',
|
||||
// action: 'setTop',
|
||||
// type: 'row',
|
||||
// filter: {
|
||||
// isTop: false,
|
||||
// },
|
||||
// },
|
||||
// // cancelTop的时候只能是isTop为true的
|
||||
// {
|
||||
// entity: 'essay',
|
||||
// action: 'cancelTop',
|
||||
// type: 'row',
|
||||
// filter: {
|
||||
// isTop: true,
|
||||
// },
|
||||
// },
|
||||
// 在删除essay的时候,同步删除extraFile和essayLabels还有log
|
||||
// 注意,在checker中为非异步环境,这点与trigger不同
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,15 +1,39 @@
|
|||
*{
|
||||
font-size: 18px;
|
||||
}
|
||||
.heading{
|
||||
color:rgb(97, 218, 251);
|
||||
font-size: 25px;
|
||||
color:rgb( 22,119,255);
|
||||
text-indent: 7em;
|
||||
font-family: Microsoft YaHei;
|
||||
}
|
||||
.messageArea{
|
||||
text-indent: 2em;
|
||||
}
|
||||
.editor {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
.id {
|
||||
font-size: 18px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.left{
|
||||
flex: 1;
|
||||
margin-left: 15%;
|
||||
}
|
||||
|
||||
.right{
|
||||
margin-right: 15%;
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
font-size: 18px;
|
||||
|
||||
}
|
||||
|
||||
.list {
|
||||
margin-left: 16.5%;
|
||||
margin-right: 15%;
|
||||
margin-bottom: 5px;
|
||||
.item {
|
||||
border: 1px solid rgb(60, 134, 236);
|
||||
padding: 20px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ import useFeatures from '@project/hooks/useFeatures';
|
|||
|
||||
const { TextArea } = Input;
|
||||
|
||||
|
||||
const List = (
|
||||
props: WebComponentProps<
|
||||
EntityDict,
|
||||
|
|
@ -20,7 +19,6 @@ const List = (
|
|||
}
|
||||
>
|
||||
) => {
|
||||
|
||||
const { list } = props.data;
|
||||
const { t, addItem, execute } = props.methods;
|
||||
const features = useFeatures();
|
||||
|
|
@ -36,33 +34,56 @@ const List = (
|
|||
execute();
|
||||
//提交后清空输入框
|
||||
setNewCommentText('');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<h3 className={Styles.heading}>{t('CommentSection')}</h3>
|
||||
|
||||
<div className={Styles.editor}>
|
||||
<div className={Styles.left}>
|
||||
{/* textarea*/}
|
||||
<TextArea
|
||||
showCount
|
||||
style={{
|
||||
width: '95%',
|
||||
height: '100px',
|
||||
resize: 'none',
|
||||
margin:'30px'
|
||||
}}
|
||||
placeholder='请输入评论'
|
||||
value={newCommentText}
|
||||
onChange={(e) => setNewCommentText(e.target.value)}
|
||||
></TextArea>
|
||||
</div>
|
||||
<div className={Styles.right}>
|
||||
{/* button */}
|
||||
<Button
|
||||
style={{
|
||||
width: "80px",
|
||||
height: "100px"
|
||||
}}
|
||||
type='primary'
|
||||
size='large'
|
||||
onClick={handleSubmit}
|
||||
>
|
||||
{t('common::submit')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{list && (
|
||||
<>
|
||||
<div className={Styles.list}>
|
||||
{list.map((item) => {
|
||||
return (
|
||||
<div key={item.id} className={Styles.item}>
|
||||
{item.id}:
|
||||
<div key={item.id} className={`${Styles.item} ${Styles.messageArea}`}>
|
||||
{item.id}:{item.content}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
</div>
|
||||
)}
|
||||
{/* textarea*/}
|
||||
<TextArea
|
||||
value={newCommentText}
|
||||
onChange={(e) => setNewCommentText(e.target.value)}
|
||||
></TextArea>
|
||||
{/* button */}
|
||||
<Button onClick={handleSubmit}>{t('common::submit')}</Button>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default List;
|
||||
export default List;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default OakComponent({
|
|||
// 先按置顶排序
|
||||
sorter: {
|
||||
$attr: {
|
||||
isTop: 1,
|
||||
topState: 1,
|
||||
},
|
||||
$direction: 'desc',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ const EssayItem = (props: {
|
|||
</div>
|
||||
<div className={Styles.body}>
|
||||
<div className={Styles.title}>
|
||||
{item.isTop && (
|
||||
{item.topState === "isTop" && (
|
||||
<div className={Styles.top}>
|
||||
{t('common::top')}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -242,7 +242,9 @@ const i18ns: I18n[] = [
|
|||
language: "zh-CN",
|
||||
module: "new-demo",
|
||||
position: "src/components/frontend/home/comment/list",
|
||||
data: {}
|
||||
data: {
|
||||
"CommentSection": "评论区"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "6fd812246bb915f692124fc05bb9ffd4",
|
||||
|
|
@ -654,7 +656,7 @@ const i18ns: I18n[] = [
|
|||
"logs": "修改记录",
|
||||
"category": "分类",
|
||||
"iState": "状态",
|
||||
"isTop": "是否置顶"
|
||||
"topState": "置顶"
|
||||
},
|
||||
"action": {
|
||||
"publish": "发布",
|
||||
|
|
@ -667,6 +669,10 @@ const i18ns: I18n[] = [
|
|||
"unpublished": "未发布",
|
||||
"published": "已发布",
|
||||
"withdrawn": "已撤回"
|
||||
},
|
||||
"topState": {
|
||||
"isTop": "",
|
||||
"noTop": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
// import { TopAction } from './Essay';
|
||||
import { String, Text, Boolean } from 'oak-domain/lib/types/DataType';
|
||||
import { ActionDef, EntityDesc, EntityShape } from 'oak-domain/lib/types';
|
||||
import { Schema as User } from 'oak-general-business/lib/entities/User';
|
||||
|
|
@ -17,13 +18,18 @@ export interface Schema extends EntityShape {
|
|||
images: ExtraFile[];
|
||||
logs: Log[];
|
||||
category?: Category;
|
||||
isTop: Boolean;
|
||||
// isTop: Boolean;
|
||||
}
|
||||
|
||||
export type IState = 'unpublished' | 'published' | 'withdrawn';
|
||||
|
||||
export type IAction = 'publish' | 'withdraw';
|
||||
|
||||
//置顶状态
|
||||
export type TopState = 'isTop' | 'noTop';
|
||||
|
||||
export type TopAction = 'setTop' | 'cancelTop';
|
||||
|
||||
export const IActionDef: ActionDef<IAction, IState> = {
|
||||
stm: {
|
||||
publish: [['unpublished', 'withdrawn'], 'published'],
|
||||
|
|
@ -32,10 +38,17 @@ export const IActionDef: ActionDef<IAction, IState> = {
|
|||
is: 'unpublished',
|
||||
};
|
||||
|
||||
// 用户行为操作
|
||||
export type CommonAction = 'setTop' | 'cancelTop';
|
||||
export const TopActionDef: ActionDef<TopAction, TopState> = {
|
||||
stm: {
|
||||
setTop: ['noTop', 'isTop'],
|
||||
cancelTop: ['isTop', 'noTop'],
|
||||
},
|
||||
is: 'noTop',
|
||||
};
|
||||
|
||||
type Action = IAction | CommonAction;
|
||||
// 用户行为操作
|
||||
type Action = IAction | TopAction;
|
||||
type State = IState | TopState;
|
||||
|
||||
export const entityDesc: EntityDesc<
|
||||
Schema,
|
||||
|
|
@ -43,6 +56,7 @@ export const entityDesc: EntityDesc<
|
|||
'',
|
||||
{
|
||||
iState: IState;
|
||||
topState: TopState;
|
||||
}
|
||||
> = {
|
||||
locales: {
|
||||
|
|
@ -58,7 +72,8 @@ export const entityDesc: EntityDesc<
|
|||
logs: '修改记录',
|
||||
category: '分类',
|
||||
iState: '状态',
|
||||
isTop: '是否置顶',
|
||||
// isTop: '是否置顶',
|
||||
topState:'置顶',
|
||||
},
|
||||
action: {
|
||||
publish: '发布',
|
||||
|
|
@ -72,6 +87,10 @@ export const entityDesc: EntityDesc<
|
|||
published: '已发布',
|
||||
withdrawn: '已撤回',
|
||||
},
|
||||
topState: {
|
||||
isTop: "",
|
||||
noTop: ""
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -83,6 +102,10 @@ export const entityDesc: EntityDesc<
|
|||
published: '#87d068',
|
||||
withdrawn: '#2db7f5',
|
||||
},
|
||||
topState: {
|
||||
isTop: "#a00",
|
||||
noTop: "#0b0"
|
||||
}
|
||||
},
|
||||
},
|
||||
indexes: [
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export default OakComponent({
|
|||
// 先按置顶排序
|
||||
sorter: {
|
||||
$attr: {
|
||||
isTop: 1,
|
||||
topState: 1,
|
||||
},
|
||||
$direction: 'desc',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import Styles from './web.pc.module.less';
|
|||
import { Button, Image, Tag } from 'antd';
|
||||
import Modal from 'antd/es/modal/Modal';
|
||||
import EssayUpsert from '@project/components/console/essay/upsert';
|
||||
import { Action } from '@project/oak-app-domain/Essay/Action';
|
||||
|
||||
const EssayList = (
|
||||
props: WebComponentProps<
|
||||
|
|
@ -67,7 +68,7 @@ const EssayList = (
|
|||
render: (row) => {
|
||||
return (
|
||||
<>
|
||||
{row.isTop ? (
|
||||
{row.topState === "isTop" ? (
|
||||
<Tag color='#f50'>{t('essay.isTop')}</Tag>
|
||||
) : (
|
||||
<Tag color='#108ee9'>{t('essay.notTop')}</Tag>
|
||||
|
|
@ -209,12 +210,16 @@ const EssayList = (
|
|||
execute();
|
||||
break;
|
||||
// 置顶和取消置顶
|
||||
case 'setTop':
|
||||
case 'cancelTop':
|
||||
updateItem({}, row.id, action);
|
||||
// case 'setTop':
|
||||
// case 'cancelTop':
|
||||
// updateItem({}, row.id, action);
|
||||
// execute();
|
||||
// break;
|
||||
|
||||
default:
|
||||
updateItem({}, row.id, action as Action );
|
||||
execute();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -245,7 +250,7 @@ const EssayList = (
|
|||
/>
|
||||
</PageHeader>
|
||||
<Modal
|
||||
title={t('label:selectLabels')}
|
||||
title={t('label.selectLabels')}
|
||||
open={showSelectLabels}
|
||||
onCancel={() => setShowSelectLabels(false)}
|
||||
onOk={() => {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const triggers: Trigger<EntityDict, 'essay', BackendRuntimeContext>[] = [
|
|||
assert(data && !(data instanceof Array));
|
||||
// 若不存在meta,则初始化一个空对象
|
||||
data.meta = data.meta || {};
|
||||
data.isTop = data.isTop || false;
|
||||
// data.isTop = data.isTop || false;
|
||||
assert(data.content, 'content is required');
|
||||
if (!data.summary) {
|
||||
// 自动截取前面100个字符,加上省略号
|
||||
|
|
@ -37,7 +37,7 @@ const triggers: Trigger<EntityDict, 'essay', BackendRuntimeContext>[] = [
|
|||
fn: async ({ operation }, context, option) => {
|
||||
const { id, data } = operation;
|
||||
assert(data && !(data instanceof Array));
|
||||
data.isTop = true;
|
||||
// data.isTop = true;
|
||||
return 1;
|
||||
},
|
||||
},
|
||||
|
|
@ -50,7 +50,7 @@ const triggers: Trigger<EntityDict, 'essay', BackendRuntimeContext>[] = [
|
|||
fn: async ({ operation }, context, option) => {
|
||||
const { id, data } = operation;
|
||||
assert(data && !(data instanceof Array));
|
||||
data.isTop = false;
|
||||
// data.isTop = false;
|
||||
return 1;
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export const essayProjection: EntityDict['essay']['Selection']['data'] = {
|
|||
name: 1,
|
||||
},
|
||||
iState: 1,
|
||||
isTop: 1,
|
||||
topState: 1,
|
||||
// 相关labels
|
||||
essayLabels$essay: {
|
||||
$entity: 'essayLabels',
|
||||
|
|
|
|||
Loading…
Reference in New Issue