Skip to content

Commit

Permalink
Revert "Vue2.0 mikelkl"
Browse files Browse the repository at this point in the history
  • Loading branch information
MeCKodo authored Nov 19, 2016
1 parent 3c22539 commit 8bc0987
Show file tree
Hide file tree
Showing 28 changed files with 322 additions and 556 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.vue files
Expand All @@ -14,8 +10,6 @@ module.exports = {
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
node_modules/
dist/
npm-debug.log
selenium-debug.log
test/unit/coverage
test/e2e/reports
selenium-debug.log

# WebStorm
.idea
45 changes: 17 additions & 28 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//app.js
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var morgan = require('morgan');
var ObjectID = require('mongodb').ObjectID

var MongoClient = require('mongodb').MongoClient;
var mongoUrl = 'mongodb://localhost:27017/mission';
Expand Down Expand Up @@ -36,30 +36,22 @@ app.all("*", function (req, res, next) {
}
});

//app.js
var ObjectID = require('mongodb').ObjectID

//获取总时长
app.get('/time', function(req, res, next) {
//获取数据表
var collection = _db.collection('my_mission');
var time = 0;
//查询出所有计划
collection.find({}).toArray(function (err, ret) {
if(err) {
console.error(err);
return;
}
//所有计划累加时长

ret.forEach(function (item, index) {
time += +item.totalTime;
});
//返回时长
res.json({errcode:0,errmsg:"ok",time:time});
});
});

//获取列表
app.get('/time-entries', function(req, res, next) {
var collection = _db.collection('my_mission');
collection.find({}).toArray(function (err, ret) {
Expand All @@ -71,13 +63,16 @@ app.get('/time-entries', function(req, res, next) {
});
});

//删除计划
app.delete('/delete/:id', function (req, res, next) {
var _id = req.params.id;
app.post('/create', function(req, res, next) {
var mission = req.body;
var collection = _db.collection('my_mission');
console.log(_id)
//使用mongodb的唯一ObjectId字段查找出对应id删除记录
collection.remove({_id: new ObjectID(_id)} ,function (err, result) {

if(!mission.comment || !mission.totalTime || !mission.date) {
res.send({errcode:-1,errmsg:"params missed"});
return;
}

collection.insert({comment: mission.comment, totalTime: mission.totalTime,date:mission.date}, function (err, ret) {
if(err) {
console.error(err);
res.status(500).end();
Expand All @@ -87,19 +82,11 @@ app.delete('/delete/:id', function (req, res, next) {
});
});

//使用post方法
app.post('/create', function(req, res, next) {
//接收前端发送的字段
var mission = req.body;
//选择一个表my_mission 此时没有没关系,也会自动创建
app.delete('/delete/:id', function (req, res, next) {
var _id = req.params.id;
var collection = _db.collection('my_mission');
//如果我们需要的字段不存在,返回前端信息
if(!mission.comment || !mission.totalTime || !mission.date) {
res.send({errcode:-1,errmsg:"params missed"});
return;
}
//如果存在就插入数据库,返回OK
collection.insert({comment: mission.comment, totalTime: mission.totalTime,date:mission.date}, function (err, ret) {
console.log(_id)
collection.remove({_id: new ObjectID(_id)} ,function (err, result) {
if(err) {
console.error(err);
res.status(500).end();
Expand All @@ -108,3 +95,5 @@ app.post('/create', function(req, res, next) {
}
});
});


2 changes: 1 addition & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spinner.start()
var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
rm('-rf', assetsPath)
mkdir('-p', assetsPath)
cp('-R', 'static/*', assetsPath)
cp('-R', 'static/', assetsPath)

webpack(webpackConfig, function (err, stats) {
spinner.stop()
Expand Down
1 change: 0 additions & 1 deletion build/dev-client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')

Expand Down
7 changes: 2 additions & 5 deletions build/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var path = require('path')
var express = require('express')
var webpack = require('webpack')
var config = require('../config')
var opn = require('opn')
var proxyMiddleware = require('http-proxy-middleware')
var webpackConfig = process.env.NODE_ENV === 'testing'
? require('./webpack.prod.conf')
Expand Down Expand Up @@ -54,15 +53,13 @@ app.use(devMiddleware)
app.use(hotMiddleware)

// serve pure static assets
var staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory)
var staticPath = path.join(config.build.assetsPublicPath, config.build.assetsSubDirectory)
app.use(staticPath, express.static('./static'))

module.exports = app.listen(port, function (err) {
if (err) {
console.log(err)
return
}
var uri = 'http://localhost:' + port
console.log('Listening at ' + uri + '\n')
opn(uri)
console.log('Listening at http://localhost:' + port + '\n')
})
59 changes: 0 additions & 59 deletions build/utils.js

This file was deleted.

65 changes: 33 additions & 32 deletions build/webpack.base.conf.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
var path = require('path')
var config = require('../config')
var utils = require('./utils')
var cssLoaders = require('./css-loaders')
var projectRoot = path.resolve(__dirname, '../')
var ExtractTextPlugin = require('extract-text-webpack-plugin')

module.exports = {
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
publicPath: config.build.assetsPublicPath,
filename: '[name].js'
},
resolve: {
extensions: ['', '.js', '.vue'],
fallback: [path.join(__dirname, '../node_modules')],
alias: {
'vue': 'vue/dist/vue.common.js',
'src': path.resolve(__dirname, '../src'),
'assets': path.resolve(__dirname, '../src/assets'),
'components': path.resolve(__dirname, '../src/components')
Expand All @@ -26,62 +26,63 @@ module.exports = {
fallback: [path.join(__dirname, '../node_modules')]
},
module: {
preLoaders: [
{
test: /\.vue$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.js$/,
loader: 'eslint',
include: projectRoot,
exclude: /node_modules/
}
],
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.css$/,
loader: "style!css"
},
{
test: /\.js$/,
loader: 'babel',
include: projectRoot,
exclude: /node_modules/
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
test: /\.(png|jpg)$/,
loader: 'url',
query: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
name: '[name].[ext]?[hash:10]'
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url',
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url",
query: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
name: '[name].[ext]?mimetype=image/svg+xml'
}
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: "url-loader?limit=10000&minetype=application/font-woff"
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url",
query: {
name: '[name].[ext]?mimetype=application/font-woff2'
}
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "url",
query: {
name: '[name].[ext]?mimetype=application/font-woff2'
}
}
]
},
vue: {
loaders: cssLoaders()
},
eslint: {
formatter: require('eslint-friendly-formatter')
},
vue: {
loaders: utils.cssLoaders(),
postcss: [
require('autoprefixer')({
browsers: ['last 2 versions']
})
]
}
}
12 changes: 4 additions & 8 deletions build/webpack.dev.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var config = require('../config')
var webpack = require('webpack')
var merge = require('webpack-merge')
var utils = require('./utils')
var baseWebpackConfig = require('./webpack.base.conf')
var HtmlWebpackPlugin = require('html-webpack-plugin')

Expand All @@ -11,15 +9,9 @@ Object.keys(baseWebpackConfig.entry).forEach(function (name) {
})

module.exports = merge(baseWebpackConfig, {
module: {
loaders: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap })
},
// eval-source-map is faster for development
devtool: '#eval-source-map',
plugins: [
new webpack.DefinePlugin({
'process.env': config.dev.env
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.HotModuleReplacementPlugin(),
Expand All @@ -29,6 +21,10 @@ module.exports = merge(baseWebpackConfig, {
filename: 'index.html',
template: 'index.html',
inject: true
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
})
]
})
Loading

0 comments on commit 8bc0987

Please sign in to comment.