初始化
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
import ElementUI from 'element-ui';
|
||||
import 'element-ui/lib/theme-chalk/index.css';
|
||||
export default (Vue)=>{
|
||||
Vue.use(ElementUI);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import '../../assets/global.less';
|
||||
export default (Vue)=>{
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import routes from "../vue-router/pages";
|
||||
|
||||
export default (Vue) => {
|
||||
const files = require.context('../../utils', true, /index\.js$/); //批量读取模块文件
|
||||
const plugin = files.keys().reduce((modules, path) => {
|
||||
const name = path.replace(/^\.\/(.*)\.js$/, '$1');
|
||||
const module = files(path).default();
|
||||
if (module) {
|
||||
Vue.prototype[module.name] = module.value
|
||||
}
|
||||
return modules;
|
||||
}, {});
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import LemonIMUI from 'lemon-imui';
|
||||
import 'lemon-imui/dist/index.css';
|
||||
export default (Vue)=>{
|
||||
Vue.use(LemonIMUI);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default {
|
||||
home: '/pages/index/index',//默认首页
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import VueRouter from 'vue-router'
|
||||
import routes from './pages'
|
||||
import config from './config.js'
|
||||
|
||||
export default (Vue) => {
|
||||
Vue.use(VueRouter)
|
||||
const router = new VueRouter({
|
||||
routes
|
||||
})
|
||||
//设置默认首页
|
||||
if (config.home) router.addRoute({path: '/', redirect: config.home})
|
||||
return {
|
||||
name : 'router',
|
||||
value: router
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
const Foo = {template: '<div>foo</div>'}
|
||||
const Bar = {template: '<div>bar</div>'}
|
||||
|
||||
const routes = [
|
||||
|
||||
]
|
||||
const files = require.context('../../pages', true, /index\.vue$/); //批量读取模块文件
|
||||
const plugin = files.keys().reduce((modules, path) => {
|
||||
const name = path.replace(/^\.\/(.*)\.vue$/, '$1');
|
||||
const module = files(path).default;
|
||||
//自动加载路由
|
||||
routes.push(
|
||||
{path: '/pages/' + name, component: module},
|
||||
)
|
||||
return modules;
|
||||
}, {});
|
||||
console.log(routes);
|
||||
|
||||
export default routes;
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
https://www.npmjs.com/package/vue-socket.io
|
||||
https://blog.51cto.com/u_15302032/5215140
|
||||
* */
|
||||
|
||||
import SocketIO from "socket.io-client";
|
||||
import VueSocketIO from 'vue-socket.io'
|
||||
|
||||
|
||||
export default (Vue) => {
|
||||
Vue.use(new VueSocketIO({
|
||||
debug: true,
|
||||
connection: SocketIO('http://127.0.0.1:3210'),
|
||||
// vuex: {
|
||||
// store,
|
||||
// actionPrefix: 'SOCKET_',
|
||||
// mutationPrefix: 'SOCKET_'
|
||||
// },
|
||||
options: { path: "/socket.io" } //Optional options
|
||||
}))
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import Vuex from 'vuex'
|
||||
|
||||
const state = {
|
||||
count: 1
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
|
||||
SET_ADD_COUNT : (state) => {
|
||||
state.count++
|
||||
},
|
||||
SET_SUBTRACT_COUNT: (state) => {
|
||||
state.count--
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
// 加
|
||||
add({commit}) {
|
||||
commit('SET_ADD_COUNT')
|
||||
},
|
||||
// 减
|
||||
subtract({commit}) {
|
||||
commit('SET_SUBTRACT_COUNT')
|
||||
}
|
||||
|
||||
}
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
//封装的存放state下count的方法
|
||||
app: {
|
||||
// namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
}
|
||||
})
|
||||
export default store
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* */
|
||||
|
||||
|
||||
import Vuex from 'vuex'
|
||||
|
||||
export default (Vue) => {
|
||||
Vue.use(Vuex);
|
||||
|
||||
const store = require("./store")
|
||||
return {
|
||||
name : "store",
|
||||
value: store.default
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import Vuex from 'vuex'
|
||||
|
||||
const state = {
|
||||
count: 1
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
|
||||
SET_ADD_COUNT : (state) => {
|
||||
state.count++
|
||||
},
|
||||
SET_SUBTRACT_COUNT: (state) => {
|
||||
state.count--
|
||||
}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
// 加
|
||||
add({commit}) {
|
||||
commit('SET_ADD_COUNT')
|
||||
},
|
||||
// 减
|
||||
subtract({commit}) {
|
||||
commit('SET_SUBTRACT_COUNT')
|
||||
}
|
||||
|
||||
}
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
//封装的存放state下count的方法
|
||||
app: {
|
||||
// namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
}
|
||||
})
|
||||
export default store
|
||||
Reference in New Issue
Block a user