Răsfoiți Sursa

add studio article

visuddhinanda 3 ani în urmă
părinte
comite
53dad8abd6

+ 5 - 0
dashboard/src/locales/zh-Hans/article/index.ts

@@ -0,0 +1,5 @@
+const items = {
+  "article.lable": "文章",
+};
+
+export default items;

+ 8 - 0
dashboard/src/locales/zh-Hans/forms.ts

@@ -4,6 +4,14 @@ const items = {
   "forms.fields.id.label": "ID",
   "forms.fields.message.label": "消息",
   "forms.fields.created-at.label": "创建时间",
+  "forms.fields.update-at.label": "创建时间",
+  "forms.fields.lang.label": "语言",
+  "forms.create.message.no.lang": "请选择一种语言",
+  "forms.fields.title.label": "标题",
+  "forms.create.message.no.title": "请输入标题",
+  "forms.fields.subtitle.label": "副标题",
+  "forms.fields.summary.label": "简介",
+  "forms.fields.content.label": "内容",
 };
 
 export default items;

+ 71 - 13
dashboard/src/pages/studio/article/edit.tsx

@@ -1,28 +1,86 @@
 import { useParams } from "react-router-dom";
 import { useIntl } from "react-intl";
 import { Layout } from "antd";
-
+import { ProForm, ProFormText, ProFormSelect, ProFormTextArea } from "@ant-design/pro-components";
+import { message } from "antd";
 import HeadBar from "../../../components/studio/HeadBar";
 import LeftSider from "../../../components/studio/LeftSider";
 import Footer from "../../../components/studio/Footer";
-const {  Content } = Layout;
+const { Content } = Layout;
+
+interface IFormData {
+	title: string;
+	subtitle: string;
+	summary: string;
+	lang: string;
+	studio: string;
+	content: string;
+}
 
 const Widget = () => {
 	const intl = useIntl();
-	const { studioname,articleid } = useParams();//url 参数
-  return (
-	<Layout>
-		<HeadBar/>
+	const { studioname, articleid } = useParams();//url 参数
+	return (
 		<Layout>
-			<LeftSider selectedKeys="article"/>
-			<Content>
-			<h2>studio/{studioname}/{intl.formatMessage({ id: "columns.studio.article.title" })}/edit/{articleid}</h2>
-			</Content>
+			<HeadBar />
+			<Layout>
+				<LeftSider selectedKeys="article" />
+				<Content>
+					<h2>studio/{studioname}/{intl.formatMessage({ id: "columns.studio.article.title" })}/edit/{articleid}</h2>
+
+					<ProForm<IFormData>
+						onFinish={async (values: IFormData) => {
+							// TODO
+							values.studio = "aaaa";
+							console.log(values);
+							message.success(intl.formatMessage({ id: "flashes.success" }));
+						}}
+					>
+						<ProForm.Group>
+							<ProFormText
+								width="md"
+								name="title"
+								required
+								label={intl.formatMessage({ id: "forms.fields.title.label" })}
+								rules={[{ required: true, message: intl.formatMessage({ id: "forms.create.message.no.title" }) }]}
+							/>
+						</ProForm.Group>
+						<ProForm.Group>
+							<ProFormText
+								width="md"
+								name="subtitle"
+								label={intl.formatMessage({ id: "forms.fields.subtitle.label" })}
+							/>
+						</ProForm.Group>
+						<ProForm.Group>
+							<ProFormTextArea name="summary" label={intl.formatMessage({ id: "forms.fields.summary.label" })} />
+						</ProForm.Group>
+						<ProForm.Group>
+							<ProFormSelect
+								options={[
+									{ value: 'zh-Hans', label: "简体中文", },
+									{ value: 'zh-Hant', label: "繁体中文", },
+									{ value: 'en-US', label: "English", },
+								]}
+								width="md"
+								name="lang"
+								rules={[{ required: true, message: intl.formatMessage({ id: "forms.create.message.no.lang" }) }]}
+								label={intl.formatMessage({ id: "channel.lang" })}
+							/>
+						</ProForm.Group>
+
+						<ProForm.Group>
+							<ProFormTextArea name="content" label={intl.formatMessage({ id: "forms.fields.content.label" })} />
+						</ProForm.Group>
+
+					</ProForm>
+
+				</Content>
+			</Layout>
+			<Footer />
 		</Layout>
-		<Footer/>
-	</Layout>
 
-  );
+	);
 };
 
 export default Widget;

+ 141 - 8
dashboard/src/pages/studio/article/index.tsx

@@ -1,27 +1,160 @@
 import { useParams ,Link} from "react-router-dom";
 import { useIntl } from "react-intl";
-import { Space,Layout } from "antd";
+import { useState } from 'react';
+
+import { Space,Layout,Breadcrumb,Button,Tag } from "antd";
+import { ProList } from '@ant-design/pro-components';
+import {
+	CheckCircleOutlined,
+  } from '@ant-design/icons';
+
 import HeadBar from "../../../components/studio/HeadBar";
 import LeftSider from "../../../components/studio/LeftSider";
 import Footer from "../../../components/studio/Footer";
 const {  Content } = Layout;
 
+const defaultData = [
+	{
+	  id: '1',
+	  title:'Nissaya Book List',
+	  name: 'Nissaya Book List',
+	  tag:[{title:"公开",color:"success",icon:<CheckCircleOutlined />}],
+	  description: '文章概要',
+	},
+	{
+	  id: '2',
+	  title:"初级巴利语入门",
+	  name: '初级巴利语入门',
+	  tag:[{title:"公开",color:"success",icon:<CheckCircleOutlined />}],
+		description: '文章概要',
+	},
+	{
+	  id: '3',
+	  title: '何人有资格接受卡提那衣',
+	  name: '何人有资格接受卡提那衣',
+	  tag:[{title:"公开",color:"success",icon:<CheckCircleOutlined />}],
+		description: '文章概要',
+	},
+	{
+	  id: '4',
+	  title: 'Adhiṭṭhana 定名/决意',
+	  name: 'Adhiṭṭhana 定名/决意',
+	  tag:[{title:"公开",color:"success",icon:<CheckCircleOutlined />}],
+		description: '文章概要',
+	},
+  ];
+  type DataItem = typeof defaultData[number];
+
 const Widget = () => {
 	const intl = useIntl();//i18n
 	const { studioname } = useParams();//url 参数
-	const linkEdit = `/studio/${studioname}/article/edit/12345`;
+	const [dataSource, setDataSource] = useState<DataItem[]>(defaultData);
+
+	const linkRead = `/article/show/12345`;
+	const linkStudio = `/studio/${studioname}`;
   return (
 	<Layout>
 		<HeadBar/>
 		<Layout>
 			<LeftSider selectedKeys="article"/>
 			<Content>
-			<h2>studio/{studioname}/{intl.formatMessage({ id: "columns.studio.article.title" })}/文章列表</h2>
-			<div>
-				<Space>
-					<Link to={linkEdit}> article edit </Link>
-				</Space>
-			</div>
+			<Breadcrumb>
+					<Breadcrumb.Item>
+						<Link to={linkStudio}>{intl.formatMessage({ id: "columns.studio.title" })}</Link>
+					</Breadcrumb.Item>
+					<Breadcrumb.Item>
+						{intl.formatMessage({ id: "columns.studio.collaboration.title" })}
+					</Breadcrumb.Item>
+					<Breadcrumb.Item >
+						{intl.formatMessage({ id: "columns.studio.article.title" })}
+					</Breadcrumb.Item>
+				</Breadcrumb>
+				<Layout>
+					<ProList<DataItem>
+					rowKey="id"
+					headerTitle="文章"
+					dataSource={dataSource}
+					showActions="hover"
+					editable={{
+						onSave: async (key, record, originRow) => {
+						console.log(key, record, originRow);
+						return true;
+						},
+					}}
+					onDataSourceChange={setDataSource}
+					metas={{
+						title: {
+						dataIndex: 'name',
+						render: (text, row, index, action) => {
+							const linkEdit = `/studio/${studioname}/article/edit/${row.id}`;
+
+							return (
+								<Link to ={linkEdit}>{row.name}</Link>
+							);
+						},
+						},
+						description: {
+						  dataIndex: 'description',
+						  search:false,
+						},
+						content: {
+							dataIndex: 'content',
+							editable: false,
+							search:false,
+						},
+						subTitle: {
+							search:false,
+						render: (text, row, index, action) => {
+							const showtag = row.tag.map((item,key) => {
+								return <Tag color={item.color} icon={item.icon}>{item.title}</Tag>
+							});
+							return (
+							<Space size={0}>
+								{showtag}
+							</Space>
+							);
+						},
+						},
+						actions: {
+						render: (text, row, index, action) => {
+							const linkEdit = `/studio/${studioname}/article/edit/${row.id}`;
+
+							return (
+								[
+									<Link to = {linkEdit}>编辑</Link>,
+									<Link to = {linkRead}>阅读</Link>,
+									<Button
+									onClick={() => {
+										
+									}}
+									key="link" danger
+									>
+									删除
+									</Button>,
+									<Button
+									onClick={() => {
+										
+									}}
+									key="link"
+									>
+									分享
+									</Button>,
+								]
+							);
+						},
+						},
+						
+					}}
+					search={{
+						filterType: 'light',
+					  }}
+					  bordered
+					  pagination={{
+						  showQuickJumper: true,
+						  showSizeChanger: true,
+					  }}
+					/>
+				</Layout>
 			</Content>
 		</Layout>
 		<Footer/>

+ 17 - 11
dashboard/src/pages/studio/group/edit.tsx

@@ -1,11 +1,15 @@
 import { useParams } from "react-router-dom";
 import { ProForm, ProFormText , ProFormSelect,ProFormTextArea } from "@ant-design/pro-components";
 import { useIntl } from "react-intl";
-import { message } from "antd";
+import { message,Layout } from "antd";
+
 import HeadBar from "../../../components/studio/HeadBar";
 import LeftSider from "../../../components/studio/LeftSider";
 import Footer from "../../../components/studio/Footer";
 
+const {  Content } = Layout;
+
+
 interface IFormData {
 	name: string;
 	type: string;
@@ -17,13 +21,13 @@ const Widget = () => {
 	const intl = useIntl();
 	const { studioname,groupid } = useParams();//url 参数
   return (
-    <div>
-		<HeadBar/>
-		<LeftSider/>
-      <h2>studio/{studioname}/{intl.formatMessage({ id: "columns.studio.group.title" })}/edit/{groupid}</h2>
-      <div>
-		
-		<div>
+	<Layout>
+	<HeadBar/>
+	<Layout>
+		<LeftSider selectedKeys="userdict"/>
+		<Content>
+           <h2>studio/{studioname}/{intl.formatMessage({ id: "columns.studio.group.title" })}/edit/{groupid}</h2>
+
 		<ProForm<IFormData>
 		onFinish={async (values: IFormData) => {
 			// TODO
@@ -73,10 +77,12 @@ const Widget = () => {
 		</ProForm.Group>
 
 		</ProForm>
-		</div>
-      </div>
+		
+		</Content>
+	</Layout>
+
       <Footer/>
-    </div>
+    </Layout>
   );
 };