Skip to content

Commit

Permalink
确定项目结构
Browse files Browse the repository at this point in the history
  • Loading branch information
sgpublic committed Jun 8, 2021
1 parent 8757aaf commit f164eff
Show file tree
Hide file tree
Showing 30 changed files with 266 additions and 203 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 11 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,17 @@
# Getting Started with Create React App
# 工科助手 Web

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
工科助手网页版适用于四川工业科技学院学生,旨在为师生提供一个更好的教务交互体验,并扩展支持更多使用功能。

## Available Scripts
## 项目使用

In the project directory, you can run:
启动项目

### `npm start`
```
npm start
```

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
编译

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
```
npm run build
```
Binary file modified public/favicon.ico
Binary file not shown.
10 changes: 4 additions & 6 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<!--suppress ALL -->
<html lang="zh-hans">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="工科助手网页版"/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -24,7 +22,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>工科助手</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file modified public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "工科助手",
"name": "工科助手网页版",
"icons": [
{
"src": "favicon.ico",
Expand Down
9 changes: 5 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './res/css/index.css';
import App from './ts/pages/App';
import {BrowserRouter} from "react-router-dom";
import App from "./ts/App";

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
<BrowserRouter>
<App />
</BrowserRouter>,
document.getElementById('root')
);
43 changes: 5 additions & 38 deletions src/res/css/App.css
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
.App {
text-align: center;
}

.App-logo {
height: 40vmin;
pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}

.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#components-layout-demo-side .logo {
height: 32px;
margin: 16px;
background: rgba(255, 255, 255, 0.3);
}
3 changes: 3 additions & 0 deletions src/res/css/Home.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.primary-background {
background: transparent;
}
15 changes: 15 additions & 0 deletions src/res/css/Welcome.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#welcome-logo {
width: 200px;
height: 200px;
}

#welcome-base {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -100%);
}

welcome-loading {
width: 100%;
}
16 changes: 3 additions & 13 deletions src/res/css/index.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
.primary-background {
background: #fff;
}
1 change: 0 additions & 1 deletion src/res/drawble/logo.svg

This file was deleted.

Binary file added src/res/drawble/mipmap/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/res/drawble/mipmap/ic_launcher_round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/ts/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {ReactComponentCompact} from "./core/ReactComponentCompact";
import {Route, Switch, withRouter} from "react-router-dom";
import Login from "./pages/Login";
import Welcome from "./pages/Welcome";
import Home from "./pages/Home";

class App extends ReactComponentCompact {
render() {
const location = this.props.location
return (
<Switch location={location}>
<Route exact path={"/"} component={Welcome} />
<Route exact path={"/login"} component={Login} />
<Route path={"/home"} component={Home} />
</Switch>
)
}
}

export default withRouter(App)
6 changes: 6 additions & 0 deletions src/ts/core/ReactComponentCompact.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import React from "react";
import {SharedPreferences} from "./SharedPreferences";
import {RouteComponentProps} from "react-router-dom"
import 'antd/dist/antd.css';
import {MenuTheme} from "antd";

export class ReactComponentCompact extends React.Component<RouteComponentProps, any> {
protected readonly theme = {
menu: 'light' as MenuTheme
}

protected static setup = false

protected getSharedPreference(name: string): SharedPreferences {
Expand Down
2 changes: 1 addition & 1 deletion src/ts/core/SharedPreferences.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Map, MapForEachCallback} from "./Map";
import {Map, MapForEachCallback} from "../util/Map";

export class SharedPreferences {
private readonly name: string;
Expand Down
27 changes: 27 additions & 0 deletions src/ts/data/HomeSiderData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export class HomeSiderData {
public readonly icon: string;
public readonly title: string;
public readonly key: string;
public readonly child: Array<HomeSiderChildData>;
public readonly path: string;

constructor(image: string, title: string, key: string, child: Array<HomeSiderChildData>, path: string) {
this.icon = image;
this.title = title;
this.key = key;
this.child = child;
this.path = path;
}
}

export class HomeSiderChildData {
public readonly title: string;
public readonly key: string;
public readonly path: string;

constructor(title: string, key: string, path: any) {
this.title = title;
this.key = key;
this.path = path;
}
}
26 changes: 0 additions & 26 deletions src/ts/pages/App.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions src/ts/pages/BasePage.tsx

This file was deleted.

68 changes: 68 additions & 0 deletions src/ts/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {ReactComponentCompact} from "../core/ReactComponentCompact";
import "../../res/css/Home.css"

import {withRouter} from "react-router-dom";
import {Layout, Menu} from "antd";
import {HomeSiderData} from "../data/HomeSiderData";

const { Header, Content, Footer, Sider } = Layout;
const { SubMenu } = Menu;

class Home extends ReactComponentCompact {
state = {
collapsed: false,
sider_items: new Array<HomeSiderData>(),
};

onCollapse = (collapsed: boolean) => {
console.log(collapsed);
this.setState({ collapsed });
};

render() {
return (
<Layout>
<Header className={"primary-background"}>
<div className={"logo"} />
</Header>
<Content>
<Layout style={{ minHeight: '100vh'}}>
<Sider className={"primary-background"} collapsible collapsed={this.state.collapsed}
onCollapse={this.onCollapse}>
<Menu theme={this.theme.menu} mode={"inline"}>{
this.state.sider_items.map((data) => {
if (data.child.length > 0){
return (
<SubMenu key={data.key} icon={data.icon} title={data.title}>{
data.child.map((index) => {
return (
<Menu.Item key={index.key}
onClick={() => this.props.history.replace(data.path)}>
{index.title}
</Menu.Item>
)
})
}</SubMenu>
)
} else {
return (
<Menu.Item key={data.key} icon={data.icon}
onClick={() => this.props.history.replace(data.path)}>
{data.title}
</Menu.Item>
)
}
})
}</Menu>
</Sider>
</Layout>
</Content>
<Footer>

</Footer>
</Layout>
)
}
}

export default withRouter(Home)
Loading

0 comments on commit f164eff

Please sign in to comment.