visuddhinanda 4 tahun lalu
induk
melakukan
7fa0380bda

+ 48 - 0
dashboard/src/components/demo.tsx

@@ -22,3 +22,51 @@ export const Widget2 = ({}) => {
     </div>
   );
 }
+
+type IWidgetCourseInfo ={
+  title: string,
+  course_id:number,
+  teacher_name:string,
+}
+
+export const WidgetCourseInfo = (course: IWidgetCourseInfo) => {
+  return (
+    <div>
+      课程名称
+      <Alert message={course.title} type="success" />
+      课程id:{course.course_id}<br />
+      授课教师:{course.teacher_name}<br />
+    </div>
+  );
+}
+
+type IWidgetArticle ={
+  text: string
+}
+export const WidgetCourseContent = (course: IWidgetArticle) => {
+  return (
+    <div>
+      <h2>课程内容</h2>
+      <WidgetWikiPaliArticle text={course.text} />
+    </div>
+  );
+}
+
+
+export const WidgetWikiPaliArticle = (content: IWidgetArticle) => {
+  return (
+    <div>
+      <p>wikipali article content</p>
+      {content.text}
+    </div>
+  );
+}
+
+export const WidgetWikiPaliArticleEdit = (content: IWidgetArticle) => {
+  return (
+    <div>
+      <p>wikipali article content edit</p>
+      <textarea>{content.text}</textarea>
+    </div>
+  );
+}

+ 21 - 0
dashboard/src/pages/demo/course/[id]/edit.tsx

@@ -0,0 +1,21 @@
+import {Link} from 'umi';
+import {Button} from 'antd';
+
+import {WidgetCourseInfo,WidgetWikiPaliArticleEdit} from '@/components/demo'
+
+export default ({match}) => {
+  return (
+    <div>
+      <h1>Edit item page by id {match.params.id}</h1>
+      <Link to="/demo">网站主页</Link>
+      &nbsp;
+      <Link to="/demo/day-2">课程主页</Link>
+      <h1>课程名称 {match.params.id}</h1>
+      <Button >保存</Button>
+      
+      <WidgetCourseInfo title="转法轮经" course_id={match.params.id} teacher_name="悟贡西亚多" />
+      <WidgetWikiPaliArticleEdit text="转法轮经内容 转法轮经内容 转法轮经内容 转法轮经内容"  />
+
+    </div>
+  );
+}

+ 20 - 0
dashboard/src/pages/demo/course/[id]/show.tsx

@@ -0,0 +1,20 @@
+import {Link,history} from 'umi';
+import {Button} from 'antd';
+
+import {WidgetCourseInfo,WidgetCourseContent} from '@/components/demo'
+
+export default ({match}) => {
+
+  return (
+    <div>
+      <Link to="/demo">网站主页</Link>
+      &nbsp;
+      <Link to="/demo/day-2">课程主页</Link>
+      <h1>课程名称 {match.params.id}</h1>
+      <Button onClick={()=>history.push('/demo/course/'+match.params.id+'/edit')}>编辑</Button>
+      
+      <WidgetCourseInfo title="转法轮经" course_id={match.params.id} teacher_name="悟贡西亚多" />
+      <WidgetCourseContent text="转法轮经内容 转法轮经内容 转法轮经内容 转法轮经内容"  />
+    </div>
+  )
+}

+ 14 - 0
dashboard/src/pages/demo/course/index.tsx

@@ -0,0 +1,14 @@
+import {Link} from 'umi';
+
+type IProps = {
+
+}
+
+export default ({}: IProps) => {
+  return (
+    <div>
+      <h1>List items page</h1>
+      <Link to="/demo">Go home</Link>
+    </div>
+  );
+}

+ 113 - 0
dashboard/src/pages/demo/day-1.tsx

@@ -0,0 +1,113 @@
+import {Link, history} from 'umi';
+import {Button} from 'antd';
+
+type IProps = {
+
+}
+
+export default ({}: IProps) => {
+    let helloworld: string;
+helloworld="name";
+
+interface User{
+    name: string;
+    id: number;
+}
+class UserAccount{
+    name: string;
+    id: number;
+    constructor(name:string,id:number){
+        this.name = name;
+        this.id=id;
+    }
+}
+const user: User={
+    name:"Hayes",
+    id:0,
+}
+
+const user1: User = new UserAccount("Hayes",0);
+
+console.log("user:"+user.name);
+
+function getAdminUser():User{
+    let user: User={
+        name:"admin",
+        id:0,
+    }
+    return user;
+}
+function deleteUser(user:User){
+
+}
+
+type MyBool = true | false;
+type WindowStates = "open" | "closed" | "minimized";
+type LockStates = "locked" | "unlocked";
+type PositiveOddNumberUnderTen = 1|3|5|7|9;
+
+function getLength(obj:string|string[]){
+    return obj.length;
+
+}
+
+function wrapInArray(obj:string|string[]){
+    if(typeof obj === "string"){
+        return [obj];
+    }
+    else{
+        return obj;
+    }
+}
+
+type StringArray= Array<string>;
+type NumberArray=Array<number>;
+type ObjectWithNameArray=Array<{name:string}>;
+
+interface Backpack<Type>{
+    add:(obj:Type)=>void;
+    get:()=>Type;
+}
+/*
+declare const backpack: Backpack<string>;
+backpack.add("22");
+*/
+interface Point {
+    x:number;
+    y:number;
+}
+function logPoint(p:Point){
+    console.log(`x=${p.x},y=${p.y}`);
+}
+const point = {x:2,y:3};
+logPoint(point);
+
+const point3 = {x:3,y:4,z:5};
+logPoint(point3);
+
+class VirtualPoint{
+    x:number;
+    y:number;
+    constructor(x:number,y:number){
+        this.x=x;
+        this.y=y;
+    }
+}
+const newPoint = new VirtualPoint(20,30);
+logPoint(newPoint);
+
+  return (
+    <div>
+      <h1>Demo home page</h1>
+      <div>
+        <Link to="/demo/items">List items</Link>
+        &nbsp;
+        <Link to="/demo/items/1/show">Show items 1</Link>
+        &nbsp;
+        <Link to="/demo/items/2/show">Show items 2</Link>
+        &nbsp;
+        <Button onClick={()=>history.push('/demo/items/333/edit')}>Edit items 333</Button>
+      </div>
+    </div>
+  );
+}

+ 24 - 0
dashboard/src/pages/demo/day-2.tsx

@@ -0,0 +1,24 @@
+import {Link, history} from 'umi';
+import {Button} from 'antd';
+
+type IProps = {
+
+}
+
+export default ({}: IProps) => {
+  return (
+    <div>
+      <h1>Wikipali Rebuild Day-2</h1>
+      <div>
+          <div><Link to="/demo/course">全部课程</Link></div>
+          <div>最新课程</div>
+         <ul>         
+          <li><Link to="/demo/course/1/show">课程1</Link></li>
+          <li><Link to="/demo/course/2/show">课程2</Link></li>
+          <li><Link to="/demo/course/3/show">课程3</Link></li>
+          <li><Link to="/demo/course/4/show">课程4</Link></li>
+        </ul>
+      </div>
+    </div>
+  );
+}

+ 0 - 3
dashboard/src/pages/demo/index.tsx

@@ -9,10 +9,7 @@ export default ({}: IProps) => {
   return (
     <div>
       <h1>Demo home page</h1>
-
-
       <div>
-
         <Link to="/demo/items">List items</Link>
         &nbsp;
         <Link to="/demo/items/1/show">Show items 1</Link>