Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.01 #1483

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

1.01 #1483

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ cd _book
git init
git add -A
git commit -m 'update book'
git push -f git@github.com:vuejs-templates/webpack.git master:gh-pages
git push -f git@github.com:git-wlking/VUT.git master:git-wlking
12 changes: 12 additions & 0 deletions meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ module.exports = {
type: 'confirm',
message: 'Install vue-router?',
},
axios: {
when: 'isNotTest',
type: 'confirm',
message: 'Install axios?',
},
vuex: {
when: 'isNotTest',
type: 'confirm',
message: 'Install vuex?',
},
lint: {
when: 'isNotTest',
type: 'confirm',
Expand Down Expand Up @@ -170,6 +180,8 @@ module.exports = {
'test/unit/setup.js': "unit && runner === 'jest'",
'test/e2e/**/*': 'e2e',
'src/router/**/*': 'router',
'src/store/**/*': 'vuex',
'src/api/**/*': 'axios',
},
complete: function(data, { chalk }) {
const green = chalk.green
Expand Down
4 changes: 3 additions & 1 deletion template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
},
"dependencies": {
"vue": "^2.5.2"{{#router}},
"vue-router": "^3.0.1"{{/router}}
"vue-router": "^3.0.1"{{/router}}{{#axios}},
"axios": "^0.18.0"{{/axios}} {{#vuex}},
"vuex": "^2.4.1"{{/vuex}}
},
"devDependencies": {
{{#lint}}
Expand Down
1 change: 1 addition & 0 deletions template/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div id="app">
<img src="./assets/logo.png">
<p>test</p>
{{#router}}
<router-view/>
{{else}}
Expand Down
70 changes: 70 additions & 0 deletions template/src/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* @Author: luox-e
* @Date: 2019-02-19 14:29:36
* @Last Modified by: glodon
* @Last Modified time: 2019-02-19 14:43:08
*/
import axios from 'axios'
import {
MessageBox
} from 'element-ui'

let api = '/api'
if (process.env.NODE_ENV === 'development') {
api = '/api/'
}

const baseURL = api
const Axios = axios.create({
baseURL: baseURL, // 因为我本地做了反向代理
headers: {
'Content-Type': 'application/json;charset=utf-8'
}
})
Axios.interceptors.response.use(
function (response) {
// 返回响应时做一些处理
if (
response.request.responseURL &&
response.request.responseURL.indexOf(
'Services/Identification/Server/login.ashx'
) > 0
) {
this.$router.push({
path: '/login'
})
// window.location = '/Services/Identification/Server/Login.aspx'
} else {
if (response) {
return response.data
} else {
const msgConfig = {
title: '系统错误',
message: response.data.ResultDetailMsg
}
MessageBox(msgConfig)
}
}
},
function (error) {
if (error.response) {
// const msgConfig = {
// title: '请求错误',
// message: error.response.status
// }
// MessageBox(msgConfig)
}
// 当响应异常时做一些处理
return Promise.reject(error)
}
)

// 对axios的实例重新封装成一个plugin ,方便 Vue.use(xxxx)
export default {
install: function (Vue, Option) {
Object.defineProperty(Vue.prototype, '$http', {
value: Axios
})
},
baseURL
}
13 changes: 13 additions & 0 deletions template/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,28 @@ import App from './App'
{{#router}}
import router from './router'
{{/router}}
{{#vuex}}
import store from './store'
{{/vuex}}
{{#axios}}
import axiosPlugin from './api'
{{/axios}}

Vue.config.productionTip = false

{{#axios}}
Vue.use(axiosPlugin)
{{/axios}}

/* eslint-disable no-new */
new Vue({
el: '#app',
{{#router}}
router,
{{/router}}
{{#vuex}}
store,
{{/vuex}}
{{#if_eq build "runtime"}}
render: h => h(App)
{{/if_eq}}
Expand Down
8 changes: 8 additions & 0 deletions template/src/store/State.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
layoutConfig: {
colNum: 120,
rowHeight: 10,
margin: [0, 0]
},
currentProtal: localStorage.getItem('currentPortal') ? JSON.parse(localStorage.getItem('currentPortal')) : {}
}
Empty file added template/src/store/action.js
Empty file.
15 changes: 15 additions & 0 deletions template/src/store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Vue from 'vue'
import Vuex from 'vuex'
import state from './State.js'
import mutations from './mutations.js'

Vue.use(Vuex)

export default new Vuex.Store({
state,
mutations,
modules: {

},
strict: process.env.NODE_ENV !== 'production' // 严格模式
})
6 changes: 6 additions & 0 deletions template/src/store/mutations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
updateCurrentProtal(state, currentProtal) {
state.currentProtal = currentProtal
localStorage.setItem('currentPortal', JSON.stringify({...currentProtal}))
}
}