初始化

This commit is contained in:
robin
2022-07-07 22:24:46 +08:00
commit 72b69615b6
42 changed files with 10068 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
export default (Vue)=>{
Vue.use(ElementUI);
}
+3
View File
@@ -0,0 +1,3 @@
import '../../assets/global.less';
export default (Vue)=>{
}
+13
View File
@@ -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;
}, {});
}
+5
View File
@@ -0,0 +1,5 @@
import LemonIMUI from 'lemon-imui';
import 'lemon-imui/dist/index.css';
export default (Vue)=>{
Vue.use(LemonIMUI);
}
+3
View File
@@ -0,0 +1,3 @@
export default {
home: '/pages/index/index',//默认首页
}
+16
View File
@@ -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
}
}
+19
View File
@@ -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;
+21
View File
@@ -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
}))
}
+39
View File
@@ -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
+15
View File
@@ -0,0 +1,15 @@
/*
* */
import Vuex from 'vuex'
export default (Vue) => {
Vue.use(Vuex);
const store = require("./store")
return {
name : "store",
value: store.default
}
}
+39
View File
@@ -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