Showing
21 changed files
with
775 additions
and
0 deletions
.browserslistrc
0 → 100644
.editorconfig
0 → 100644
.eslintrc.js
0 → 100644
| 1 | +module.exports = { | ||
| 2 | + root: true, | ||
| 3 | + env: { | ||
| 4 | + node: true, | ||
| 5 | + browser: true, | ||
| 6 | + commonjs: true, | ||
| 7 | + es6: true | ||
| 8 | + }, | ||
| 9 | + globals: { | ||
| 10 | + $: true, | ||
| 11 | + axios: true, | ||
| 12 | + moment: true, | ||
| 13 | + _: true | ||
| 14 | + }, | ||
| 15 | + 'extends': [ | ||
| 16 | + 'plugin:vue/essential', | ||
| 17 | + '@vue/standard' | ||
| 18 | + ], | ||
| 19 | + rules: { | ||
| 20 | + // allow paren-less arrow functions | ||
| 21 | + 'arrow-parens': 0, | ||
| 22 | + // allow async-await | ||
| 23 | + 'generator-star-spacing': 0, | ||
| 24 | + // allow debugger during development | ||
| 25 | + 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, | ||
| 26 | + // allow no-new | ||
| 27 | + 'no-new': 0, | ||
| 28 | + // allow semi | ||
| 29 | + 'semi': 0, | ||
| 30 | + // allow indent | ||
| 31 | + 'indent': ['error', 2], | ||
| 32 | + // 'indent': 0, | ||
| 33 | + // allow no-tabs | ||
| 34 | + 'no-tabs': 0, | ||
| 35 | + // allow camelcase | ||
| 36 | + 'camelcase': 0, | ||
| 37 | + 'eqeqeq': 0, | ||
| 38 | + 'no-undef': 0, | ||
| 39 | + 'no-self-assign': 0, | ||
| 40 | + 'no-console': ['error', { allow: ['warn', 'error'] }] | ||
| 41 | + }, | ||
| 42 | + parserOptions: { | ||
| 43 | + parser: 'babel-eslint' | ||
| 44 | + } | ||
| 45 | +} |
.gitignore
0 → 100644
package-lock.json
0 → 100644
This diff could not be displayed because it is too large.
package.json
0 → 100644
| 1 | +{ | ||
| 2 | + "name": "muse-test", | ||
| 3 | + "version": "0.1.0", | ||
| 4 | + "private": true, | ||
| 5 | + "scripts": { | ||
| 6 | + "serve": "vue-cli-service serve", | ||
| 7 | + "build": "vue-cli-service build", | ||
| 8 | + "lint": "vue-cli-service lint" | ||
| 9 | + }, | ||
| 10 | + "dependencies": { | ||
| 11 | + "axios": "^0.18.0", | ||
| 12 | + "core-js": "^2.6.5", | ||
| 13 | + "jquery": "^3.4.1", | ||
| 14 | + "lodash": "^4.17.11", | ||
| 15 | + "moment": "^2.24.0", | ||
| 16 | + "muse-ui": "^3.0.2", | ||
| 17 | + "muse-ui-loading": "^0.2.0", | ||
| 18 | + "muse-ui-message": "^0.2.1", | ||
| 19 | + "muse-ui-progress": "^0.1.0", | ||
| 20 | + "muse-ui-toast": "^0.3.0", | ||
| 21 | + "vue": "^2.6.10", | ||
| 22 | + "vue-router": "^3.0.3", | ||
| 23 | + "vuex": "^3.0.1" | ||
| 24 | + }, | ||
| 25 | + "devDependencies": { | ||
| 26 | + "@vue/cli-plugin-babel": "^3.7.0", | ||
| 27 | + "@vue/cli-plugin-eslint": "^3.7.0", | ||
| 28 | + "@vue/cli-service": "^3.7.0", | ||
| 29 | + "@vue/eslint-config-standard": "^4.0.0", | ||
| 30 | + "babel-eslint": "^10.0.1", | ||
| 31 | + "babel-plugin-import": "^1.11.0", | ||
| 32 | + "compression-webpack-plugin": "^2.0.0", | ||
| 33 | + "eslint": "^5.16.0", | ||
| 34 | + "eslint-plugin-vue": "^5.0.0", | ||
| 35 | + "less": "^3.0.4", | ||
| 36 | + "less-loader": "^4.1.0", | ||
| 37 | + "vue-template-compiler": "^2.5.21" | ||
| 38 | + } | ||
| 39 | +} |
public/favicon.ico
0 → 100644
No preview for this file type
public/index.html
0 → 100644
| 1 | +<!DOCTYPE html> | ||
| 2 | +<html lang="en"> | ||
| 3 | + <head> | ||
| 4 | + <meta charset="utf-8"> | ||
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| 6 | + <meta name="viewport" content="width=device-width,initial-scale=1.0"> | ||
| 7 | + <link rel="icon" href="<%= BASE_URL %>favicon.ico"> | ||
| 8 | + <link rel="stylesheet" href="https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.css"> | ||
| 9 | + <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic"> | ||
| 10 | + <title>muse-test</title> | ||
| 11 | + </head> | ||
| 12 | + <body> | ||
| 13 | + <noscript> | ||
| 14 | + <strong>We're sorry but muse-test doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> | ||
| 15 | + </noscript> | ||
| 16 | + <div id="app"></div> | ||
| 17 | + <!-- built files will be auto injected --> | ||
| 18 | + </body> | ||
| 19 | +</html> |
src/App.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div id="app"> | ||
| 3 | + <mu-drawer :open.sync="side_show" :docked="docked" :right="position === 'right'" :z-depth="1"> | ||
| 4 | + <mu-list> | ||
| 5 | + <mu-list-item v-for="(v, k) in side_menu" :key="k" button> | ||
| 6 | + <mu-list-item-title>{{ v.title }}</mu-list-item-title> | ||
| 7 | + </mu-list-item> | ||
| 8 | + <!-- <mu-list-item @click="close" button> | ||
| 9 | + <mu-list-item-title>Close</mu-list-item-title> | ||
| 10 | + </mu-list-item> --> | ||
| 11 | + </mu-list> | ||
| 12 | + </mu-drawer> | ||
| 13 | + <mu-appbar :class="['mu-appbar-header', {'is-open': side_show}]" color="primary"> | ||
| 14 | + <mu-button v-if="!side_show" @click="side_show = !side_show" icon slot="left"> | ||
| 15 | + <mu-icon value="menu"></mu-icon> | ||
| 16 | + </mu-button> | ||
| 17 | + <p style="text-align: left;">Title</p> | ||
| 18 | + <mu-button flat slot="right">LOGIN</mu-button> | ||
| 19 | + </mu-appbar> | ||
| 20 | + <!-- <mu-row gutter> | ||
| 21 | + <mu-col span="4" sm="0" md="3" lg="2" xl="2"> | ||
| 22 | + <side :show="show2"></side> | ||
| 23 | + 123 | ||
| 24 | + </mu-col> | ||
| 25 | + <mu-col span="8" sm="12" md="9" lg="10" xl="10"> | ||
| 26 | + <mu-appbar style="width: 100%;" color="primary"> | ||
| 27 | + <mu-button icon slot="left"> | ||
| 28 | + <mu-icon value="menu"></mu-icon> | ||
| 29 | + </mu-button> | ||
| 30 | + Title | ||
| 31 | + | ||
| 32 | + <mu-button flat slot="right">LOGIN</mu-button> | ||
| 33 | + </mu-appbar> | ||
| 34 | + <p>111</p> | ||
| 35 | + <router-view/> | ||
| 36 | + </mu-col> | ||
| 37 | + </mu-row> --> | ||
| 38 | + <div style="left: 256px; top: 100px; position: relative; width: calc(100% - 256px)"> | ||
| 39 | + <router-view/> | ||
| 40 | + </div> | ||
| 41 | + </div> | ||
| 42 | +</template> | ||
| 43 | + | ||
| 44 | +<script> | ||
| 45 | +// import side from 'components/side' | ||
| 46 | + | ||
| 47 | +export default { | ||
| 48 | + components: { | ||
| 49 | + // side | ||
| 50 | + }, | ||
| 51 | + mounted () { | ||
| 52 | + // 屏幕宽度小于600隐藏侧边栏 | ||
| 53 | + if ($('body').width() <= 600) { | ||
| 54 | + this.side_show = false; | ||
| 55 | + this.docked = false; | ||
| 56 | + } else { | ||
| 57 | + this.side_show = true; | ||
| 58 | + this.docked = true; | ||
| 59 | + } | ||
| 60 | + // 键盘屏幕宽度 | ||
| 61 | + $(window).resize(() => { | ||
| 62 | + this.screen_width = $('body').width(); | ||
| 63 | + // 屏幕宽度小于600隐藏侧边栏 | ||
| 64 | + if (this.screen_width <= 600) { | ||
| 65 | + this.side_show = false; | ||
| 66 | + this.docked = false; | ||
| 67 | + } else { | ||
| 68 | + this.side_show = true; | ||
| 69 | + this.docked = true; | ||
| 70 | + } | ||
| 71 | + }); | ||
| 72 | + }, | ||
| 73 | + data () { | ||
| 74 | + return { | ||
| 75 | + side_show: false, | ||
| 76 | + screen_width: '', | ||
| 77 | + docked: false, | ||
| 78 | + position: 'left', | ||
| 79 | + side_menu: [{ | ||
| 80 | + title: 'Menu Item 1' | ||
| 81 | + }, { | ||
| 82 | + title: 'Menu Item 2' | ||
| 83 | + }] | ||
| 84 | + } | ||
| 85 | + }, | ||
| 86 | + methods: { | ||
| 87 | + close () { | ||
| 88 | + // 关闭侧边栏 | ||
| 89 | + this.side_show = false; | ||
| 90 | + $(window).resize() | ||
| 91 | + } | ||
| 92 | + } | ||
| 93 | +} | ||
| 94 | +</script> | ||
| 95 | + | ||
| 96 | +<style lang="less"> | ||
| 97 | +#app { | ||
| 98 | + font-family: 'Avenir', Helvetica, Arial, sans-serif; | ||
| 99 | + -webkit-font-smoothing: antialiased; | ||
| 100 | + -moz-osx-font-smoothing: grayscale; | ||
| 101 | + text-align: center; | ||
| 102 | + color: #2c3e50; | ||
| 103 | +} | ||
| 104 | + | ||
| 105 | +.mu-appbar-header { | ||
| 106 | + position: fixed; | ||
| 107 | + left: 0; | ||
| 108 | + right: 0; | ||
| 109 | + top: 0; | ||
| 110 | + z-index: 101; | ||
| 111 | + overflow: hidden | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +.mu-appbar-header.is-open { | ||
| 115 | + left: 256px; | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +.mu-appbar-header.is-only-title .mu-appbar-title { | ||
| 119 | + margin-left: 16px | ||
| 120 | +} | ||
| 121 | + | ||
| 122 | +</style> |
src/assets/logo.png
0 → 100644
6.69 KB
src/components/HelloWorld.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="hello"> | ||
| 3 | + <h1>{{ msg }}</h1> | ||
| 4 | + <p> | ||
| 5 | + For a guide and recipes on how to configure / customize this project,<br> | ||
| 6 | + check out the | ||
| 7 | + <a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>. | ||
| 8 | + </p> | ||
| 9 | + <h3>Installed CLI Plugins</h3> | ||
| 10 | + <ul> | ||
| 11 | + <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li> | ||
| 12 | + <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li> | ||
| 13 | + </ul> | ||
| 14 | + <h3>Essential Links</h3> | ||
| 15 | + <ul> | ||
| 16 | + <li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li> | ||
| 17 | + <li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li> | ||
| 18 | + <li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li> | ||
| 19 | + <li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li> | ||
| 20 | + <li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li> | ||
| 21 | + </ul> | ||
| 22 | + <h3>Ecosystem</h3> | ||
| 23 | + <ul> | ||
| 24 | + <li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li> | ||
| 25 | + <li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li> | ||
| 26 | + <li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li> | ||
| 27 | + <li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li> | ||
| 28 | + <li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li> | ||
| 29 | + </ul> | ||
| 30 | + </div> | ||
| 31 | +</template> | ||
| 32 | + | ||
| 33 | +<script> | ||
| 34 | +export default { | ||
| 35 | + name: 'HelloWorld', | ||
| 36 | + props: { | ||
| 37 | + msg: String | ||
| 38 | + } | ||
| 39 | +} | ||
| 40 | +</script> | ||
| 41 | + | ||
| 42 | +<!-- Add "scoped" attribute to limit CSS to this component only --> | ||
| 43 | +<style scoped lang="less"> | ||
| 44 | +h3 { | ||
| 45 | + margin: 40px 0 0; | ||
| 46 | +} | ||
| 47 | +ul { | ||
| 48 | + list-style-type: none; | ||
| 49 | + padding: 0; | ||
| 50 | +} | ||
| 51 | +li { | ||
| 52 | + display: inline-block; | ||
| 53 | + margin: 0 10px; | ||
| 54 | +} | ||
| 55 | +a { | ||
| 56 | + color: #42b983; | ||
| 57 | +} | ||
| 58 | +</style> |
src/components/side.vue
0 → 100644
| 1 | +<template lang="html"> | ||
| 2 | + <mu-drawer :open.sync="open" :docked="docked" :right="position === 'right'" :z-depth="1"> | ||
| 3 | + <mu-list> | ||
| 4 | + <mu-list-item v-for="(v, k) in side_menu" :key="k" button> | ||
| 5 | + <mu-list-item-title>{{ v.title }}</mu-list-item-title> | ||
| 6 | + </mu-list-item> | ||
| 7 | + <mu-list-item @click="close" button> | ||
| 8 | + <mu-list-item-title>Close</mu-list-item-title> | ||
| 9 | + </mu-list-item> | ||
| 10 | + </mu-list> | ||
| 11 | + </mu-drawer> | ||
| 12 | +</template> | ||
| 13 | + | ||
| 14 | +<script> | ||
| 15 | +export default { | ||
| 16 | + props: ['open'], | ||
| 17 | + data () { | ||
| 18 | + return { | ||
| 19 | + docked: true, | ||
| 20 | + position: 'left', | ||
| 21 | + side_menu: [{ | ||
| 22 | + title: 'Menu Item 1' | ||
| 23 | + }, { | ||
| 24 | + title: 'Menu Item 2' | ||
| 25 | + }] | ||
| 26 | + } | ||
| 27 | + }, | ||
| 28 | + methods: { | ||
| 29 | + close () { | ||
| 30 | + // 关闭侧边栏 | ||
| 31 | + this.open = false; | ||
| 32 | + $(window).resize() | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | +} | ||
| 36 | +</script> | ||
| 37 | + | ||
| 38 | +<style lang="css" scoped> | ||
| 39 | +</style> |
src/main.js
0 → 100644
| 1 | +import Vue from 'vue' | ||
| 2 | +import App from './App.vue' | ||
| 3 | +import router from './router' | ||
| 4 | +import store from './store' | ||
| 5 | +import MuseUI from 'muse-ui'; | ||
| 6 | +import 'muse-ui/dist/muse-ui.css'; | ||
| 7 | +import Toast from 'muse-ui-toast'; | ||
| 8 | +import Message from 'muse-ui-message'; | ||
| 9 | +import Loading from 'muse-ui-loading'; | ||
| 10 | +import NProgress from 'muse-ui-progress'; | ||
| 11 | + | ||
| 12 | +Vue.config.productionTip = false | ||
| 13 | + | ||
| 14 | +Vue.use(MuseUI); | ||
| 15 | +Vue.use(Toast); | ||
| 16 | +Vue.use(Message); | ||
| 17 | +Vue.use(Loading); | ||
| 18 | +Vue.use(NProgress); | ||
| 19 | + | ||
| 20 | +new Vue({ | ||
| 21 | + router, | ||
| 22 | + store, | ||
| 23 | + render: h => h(App) | ||
| 24 | +}).$mount('#app') |
src/router.js
0 → 100644
| 1 | +import Vue from 'vue' | ||
| 2 | +import Router from 'vue-router' | ||
| 3 | +import Home from './views/Home.vue' | ||
| 4 | + | ||
| 5 | +Vue.use(Router) | ||
| 6 | + | ||
| 7 | +export default new Router({ | ||
| 8 | + routes: [ | ||
| 9 | + { | ||
| 10 | + path: '/', | ||
| 11 | + name: 'home', | ||
| 12 | + component: Home | ||
| 13 | + }, | ||
| 14 | + { | ||
| 15 | + path: '/about', | ||
| 16 | + name: 'about', | ||
| 17 | + // route level code-splitting | ||
| 18 | + // this generates a separate chunk (about.[hash].js) for this route | ||
| 19 | + // which is lazy-loaded when the route is visited. | ||
| 20 | + component: () => import(/* webpackChunkName: "about" */ './views/About.vue') | ||
| 21 | + }, | ||
| 22 | + { | ||
| 23 | + path: '/test', | ||
| 24 | + name: 'test', | ||
| 25 | + // route level code-splitting | ||
| 26 | + // this generates a separate chunk (about.[hash].js) for this route | ||
| 27 | + // which is lazy-loaded when the route is visited. | ||
| 28 | + component: () => import(/* webpackChunkName: "about" */ './views/test.vue') | ||
| 29 | + } | ||
| 30 | + ] | ||
| 31 | +}) |
src/store.js
0 → 100644
src/views/About.vue
0 → 100644
src/views/Home.vue
0 → 100644
src/views/test.vue
0 → 100644
| 1 | +<template lang="html"> | ||
| 2 | + <mu-container> | ||
| 3 | + <!-- <div style="margin: 0.5rem;"> --> | ||
| 4 | + <mu-paper :z-depth="1"> | ||
| 5 | + <mu-data-table :columns="columns" :sort.sync="sort" @sort-change="handleSortChange" :data="list"> | ||
| 6 | + <template slot-scope="scope"> | ||
| 7 | + <td class="is-center">{{scope.row.name}}</td> | ||
| 8 | + <td class="is-center">{{scope.row.calories}}</td> | ||
| 9 | + <td class="is-center">{{scope.row.fat}}</td> | ||
| 10 | + <td class="is-center">{{scope.row.carbs}}</td> | ||
| 11 | + <td class="is-center">{{scope.row.protein}}</td> | ||
| 12 | + <td class="is-center"> | ||
| 13 | + jjj | ||
| 14 | + </td> | ||
| 15 | + </template> | ||
| 16 | + </mu-data-table> | ||
| 17 | + </mu-paper> | ||
| 18 | + <!-- </div> --> | ||
| 19 | + | ||
| 20 | +</mu-container> | ||
| 21 | +</template> | ||
| 22 | + | ||
| 23 | +<script> | ||
| 24 | +export default { | ||
| 25 | + mounted () { | ||
| 26 | + }, | ||
| 27 | + data () { | ||
| 28 | + return { | ||
| 29 | + sort: { | ||
| 30 | + name: '', | ||
| 31 | + order: 'asc' | ||
| 32 | + }, | ||
| 33 | + columns: [ | ||
| 34 | + { title: 'Dessert (100g serving)', name: 'name' }, | ||
| 35 | + { title: 'Calories', name: 'calories', align: 'center', sortable: true }, | ||
| 36 | + { title: 'Fat (g)', name: 'fat', align: 'center', sortable: true }, | ||
| 37 | + { title: 'Carbs (g)', name: 'carbs', align: 'center', sortable: true }, | ||
| 38 | + { title: 'Protein (g)', name: 'protein', align: 'center', sortable: true }, | ||
| 39 | + { title: '操作', name: 'iron', align: 'center', sortable: true } | ||
| 40 | + ], | ||
| 41 | + list: [ | ||
| 42 | + { | ||
| 43 | + name: 'Frozen Yogurt', | ||
| 44 | + calories: 159, | ||
| 45 | + fat: 6.0, | ||
| 46 | + carbs: 24, | ||
| 47 | + protein: 4.0, | ||
| 48 | + iron: 1 | ||
| 49 | + }, | ||
| 50 | + { | ||
| 51 | + name: 'Ice cream sandwich', | ||
| 52 | + calories: 237, | ||
| 53 | + fat: 9.0, | ||
| 54 | + carbs: 37, | ||
| 55 | + protein: 4.3, | ||
| 56 | + iron: 1 | ||
| 57 | + }, | ||
| 58 | + { | ||
| 59 | + name: 'Eclair', | ||
| 60 | + calories: 262, | ||
| 61 | + fat: 16.0, | ||
| 62 | + carbs: 23, | ||
| 63 | + protein: 6.0, | ||
| 64 | + iron: 7 | ||
| 65 | + }, | ||
| 66 | + { | ||
| 67 | + name: 'Cupcake', | ||
| 68 | + calories: 305, | ||
| 69 | + fat: 3.7, | ||
| 70 | + carbs: 67, | ||
| 71 | + protein: 4.3, | ||
| 72 | + iron: 8 | ||
| 73 | + }, | ||
| 74 | + { | ||
| 75 | + name: 'Gingerbread', | ||
| 76 | + calories: 356, | ||
| 77 | + fat: 16.0, | ||
| 78 | + carbs: 49, | ||
| 79 | + protein: 3.9, | ||
| 80 | + iron: 16 | ||
| 81 | + }, | ||
| 82 | + { | ||
| 83 | + name: 'Jelly bean', | ||
| 84 | + calories: 375, | ||
| 85 | + fat: 0.0, | ||
| 86 | + carbs: 94, | ||
| 87 | + protein: 0.0, | ||
| 88 | + iron: 0 | ||
| 89 | + }, | ||
| 90 | + { | ||
| 91 | + name: 'Lollipop', | ||
| 92 | + calories: 392, | ||
| 93 | + fat: 0.2, | ||
| 94 | + carbs: 98, | ||
| 95 | + protein: 0, | ||
| 96 | + iron: 2 | ||
| 97 | + }, | ||
| 98 | + { | ||
| 99 | + name: 'Honeycomb', | ||
| 100 | + calories: 408, | ||
| 101 | + fat: 3.2, | ||
| 102 | + carbs: 87, | ||
| 103 | + protein: 6.5, | ||
| 104 | + iron: 45 | ||
| 105 | + }, | ||
| 106 | + { | ||
| 107 | + name: 'Donut', | ||
| 108 | + calories: 452, | ||
| 109 | + fat: 25.0, | ||
| 110 | + carbs: 51, | ||
| 111 | + protein: 4.9, | ||
| 112 | + iron: 22 | ||
| 113 | + }, | ||
| 114 | + { | ||
| 115 | + name: 'KitKat', | ||
| 116 | + calories: 518, | ||
| 117 | + fat: 26.0, | ||
| 118 | + carbs: 65, | ||
| 119 | + protein: 7, | ||
| 120 | + iron: 6 | ||
| 121 | + } | ||
| 122 | + ] | ||
| 123 | + } | ||
| 124 | + }, | ||
| 125 | + methods: { | ||
| 126 | + handleSortChange ({ name, order }) { | ||
| 127 | + this.list = this.list.sort((a, b) => order === 'asc' ? a[name] - b[name] : b[name] - a[name]); | ||
| 128 | + } | ||
| 129 | + } | ||
| 130 | +} | ||
| 131 | +</script> | ||
| 132 | + | ||
| 133 | +<style lang="css" scoped> | ||
| 134 | + .demo-button { | ||
| 135 | + margin: 6px 8px; | ||
| 136 | + } | ||
| 137 | +</style> |
vue.config.js
0 → 100644
| 1 | +/* jshint esversion: 6 */ | ||
| 2 | +const path = require('path') | ||
| 3 | +const webpack = require('webpack') | ||
| 4 | +const CompressionWebpackPlugin = require('compression-webpack-plugin') | ||
| 5 | + | ||
| 6 | +function resolve(dir) { | ||
| 7 | + return path.join(__dirname, './', dir) | ||
| 8 | +} | ||
| 9 | + | ||
| 10 | +// cdn预加载使用 | ||
| 11 | +const externals = { | ||
| 12 | + 'vue': 'Vue', | ||
| 13 | + 'vue-router': 'VueRouter', | ||
| 14 | + 'vuex': 'Vuex', | ||
| 15 | + 'axios': 'axios', | ||
| 16 | + '$': 'jquery', | ||
| 17 | + 'jquery': 'Jquery', | ||
| 18 | + 'moment': 'moment' | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +const cdn = { | ||
| 22 | + // 开发环境 | ||
| 23 | + dev: { | ||
| 24 | + css: [], | ||
| 25 | + js: [] | ||
| 26 | + }, | ||
| 27 | + // 生产环境 | ||
| 28 | + build: { | ||
| 29 | + css: [ | ||
| 30 | + ], | ||
| 31 | + js: [ | ||
| 32 | + 'https://cdn.jsdelivr.net/npm/vue@2.5.21/dist/vue.min.js', | ||
| 33 | + 'https://cdn.jsdelivr.net/npm/vue-router@3.0.1/dist/vue-router.min.js', | ||
| 34 | + 'https://cdn.jsdelivr.net/npm/vuex@3.0.1/dist/vuex.min.js', | ||
| 35 | + 'https://cdn.jsdelivr.net/npm/axios@0.18.0/dist/axios.min.js', | ||
| 36 | + 'https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js', | ||
| 37 | + 'https://cdn.jsdelivr.net/npm/moment@2.23.0/moment.min.js' | ||
| 38 | + ] | ||
| 39 | + } | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +// 是否使用gzip | ||
| 43 | +const productionGzip = true | ||
| 44 | +// 需要gzip压缩的文件后缀 | ||
| 45 | +const productionGzipExtensions = ['js', 'css'] | ||
| 46 | + | ||
| 47 | +module.exports = { | ||
| 48 | + // 基本路径 | ||
| 49 | + publicPath: process.env.NODE_ENV === 'production' ? '/boh/' : '/', | ||
| 50 | + // 输出文件目录 | ||
| 51 | + outputDir: 'dist', | ||
| 52 | + // 放置生成的静态资源的目录 | ||
| 53 | + assetsDir: '', | ||
| 54 | + // 指定生成的 index.html 的输出路径 (相对于 outputDir)。也可以是一个绝对路径。 | ||
| 55 | + indexPath: 'index.html', | ||
| 56 | + filenameHashing: true, | ||
| 57 | + pages: { | ||
| 58 | + index: { | ||
| 59 | + // page 的入口 | ||
| 60 | + entry: 'src/main.js', | ||
| 61 | + // 模板来源 | ||
| 62 | + template: 'public/index.html', | ||
| 63 | + // 在 dist/index.html 的输出 | ||
| 64 | + filename: 'index.html', | ||
| 65 | + // 当使用 title 选项时, | ||
| 66 | + // template 中的 title 标签需要是 <title><%= htmlWebpackPlugin.options.title %></title> | ||
| 67 | + title: 'Index Page', | ||
| 68 | + // 在这个页面中包含的块,默认情况下会包含 | ||
| 69 | + // 提取出来的通用 chunk 和 vendor chunk。 | ||
| 70 | + chunks: ['chunk-vendors', 'chunk-common', 'index'] | ||
| 71 | + } | ||
| 72 | + }, | ||
| 73 | + // eslint-loader 是否在保存的时候检查 | ||
| 74 | + lintOnSave: 'error', | ||
| 75 | + // 是否使用包含运行时编译器的 Vue 构建版本。设置为 true 后你就可以在 Vue 组件中使用 template 选项了。 | ||
| 76 | + runtimeCompiler: true, | ||
| 77 | + // 生产环境是否生成 sourceMap 文件 | ||
| 78 | + productionSourceMap: false, | ||
| 79 | + // vux 相关配置,使用vux-ui | ||
| 80 | + // 如果这个值是一个对象,则会通过 webpack-merge 合并到最终的配置中。 | ||
| 81 | + // 如果这个值是一个函数,则会接收被解析的配置作为参数。该函数及可以修改配置并不返回任何东西,也可以返回一个被克隆或合并过的配置版本。 | ||
| 82 | + configureWebpack: config => { | ||
| 83 | + config.plugins.push( | ||
| 84 | + new webpack.ProvidePlugin({ | ||
| 85 | + $: 'jquery', | ||
| 86 | + jQuery: 'jquery', | ||
| 87 | + '_': 'lodash', | ||
| 88 | + 'axios': 'axios', | ||
| 89 | + 'moment': 'moment' | ||
| 90 | + }) | ||
| 91 | + ) | ||
| 92 | + config.resolve.extensions.push('.less') | ||
| 93 | + config.resolve.extensions.push('.css') | ||
| 94 | + // | ||
| 95 | + config.resolve.alias.src = path.resolve(__dirname, './src/src') | ||
| 96 | + config.resolve.alias.assets = path.resolve(__dirname, './src/assets') | ||
| 97 | + config.resolve.alias.components = path.resolve(__dirname, './src/components') | ||
| 98 | + // 修改webpack config, 使其不打包externals下的资源 | ||
| 99 | + if (process.env.NODE_ENV === 'production') { | ||
| 100 | + // 1. 生产环境npm包转CDN | ||
| 101 | + config.externals = externals | ||
| 102 | + // 2. 构建时开启gzip,降低服务器压缩对CPU资源的占用,服务器也要相应开启gzip | ||
| 103 | + productionGzip && config.plugins.push( | ||
| 104 | + new CompressionWebpackPlugin({ | ||
| 105 | + test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'), | ||
| 106 | + threshold: 8192, | ||
| 107 | + minRatio: 0.8 | ||
| 108 | + }) | ||
| 109 | + ) | ||
| 110 | + } | ||
| 111 | + if (process.env.NODE_ENV === 'development') { | ||
| 112 | + } | ||
| 113 | + }, | ||
| 114 | + // 是一个函数,会接收一个基于 webpack-chain 的 ChainableConfig 实例。允许对内部的 webpack 配置进行更细粒度的修改。 | ||
| 115 | + chainWebpack: (config) => { | ||
| 116 | + /** | ||
| 117 | + * 添加CDN参数到htmlWebpackPlugin配置中, 详见public/index.html 修改 | ||
| 118 | + * vue inspect --plugins 查询插件 使用pages会有多个html实例 | ||
| 119 | + */ | ||
| 120 | + config | ||
| 121 | + .plugin('html-index') | ||
| 122 | + .tap(args => { | ||
| 123 | + if (process.env.NODE_ENV === 'production') { | ||
| 124 | + args[0].cdn = cdn.build | ||
| 125 | + } | ||
| 126 | + if (process.env.NODE_ENV === 'development') { | ||
| 127 | + args[0].cdn = cdn.dev | ||
| 128 | + } | ||
| 129 | + return args | ||
| 130 | + }) | ||
| 131 | + .end() | ||
| 132 | + }, | ||
| 133 | + // css相关配置 | ||
| 134 | + css: { | ||
| 135 | + // 是否使用css分离插件 ExtractTextPlugin | ||
| 136 | + // extract: true, | ||
| 137 | + // 开启 CSS source maps? | ||
| 138 | + sourceMap: false, | ||
| 139 | + // css预设器配置项 | ||
| 140 | + loaderOptions: { | ||
| 141 | + css: { | ||
| 142 | + // 这里的选项会传递给 css-loader | ||
| 143 | + }, | ||
| 144 | + postcss: { | ||
| 145 | + // 这里的选项会传递给 postcss-loader | ||
| 146 | + } | ||
| 147 | + }, | ||
| 148 | + // 默认情况下,只有 *.module.[ext] 结尾的文件才会被视作 CSS Modules 模块。设置为 true 后你就可以去掉文件名中的 .module 并将所有的 *.(css|scss|sass|less|styl(us)?) 文件视为 CSS Modules 模块。 | ||
| 149 | + modules: false | ||
| 150 | + }, | ||
| 151 | + // use thread-loader for babel & TS in production build | ||
| 152 | + // enabled by default if the machine has more than 1 cores | ||
| 153 | + parallel: require('os').cpus().length > 1, | ||
| 154 | + // PWA 插件相关配置 | ||
| 155 | + // see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa | ||
| 156 | + pwa: {}, | ||
| 157 | + // webpack-dev-server 相关配置 | ||
| 158 | + devServer: { | ||
| 159 | + open: false, | ||
| 160 | + // open: process.platform === 'darwin', | ||
| 161 | + host: '0.0.0.0', | ||
| 162 | + port: 8080, | ||
| 163 | + https: false, | ||
| 164 | + hotOnly: false, | ||
| 165 | + // 设置代理 | ||
| 166 | + proxy: { | ||
| 167 | + 'api': { | ||
| 168 | + filter: ['/op/', '/fi/', '/de/', '/st/', '/fr/', '/pr/', '/pu/', '/dl/', '/b/', '/t/', '/rpt/'], | ||
| 169 | + target: 'http://dev.kmlab.com/boh', | ||
| 170 | + // target: 'http://itomix-dev.kmlab.com/boh' | ||
| 171 | + changeOrigin: true, | ||
| 172 | + pathRewrite: { | ||
| 173 | + '^/(.*)': '/$1' | ||
| 174 | + }, | ||
| 175 | + onProxyReq: function (proxyReq, req, res, options) { | ||
| 176 | + proxyReq.setHeader('X-Proxy-Host', req.header('host')) | ||
| 177 | + proxyReq.setHeader('X-Proxy-Request-URI', req.url) | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + }, | ||
| 181 | + before: app => {}, | ||
| 182 | + overlay: { | ||
| 183 | + warnings: false, | ||
| 184 | + errors: true | ||
| 185 | + } | ||
| 186 | + }, | ||
| 187 | + // 第三方插件配置 | ||
| 188 | + pluginOptions: { | ||
| 189 | + // ... | ||
| 190 | + } | ||
| 191 | +} |
-
Please register or login to post a comment