Selaa lähdekoodia

adapt to latest vue-cli

Junx 7 vuotta sitten
vanhempi
sitoutus
7ad72e9c23
6 muutettua tiedostoa jossa 135 lisäystä ja 71 poistoa
  1. 0 9
      build/dev-client.js
  2. 0 58
      build/dev-server.js
  3. 25 0
      build/webpack.dev.conf.js
  4. 1 3
      config/index.js
  5. 0 1
      package.json
  6. 109 0
      update.md

+ 0 - 9
build/dev-client.js

@@ -1,9 +0,0 @@
-/* eslint-disable */
-require('eventsource-polyfill')
-var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
-
-hotClient.subscribe(function (event) {
-  if (event.action === 'reload') {
-    window.location.reload()
-  }
-})

+ 0 - 58
build/dev-server.js

@@ -1,58 +0,0 @@
-require('./check-versions')()
-var config = require('../config')
-var path = require('path')
-var express = require('express')
-var opn = require('opn')
-
-// default port where dev server listens for incoming traffic
-var port = '8088'
-
-var app = express()
-
-var appData = require('../data.json')
-var seller = appData.seller
-var goods = appData.goods
-var ratings = appData.ratings
-
-var apiRoutes = express.Router()
-
-apiRoutes.get('/seller', function (req, res) {
-  res.json({
-    errno: 0,
-    data: seller
-  });
-})
-
-apiRoutes.get('/goods', function (req, res) {
-  res.json({
-    errno: 0,
-    data: goods
-  })
-})
-
-apiRoutes.get('/ratings', function (req, res) {
-  res.json({
-    errno: 0,
-    data: ratings
-  });
-})
-
-app.use('/api', apiRoutes)
-
-// handle fallback for HTML5 history API
-app.use(require('connect-history-api-fallback')())
-
-var uri = 'http://0.0.0.0:' + port
-
-module.exports = app.listen(port, function (err) {
-  console.log('> Listening at ' + uri + '\n')
-  if (err) {
-    console.log(err)
-    return
-  }
-
-  // when env is testing, don't need open it
-  // if (process.env.NODE_ENV !== 'testing') {
-  //   opn(uri)
-  // }
-})

+ 25 - 0
build/webpack.dev.conf.js

@@ -8,6 +8,11 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
 const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
 const portfinder = require('portfinder')
 
+const appData = require('../data.json')
+const seller = appData.seller
+const goods = appData.goods
+const ratings = appData.ratings
+
 const devWebpackConfig = merge(baseWebpackConfig, {
   module: {
     rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
@@ -17,6 +22,26 @@ const devWebpackConfig = merge(baseWebpackConfig, {
   
   // these devServer options should be customized in /config/index.js
   devServer: {
+    before(app) {
+      app.get('/api/seller', function(req, res) {
+        res.json({
+          errno: 0,
+          data: seller
+        })
+      });
+      app.get('/api/goods', function(req, res) {
+        res.json({
+          errno: 0,
+          data: goods
+        })
+      });
+      app.get('/api/ratings', function(req, res) {
+        res.json({
+          errno: 0,
+          data: ratings
+        })
+      });
+    },
     clientLogLevel: 'warning',
     historyApiFallback: true,
     hot: true,

+ 1 - 3
config/index.js

@@ -10,9 +10,7 @@ module.exports = {
     // Paths
     assetsSubDirectory: 'static',
     assetsPublicPath: '/',
-    proxyTable: {
-        '/api': 'http://localhost:8088'
-    },
+    proxyTable: {},
     // Various Dev Server settings
     host: '0.0.0.0', // can be overwritten by process.env.HOST
     port: 8080, // can be overwritten by process.env.HOST, if port is in use, a free one will be determined

+ 0 - 1
package.json

@@ -6,7 +6,6 @@
   "private": true,
   "scripts": {
     "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
-    "server": "node build/dev-server.js",
     "start": "npm run dev",
     "lint": "eslint --ext .js,.vue src",
     "build": "node build/build.js"

+ 109 - 0
update.md

@@ -0,0 +1,109 @@
+更新说明
+===================
+
+
+使vue-sell项目适配最新的vue-cli
+
+----------
+
+
+更新内容
+-------------
+
+
+####1.安装vue-resource  better-scroll
+```
+cnpm install vue-resource better-scroll --save
+```
+
+####2.安装stylus stylus-loader 
+```
+cnpm install stylus stylus-loader --save-dev
+```
+
+####3.设置缩略路径
+>build/webapck.base.conf.js
+```
+    {
+        'src': path.resolve(__dirname, '../src'),
+        'common': path.resolve(__dirname, '../src/common'),
+        'components': path.resolve(__dirname, '../src/components')
+    }
+```
+
+####4.修改.eslintrc.js 添加规则
+>/.eslintrc.js
+```
+    'semi': ['error', 'always'],
+    'no-tabs': 0,
+    'indent': 0,
+    'space-before-function-paren': 0
+```
+
+
+
+####5.http://eslint.org/docs/rules/no-multiple-empty-lines  Too many blank lines at the end of file. Max of 0 allowed src\App.vue:52:1   App.vue报错
+
+.eslintrc.js 添加规则
+>/.eslintrc.js
+```
+    'no-multiple-empty-lines': ["error", { "max": 2, "maxBOF": 1}]
+```
+
+
+####6.修改config目录下的index.js文件
+
+修改host
+>/config/index.js
+```
+host: '0.0.0.0'
+```
+
+
+####7.删除dev-server.js文件,使用webpack内置的devServer,设置before()
+>/build/webpack.dev.conf.js
+```
+devServer: {
+    before(app) {
+      app.get('/api/seller', function(req, res) {
+        res.json({
+          errno: 0,
+          data: seller
+        })
+      });
+      app.get('/api/goods', function(req, res) {
+        res.json({
+          errno: 0,
+          data: goods
+        })
+      });
+      app.get('/api/ratings', function(req, res) {
+        res.json({
+          errno: 0,
+          data: ratings
+        })
+      });
+    },
+    ```````
+    ```````
+}
+```
+
+
+####8.路由栏     商品 评论 商家   的下划线消失了
+修改文件样式
+>/src/App.vue
+ 
+ 将.tab 选择器下的
+```
+border-1px(rgba(7, 17, 27, 0.1))
+```
+移到注释
+```
+//border-bottom: 1px solid rgba(7, 17, 27, 0.1)
+```
+之前
+
+
+####9.从App.vue提取路由
+>/src/router/index.js