Mesamo / dva-admin

A dashboard application built upon dva and ant-design
https://dva-admin.firebaseapp.com/
MIT License
19 stars 4 forks source link

Todos #2

Open Mesamo opened 7 years ago

Mesamo commented 7 years ago
Mesamo commented 7 years ago

bundle提取公用模块

  1. src目录添加vendor.js, 把一些公用的模块都引用下
    
    import 'react'
    import 'react-dom'
    import 'react-router'
    import 'core-js'
    import 'rc-queue-anim';
    import 'prop-types'
    import 'path-to-regexp'
    import 'dva'
    import 'dva-loading'
    import 'firebase/app'
    import 'firebase/auth'
    import 'firebase/database'

import antd from 'antd'

/ eslint-disable / const { Table, Form, Layout, Row, Col, Menu, Dropdown, Popover, Input, Button, Checkbox, Card, Icon, Progress, Alert, Switch, Radio, Modal, message, notification } = antd / eslint-disable /


2. 修改`.roadhogrc`  
```diff
{
- "entry": "./src/index.js",
+ "entry": {
+   "index": "./src/index.js",
+   "common": "./src/vendor.js"
+ },
+ "multipage": true,
    ....
    ....
}
Mesamo commented 7 years ago

Progressive Web App

  1. 安装sw-precache

    $ npm install sw-precache --save-dev
  2. 根目录添加sw-precache-config.js

    +module.exports = {
    +  stripPrefix: 'dist/',
    +  staticFileGlobs: [
    +    'dist/favicon.ico',
    +    'dist/manifest.json',
    +    'dist/index.html',
    +    'dist/assets/**/*',
    +    'dist/static/*',
    +    'dist/*.js',
    +    'dist/*.css'
    +  ],
    +  dontCacheBustUrlsMatching: /\.\w{8}\./,
    +  swFilePath: 'dist/service-worker.js'
    +};

    将静态文件和不常变动的第三方模块加入cache storage

  3. 修改构建脚本

    {
    ...
    "scripts": {
      "start": "roadhog server",
    -     "build": "roadhog build",
    +     "build": "roadhog build && sw-precache --config=sw-precache-config.js",
      "analyze": "roadhog build --analyze",
      "lint": "eslint --ext .js src test",
      "precommit": "npm run lint"
    }
    ...
    }
  4. 修改index.ejs,注册service worker

    <body>
    <div id="root">loading</div>
    + <script>
    +    if ('serviceWorker' in navigator) {
    +     navigator.serviceWorker.register('/service-worker.js');
    +   }
    + </script>
    </body>
  5. public目录下添加manifest.json

    {
    "name": "Dva Admin -- Mesamo",
    "short_name": "Dva Admin",
    "display": "standalone",
    "start_url": "/",
    "theme_color": "#8fc9fb",
    "background_color": "#ffffff",
    "icons": [
    {
      "src": "favicon.ico",
      "sizes": "400x400",
      "type": "image/png"
    }
    ]
    }

Your First Progressive Web App

LuciferLi commented 7 years ago

不是npm install sw-pecache --save-dev,是npm install sw-percache --save-dev

Mesamo commented 7 years ago

@LuciferLi 已修改,谢谢

syaivin commented 6 years ago

@Mesamo 没有测试账号密码吗?

Mesamo commented 6 years ago

@syaivin 登录功能使用的是firebase的服务,可以直接注册(需要科学上网)。