Browse Source

第五天

visuddhinanda 4 years ago
parent
commit
dbe014a28f
4 changed files with 91 additions and 5 deletions
  1. 38 0
      app/day-5.json
  2. 15 5
      dashboard/.umirc.ts
  3. 14 0
      dashboard/src/pages/demo/day-4.tsx
  4. 24 0
      dashboard/src/pages/demo/day-5.tsx

+ 38 - 0
app/day-5.json

@@ -0,0 +1,38 @@
+[
+  {
+    "key": "1",
+    "name": "name1",
+    "age": 32,
+    "adress": "西湖南路"
+  },
+  {
+    "key": "2",
+    "name": "name2",
+    "age": 34,
+    "adress": "西湖公园"
+  },
+  {
+    "key": "3",
+    "name": "name1",
+    "age": 32,
+    "adress": "西湖南路"
+  },
+  {
+    "key": "4",
+    "name": "name2",
+    "age": 34,
+    "adress": "西湖公园"
+  },
+  {
+    "key": "5",
+    "name": "name1",
+    "age": 32,
+    "adress": "西湖南路"
+  },
+  {
+    "key": "6",
+    "name": "name2",
+    "age": 34,
+    "adress": "西湖公园"
+  }
+]

+ 15 - 5
dashboard/.umirc.ts

@@ -1,9 +1,19 @@
 import { defineConfig } from 'umi';
 
 export default defineConfig({
-  nodeModulesTransform: {
-    type: 'none',
-  },
-  base: '/my/',
-  fastRefresh: {},
+	nodeModulesTransform: {
+		type: 'none',
+	},
+	base: '/my/',
+	fastRefresh: {},
+	routes: [
+		{ exact: true, path: "/", component: 'index' },
+		{ exact: true, path: "/items", component: 'items' },
+		{ exact: true, path: "/course", component: 'course' },
+	],
+	layout: {
+		name: 'wikipali',
+		locale: true,
+		layout: 'side',
+	}
 });

+ 14 - 0
dashboard/src/pages/demo/day-4.tsx

@@ -5,6 +5,7 @@ import { Footer } from "antd/lib/layout/layout";
 import { useState } from 'react';
 import { WidgetCommitNofifiction } from '@/components/demo'
 
+
 const { SubMenu } = Menu;
 const { Header, Content, Sider } = Layout;
 const { Link } = Anchor;
@@ -97,6 +98,19 @@ export default () => {
 	const [commitTime, setcommitTime] = useState(0);
 	const [commitMsg, setcommitMsg] = useState("失败");
 
+	const [tableData, setTableData] = useState();
+	/*
+		fetch('http://localhost/mint/app/day-5.json')
+			.then(function (response) {
+				console.log("ajex:", response);
+				return response.json();
+			})
+			.then(function (myJson) {
+				console.log(myJson);
+				setTableData(myJson);
+			});
+	*/
+
 	function pageChange(page: number, pagesize?: number | undefined) {
 		setcommitTime(page);
 		message.info("page:" + page);

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

@@ -0,0 +1,24 @@
+import React from 'react';
+import {
+	BasicLayoutProps,
+	Settings as LayoutSettings,
+} from '@ant-design/pro-layout';
+export const layout = ({
+	initialState,
+}: {
+	initialState: { settings?: LayoutSettings; currentUser?: API.CurrentUser };
+}): BasicLayoutProps => {
+	return {
+		rightContentRender: () => <RightContent />,
+		footerRender: () => <Footer />,
+		onPageChange: () => {
+			const { currentUser } = initialState;
+			const { location } = history;
+			if (!currentUser && location.pathname != '/user/login') {
+				history.push('/user/login');
+			}
+		},
+		menuHeaderRender: undefined,
+		...initialState?.settings,
+	};
+};