diff --git a/deploy-docs.sh b/deploy-docs.sh index a9f76366a4..360e6f9dc0 100644 --- a/deploy-docs.sh +++ b/deploy-docs.sh @@ -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 diff --git a/meta.js b/meta.js index a521f9bdd0..07e828b1bd 100644 --- a/meta.js +++ b/meta.js @@ -74,6 +74,26 @@ module.exports = { type: 'confirm', message: 'Install vue-router?', }, + axios: { + when: 'isNotTest', + type: 'confirm', + message: 'Install axios?', + }, + elementui: { + when: 'isNotTest', + type: 'confirm', + message: 'Install element-ui?', + }, + vuex: { + when: 'isNotTest', + type: 'confirm', + message: 'Install vuex?', + }, + sass: { + when: 'isNotTest', + type: 'confirm', + message: 'Install sass?', + }, lint: { when: 'isNotTest', type: 'confirm', @@ -170,6 +190,9 @@ module.exports = { 'test/unit/setup.js': "unit && runner === 'jest'", 'test/e2e/**/*': 'e2e', 'src/router/**/*': 'router', + 'src/store/**/*': 'vuex', + 'src/api/**/*': 'axios', + 'src/assets/style/*': 'axios', }, complete: function(data, { chalk }) { const green = chalk.green diff --git a/template/build/utils.js b/template/build/utils.js index e534fb0fd6..c01f656fbc 100644 --- a/template/build/utils.js +++ b/template/build/utils.js @@ -60,7 +60,14 @@ exports.cssLoaders = function (options) { postcss: generateLoaders(), less: generateLoaders('less'), sass: generateLoaders('sass', { indentedSyntax: true }), - scss: generateLoaders('sass'), + scss: generateLoaders('sass'){{#sass}}.concat( + { + loader: 'sass-resources-loader', + options: { + resources: path.resolve(__dirname, '../src/assets/style/index.scss') + } + } + ),{{/sass}} stylus: generateLoaders('stylus'), styl: generateLoaders('stylus') } diff --git a/template/build/webpack.base.conf.js b/template/build/webpack.base.conf.js index 391160c571..98e31ed25a 100644 --- a/template/build/webpack.base.conf.js +++ b/template/build/webpack.base.conf.js @@ -78,7 +78,13 @@ module.exports = { limit: 10000, name: utils.assetsPath('fonts/[name].[hash:7].[ext]') } + }, + {{#sass}} + { + test: /\.scss$/, + loaders: ["style", "css", "sass"] } + {{/sass}} ] }, node: { diff --git a/template/package.json b/template/package.json index 207322b98c..27df1c34fe 100644 --- a/template/package.json +++ b/template/package.json @@ -2,7 +2,7 @@ "name": "{{ name }}", "version": "1.0.0", "description": "{{ description }}", - "author": "{{ author }}", + "author": "glodon-lo-{{ author }}", "private": true, "scripts": { "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", @@ -26,7 +26,10 @@ }, "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}}{{#elementui}}, + "element-ui": "^2.5.4"{{/elementui}} }, "devDependencies": { {{#lint}} @@ -82,6 +85,11 @@ "nightwatch": "^0.9.12", "selenium-server": "^3.0.1", {{/e2e}} + {{#sass}} + "sass-loader": "^7.1.0", + "sass-resources-loader": "^2.0.0", + "node-sass": "^4.11.0", + {{/sass}} "autoprefixer": "^7.1.2", "babel-core": "^6.22.1", "babel-helper-vue-jsx-merge-props": "^2.0.3", diff --git a/template/src/api/index.js b/template/src/api/index.js new file mode 100644 index 0000000000..7d7a9b260c --- /dev/null +++ b/template/src/api/index.js @@ -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 +} diff --git a/template/src/assets/style/base.scss b/template/src/assets/style/base.scss new file mode 100644 index 0000000000..b3b16f4722 --- /dev/null +++ b/template/src/assets/style/base.scss @@ -0,0 +1,20 @@ +/* + * @Author: luox-e + * @Date: 2019-02-19 11:00:02 + * @Last Modified by: glodon + * @Last Modified time: 2019-02-19 14:26:21 + */ + +//写一些我们需要全局设置的一些基本样式,例如清除浮动 + + //清除浮动; + %clearfix { + *zoom: 1; + &:before, &:after { + content: " "; + display: table; + } + &:after { + clear: both; + } +} diff --git a/template/src/assets/style/index.scss b/template/src/assets/style/index.scss new file mode 100644 index 0000000000..d5af5cd681 --- /dev/null +++ b/template/src/assets/style/index.scss @@ -0,0 +1,20 @@ +/* + * @Author: luox-e + * @Date: 2019-02-19 11:00:19 + * @Last Modified by: glodon + * @Last Modified time: 2019-02-19 14:11:20 + */ +//是我们scss的总体引入文件,将我们所有的公共scss引入,这样一来我们只要全局引用index.scss文件就可以了 +//minxin +@import './mixin.scss'; + //全局设置的基本样式 +@import './base.scss'; +/* element UI 样式总控*/ + +/* 改变主题色变量 */ +$--color-primary: #1D8CE0; + +/* 改变 icon 字体路径变量,必需 */ +$--font-path: '~element-ui/lib/theme-chalk/fonts'; + +@import "~element-ui/packages/theme-chalk/src/index"; \ No newline at end of file diff --git a/template/src/assets/style/mixin.scss b/template/src/assets/style/mixin.scss new file mode 100644 index 0000000000..30ada9ce6b --- /dev/null +++ b/template/src/assets/style/mixin.scss @@ -0,0 +1,7 @@ +/* + * @Author: luox-e + * @Date: 2019-02-19 11:00:14 + * @Last Modified by: glodon + * @Last Modified time: 2019-02-19 11:00:14 + */ +// 这个文件就是我们scss的mixin文件了 \ No newline at end of file diff --git a/template/src/main.js b/template/src/main.js index 48833b5ab7..8b6a3331c8 100644 --- a/template/src/main.js +++ b/template/src/main.js @@ -7,15 +7,36 @@ import App from './App' {{#router}} import router from './router' {{/router}} +{{#vuex}} +import store from './store' +{{/vuex}} +{{#axios}} +import axiosPlugin from './api' +{{/axios}} +{{#elementui}} +import ElementUI from 'element-ui'; +import 'element-ui/lib/theme-chalk/index.css'; +{{/elementui}} Vue.config.productionTip = false +{{#axios}} +Vue.use(axiosPlugin) +{{/axios}} + +{{#elementui}} +Vue.use(ElementUI); +{{/elementui}} + /* eslint-disable no-new */ new Vue({ el: '#app', {{#router}} router, {{/router}} + {{#vuex}} + store, + {{/vuex}} {{#if_eq build "runtime"}} render: h => h(App) {{/if_eq}} diff --git a/template/src/store/State.js b/template/src/store/State.js new file mode 100644 index 0000000000..c2c973f98a --- /dev/null +++ b/template/src/store/State.js @@ -0,0 +1,8 @@ +export default { + layoutConfig: { + colNum: 120, + rowHeight: 10, + margin: [0, 0] + }, + currentProtal: localStorage.getItem('currentPortal') ? JSON.parse(localStorage.getItem('currentPortal')) : {} +} diff --git a/template/src/store/action.js b/template/src/store/action.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/template/src/store/index.js b/template/src/store/index.js new file mode 100644 index 0000000000..1853e2cb9e --- /dev/null +++ b/template/src/store/index.js @@ -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' // 严格模式 +}) diff --git a/template/src/store/mutations.js b/template/src/store/mutations.js new file mode 100644 index 0000000000..c1f68d93f8 --- /dev/null +++ b/template/src/store/mutations.js @@ -0,0 +1,6 @@ +export default { + updateCurrentProtal(state, currentProtal) { + state.currentProtal = currentProtal + localStorage.setItem('currentPortal', JSON.stringify({...currentProtal})) + } +}