-
还没有任何任务
+
还没有任何计划
+
-
diff --git a/src/main.js b/src/main.js
index 95b728ca..bbc73129 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,33 +1,60 @@
import Vue from 'vue'
-import App from './App.vue'
-import Home from './components/Home.vue'
+import VueRouter from 'vue-router'
+import store from './store'
+import App from './App'
+import Home from './components/Home'
import TimeEntries from './components/TimeEntries.vue'
import LogTime from './components/LogTime.vue'
-import VueRouter from 'vue-router'
+import NotFound from './components/404'
import VueResource from 'vue-resource'
import 'bootstrap/dist/css/bootstrap.css'
-Vue.use(VueResource)
Vue.use(VueRouter)
+Vue.use(VueResource)
+
+const routes = [{
+ path : '/',
+ component : Home
+},{
+ path : '/home',
+ component : Home
+},{
+ path : '/time-entries',
+ component : TimeEntries,
+ children : [{
+ path : 'log-time',
+ component : LogTime,
+ }]
+},{
+ path : '*',
+ component : NotFound
+}];
-const router = new VueRouter()
+const router = new VueRouter({
+ routes
+});
-router.map({
- '/Home': {
- component: Home
- },
- '/time-entries': {
- component: TimeEntries,
- subRoutes: {
- '/log-time': {
- component: LogTime
- }
- }
- }
-})
+/* eslint-disable no-new */
+// 这灵活得亮瞎了
+/*new Vue({
+ el: '#app',
+ template: '
',
+ router,
+ components: { App }
+});
-router.redirect({
- '*': '/Home'
-})
+ new Vue(Vue.util.extend({
+ router
+ }, App)).$mount('#app');
-router.start(App, '#app')
+new Vue({
+ el:'#app',
+ router,
+ render:h => h(App)
+});*/
+var app = new Vue({
+ el: '#app',
+ router,
+ store,
+ ...App,
+});
diff --git a/src/store/actions.js b/src/store/actions.js
new file mode 100644
index 00000000..36811d63
--- /dev/null
+++ b/src/store/actions.js
@@ -0,0 +1,16 @@
+import * as types from './mutation-types'
+
+export default {
+ addTotalTime({ commit }, time) {
+ commit(types.ADD_TOTAL_TIME, time)
+ },
+ decTotalTime({ commit }, time) {
+ commit(types.DEC_TOTAL_TIME, time)
+ },
+ savePlan({ commit }, plan) {
+ commit(types.SAVE_PLAN, plan);
+ },
+ deletePlan({ commit }, plan) {
+ commit(types.DELETE_PLAN, plan)
+ }
+};
diff --git a/src/store/index.js b/src/store/index.js
new file mode 100644
index 00000000..37c745c2
--- /dev/null
+++ b/src/store/index.js
@@ -0,0 +1,18 @@
+import Vue from 'vue'
+import Vuex from 'vuex'
+import mutations from './mutations'
+import actions from './actions'
+
+Vue.use(Vuex);
+
+const state = {
+ totalTime: 0,
+ list: []
+};
+
+export default new Vuex.Store({
+ state,
+ mutations,
+ actions
+})
+
diff --git a/src/store/mutation-types.js b/src/store/mutation-types.js
new file mode 100644
index 00000000..32635751
--- /dev/null
+++ b/src/store/mutation-types.js
@@ -0,0 +1,7 @@
+// 增加总时间或者减少总时间
+export const ADD_TOTAL_TIME = 'ADD_TOTAL_TIME';
+export const DEC_TOTAL_TIME = 'DEC_TOTAL_TIME';
+
+// 新增和删除一条计划
+export const SAVE_PLAN = 'SAVE_PLAN';
+export const DELETE_PLAN = 'DELETE_PLAN';
diff --git a/src/store/mutations.js b/src/store/mutations.js
new file mode 100644
index 00000000..d03a9046
--- /dev/null
+++ b/src/store/mutations.js
@@ -0,0 +1,21 @@
+import * as types from './mutation-types'
+
+export default {
+ [types.ADD_TOTAL_TIME] (state, time) {
+ state.totalTime = state.totalTime + time
+ },
+ [types.DEC_TOTAL_TIME] (state, time) {
+ state.totalTime = state.totalTime - time
+ },
+ [types.SAVE_PLAN] (state, plan) {
+ // 设置默认值,未来我们可以做登入直接读取昵称和头像
+ const avatar = 'https://sfault-avatar.b0.upaiyun.com/147/223/147223148-573297d0913c5_huge256';
+
+ state.list.push(
+ Object.assign({ name: '二哲', avatar: avatar }, plan)
+ )
+ },
+ [types.DELETE_PLAN] (state, idx) {
+ state.list.splice(idx, 1);
+ }
+};
diff --git a/test/e2e/custom-assertions/elementCount.js b/test/e2e/custom-assertions/elementCount.js
deleted file mode 100644
index c0d5fe00..00000000
--- a/test/e2e/custom-assertions/elementCount.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// A custom Nightwatch assertion.
-// the name of the method is the filename.
-// can be used in tests like this:
-//
-// browser.assert.elementCount(selector, count)
-//
-// for how to write custom assertions see
-// http://nightwatchjs.org/guide#writing-custom-assertions
-exports.assertion = function (selector, count) {
- this.message = 'Testing if element <' + selector + '> has count: ' + count
- this.expected = count
- this.pass = function (val) {
- return val === this.expected
- }
- this.value = function (res) {
- return res.value
- }
- this.command = function (cb) {
- var self = this
- return this.api.execute(function (selector) {
- return document.querySelectorAll(selector).length
- }, [selector], function (res) {
- cb.call(self, res)
- })
- }
-}
diff --git a/test/e2e/nightwatch.conf.js b/test/e2e/nightwatch.conf.js
deleted file mode 100644
index b5d911ce..00000000
--- a/test/e2e/nightwatch.conf.js
+++ /dev/null
@@ -1,40 +0,0 @@
-// http://nightwatchjs.org/guide#settings-file
-module.exports = {
- "src_folders": ["test/e2e/specs"],
- "output_folder": "test/e2e/reports",
- "custom_assertions_path": ["test/e2e/custom-assertions"],
-
- "selenium": {
- "start_process": true,
- "server_path": "node_modules/selenium-server/lib/runner/selenium-server-standalone-2.53.0.jar",
- "host": "127.0.0.1",
- "port": 4444,
- "cli_args": {
- "webdriver.chrome.driver": require('chromedriver').path
- }
- },
-
- "test_settings": {
- "default": {
- "selenium_port": 4444,
- "selenium_host": "localhost",
- "silent": true
- },
-
- "chrome": {
- "desiredCapabilities": {
- "browserName": "chrome",
- "javascriptEnabled": true,
- "acceptSslCerts": true
- }
- },
-
- "firefox": {
- "desiredCapabilities": {
- "browserName": "firefox",
- "javascriptEnabled": true,
- "acceptSslCerts": true
- }
- }
- }
-}
diff --git a/test/e2e/runner.js b/test/e2e/runner.js
deleted file mode 100644
index b9f009c5..00000000
--- a/test/e2e/runner.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// 1. start the dev server using production config
-process.env.NODE_ENV = 'testing'
-var server = require('../../build/dev-server.js')
-
-// 2. run the nightwatch test suite against it
-// to run in additional browsers:
-// 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
-// 2. add it to the --env flag below
-// For more information on Nightwatch's config file, see
-// http://nightwatchjs.org/guide#settings-file
-var spawn = require('cross-spawn')
-var runner = spawn(
- './node_modules/.bin/nightwatch',
- [
- '--config', 'test/e2e/nightwatch.conf.js',
- '--env', 'chrome,firefox'
- ],
- {
- stdio: 'inherit'
- }
-)
-
-runner.on('exit', function (code) {
- server.close()
- process.exit(code)
-})
-
-runner.on('error', function (err) {
- server.close()
- throw err
-})
diff --git a/test/e2e/specs/test.js b/test/e2e/specs/test.js
deleted file mode 100644
index 49bc7f70..00000000
--- a/test/e2e/specs/test.js
+++ /dev/null
@@ -1,14 +0,0 @@
-// For authoring Nightwatch tests, see
-// http://nightwatchjs.org/guide#usage
-
-module.exports = {
- 'default e2e tests': function (browser) {
- browser
- .url('http://localhost:8080')
- .waitForElementVisible('#app', 5000)
- .assert.elementPresent('.logo')
- .assert.containsText('h1', 'Hello World!')
- .assert.elementCount('p', 3)
- .end()
- }
-}
diff --git a/test/unit/.eslintrc b/test/unit/.eslintrc
deleted file mode 100644
index 959a4f4b..00000000
--- a/test/unit/.eslintrc
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "env": {
- "mocha": true
- },
- "globals": {
- "expect": true,
- "sinon": true
- }
-}
diff --git a/test/unit/index.js b/test/unit/index.js
deleted file mode 100644
index 42202514..00000000
--- a/test/unit/index.js
+++ /dev/null
@@ -1,13 +0,0 @@
-// Polyfill fn.bind() for PhantomJS
-/* eslint-disable no-extend-native */
-Function.prototype.bind = require('function-bind')
-
-// require all test files (files that ends with .spec.js)
-var testsContext = require.context('./specs', true, /\.spec$/)
-testsContext.keys().forEach(testsContext)
-
-// require all src files except main.js for coverage.
-// you can also change this to match only the subset of files that
-// you want coverage for.
-var srcContext = require.context('../../src', true, /^\.\/(?!main(\.js)?$)/)
-srcContext.keys().forEach(srcContext)
diff --git a/test/unit/karma.conf.js b/test/unit/karma.conf.js
deleted file mode 100644
index b3348719..00000000
--- a/test/unit/karma.conf.js
+++ /dev/null
@@ -1,66 +0,0 @@
-// This is a karma config file. For more details see
-// http://karma-runner.github.io/0.13/config/configuration-file.html
-// we are also using it with karma-webpack
-// https://github.com/webpack/karma-webpack
-
-var path = require('path')
-var merge = require('webpack-merge')
-var baseConfig = require('../../build/webpack.base.conf')
-var projectRoot = path.resolve(__dirname, '../../')
-
-var webpackConfig = merge(baseConfig, {
- // use inline sourcemap for karma-sourcemap-loader
- devtool: '#inline-source-map',
- vue: {
- loaders: {
- js: 'isparta'
- }
- }
-})
-
-// no need for app entry during tests
-delete webpackConfig.entry
-
-// make sure isparta loader is applied before eslint
-webpackConfig.module.preLoaders = webpackConfig.module.preLoaders || []
-webpackConfig.module.preLoaders.unshift({
- test: /\.js$/,
- loader: 'isparta',
- include: projectRoot,
- exclude: /test\/unit|node_modules/
-})
-
-// only apply babel for test files when using isparta
-webpackConfig.module.loaders.some(function (loader, i) {
- if (loader.loader === 'babel') {
- loader.include = /test\/unit/
- return true
- }
-})
-
-module.exports = function (config) {
- config.set({
- // to run in additional browsers:
- // 1. install corresponding karma launcher
- // http://karma-runner.github.io/0.13/config/browsers.html
- // 2. add it to the `browsers` array below.
- browsers: ['PhantomJS'],
- frameworks: ['mocha', 'sinon-chai'],
- reporters: ['spec', 'coverage'],
- files: ['./index.js'],
- preprocessors: {
- './index.js': ['webpack', 'sourcemap']
- },
- webpack: webpackConfig,
- webpackMiddleware: {
- noInfo: true
- },
- coverageReporter: {
- dir: './coverage',
- reporters: [
- { type: 'lcov', subdir: '.' },
- { type: 'text-summary' }
- ]
- }
- })
-}
diff --git a/test/unit/specs/Hello.spec.js b/test/unit/specs/Hello.spec.js
deleted file mode 100644
index 835ad99f..00000000
--- a/test/unit/specs/Hello.spec.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import Vue from 'vue'
-import Hello from 'src/components/Hello'
-
-describe('Hello.vue', () => {
- it('should render correct contents', () => {
- const vm = new Vue({
- template: '
',
- components: { Hello }
- }).$mount()
- expect(vm.$el.querySelector('.hello h1').textContent).to.contain('Hello World!')
- })
-})
{{ timeEntry.comment }}
-