├── src ├── Login │ ├── Login.less │ └── Login.tsx ├── Register │ ├── Register.less │ └── Register.tsx ├── typings │ ├── index.d.ts │ └── custom.d.ts ├── react-app-env.d.ts ├── Order │ ├── Order.less │ ├── Total.less │ ├── Order.tsx │ └── Total.tsx ├── Book │ ├── Book.less │ └── Book.tsx ├── Message │ ├── Message.less │ └── Message.tsx ├── Home │ ├── Home.less │ └── Home.tsx ├── Common │ ├── client.ts │ └── Base.tsx ├── config.ts ├── App.test.tsx ├── index.css ├── About │ ├── Abount.less │ └── About.tsx ├── index.tsx ├── App.css ├── App.tsx ├── AuthRoute │ └── AuthRoute.tsx ├── logo.svg └── serviceWorker.ts ├── data ├── demo1.png └── demo2.png ├── public ├── favicon.ico ├── manifest.json └── index.html ├── README.md ├── tsconfig.json ├── conf └── webpack.config.js ├── package.json ├── config-overrides.js └── LICENSE /src/Login/Login.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/Register/Register.less: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /src/Order/Order.less: -------------------------------------------------------------------------------- 1 | .order{ 2 | width: 100%; 3 | height: 100%; 4 | } -------------------------------------------------------------------------------- /data/demo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilbinary/eatery/master/data/demo1.png -------------------------------------------------------------------------------- /data/demo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilbinary/eatery/master/data/demo2.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/evilbinary/eatery/master/public/favicon.ico -------------------------------------------------------------------------------- /src/Book/Book.less: -------------------------------------------------------------------------------- 1 | .book-list{ 2 | width: 100%; 3 | .am-list-extra{ 4 | overflow: initial !important; 5 | } 6 | } -------------------------------------------------------------------------------- /src/Order/Total.less: -------------------------------------------------------------------------------- 1 | .am-list-extra{ 2 | overflow: initial !important; 3 | } 4 | .order{ 5 | width: 100%; 6 | height: 100%; 7 | } -------------------------------------------------------------------------------- /src/Message/Message.less: -------------------------------------------------------------------------------- 1 | .message{ 2 | width: 100%; 3 | height: 100%; 4 | } 5 | .content{ 6 | text-align: left; 7 | line-height: 26px; 8 | } -------------------------------------------------------------------------------- /src/Home/Home.less: -------------------------------------------------------------------------------- 1 | .footer { 2 | margin: 40px 0px 16px 0px; 3 | left: auto; 4 | right: auto; 5 | width: 100%; 6 | display: block; 7 | text-align: center; 8 | } -------------------------------------------------------------------------------- /src/Common/client.ts: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | import { conf } from "../config"; 3 | 4 | export const client = axios.create({ 5 | baseURL: conf.apiUrl, 6 | timeout: 6000, 7 | headers: { 'gaga': 'evilbinary' } 8 | }); 9 | -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | 2 | export const conf = { 3 | copyright:'©Copyright 2019 中国人民银行尤溪县支行', /* ©Copyright 2019, evilbinary.org. */ 4 | apiUrl:'http://eatery.evilbinary.org/api/', 5 | // apiUrl:'http://localhost:3201' 6 | maxNumber:10, 7 | } -------------------------------------------------------------------------------- /src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from './App'; 4 | 5 | it('renders without crashing', () => { 6 | const div = document.createElement('div'); 7 | ReactDOM.render(, div); 8 | ReactDOM.unmountComponentAtNode(div); 9 | }); 10 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | } 10 | ], 11 | "start_url": ".", 12 | "display": "standalone", 13 | "theme_color": "#000000", 14 | "background_color": "#ffffff" 15 | } 16 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 5 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 6 | sans-serif; 7 | -webkit-font-smoothing: antialiased; 8 | -moz-osx-font-smoothing: grayscale; 9 | } 10 | 11 | code { 12 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 13 | monospace; 14 | } 15 | -------------------------------------------------------------------------------- /src/About/Abount.less: -------------------------------------------------------------------------------- 1 | .about{ 2 | font-size: 20px; 3 | background: white; 4 | height: 100%; 5 | padding-top: 40px; 6 | padding-bottom: 40px; 7 | padding-left: 60px; 8 | .title{ 9 | font-size: 26px; 10 | margin-bottom: 20px; 11 | text-align: center; 12 | margin-left: auto; 13 | margin-right: auto; 14 | } 15 | .item{ 16 | margin-top: 8px; 17 | margin-bottom: 8px; 18 | } 19 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # eatery 2 | 3 | eatery 食堂点餐 4 | 5 | https://github.com/evilbinary/eatery 6 | 7 | ## 演示 8 | 9 | 10 | 11 | ## 如何运行 12 | 13 | 14 | ### `npm start` 15 | 16 | 17 | ### `npm test` 18 | 19 | 20 | ## 发布 21 | 22 | ### `npm run build` 23 | 24 | ### `serve -s build ` 25 | 26 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | import { BrowserRouter } from 'react-router-dom'; 7 | 8 | ReactDOM.render( 9 | 10 | 11 | , 12 | document.getElementById('root') 13 | ); 14 | 15 | // If you want your app to work offline and load faster, you can change 16 | // unregister() to register() below. Note this comes with some pitfalls. 17 | // Learn more about service workers: https://bit.ly/CRA-PWA 18 | serviceWorker.register(); 19 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "preserve", 21 | "noImplicitAny":false 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /conf/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | 4 | module.exports = { 5 | devtool: false, 6 | mode: 'production', 7 | entry: { 8 | bundle: ['react','react-dom','react-router-dom','react-responsive'] //提取公共模块 9 | }, 10 | output: { 11 | path: path.join(__dirname, 'src/js'), 12 | filename: '[name].dll.js', 13 | library: '[name]_library' 14 | }, 15 | plugins: [ 16 | new webpack.DllPlugin({ 17 | path: path.join(__dirname, 'src/js','[name]-manifest.json'), 18 | 19 | name: '[name]_library' 20 | }) 21 | ] 22 | }; -------------------------------------------------------------------------------- /src/About/About.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Flex, WhiteSpace } from 'antd-mobile'; 3 | import './Abount.less'; 4 | 5 | export class About extends Component { 6 | render() { 7 | return ( 8 |
9 | 10 | 关于 11 | 作者: 🦆依依鸭 12 | 主页:http://evilbinary.org 13 | 邮箱:rootdebug@163.com 14 | 15 |
16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | animation: App-logo-spin infinite 20s linear; 7 | height: 40vmin; 8 | pointer-events: none; 9 | } 10 | 11 | .App-header { 12 | background-color: #282c34; 13 | min-height: 100vh; 14 | display: flex; 15 | flex-direction: column; 16 | align-items: center; 17 | justify-content: center; 18 | font-size: calc(10px + 2vmin); 19 | color: white; 20 | } 21 | 22 | .App-link { 23 | color: #61dafb; 24 | } 25 | 26 | @keyframes App-logo-spin { 27 | from { 28 | transform: rotate(0deg); 29 | } 30 | 31 | to { 32 | transform: rotate(360deg); 33 | } 34 | } 35 | 36 | .content { 37 | display: flex; 38 | height: 100%; 39 | background: white; 40 | width: 100%; 41 | } -------------------------------------------------------------------------------- /src/typings/custom.d.ts: -------------------------------------------------------------------------------- 1 | // declare module 'classnames'; 2 | 3 | // declare module 'antd-mobile-demo-data'; 4 | 5 | // declare module 'rmc-list-view'; 6 | 7 | // declare module 'rc-collapse'; 8 | 9 | // declare module 'rc-checkbox'; 10 | 11 | // declare module 'rmc-feedback'; 12 | 13 | // declare module 'rc-slider'; 14 | 15 | // declare module 'rn-topview'; 16 | 17 | // declare module 'rc-notification'; 18 | // declare module 'rmc-notification'; 19 | 20 | // declare module 'rmc-drawer'; 21 | 22 | // declare module 'rmc-dialog'; 23 | // declare module 'rmc-nuka-carousel'; 24 | // declare module 'rmc-tooltip'; 25 | // declare module 'rmc-pull-to-refresh'; 26 | // declare module 'rc-slider/lib/Range'; 27 | // declare module 'rc-slider/lib/Slider'; 28 | // declare module 'rmc-steps'; 29 | declare module 'rc-form'; 30 | 31 | // declare var process: { 32 | // env: { 33 | // NODE_ENV: string; 34 | // DISABLE_ANTD_MOBILE_UPGRADE: string; 35 | // }; 36 | // }; 37 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | 5 | import { Login } from './Login/Login'; 6 | import { Home } from './Home/Home'; 7 | 8 | import { createForm, formShape } from 'rc-form'; 9 | 10 | import { Route, Redirect, Switch } from 'react-router-dom'; 11 | import { Register } from './Register/Register'; 12 | import { AuthRoute } from './AuthRoute/AuthRoute'; 13 | import { About } from './About/About'; 14 | import { Total } from './Order/Total'; 15 | 16 | 17 | class App extends Component { 18 | render() { 19 | const LoginForm = createForm()(Login); 20 | const RegisterForm = createForm()(Register); 21 | const TotalForm=createForm()(Total); 22 | return ( 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
32 | ); 33 | } 34 | } 35 | 36 | export default App; 37 | -------------------------------------------------------------------------------- /src/AuthRoute/AuthRoute.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Route, withRouter, Redirect } from 'react-router-dom'; 3 | import { Base } from '../Common/Base'; 4 | 5 | export class AuthRoute extends Base { 6 | constructor(props) { 7 | super(props); 8 | this.state = { 9 | auth: this.getToken() ? true : false 10 | }; 11 | } 12 | 13 | componentWillMount() { 14 | if (!this.state.auth) { 15 | const { history } = this.props; 16 | // setTimeout(() => { 17 | // history.replace('/login'); 18 | // }, 1000); 19 | } 20 | } 21 | 22 | componentDidMount() { 23 | // authPromise().then(result => { 24 | // if (result == true) { 25 | // this.setState({ auth: true}); 26 | // } else { 27 | // this.setState({ auth: false}); 28 | // } 29 | // }); 30 | } 31 | 32 | render() { 33 | let { component: Component, ...rest } = this.props; 34 | return this.state.auth ? ( 35 | // } /> 36 | 37 | ) : ( 38 | 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "eatery", 3 | "version": "0.1.0", 4 | "homepage": ".", 5 | "private": true, 6 | "dependencies": { 7 | "@types/jest": "24.0.11", 8 | "@types/node": "11.11.6", 9 | "@types/react": "16.8.8", 10 | "@types/react-dom": "16.8.3", 11 | "antd-mobile": "^2.2.11", 12 | "axios": "^0.21.2", 13 | "moment": "^2.24.0", 14 | "rc-form": "^2.4.3", 15 | "react": "^16.8.5", 16 | "react-dom": "^16.8.5", 17 | "react-router-dom": "^5.0.0", 18 | "react-scripts": "2.1.8", 19 | "typescript": "3.3.4000" 20 | }, 21 | "scripts": { 22 | "start1": "react-scripts start", 23 | "build1": "react-scripts build", 24 | "test1": "react-scripts test", 25 | "start": "react-app-rewired start", 26 | "build": "react-app-rewired build", 27 | "test": "react-app-rewired test --env=jsdom", 28 | "eject": "react-scripts eject" 29 | }, 30 | "eslintConfig": { 31 | "extends": "react-app" 32 | }, 33 | "browserslist": [ 34 | ">0.2%", 35 | "not dead", 36 | "not ie <= 11", 37 | "not op_mini all" 38 | ], 39 | "devDependencies": { 40 | "babel-plugin-import": "^1.11.0", 41 | "customize-cra": "^0.2.12", 42 | "less": "^3.9.0", 43 | "less-loader": "^4.1.0", 44 | "react-app-rewired": "^2.1.1" 45 | }, 46 | "typings": "lib/index.d.ts" 47 | } 48 | -------------------------------------------------------------------------------- /src/Common/Base.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { client } from './client'; 3 | import { AxiosResponse } from 'axios'; 4 | import { conf } from '../config'; 5 | 6 | export class Base extends Component { 7 | client = client; 8 | tokenSymbol = 'authorization'; 9 | 10 | constructor(props) { 11 | super(props); 12 | client.interceptors.request.use( 13 | config => { 14 | if ( 15 | config.baseURL === conf.apiUrl && 16 | !config.headers[this.tokenSymbol] 17 | ) { 18 | const token = this.getToken(); 19 | // console.log('getToken ', token); 20 | config.headers[this.tokenSymbol] = token; 21 | } 22 | return config; 23 | }, 24 | error => Promise.reject(error) 25 | ); 26 | } 27 | 28 | getToken() { 29 | const token = localStorage.getItem('token'); 30 | if (token) return token; 31 | return ''; 32 | } 33 | setToken(token) { 34 | if (token) { 35 | localStorage.setItem('token', token); 36 | } 37 | } 38 | saveToken(res: AxiosResponse) { 39 | this.setToken(res.headers[this.tokenSymbol]); 40 | } 41 | verifyToken(token){ 42 | 43 | } 44 | redirect(url, param?) { 45 | this.props.history.replace({ pathname: url, ...param }); 46 | } 47 | navigate(url, param?) { 48 | this.props.history.push(url, param); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /config-overrides.js: -------------------------------------------------------------------------------- 1 | const { 2 | override, 3 | fixBabelImports, 4 | addLessLoader, 5 | } = require("customize-cra"); 6 | const { 7 | paths 8 | } = require('react-app-rewired'); 9 | 10 | let overideConfig = override( 11 | fixBabelImports("babel-plugin-import", { 12 | libraryName: "antd-mobile", 13 | style: true 14 | }), 15 | addLessLoader({ 16 | // ident: 'postcss' 17 | javascriptEnabled: true 18 | }) 19 | ); 20 | const webpackConfig = require(paths.scriptVersion + '/config/webpack.config'); 21 | const overrides = require('react-app-rewired/config-overrides'); 22 | // module.exports = overrides.webpack(config, process.env.NODE_ENV); 23 | 24 | // console.log(' overrides.webpack(config, process.env.NODE_ENV);->', overrides.webpack(webpackConfig, process.env.NODE_ENV)); 25 | // console.log('webpackConfig===>',webpackConfig); 26 | // console.log('overideConfig=>',overideConfig); 27 | module.exports = { 28 | webpack: override( 29 | // customize-cra plugins here 30 | overideConfig, 31 | // webpackConfig, 32 | (conf)=>{ 33 | // console.log('conf',conf); 34 | return conf; 35 | }, 36 | // overrides.webpack(webpackConfig, process.env.NODE_ENV), 37 | (config) => { 38 | config.devtool=false; 39 | // console.log('config',config); 40 | return config; 41 | }, 42 | ), 43 | 44 | jest: config => { 45 | return config; 46 | }, 47 | 48 | devServer: configFunction => (proxy, allowedHost) => { 49 | const config = configFunction(proxy, allowedHost); 50 | return config; 51 | }, 52 | 53 | paths: (paths, env) => { 54 | return paths; 55 | } 56 | }; -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 11 | 15 | 16 | 25 | 订餐 26 | 27 | 28 | 29 |
30 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/Home/Home.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Button, Tabs, Badge } from 'antd-mobile'; 3 | import { Book } from '../Book/Book'; 4 | import { createForm, formShape } from 'rc-form'; 5 | import { Message } from '../Message/Message'; 6 | import { Order } from '../Order/Order'; 7 | import { Link } from 'react-router-dom'; 8 | import './Home.less'; 9 | import { conf } from '../config'; 10 | 11 | export class Home extends Component { 12 | state = { 13 | orderList: [], 14 | messageList: [] 15 | }; 16 | render() { 17 | const tabs = [ 18 | { title: 我要订餐 }, 19 | { title: 我的订单 }, 20 | { title: 公告 } 21 | ]; 22 | const BookForm = createForm()(Book); 23 | 24 | return ( 25 |
26 | { 30 | console.log('onChange', index, tab); 31 | if (index === 1) { 32 | this.setState({ orderList: [] }); 33 | } else if (index === 2) { 34 | this.setState({ messageList: [] }); 35 | } 36 | }} 37 | onTabClick={(tab, index) => { 38 | // console.log('onTabClick', index, tab); 39 | }} 40 | > 41 |
42 | 43 |
44 |
45 | 46 |
47 | 48 |
49 | 50 |
51 |
52 | 53 | {conf.copyright} 54 | 55 |
56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Message/Message.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { 3 | WingBlank, 4 | Toast, 5 | Flex, 6 | NoticeBar, 7 | WhiteSpace, 8 | Card 9 | } from 'antd-mobile'; 10 | import { MarqueeProps } from 'antd-mobile/lib/notice-bar/Marquee'; 11 | import './Message.less'; 12 | import { Base } from '../Common/Base'; 13 | import moment from 'moment'; 14 | 15 | export class Message extends Base { 16 | componentDidMount() { 17 | this.getMessage(); 18 | } 19 | getMessage(){ 20 | this.client.get('/message').then(ret => { 21 | if (ret.data.code === 200) { 22 | this.setState({ 23 | message: ret.data.result 24 | }); 25 | } else { 26 | Toast.fail(ret.data.message, 1); 27 | } 28 | }); 29 | } 30 | state = { 31 | message: { 32 | list: [], 33 | notice: null 34 | } 35 | }; 36 | componentWillReceiveProps(){ 37 | this.getMessage(); 38 | } 39 | render() { 40 | const { list, notice } = this.state.message; 41 | return ( 42 |
43 | {notice ? ( 44 | 49 | 通知: 50 | {notice} 51 | 52 | ) : null} 53 | 54 | {list.map((item: any, index) => ( 55 |
56 | {/* */} 57 | 58 | 59 | 63 | 64 |
{item.content}
65 |
66 | 67 | 68 |
69 | {/*
*/} 70 |
71 | ))} 72 | 73 |
74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/Order/Order.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { WingBlank, Card, WhiteSpace, Flex, Toast } from 'antd-mobile'; 3 | import './Order.less'; 4 | import { Base } from '../Common/Base'; 5 | import moment from 'moment'; 6 | 7 | export class Order extends Base { 8 | state = { 9 | orderList: [] 10 | }; 11 | type = [ 12 | { 13 | label: '早餐', 14 | value: 1 15 | }, 16 | { 17 | label: '午餐', 18 | value: 2 19 | }, 20 | { 21 | label: '晚餐', 22 | value: 3 23 | } 24 | ]; 25 | getList(){ 26 | this.client.get('order/list').then(ret => { 27 | if (ret.data.code === 200) { 28 | this.setState({ 29 | orderList: ret.data.result 30 | }); 31 | } else { 32 | Toast.fail(ret.data.message, 1); 33 | } 34 | }); 35 | } 36 | componentWillReceiveProps(){ 37 | console.log('componentWillReceiveProps'); 38 | this.getList(); 39 | } 40 | componentWillMount() {} 41 | componentDidMount() { 42 | this.getList(); 43 | } 44 | getTypeName(type) { 45 | const i: any = this.type.find(o => o.value === type); 46 | return i.label; 47 | } 48 | render() { 49 | const orderList = this.state.orderList; 50 | return ( 51 |
52 | {orderList.map((item: any, index) => ( 53 |
54 | 55 | 56 | 57 | 58 | 59 | 65 | 类型:{this.getTypeName(item.type)} 66 | 数量:{item.count}份 67 | 68 | 69 | 时间: 70 | {moment(item.date).format('YYYY年MM月DD日 HH:mm:ss')} 71 | 72 | 73 | 备注:{item.note} 74 | 75 | 76 | {/* extra footer content
} 79 | /> */} 80 | 81 | 82 |
83 | ))} 84 | 85 | 86 | ); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/Login/Login.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { 3 | Button, 4 | List, 5 | DatePicker, 6 | Picker, 7 | InputItem, 8 | TextareaItem, 9 | WhiteSpace, 10 | WingBlank, 11 | Toast 12 | } from 'antd-mobile'; 13 | import { Base } from '../Common/Base'; 14 | 15 | const Item = List.Item; 16 | 17 | export class Login extends Base { 18 | constructor(props) { 19 | super(props); 20 | } 21 | render() { 22 | const { getFieldProps, getFieldError } = this.props.form; 23 | return ( 24 |
25 | '登录'} 27 | renderFooter={() => 28 | getFieldError('name') && getFieldError('name').join(',') 29 | } 30 | > 31 | { 42 | alert(getFieldError('name').join('、')); 43 | }} 44 | placeholder="请输入用户名" 45 | > 46 | 用户名 47 | 48 | 53 | 密码 54 | 55 | 56 | 57 | 60 | 61 | 62 | 63 |
64 | ); 65 | } 66 | validateName = (rule, value, callback) => { 67 | if (value && value.length >= 3) { 68 | callback(); 69 | } else { 70 | callback(new Error('请输入至少3个字符的用户名')); 71 | } 72 | }; 73 | 74 | onSubmit = () => { 75 | this.props.form.validateFields({ force: true }, error => { 76 | if (!error) { 77 | let data = this.props.form.getFieldsValue(); 78 | data.password = new Buffer(data.password).toString('base64'); 79 | this.client.post('/login', data).then(res => { 80 | console.log('res', res); 81 | if (res.data.code === 200) { 82 | this.saveToken(res); 83 | Toast.success(res.data.message, 1); 84 | this.redirect('/'); 85 | } else { 86 | Toast.fail(res.data.message, 1); 87 | } 88 | }); 89 | } else { 90 | // new Error('请输入至少3个字符的账号') 91 | } 92 | }); 93 | }; 94 | register = () => { 95 | this.navigate('/register'); 96 | }; 97 | } 98 | -------------------------------------------------------------------------------- /src/Register/Register.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { 3 | Button, 4 | List, 5 | DatePicker, 6 | Picker, 7 | InputItem, 8 | TextareaItem, 9 | WhiteSpace, 10 | WingBlank, 11 | Toast 12 | } from 'antd-mobile'; 13 | import { Base } from '../Common/Base'; 14 | const Item = List.Item; 15 | 16 | export class Register extends Base { 17 | constructor(props) { 18 | super(props); 19 | } 20 | validateName = (rule, value, callback) => { 21 | if (value && value.length >= 3) { 22 | callback(); 23 | } else { 24 | callback(new Error('请输入至少3个字符的用户名')); 25 | } 26 | }; 27 | validatePassword = (rule, value, callback) => { 28 | if (value && value.length >= 3) { 29 | callback(); 30 | } else { 31 | callback(new Error('请输入至少3个字符的密码')); 32 | } 33 | }; 34 | onSubmit = () => { 35 | this.props.form.validateFields({ force: true }, error => { 36 | if (!error) { 37 | let data = this.props.form.getFieldsValue(); 38 | data.password = new Buffer(data.password).toString('base64'); 39 | this.client.post('/register', data).then(res => { 40 | if (res.data.code === 200) { 41 | Toast.success(res.data.message, 1); 42 | this.props.location.pathname = '/'; 43 | } else { 44 | Toast.fail(res.data.message, 1); 45 | } 46 | }); 47 | } else { 48 | // new Error('请输入至少3个字符的账号') 49 | } 50 | }); 51 | }; 52 | 53 | login = () => { 54 | this.props.history.push('/login', { 55 | dotData: 'haha' 56 | }); 57 | }; 58 | render() { 59 | const { getFieldProps, getFieldError } = this.props.form; 60 | return ( 61 |
62 | '登录'} 64 | renderFooter={() => 65 | (getFieldError('name') && getFieldError('name').join(',')) || 66 | (getFieldError('password') && getFieldError('password').join(',')) 67 | } 68 | > 69 | { 80 | alert(getFieldError('name').join('、')); 81 | }} 82 | placeholder="请输入用户名" 83 | > 84 | 用户名 85 | 86 | 96 | 密码 97 | 98 | 99 | 100 | 103 | 104 | 105 | 106 |
107 | ); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/Order/Total.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { 3 | WingBlank, 4 | DatePicker, 5 | List, 6 | Card, 7 | WhiteSpace, 8 | Flex, 9 | Toast 10 | } from 'antd-mobile'; 11 | import './Total.less'; 12 | import { Base } from '../Common/Base'; 13 | import moment from 'moment'; 14 | 15 | const nowTimeStamp = Date.now(); 16 | const now = new Date(nowTimeStamp); 17 | 18 | export class Total extends Base { 19 | state = { 20 | orderList: [], 21 | date: now 22 | }; 23 | type = [ 24 | { 25 | label: '早餐', 26 | value: 1 27 | }, 28 | { 29 | label: '午餐', 30 | value: 2 31 | }, 32 | { 33 | label: '晚餐', 34 | value: 3 35 | } 36 | ]; 37 | componentWillMount() {} 38 | componentDidMount() { 39 | this.getTotal(this.state.date); 40 | } 41 | getTotal(d) { 42 | const start = moment(d).format('YYYY-MM-DD'); 43 | const end = moment(d).add(1,'day').format('YYYY-MM-DD'); 44 | this.client.get(`order/total?start=${start}&end=${end}`).then(ret => { 45 | if (ret.data.code === 200) { 46 | this.setState({ 47 | orderList: ret.data.result 48 | }); 49 | } else { 50 | Toast.fail(ret.data.message, 1); 51 | } 52 | }); 53 | } 54 | getTypeName(type) { 55 | const i: any = this.type.find(o => o.value === type); 56 | return i.label; 57 | } 58 | render() { 59 | const orderList = this.state.orderList; 60 | return ( 61 |
62 | { 66 | this.setState({ date }); 67 | this.getTotal(date); 68 | }} 69 | > 70 | 下单时间 71 | 72 | 73 | {orderList.map((item: any, index) => ( 74 |
75 | 76 | 77 | 78 | 82 | 83 | 89 | 类型:{this.getTypeName(item.type)} 90 | 数量:{item.count}份 91 | 92 | {/* 93 | 时间: 94 | {moment(item.date).format('YYYY年MM月DD日 HH:mm:ss')} 95 | */} 96 | {/* */} 97 | {/* 备注:{item.note} */} 98 | 99 | 100 | {/* extra footer content
} 103 | /> */} 104 | 105 | 106 |
107 | ))} 108 | 109 | 110 | ); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/serviceWorker.ts: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.1/8 is considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | type Config = { 24 | onSuccess?: (registration: ServiceWorkerRegistration) => void; 25 | onUpdate?: (registration: ServiceWorkerRegistration) => void; 26 | }; 27 | 28 | export function register(config?: Config) { 29 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 30 | // The URL constructor is available in all browsers that support SW. 31 | const publicUrl = new URL( 32 | (process as { env: { [key: string]: string } }).env.PUBLIC_URL, 33 | window.location.href 34 | ); 35 | if (publicUrl.origin !== window.location.origin) { 36 | // Our service worker won't work if PUBLIC_URL is on a different origin 37 | // from what our page is served on. This might happen if a CDN is used to 38 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 39 | return; 40 | } 41 | 42 | window.addEventListener('load', () => { 43 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 44 | 45 | if (isLocalhost) { 46 | // This is running on localhost. Let's check if a service worker still exists or not. 47 | checkValidServiceWorker(swUrl, config); 48 | 49 | // Add some additional logging to localhost, pointing developers to the 50 | // service worker/PWA documentation. 51 | navigator.serviceWorker.ready.then(() => { 52 | console.log( 53 | 'This web app is being served cache-first by a service ' + 54 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 55 | ); 56 | }); 57 | } else { 58 | // Is not localhost. Just register service worker 59 | registerValidSW(swUrl, config); 60 | } 61 | }); 62 | } 63 | } 64 | 65 | function registerValidSW(swUrl: string, config?: Config) { 66 | navigator.serviceWorker 67 | .register(swUrl) 68 | .then(registration => { 69 | registration.onupdatefound = () => { 70 | const installingWorker = registration.installing; 71 | if (installingWorker == null) { 72 | return; 73 | } 74 | installingWorker.onstatechange = () => { 75 | if (installingWorker.state === 'installed') { 76 | if (navigator.serviceWorker.controller) { 77 | // At this point, the updated precached content has been fetched, 78 | // but the previous service worker will still serve the older 79 | // content until all client tabs are closed. 80 | console.log( 81 | 'New content is available and will be used when all ' + 82 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 83 | ); 84 | 85 | // Execute callback 86 | if (config && config.onUpdate) { 87 | config.onUpdate(registration); 88 | } 89 | } else { 90 | // At this point, everything has been precached. 91 | // It's the perfect time to display a 92 | // "Content is cached for offline use." message. 93 | console.log('Content is cached for offline use.'); 94 | 95 | // Execute callback 96 | if (config && config.onSuccess) { 97 | config.onSuccess(registration); 98 | } 99 | } 100 | } 101 | }; 102 | }; 103 | }) 104 | .catch(error => { 105 | console.error('Error during service worker registration:', error); 106 | }); 107 | } 108 | 109 | function checkValidServiceWorker(swUrl: string, config?: Config) { 110 | // Check if the service worker can be found. If it can't reload the page. 111 | fetch(swUrl) 112 | .then(response => { 113 | // Ensure service worker exists, and that we really are getting a JS file. 114 | const contentType = response.headers.get('content-type'); 115 | if ( 116 | response.status === 404 || 117 | (contentType != null && contentType.indexOf('javascript') === -1) 118 | ) { 119 | // No service worker found. Probably a different app. Reload the page. 120 | navigator.serviceWorker.ready.then(registration => { 121 | registration.unregister().then(() => { 122 | window.location.reload(); 123 | }); 124 | }); 125 | } else { 126 | // Service worker found. Proceed as normal. 127 | registerValidSW(swUrl, config); 128 | } 129 | }) 130 | .catch(() => { 131 | console.log( 132 | 'No internet connection found. App is running in offline mode.' 133 | ); 134 | }); 135 | } 136 | 137 | export function unregister() { 138 | if ('serviceWorker' in navigator) { 139 | navigator.serviceWorker.ready.then(registration => { 140 | registration.unregister(); 141 | }); 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /src/Book/Book.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { 3 | Button, 4 | List, 5 | DatePicker, 6 | Picker, 7 | InputItem, 8 | Radio, 9 | TextareaItem, 10 | WhiteSpace, 11 | WingBlank, 12 | Toast 13 | } from 'antd-mobile'; 14 | import { PickerData } from 'antd-mobile/lib/picker/PropsType'; 15 | import { createForm, formShape } from 'rc-form'; 16 | import './Book.less'; 17 | import { Base } from '../Common/Base'; 18 | import { conf } from '../config'; 19 | import moment from 'moment'; 20 | 21 | 22 | export class Book extends Base { 23 | constructor(props: any) { 24 | super(props); 25 | 26 | const now = moment(); 27 | let type = this.getTodayDefaultType(); 28 | this.state = { 29 | date: type > 0 ? now.toDate() : now.add(1, 'days').toDate(), // 自动选择今日或明日 30 | type: [type || 1], // 今日或明日早餐 31 | time: now 32 | }; 33 | } 34 | static propTypes = { 35 | form: formShape 36 | }; 37 | 38 | 39 | inputRef: any; 40 | customFocusInst: any; 41 | 42 | onSubmit = e => { 43 | e.preventDefault(); 44 | this.props.form.validateFields((error, values) => { 45 | if (!error) { 46 | const data = { 47 | ...values, 48 | type: values['type'][0] 49 | }; 50 | this.client 51 | .post('order/submit', data) 52 | .then(ret => { 53 | if (ret.data.code === 200) { 54 | Toast.success(ret.data.message, 1); 55 | } else { 56 | Toast.fail(ret.data.message, 1); 57 | } 58 | this.props.form.resetFields(); 59 | }) 60 | .catch(err => console.log(err)); 61 | } else { 62 | // for (const i of Object.keys(error)) { 63 | // const msg = error[i].errors.map(o => o.message).join(','); 64 | // Toast.fail(msg, 1); 65 | // } 66 | } 67 | }); 68 | }; 69 | onErrorClick(e) { 70 | Toast.fail(e, 1); 71 | } 72 | 73 | validateCount = (rule, value, callback) => { 74 | if (value && value < conf.maxNumber) { 75 | callback(); 76 | } else { 77 | callback(new Error(`不能超过${conf.maxNumber}份`)); 78 | } 79 | }; 80 | 81 | /* 82 | 根据当前时间和就餐时间段表数据,智能选择默认今日订餐类型 83 | @return 0 今日不能订餐 84 | */ 85 | getTodayDefaultType() { 86 | let typeTimeRanges = [ // 这个数据可能从后端来 87 | {begin: '7:00'}, 88 | {begin: '12:00'}, 89 | {begin: '18:00'} 90 | ]; 91 | 92 | let result = 0; 93 | const now = moment('16:00', 'HH:mm'); 94 | for (let i = 0; i < typeTimeRanges.length; i++) { 95 | let begin = moment(typeTimeRanges[i].begin, 'HH:mm'); 96 | if (now.diff(begin, 'minutes') < -30) { // 如果在就餐30分钟之前或者更早 97 | result = i + 1; 98 | break; 99 | } 100 | } 101 | 102 | return result; 103 | } 104 | 105 | render() { 106 | let errors; 107 | const { getFieldProps, getFieldError, getFieldValue } = this.props.form; 108 | const Item = List.Item; 109 | const Brief = Item.Brief; 110 | const type = [ 111 | { 112 | label: '早餐', 113 | value: 1 114 | }, 115 | { 116 | label: '午餐', 117 | value: 2 118 | }, 119 | { 120 | label: '晚餐', 121 | value: 3 122 | } 123 | ]; 124 | return ( 125 |
126 | 128 | (getFieldError('type') && getFieldError('type').join(',')) || 129 | (getFieldError('count') && getFieldError('count').join(',')) 130 | } 131 | > 132 | this.setState({ date })} 141 | > 142 | 日期 143 | 144 | 153 | 154 | 类型 155 | 156 | 157 | 158 | { 167 | // if (v && !/^(([1-9]\d*)|0)(\.\d{0,2}?)?$/.test(v)) { 168 | // if (v === '.') { 169 | // return 0; 170 | // } 171 | // return prev; 172 | // } 173 | // return v; 174 | // } 175 | })} 176 | error={getFieldError('count')} 177 | onErrorClick={this.onErrorClick.bind(this, getFieldError('count'))} 178 | type="number" 179 | extra="份" 180 | placeholder="请输入数量" 181 | ref={(el: any) => (this.inputRef = el)} 182 | onVirtualKeyboardConfirm={v => 183 | console.log('onVirtualKeyboardConfirm:', v) 184 | } 185 | clear 186 | > 187 | 数量 188 | 189 | 190 | 199 | 200 | 201 | 204 | 205 |
206 | ); 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------