├── shoppingcart-vuejs ├── static │ ├── .gitkeep │ └── img │ │ ├── cart.png │ │ ├── cup.jpg │ │ ├── dish.jpg │ │ ├── bottle.jpg │ │ ├── dish-02.jpg │ │ ├── milk-cup.jpg │ │ ├── animal-cup.jpg │ │ ├── morning-cup.jpg │ │ └── shopping-cart.gif ├── .eslintignore ├── config │ ├── prod.env.js │ ├── test.env.js │ ├── dev.env.js │ └── index.js ├── .gitignore ├── test │ └── unit │ │ ├── .eslintrc │ │ ├── specs │ │ └── Hello.spec.js │ │ ├── index.js │ │ └── karma.conf.js ├── .editorconfig ├── src │ ├── store │ │ ├── actions.js │ │ ├── mutation-type.js │ │ ├── index.js │ │ └── modules │ │ │ ├── products.js │ │ │ └── cart.js │ ├── router │ │ └── index.js │ ├── main.js │ ├── api │ │ └── products.js │ ├── App.vue │ └── components │ │ ├── Main.vue │ │ ├── About.vue │ │ ├── Nav.vue │ │ ├── Cart.vue │ │ └── Products.vue ├── .babelrc ├── build │ ├── dev-client.js │ ├── vue-loader.conf.js │ ├── webpack.test.conf.js │ ├── build.js │ ├── check-versions.js │ ├── webpack.dev.conf.js │ ├── webpack.base.conf.js │ ├── utils.js │ ├── dev-server.js │ └── webpack.prod.conf.js ├── index.html ├── .eslintrc.js ├── README.md └── package.json ├── wikipediaViewer-vuejs ├── .gitignore ├── .babelrc ├── src │ ├── assets │ │ ├── logo.png │ │ └── search.png │ ├── main.js │ ├── router │ │ └── index.js │ ├── components │ │ ├── AppHeader.vue │ │ ├── SearchResult.vue │ │ ├── AppFooter.vue │ │ └── WikipediaViewer.vue │ └── App.vue ├── img │ └── wikipedia-viewer.gif ├── index.html ├── package.json ├── README.md └── webpack.config.js └── README.md /shoppingcart-vuejs/static/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/.eslintignore: -------------------------------------------------------------------------------- 1 | build/*.js 2 | config/*.js 3 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/config/prod.env.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | NODE_ENV: '"production"' 3 | } 4 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | npm-debug.log 5 | test/unit/coverage 6 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["es2015", { "modules": false }] 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/cart.png -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/cup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/cup.jpg -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/dish.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/dish.jpg -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/bottle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/bottle.jpg -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/dish-02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/dish-02.jpg -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/wikipediaViewer-vuejs/src/assets/logo.png -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/milk-cup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/milk-cup.jpg -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/assets/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/wikipediaViewer-vuejs/src/assets/search.png -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/animal-cup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/animal-cup.jpg -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/morning-cup.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/morning-cup.jpg -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/img/wikipedia-viewer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/wikipediaViewer-vuejs/img/wikipedia-viewer.gif -------------------------------------------------------------------------------- /shoppingcart-vuejs/static/img/shopping-cart.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/heyacherry/vue-demos/HEAD/shoppingcart-vuejs/static/img/shopping-cart.gif -------------------------------------------------------------------------------- /shoppingcart-vuejs/test/unit/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "mocha": true 4 | }, 5 | "globals": { 6 | "expect": true, 7 | "sinon": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/config/test.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var devEnv = require('./dev.env') 3 | 4 | module.exports = merge(devEnv, { 5 | NODE_ENV: '"testing"' 6 | }) 7 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/config/dev.env.js: -------------------------------------------------------------------------------- 1 | var merge = require('webpack-merge') 2 | var prodEnv = require('./prod.env') 3 | 4 | module.exports = merge(prodEnv, { 5 | NODE_ENV: '"development"' 6 | }) 7 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/store/actions.js: -------------------------------------------------------------------------------- 1 | import * as types from 'store/mutation-type.js' 2 | 3 | export const addToCart = ({commit}, product) => { 4 | if (product.inventory > 0) { 5 | commit(types.ADD_TO_CART, product) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/store/mutation-type.js: -------------------------------------------------------------------------------- 1 | export const GET_PRODUCT_LIST = 'GET_PRODUCT_LIST' 2 | export const ADD_TO_CART = 'ADD_TO_CART' 3 | export const DELETE_PRODUCT = 'DELETE_PRODUCT' 4 | export const CHECK_OUT_PRODUCT = 'CHECK_OUT_PRODUCT' 5 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import App from './App.vue'; 3 | import router from './router'; //inclued router/index.js 4 | 5 | new Vue({ 6 | el: '#app', 7 | router, 8 | render: h => h(App) 9 | }); 10 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["es2015", { "modules": false }], 4 | "stage-2" 5 | ], 6 | "plugins": ["transform-runtime"], 7 | "comments": false, 8 | "env": { 9 | "test": { 10 | "plugins": [ "istanbul" ] 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/dev-client.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | require('eventsource-polyfill') 3 | var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true') 4 | 5 | hotClient.subscribe(function (event) { 6 | if (event.action === 'reload') { 7 | window.location.reload() 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import products from 'store/modules/products' 4 | import cart from 'store/modules/cart' 5 | import * as actions from 'store/actions' 6 | 7 | Vue.use(Vuex) 8 | 9 | export default new Vuex.Store({ 10 | actions, 11 | modules: { 12 | products, 13 | cart 14 | } 15 | }) 16 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/test/unit/specs/Hello.spec.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Hello from 'src/components/Hello' 3 | 4 | describe('Hello.vue', () => { 5 | it('should render correct contents', () => { 6 | const Constructor = Vue.extend(Hello) 7 | const vm = new Constructor().$mount() 8 | expect(vm.$el.querySelector('.hello h1').textContent) 9 | .to.equal('Welcome to Your Vue.js App') 10 | }) 11 | }) 12 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue'; 2 | import Router from 'vue-router'; 3 | 4 | Vue.use(Router); 5 | 6 | import SearchResult from '../components/SearchResult.vue'; 7 | 8 | export default new Router({ 9 | mode: 'history', 10 | scrollBehavior: () => ({ y: 0 }), 11 | routes: [ 12 | { path: '/search', component: SearchResult }, 13 | { path: '/', redirect: 'http://localhost:8080/'} 14 | ] 15 | }) -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | vue-ajax-wikipedia-viewer 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import Main from '.././components/Main' 4 | import About from '.././components/About' 5 | 6 | Vue.use(Router) 7 | 8 | export default new Router({ 9 | mode: 'history', 10 | base: __dirname, 11 | routes: [ 12 | { path: '/', redirect: { name: 'Home' } }, 13 | { path: '/home', name: 'Home', component: Main }, 14 | { path: '/about', name: 'About', component: About } 15 | ] 16 | }) 17 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/vue-loader.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var config = require('../config') 3 | var isProduction = process.env.NODE_ENV === 'production' 4 | 5 | module.exports = { 6 | loaders: utils.cssLoaders({ 7 | sourceMap: isProduction 8 | ? config.build.productionSourceMap 9 | : config.dev.cssSourceMap, 10 | extract: isProduction 11 | }), 12 | postcss: [ 13 | require('autoprefixer')({ 14 | browsers: ['last 2 versions'] 15 | }) 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |   7 | vue-vuex-shoppingcart 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/test/unit/index.js: -------------------------------------------------------------------------------- 1 | // Polyfill fn.bind() for PhantomJS 2 | /* eslint-disable no-extend-native */ 3 | Function.prototype.bind = require('function-bind') 4 | 5 | // require all test files (files that ends with .spec.js) 6 | const testsContext = require.context('./specs', true, /\.spec$/) 7 | testsContext.keys().forEach(testsContext) 8 | 9 | // require all src files except main.js for coverage. 10 | // you can also change this to match only the subset of files that 11 | // you want coverage for. 12 | const srcContext = require.context('src', true, /^\.\/(?!main(\.js)?$)/) 13 | srcContext.keys().forEach(srcContext) 14 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/main.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import ElementUI from 'element-ui' 5 | import router from './router' 6 | import store from './store' 7 | 8 | import 'element-ui/lib/theme-default/index.css' 9 | import locale from 'element-ui/lib/locale/lang/en' 10 | 11 | import App from './App' 12 | 13 | Vue.use(ElementUI, { locale }) 14 | /* eslint-disable no-new */ 15 | new Vue({ 16 | el: '#app', 17 | router, 18 | store, 19 | template: '', 20 | components: { App } 21 | }) 22 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/api/products.js: -------------------------------------------------------------------------------- 1 | 2 | const products = [ 3 | {'id': 1, 'title': 'cup-01', 'price': 9.00, 'inventory': 2, 'img': '../static/img/cup.jpg'}, 4 | {'id': 2, 'title': 'cup-02', 'price': 15.00, 'inventory': 5, 'img': '../static/img/animal-cup.jpg'}, 5 | {'id': 3, 'title': 'dish-01', 'price': 20.00, 'inventory': 10, 'img': '../static/img/dish.jpg'}, 6 | {'id': 4, 'title': 'dish-02', 'price': 25.00, 'inventory': 10, 'img': '../static/img/dish-02.jpg'}, 7 | {'id': 5, 'title': 'bottle', 'price': 18.00, 'inventory': 2, 'img': '../static/img/bottle.jpg'} 8 | ] 9 | 10 | export default { 11 | // expose the products API instead the products variable 12 | getAllProducts: () => products 13 | } 14 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/App.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 19 | 20 | 35 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/webpack.test.conf.js: -------------------------------------------------------------------------------- 1 | // This is the webpack config used for unit tests. 2 | 3 | var utils = require('./utils') 4 | var webpack = require('webpack') 5 | var merge = require('webpack-merge') 6 | var baseConfig = require('./webpack.base.conf') 7 | 8 | var webpackConfig = merge(baseConfig, { 9 | // use inline sourcemap for karma-sourcemap-loader 10 | module: { 11 | rules: utils.styleLoaders() 12 | }, 13 | devtool: '#inline-source-map', 14 | plugins: [ 15 | new webpack.DefinePlugin({ 16 | 'process.env': require('../config/test.env') 17 | }) 18 | ] 19 | }) 20 | 21 | // no need for app entry during tests 22 | delete webpackConfig.entry 23 | 24 | module.exports = webpackConfig 25 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/components/AppHeader.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 20 | 21 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/.eslintrc.js: -------------------------------------------------------------------------------- 1 | // http://eslint.org/docs/user-guide/configuring 2 | 3 | module.exports = { 4 | root: true, 5 | parser: 'babel-eslint', 6 | parserOptions: { 7 | sourceType: 'module' 8 | }, 9 | env: { 10 | browser: true, 11 | }, 12 | // https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style 13 | extends: 'standard', 14 | // required to lint *.vue files 15 | plugins: [ 16 | 'html' 17 | ], 18 | // add your custom rules here 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 | } 27 | } 28 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/components/Main.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 26 | 27 | 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vue-demos 2 | This is the repo for vue2.x-demos 3 | 4 | --- 5 | simply-calculator-vuejs | 用vue.js实现简易计算器 6 | 7 | - A simply vue-calculator built by vue2.0 + vue-cli (webpack- simple) 8 | - This demo has been merged into the project : awesome-vue😋 9 | 10 |
11 | vue-ajax-wikipedia-viewer | 利用vue2.0实现简单页面 12 | 13 | - A wikipedia viewer built with vue2.x ,vue-router,vue-cli(webpack-simple) and ajax(jsonp) 14 | - This demo has been merged into the project : awesome-vue😋 15 | 16 |
17 |
18 | ~(≧▽≦)/~ Encourage me a start🌟 if you like it~(≧▽≦)/
19 | ~(≧▽≦)/~ 如果有那么一丁点儿喜欢 请随手🌟~(≧▽≦)/~啦啦啦 20 | 21 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-ajax-wikipedia-viewer", 3 | "description": "A wikipedia viewer built with vue,ajax and element-ui", 4 | "version": "1.0.0", 5 | "author": "CaiYiLiang", 6 | "private": true, 7 | "scripts": { 8 | "dev": "cross-env NODE_ENV=development webpack-dev-server --open --inline --hot", 9 | "build": "cross-env NODE_ENV=production webpack --progress --hide-modules" 10 | }, 11 | "dependencies": { 12 | "vue": "^2.1.0", 13 | "vue-router": "^2.1.3" 14 | }, 15 | "devDependencies": { 16 | "babel-core": "^6.0.0", 17 | "babel-loader": "^6.0.0", 18 | "babel-preset-es2015": "^6.0.0", 19 | "cross-env": "^3.0.0", 20 | "css-loader": "^0.25.0", 21 | "file-loader": "^0.9.0", 22 | "jquery": "^3.1.1", 23 | "vue-loader": "^10.0.0", 24 | "vue-template-compiler": "^2.1.0", 25 | "webpack": "^2.1.0-beta.25", 26 | "webpack-dev-server": "^2.1.0-beta.9" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/App.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 25 | 26 | 47 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/store/modules/products.js: -------------------------------------------------------------------------------- 1 | import productsList from 'api/products' 2 | import * as types from 'store/mutation-type.js' 3 | 4 | const state = { 5 | all: [] 6 | } 7 | 8 | const getters = { 9 | allProducts: state => state.all 10 | } 11 | 12 | const actions = { 13 | getAllProducts ({ commit }) { 14 | commit(types.GET_PRODUCT_LIST, productsList) 15 | } 16 | 17 | } 18 | 19 | const mutations = { 20 | [types.GET_PRODUCT_LIST] (state, productsList) { 21 | state.all = productsList.getAllProducts() 22 | }, 23 | 24 | [types.ADD_TO_CART] (state, product) { 25 | // the find the triiger obj and minus its storage 26 | state.all.find((p) => p.id === product.id).inventory-- 27 | console.log('==types.ADD_TO_CART==') 28 | console.log(state) 29 | }, 30 | 31 | [types.DELETE_PRODUCT] (state, productTitle) { 32 | console.log(' where:product.js ') 33 | state.all.find((p) => p.title === productTitle).inventory++ 34 | } 35 | } 36 | 37 | export default{ 38 | state, 39 | getters, 40 | actions, 41 | mutations 42 | } 43 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/README.md: -------------------------------------------------------------------------------- 1 | # vue-vuex-shoppingcart 2 | 3 | > 利用**vue2.0,vuex,vue-router**实现简单页面
4 | > A shopping cart built with **vue2.x ,vue-router,vue-cli(webpack) and Element-UI**
5 | > 6 | > -When you select/delete items you want to buy , the merchandise inventory account and the bill will change accordingly
7 | > 8 | 9 | # demo 10 |
shopping-cart.vuejs-demo
11 | 12 | ## Build Setup 13 | 14 | ``` bash 15 | # install dependencies 16 | npm install 17 | 18 | # serve with hot reload at localhost:8080 19 | npm run dev 20 | 21 | # build for production with minification 22 | npm run build 23 | 24 | ``` 25 | 26 | For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader). 27 | 28 | ## todo item 29 | - optimize the demo with vue-router 30 | - optimize the demo with vue-transition effect
31 | 32 | ٩(๑>◡<๑)۶ 如果有那么一丁点儿喜欢 请随手🌟ヾ(✿゚▽゚)ノ
33 | ٩(๑>◡<๑)۶ Encourage me a start🌟 if you like itヾ(✿゚▽゚)ノ 34 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/test/unit/karma.conf.js: -------------------------------------------------------------------------------- 1 | // This is a karma config file. For more details see 2 | // http://karma-runner.github.io/0.13/config/configuration-file.html 3 | // we are also using it with karma-webpack 4 | // https://github.com/webpack/karma-webpack 5 | 6 | var webpackConfig = require('../../build/webpack.test.conf') 7 | 8 | module.exports = function (config) { 9 | config.set({ 10 | // to run in additional browsers: 11 | // 1. install corresponding karma launcher 12 | // http://karma-runner.github.io/0.13/config/browsers.html 13 | // 2. add it to the `browsers` array below. 14 | browsers: ['PhantomJS'], 15 | frameworks: ['mocha', 'sinon-chai'], 16 | reporters: ['spec', 'coverage'], 17 | files: ['./index.js'], 18 | preprocessors: { 19 | './index.js': ['webpack', 'sourcemap'] 20 | }, 21 | webpack: webpackConfig, 22 | webpackMiddleware: { 23 | noInfo: true 24 | }, 25 | coverageReporter: { 26 | dir: './coverage', 27 | reporters: [ 28 | { type: 'lcov', subdir: '.' }, 29 | { type: 'text-summary' } 30 | ] 31 | } 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/components/About.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 21 | 22 | 38 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/build.js: -------------------------------------------------------------------------------- 1 | // https://github.com/shelljs/shelljs 2 | require('./check-versions')() 3 | 4 | process.env.NODE_ENV = 'production' 5 | 6 | var ora = require('ora') 7 | var path = require('path') 8 | var chalk = require('chalk') 9 | var shell = require('shelljs') 10 | var webpack = require('webpack') 11 | var config = require('../config') 12 | var webpackConfig = require('./webpack.prod.conf') 13 | 14 | var spinner = ora('building for production...') 15 | spinner.start() 16 | 17 | var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory) 18 | shell.rm('-rf', assetsPath) 19 | shell.mkdir('-p', assetsPath) 20 | shell.config.silent = true 21 | shell.cp('-R', 'static/*', assetsPath) 22 | shell.config.silent = false 23 | 24 | webpack(webpackConfig, function (err, stats) { 25 | spinner.stop() 26 | if (err) throw err 27 | process.stdout.write(stats.toString({ 28 | colors: true, 29 | modules: false, 30 | children: false, 31 | chunks: false, 32 | chunkModules: false 33 | }) + '\n\n') 34 | 35 | console.log(chalk.cyan(' Build complete.\n')) 36 | console.log(chalk.yellow( 37 | ' Tip: built files are meant to be served over an HTTP server.\n' + 38 | ' Opening index.html over file:// won\'t work.\n' 39 | )) 40 | }) 41 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/check-versions.js: -------------------------------------------------------------------------------- 1 | var chalk = require('chalk') 2 | var semver = require('semver') 3 | var packageConfig = require('../package.json') 4 | 5 | function exec (cmd) { 6 | return require('child_process').execSync(cmd).toString().trim() 7 | } 8 | 9 | var versionRequirements = [ 10 | { 11 | name: 'node', 12 | currentVersion: semver.clean(process.version), 13 | versionRequirement: packageConfig.engines.node 14 | }, 15 | { 16 | name: 'npm', 17 | currentVersion: exec('npm --version'), 18 | versionRequirement: packageConfig.engines.npm 19 | } 20 | ] 21 | 22 | module.exports = function () { 23 | var warnings = [] 24 | for (var i = 0; i < versionRequirements.length; i++) { 25 | var mod = versionRequirements[i] 26 | if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) { 27 | warnings.push(mod.name + ': ' + 28 | chalk.red(mod.currentVersion) + ' should be ' + 29 | chalk.green(mod.versionRequirement) 30 | ) 31 | } 32 | } 33 | 34 | if (warnings.length) { 35 | console.log('') 36 | console.log(chalk.yellow('To use this template, you must update following to modules:')) 37 | console.log() 38 | for (var i = 0; i < warnings.length; i++) { 39 | var warning = warnings[i] 40 | console.log(' ' + warning) 41 | } 42 | console.log() 43 | process.exit(1) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/webpack.dev.conf.js: -------------------------------------------------------------------------------- 1 | var utils = require('./utils') 2 | var webpack = require('webpack') 3 | var config = require('../config') 4 | var merge = require('webpack-merge') 5 | var baseWebpackConfig = require('./webpack.base.conf') 6 | var HtmlWebpackPlugin = require('html-webpack-plugin') 7 | var FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin') 8 | 9 | // add hot-reload related code to entry chunks 10 | Object.keys(baseWebpackConfig.entry).forEach(function (name) { 11 | baseWebpackConfig.entry[name] = ['./build/dev-client'].concat(baseWebpackConfig.entry[name]) 12 | }) 13 | 14 | module.exports = merge(baseWebpackConfig, { 15 | module: { 16 | rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap }) 17 | }, 18 | // cheap-module-eval-source-map is faster for development 19 | devtool: '#cheap-module-eval-source-map', 20 | plugins: [ 21 | new webpack.DefinePlugin({ 22 | 'process.env': config.dev.env 23 | }), 24 | // https://github.com/glenjamin/webpack-hot-middleware#installation--usage 25 | new webpack.HotModuleReplacementPlugin(), 26 | new webpack.NoEmitOnErrorsPlugin(), 27 | // https://github.com/ampedandwired/html-webpack-plugin 28 | new HtmlWebpackPlugin({ 29 | filename: 'index.html', 30 | template: 'index.html', 31 | inject: true 32 | }), 33 | new FriendlyErrorsPlugin() 34 | ] 35 | }) 36 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/store/modules/cart.js: -------------------------------------------------------------------------------- 1 | import * as types from 'store/mutation-type.js' 2 | 3 | const state = { 4 | added: [], 5 | checkoutStatus: null 6 | } 7 | 8 | const getters = { 9 | getAddedProducts: state => state.added, 10 | getTotalQuantity: state => state.added.length > 0 ? state.added.map(addedProduct => addedProduct.quantity).reduce((prev, curr) => prev + curr, 0) : 0, 11 | getTotalPrice: state => state.added.length > 0 ? state.added.map(addedProduct => addedProduct.quantity * addedProduct.price).reduce((prev, curr) => prev + curr, 0) : 0 12 | } 13 | 14 | const mutations = { 15 | [types.ADD_TO_CART] (state, product) { 16 | // the find the triiger obj and minus its storage 17 | let record = state.added.find((p) => p.id === product.id) 18 | if (!record) { 19 | state.added.push({ 20 | 'id': product.id, 21 | 'title': product.title, 22 | 'quantity': 1, 23 | 'price': product.price 24 | }) 25 | } else { record.quantity++ } 26 | }, 27 | 28 | [types.DELETE_PRODUCT] (state, productTitle) { 29 | let index = state.added.findIndex((p) => p.title === productTitle) 30 | if (index !== -1) { 31 | state.added[index].quantity-- 32 | if (state.added[index].quantity === 0) { 33 | state.added.splice(index, 1) 34 | } 35 | } 36 | } 37 | } 38 | 39 | export default{ 40 | state, 41 | getters, 42 | mutations 43 | } 44 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/README.md: -------------------------------------------------------------------------------- 1 | # vue-ajax-wikipedia-viewer 2 | 3 | > 利用vue2.0实现简单页面
4 | > A wikipedia viewer built with vue2.x ,vue-router,vue-cli(webpack-simple) and ajax(jsonp)
5 | > -Yuo can click a button to see a random Wikipedia entry.
6 | > -Yuo can search Wikipedia entries in a search box and see the results.
7 | 8 | Grade that this demo has been merged into the project :awesome-vue:yum:
9 | And also here is another vue demo simply-calculator-vuejs ,which is merged into the project :awesome-vue:yum: 10 | 11 | 12 | # demo 13 | wikipedia-viewer.vuejs-demo 14 | 15 | 16 | 17 | ## Build Setup 18 | 19 | ``` bash 20 | # install dependencies 21 | npm install 22 | 23 | # serve with hot reload at localhost:8080 24 | npm run dev 25 | 26 | # build for production with minification 27 | npm run build 28 | ``` 29 | 30 | For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader). 31 | 32 | #todo item 33 | - optimize the demo with vue-router 34 | - optimize the demo with vue-transition effect 35 |
36 | 37 | ~(≧▽≦)/~ 如果有那么一丁点儿喜欢 请随手🌟~(≧▽≦)/~啦啦啦
38 | ~(≧▽≦)/~ Encourage me a start🌟 if you like it~(≧▽≦)/ 39 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/components/SearchResult.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 33 | 34 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/components/AppFooter.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 29 | 30 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/config/index.js: -------------------------------------------------------------------------------- 1 | // see http://vuejs-templates.github.io/webpack for documentation. 2 | var path = require('path') 3 | 4 | module.exports = { 5 | build: { 6 | env: require('./prod.env'), 7 | index: path.resolve(__dirname, '../dist/index.html'), 8 | assetsRoot: path.resolve(__dirname, '../dist'), 9 | assetsSubDirectory: 'static', 10 | assetsPublicPath: '/', 11 | productionSourceMap: true, 12 | // Gzip off by default as many popular static hosts such as 13 | // Surge or Netlify already gzip all static assets for you. 14 | // Before setting to `true`, make sure to: 15 | // npm install --save-dev compression-webpack-plugin 16 | productionGzip: false, 17 | productionGzipExtensions: ['js', 'css'], 18 | // Run the build command with an extra argument to 19 | // View the bundle analyzer report after build finishes: 20 | // `npm run build --report` 21 | // Set to `true` or `false` to always turn it on or off 22 | bundleAnalyzerReport: process.env.npm_config_report 23 | }, 24 | dev: { 25 | env: require('./dev.env'), 26 | port: 8080, 27 | autoOpenBrowser: true, 28 | assetsSubDirectory: 'static', 29 | assetsPublicPath: '/', 30 | proxyTable: {}, 31 | // CSS Sourcemaps off by default because relative paths are "buggy" 32 | // with this option, according to the CSS-Loader README 33 | // (https://github.com/webpack/css-loader#sourcemaps) 34 | // In our experience, they generally work as expected, 35 | // just be aware of this issue when enabling this option. 36 | cssSourceMap: false 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/webpack.base.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var config = require('../config') 4 | var vueLoaderConfig = require('./vue-loader.conf') 5 | 6 | function resolve (dir) { 7 | return path.join(__dirname, '..', dir) 8 | } 9 | 10 | module.exports = { 11 | entry: { 12 | app: './src/main.js' 13 | }, 14 | output: { 15 | path: config.build.assetsRoot, 16 | filename: '[name].js', 17 | publicPath: process.env.NODE_ENV === 'production' 18 | ? config.build.assetsPublicPath 19 | : config.dev.assetsPublicPath 20 | }, 21 | resolve: { 22 | extensions: ['.js', '.vue', '.json'], 23 | modules: [ 24 | resolve('src'), 25 | resolve('node_modules') 26 | ], 27 | alias: { 28 | 'vue$': 'vue/dist/vue.common.js', 29 | 'src': resolve('src'), 30 | 'assets': resolve('src/assets'), 31 | 'components': resolve('src/components'), 32 | 'api': resolve('src/api'), 33 | 'store': resolve('src/store') 34 | } 35 | }, 36 | module: { 37 | rules: [ 38 | { 39 | test: /\.(js|vue)$/, 40 | loader: 'eslint-loader', 41 | enforce: "pre", 42 | include: [resolve('src'), resolve('test')], 43 | options: { 44 | formatter: require('eslint-friendly-formatter') 45 | } 46 | }, 47 | { 48 | test: /\.vue$/, 49 | loader: 'vue-loader', 50 | options: vueLoaderConfig 51 | }, 52 | { 53 | test: /\.js$/, 54 | loader: 'babel-loader', 55 | include: [resolve('src'), resolve('test')] 56 | }, 57 | { 58 | test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, 59 | loader: 'url-loader', 60 | query: { 61 | limit: 10000, 62 | name: utils.assetsPath('img/[name].[hash:7].[ext]') 63 | } 64 | }, 65 | { 66 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 67 | loader: 'url-loader', 68 | query: { 69 | limit: 10000, 70 | name: utils.assetsPath('fonts/[name].[hash:7].[ext]') 71 | } 72 | } 73 | ] 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var webpack = require('webpack') 3 | // npm install jquery --save 4 | 5 | module.exports = { 6 | entry: './src/main.js', 7 | output: { 8 | path: path.resolve(__dirname, './dist'), 9 | publicPath: '/dist/', 10 | filename: 'build.js' 11 | }, 12 | module: { 13 | rules: [ 14 | { 15 | test: /\.vue$/, 16 | loader: 'vue-loader', 17 | options: { 18 | loaders: { 19 | // Since sass-loader (weirdly) has SCSS as its default parse mode, we map 20 | // the "scss" and "sass" values for the lang attribute to the right configs here. 21 | // other preprocessors should work out of the box, no loader config like this nessessary. 22 | 'scss': 'vue-style-loader!css-loader!sass-loader', 23 | 'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax' 24 | } 25 | // other vue-loader options go here 26 | } 27 | }, 28 | { 29 | test: /\.js$/, 30 | loader: 'babel-loader', 31 | exclude: /node_modules/ 32 | }, 33 | { 34 | test: /\.(png|jpg|gif|svg)$/, 35 | loader: 'file-loader', 36 | options: { 37 | name: '[name].[ext]?[hash]' 38 | } 39 | } 40 | ] 41 | }, 42 | resolve: { 43 | alias: { 44 | 'vue$': 'vue/dist/vue.common.js', 45 | "components":"./components" 46 | } 47 | }, 48 | devServer: { 49 | historyApiFallback: true, 50 | noInfo: true 51 | }, 52 | performance: { 53 | hints: false 54 | }, 55 | devtool: '#eval-source-map' 56 | } 57 | 58 | if (process.env.NODE_ENV === 'production') { 59 | module.exports.devtool = '#source-map' 60 | // http://vue-loader.vuejs.org/en/workflow/production.html 61 | module.exports.plugins = (module.exports.plugins || []).concat([ 62 | new webpack.DefinePlugin({ 63 | 'process.env': { 64 | NODE_ENV: '"production"' 65 | } 66 | }), 67 | new webpack.optimize.UglifyJsPlugin({ 68 | sourceMap: true, 69 | compress: { 70 | warnings: false 71 | } 72 | }), 73 | new webpack.LoaderOptionsPlugin({ 74 | minimize: true 75 | }) 76 | ]) 77 | } 78 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/utils.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var config = require('../config') 3 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 4 | 5 | exports.assetsPath = function (_path) { 6 | var assetsSubDirectory = process.env.NODE_ENV === 'production' 7 | ? config.build.assetsSubDirectory 8 | : config.dev.assetsSubDirectory 9 | return path.posix.join(assetsSubDirectory, _path) 10 | } 11 | 12 | exports.cssLoaders = function (options) { 13 | options = options || {} 14 | // generate loader string to be used with extract text plugin 15 | function generateLoaders (loaders) { 16 | var sourceLoader = loaders.map(function (loader) { 17 | var extraParamChar 18 | if (/\?/.test(loader)) { 19 | loader = loader.replace(/\?/, '-loader?') 20 | extraParamChar = '&' 21 | } else { 22 | loader = loader + '-loader' 23 | extraParamChar = '?' 24 | } 25 | return loader + (options.sourceMap ? extraParamChar + 'sourceMap' : '') 26 | }).join('!') 27 | 28 | // Extract CSS when that option is specified 29 | // (which is the case during production build) 30 | if (options.extract) { 31 | return ExtractTextPlugin.extract({ 32 | use: sourceLoader, 33 | fallback: 'vue-style-loader' 34 | }) 35 | } else { 36 | return ['vue-style-loader', sourceLoader].join('!') 37 | } 38 | } 39 | 40 | // http://vuejs.github.io/vue-loader/en/configurations/extract-css.html 41 | return { 42 | css: generateLoaders(['css']), 43 | postcss: generateLoaders(['css']), 44 | less: generateLoaders(['css', 'less']), 45 | sass: generateLoaders(['css', 'sass?indentedSyntax']), 46 | scss: generateLoaders(['css', 'sass']), 47 | stylus: generateLoaders(['css', 'stylus']), 48 | styl: generateLoaders(['css', 'stylus']) 49 | } 50 | } 51 | 52 | // Generate loaders for standalone style files (outside of .vue) 53 | exports.styleLoaders = function (options) { 54 | var output = [] 55 | var loaders = exports.cssLoaders(options) 56 | for (var extension in loaders) { 57 | var loader = loaders[extension] 58 | output.push({ 59 | test: new RegExp('\\.' + extension + '$'), 60 | loader: loader 61 | }) 62 | } 63 | return output 64 | } 65 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/components/Nav.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 20 | 21 | 91 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/dev-server.js: -------------------------------------------------------------------------------- 1 | require('./check-versions')() 2 | 3 | var config = require('../config') 4 | if (!process.env.NODE_ENV) { 5 | process.env.NODE_ENV = JSON.parse(config.dev.env.NODE_ENV) 6 | } 7 | 8 | var opn = require('opn') 9 | var path = require('path') 10 | var express = require('express') 11 | var webpack = require('webpack') 12 | var proxyMiddleware = require('http-proxy-middleware') 13 | var webpackConfig = process.env.NODE_ENV === 'testing' 14 | ? require('./webpack.prod.conf') 15 | : require('./webpack.dev.conf') 16 | 17 | // default port where dev server listens for incoming traffic 18 | var port = process.env.PORT || config.dev.port 19 | // automatically open browser, if not set will be false 20 | var autoOpenBrowser = !!config.dev.autoOpenBrowser 21 | // Define HTTP proxies to your custom API backend 22 | // https://github.com/chimurai/http-proxy-middleware 23 | var proxyTable = config.dev.proxyTable 24 | 25 | var app = express() 26 | var compiler = webpack(webpackConfig) 27 | 28 | var devMiddleware = require('webpack-dev-middleware')(compiler, { 29 | publicPath: webpackConfig.output.publicPath, 30 | quiet: true 31 | }) 32 | 33 | var hotMiddleware = require('webpack-hot-middleware')(compiler, { 34 | log: () => {} 35 | }) 36 | // force page reload when html-webpack-plugin template changes 37 | compiler.plugin('compilation', function (compilation) { 38 | compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) { 39 | hotMiddleware.publish({ action: 'reload' }) 40 | cb() 41 | }) 42 | }) 43 | 44 | // proxy api requests 45 | Object.keys(proxyTable).forEach(function (context) { 46 | var options = proxyTable[context] 47 | if (typeof options === 'string') { 48 | options = { target: options } 49 | } 50 | app.use(proxyMiddleware(options.filter || context, options)) 51 | }) 52 | 53 | // handle fallback for HTML5 history API 54 | app.use(require('connect-history-api-fallback')()) 55 | 56 | // serve webpack bundle output 57 | app.use(devMiddleware) 58 | 59 | // enable hot-reload and state-preserving 60 | // compilation error display 61 | app.use(hotMiddleware) 62 | 63 | // serve pure static assets 64 | var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory) 65 | app.use(staticPath, express.static('./static')) 66 | 67 | var uri = 'http://localhost:' + port 68 | 69 | devMiddleware.waitUntilValid(function () { 70 | console.log('> Listening at ' + uri + '\n') 71 | }) 72 | 73 | module.exports = app.listen(port, function (err) { 74 | if (err) { 75 | console.log(err) 76 | return 77 | } 78 | 79 | // when env is testing, don't need open it 80 | if (autoOpenBrowser && process.env.NODE_ENV !== 'testing') { 81 | opn(uri) 82 | } 83 | }) 84 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-vuex-shoppingcart", 3 | "version": "1.0.0", 4 | "description": "A vue2.x project - shopping cart", 5 | "author": "CaiYiLiang", 6 | "private": true, 7 | "scripts": { 8 | "dev": "node build/dev-server.js", 9 | "build": "node build/build.js", 10 | "unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run", 11 | "test": "npm run unit", 12 | "lint": "eslint --ext .js,.vue src test/unit/specs" 13 | }, 14 | "dependencies": { 15 | "element-ui": "^1.1.6", 16 | "vue": "^2.1.10", 17 | "vue-router": "^2.2.0", 18 | "vuex": "^2.1.2" 19 | }, 20 | "devDependencies": { 21 | "autoprefixer": "^6.7.2", 22 | "babel-core": "^6.22.1", 23 | "babel-eslint": "^7.1.1", 24 | "babel-loader": "^6.2.10", 25 | "babel-plugin-transform-runtime": "^6.22.0", 26 | "babel-preset-es2015": "^6.22.0", 27 | "babel-preset-stage-2": "^6.22.0", 28 | "babel-register": "^6.22.0", 29 | "chalk": "^1.1.3", 30 | "connect-history-api-fallback": "^1.3.0", 31 | "css-loader": "^0.26.1", 32 | "eslint": "^3.14.1", 33 | "eslint-friendly-formatter": "^2.0.7", 34 | "eslint-loader": "^1.6.1", 35 | "eslint-plugin-html": "^2.0.0", 36 | "eslint-config-standard": "^6.2.1", 37 | "eslint-plugin-promise": "^3.4.0", 38 | "eslint-plugin-standard": "^2.0.1", 39 | "eventsource-polyfill": "^0.9.6", 40 | "express": "^4.14.1", 41 | "extract-text-webpack-plugin": "^2.0.0-rc.2", 42 | "file-loader": "^0.10.0", 43 | "friendly-errors-webpack-plugin": "^1.1.3", 44 | "function-bind": "^1.1.0", 45 | "html-webpack-plugin": "^2.28.0", 46 | "http-proxy-middleware": "^0.17.3", 47 | "webpack-bundle-analyzer": "^2.2.1", 48 | "cross-env": "^3.1.4", 49 | "karma": "^1.4.1", 50 | "karma-coverage": "^1.1.1", 51 | "karma-mocha": "^1.3.0", 52 | "karma-phantomjs-launcher": "^1.0.2", 53 | "karma-sinon-chai": "^1.2.4", 54 | "karma-sourcemap-loader": "^0.3.7", 55 | "karma-spec-reporter": "0.0.26", 56 | "karma-webpack": "^2.0.2", 57 | "lolex": "^1.5.2", 58 | "mocha": "^3.2.0", 59 | "chai": "^3.5.0", 60 | "sinon": "^1.17.7", 61 | "sinon-chai": "^2.8.0", 62 | "inject-loader": "^2.0.1", 63 | "babel-plugin-istanbul": "^3.1.2", 64 | "phantomjs-prebuilt": "^2.1.14", 65 | "semver": "^5.3.0", 66 | "opn": "^4.0.2", 67 | "ora": "^1.1.0", 68 | "shelljs": "^0.7.6", 69 | "url-loader": "^0.5.7", 70 | "vue-loader": "^10.3.0", 71 | "vue-style-loader": "^2.0.0", 72 | "vue-template-compiler": "^2.1.10", 73 | "webpack": "^2.2.1", 74 | "webpack-dev-middleware": "^1.10.0", 75 | "webpack-hot-middleware": "^2.16.1", 76 | "webpack-merge": "^2.6.1" 77 | }, 78 | "engines": { 79 | "node": ">= 4.0.0", 80 | "npm": ">= 3.0.0" 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/components/Cart.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | 54 | 55 | 132 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/src/components/Products.vue: -------------------------------------------------------------------------------- 1 | 24 | 25 | 43 | 44 | 172 | -------------------------------------------------------------------------------- /shoppingcart-vuejs/build/webpack.prod.conf.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var utils = require('./utils') 3 | var webpack = require('webpack') 4 | var config = require('../config') 5 | var merge = require('webpack-merge') 6 | var baseWebpackConfig = require('./webpack.base.conf') 7 | var HtmlWebpackPlugin = require('html-webpack-plugin') 8 | var ExtractTextPlugin = require('extract-text-webpack-plugin') 9 | var env = process.env.NODE_ENV === 'testing' 10 | ? require('../config/test.env') 11 | : config.build.env 12 | 13 | var webpackConfig = merge(baseWebpackConfig, { 14 | module: { 15 | rules: utils.styleLoaders({ 16 | sourceMap: config.build.productionSourceMap, 17 | extract: true 18 | }) 19 | }, 20 | devtool: config.build.productionSourceMap ? '#source-map' : false, 21 | output: { 22 | path: config.build.assetsRoot, 23 | filename: utils.assetsPath('js/[name].[chunkhash].js'), 24 | chunkFilename: utils.assetsPath('js/[id].[chunkhash].js') 25 | }, 26 | plugins: [ 27 | // http://vuejs.github.io/vue-loader/en/workflow/production.html 28 | new webpack.DefinePlugin({ 29 | 'process.env': env 30 | }), 31 | new webpack.optimize.UglifyJsPlugin({ 32 | compress: { 33 | warnings: false 34 | }, 35 | sourceMap: true 36 | }), 37 | // extract css into its own file 38 | new ExtractTextPlugin({ 39 | filename: utils.assetsPath('css/[name].[contenthash].css') 40 | }), 41 | // generate dist index.html with correct asset hash for caching. 42 | // you can customize output by editing /index.html 43 | // see https://github.com/ampedandwired/html-webpack-plugin 44 | new HtmlWebpackPlugin({ 45 | filename: process.env.NODE_ENV === 'testing' 46 | ? 'index.html' 47 | : config.build.index, 48 | template: 'index.html', 49 | inject: true, 50 | minify: { 51 | removeComments: true, 52 | collapseWhitespace: true, 53 | removeAttributeQuotes: true 54 | // more options: 55 | // https://github.com/kangax/html-minifier#options-quick-reference 56 | }, 57 | // necessary to consistently work with multiple chunks via CommonsChunkPlugin 58 | chunksSortMode: 'dependency' 59 | }), 60 | // split vendor js into its own file 61 | new webpack.optimize.CommonsChunkPlugin({ 62 | name: 'vendor', 63 | minChunks: function (module, count) { 64 | // any required modules inside node_modules are extracted to vendor 65 | return ( 66 | module.resource && 67 | /\.js$/.test(module.resource) && 68 | module.resource.indexOf( 69 | path.join(__dirname, '../node_modules') 70 | ) === 0 71 | ) 72 | } 73 | }), 74 | // extract webpack runtime and module manifest to its own file in order to 75 | // prevent vendor hash from being updated whenever app bundle is updated 76 | new webpack.optimize.CommonsChunkPlugin({ 77 | name: 'manifest', 78 | chunks: ['vendor'] 79 | }) 80 | ] 81 | }) 82 | 83 | if (config.build.productionGzip) { 84 | var CompressionWebpackPlugin = require('compression-webpack-plugin') 85 | 86 | webpackConfig.plugins.push( 87 | new CompressionWebpackPlugin({ 88 | asset: '[path].gz[query]', 89 | algorithm: 'gzip', 90 | test: new RegExp( 91 | '\\.(' + 92 | config.build.productionGzipExtensions.join('|') + 93 | ')$' 94 | ), 95 | threshold: 10240, 96 | minRatio: 0.8 97 | }) 98 | ) 99 | } 100 | 101 | if (config.build.bundleAnalyzerReport) { 102 | var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin 103 | webpackConfig.plugins.push(new BundleAnalyzerPlugin()) 104 | } 105 | 106 | module.exports = webpackConfig 107 | -------------------------------------------------------------------------------- /wikipediaViewer-vuejs/src/components/WikipediaViewer.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 99 | 100 | --------------------------------------------------------------------------------