meixioacomponent 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meixioacomponent",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "private": false,
5
5
  "author": "YuRi",
6
6
  "main": "lib/meixioacomponent.umd.min.js",
@@ -4,8 +4,7 @@
4
4
 
5
5
  <script>
6
6
  import Vue from "vue";
7
- import store from "../../store";
8
- import router from "../../router";
7
+ import componentConfig from "../../config/componentConfig";
9
8
  export default {
10
9
  name: "dynamicMount",
11
10
  data() {
@@ -54,9 +53,9 @@ export default {
54
53
  propsData: {
55
54
  ...this.componentProps,
56
55
  },
57
- store: store,
56
+ store: componentConfig.store,
58
57
  parent: this,
59
- router: router,
58
+ router: componentConfig.router,
60
59
  });
61
60
  this.registerListen();
62
61
  this.$children.push(this.componentMounted);
@@ -1,6 +1,6 @@
1
1
  import Vue from "vue";
2
- import store from "../../store/index";
3
2
  import dynamicMountComponent from "./dynamicMount.vue";
3
+ import componentConfig from "../../config/componentConfig";
4
4
  const ComponentInsertConstructor = Vue.extend(dynamicMountComponent);
5
5
 
6
6
  //使用方法
@@ -11,8 +11,8 @@ const ComponentInsertConstructor = Vue.extend(dynamicMountComponent);
11
11
  // });
12
12
 
13
13
  const Insert = (options) => {
14
- store.commit("component/SET_DYNAMICID");
15
- let id = store.getters.dynamicId;
14
+ componentConfig.setDynamicId();
15
+ let id = componentConfig.dynamicId;
16
16
  const componentInsertConstructor = new ComponentInsertConstructor();
17
17
  componentInsertConstructor.vm = componentInsertConstructor.$mount();
18
18
  componentInsertConstructor.dom = componentInsertConstructor.vm.$el;
@@ -30,6 +30,13 @@ import baseDialogForm from "./proForm/dialogForm/dialogFormIndex";
30
30
  import baseForm from "./proForm/proForm/index";
31
31
  import baseFormWrap from "./proForm/proFormWrap/index";
32
32
  import baseProTable from "./proPageTable/index";
33
+ // js 文件相关
34
+ import DynamicMount from "./dynamicmount/index.js";
35
+ import componentConfig from "../config/componentConfig";
36
+ import SelectStore from "../config/selectStore/SelectStore";
37
+ //
38
+ import useImg from "../config/use/UseImg";
39
+ import useFixedHeader from "../config/use/useFixedHeader";
33
40
 
34
41
  const meixicomponents = [
35
42
  baseAnchor,
@@ -70,6 +77,7 @@ const install = (Vue) => {
70
77
  meixicomponents.forEach((component) => {
71
78
  Vue.component(component.name, component);
72
79
  });
80
+ Vue.use(DynamicMount);
73
81
  };
74
82
 
75
83
  if (typeof window !== "undefined" && window.Vue) {
@@ -78,6 +86,7 @@ if (typeof window !== "undefined" && window.Vue) {
78
86
 
79
87
  export default {
80
88
  install,
89
+ componentConfig,
81
90
  meixicomponents,
82
91
  baseAnchor,
83
92
  baseAppendix,
@@ -111,4 +120,7 @@ export default {
111
120
  baseForm,
112
121
  baseFormWrap,
113
122
  baseProTable,
123
+ SelectStore,
124
+ useImg,
125
+ useFixedHeader,
114
126
  };
@@ -186,7 +186,7 @@
186
186
  <script>
187
187
  import { FilterTime } from "../../../utils/utils";
188
188
  //
189
- import UseSelectStore from "../../../config/use/UseSelectStore";
189
+ import componentConfig from "../../../config/componentConfig";
190
190
  export default {
191
191
  data() {
192
192
  return {
@@ -218,8 +218,7 @@ export default {
218
218
  return this.selectStore.getLoading();
219
219
  },
220
220
  selectStore() {
221
- // console.log()
222
- return UseSelectStore.getStore(this.$props.config.useStore);
221
+ return componentConfig.selectStore.getStore(this.$props.config.useStore);
223
222
  },
224
223
 
225
224
  selectData() {
@@ -0,0 +1,25 @@
1
+ // import UseSelectStoreClass from "./selectStore/UseSelectStoreClass";
2
+ import selectStore from "./storeModule/selectStore";
3
+ const componentConfig = {
4
+ store: null,
5
+ router: null,
6
+ dynamicId: 0,
7
+ selectStore: null,
8
+
9
+ setDynamicId: () => {
10
+ componentConfig.dynamicId += 1;
11
+ },
12
+
13
+ initConfig: (_store, _router) => {
14
+ // 动态注册vuex modules
15
+ _store.registerModule("selectStore", selectStore);
16
+ // 注册vuex里面selectStore管理类
17
+ _store.commit("selectStore/CREATE_SELECTSTORE");
18
+ componentConfig.store = _store;
19
+ componentConfig.router = _router;
20
+ componentConfig.selectStore =
21
+ componentConfig.store.getters["selectStore/getSelectStore"];
22
+ },
23
+ };
24
+
25
+ export default componentConfig;
@@ -1,14 +1,16 @@
1
+ import componentConfig from "../componentConfig";
1
2
  class SelectStore {
2
- constructor(request) {
3
+ constructor(params) {
3
4
  this.data = [];
4
5
  this.loading = false;
5
- this.request = request;
6
+ this.name = params.name;
7
+ this.request = params.request;
6
8
  }
7
9
 
8
10
  async loadData() {
9
11
  this.loading = true;
10
12
  let result = await this.request();
11
-
13
+
12
14
  this.loading = false;
13
15
  this.data = result;
14
16
  }
@@ -1,5 +1,6 @@
1
1
  class UseSelectStoreClass {
2
2
  constructor() {
3
+ this.storeClassList = {};
3
4
  this.storeList = [];
4
5
  }
5
6
  hasStore(store) {
@@ -9,13 +10,12 @@ class UseSelectStoreClass {
9
10
  return index;
10
11
  }
11
12
  getStore(store) {
12
- console.log(store);
13
13
  let flag = this.hasStore(store);
14
14
  if (flag == -1) {
15
- let value = require(`@/config/selectStore/${store}.js`);
15
+ let value = this.storeClassList[`${store}`];
16
16
  let obj = {
17
17
  key: `${store}`,
18
- value: value.default,
18
+ value: value,
19
19
  };
20
20
  this.storeList.push(obj);
21
21
  return obj.value;
@@ -23,5 +23,11 @@ class UseSelectStoreClass {
23
23
 
24
24
  return this.storeList[flag].value;
25
25
  }
26
+
27
+ registerStore(params) {
28
+ console.log(params);
29
+ this.storeClassList[`${params.name}`] = params.class;
30
+ console.log(this.storeClassList);
31
+ }
26
32
  }
27
33
  export default UseSelectStoreClass;
@@ -0,0 +1,24 @@
1
+ import UseSelectStoreClass from "../selectStore/UseSelectStoreClass";
2
+
3
+ const selectStore = {
4
+ namespaced: true,
5
+ state: {
6
+ selectStore: null,
7
+ },
8
+
9
+ getters: {
10
+ getSelectStore(state) {
11
+ return state.selectStore;
12
+ },
13
+ },
14
+
15
+ mutations: {
16
+ CREATE_SELECTSTORE: (state) => {
17
+ state.selectStore = new UseSelectStoreClass();
18
+ console.log("注册成功");
19
+ },
20
+ },
21
+ actions: {},
22
+ };
23
+
24
+ export default selectStore;
@@ -1,5 +1,6 @@
1
- import baseFixedHeader from "../../components/base/baseFixedHeader.vue";
1
+
2
2
  import DynamicMount from "../../components/dynamicmount/DynamicMount";
3
+ import baseFixedHeader from "../../components/base/baseFixedHeader/baseFixedHeader.vue";
3
4
 
4
5
  class UseFixedHeader {
5
6
  constructor() {
@@ -1,40 +0,0 @@
1
- import SelectStore from "./SelectStore";
2
- // 示例
3
- let testRequest = () => {
4
- return new Promise((resolve, reject) => {
5
- setTimeout(() => {
6
- resolve([
7
- {
8
- value: 1,
9
- label: "黄金糕",
10
- },
11
- {
12
- value: 2,
13
- label: "双皮奶",
14
- },
15
- {
16
- value: 3,
17
- label: "蚵仔煎",
18
- },
19
- {
20
- value: 4,
21
- label: "龙须面",
22
- },
23
- {
24
- value: 5,
25
- label: "北京烤鸭",
26
- },
27
- ]);
28
- }, 5000);
29
- });
30
- };
31
-
32
- class TestSelectStore extends SelectStore {
33
- constructor(request) {
34
- super(request);
35
- }
36
- }
37
-
38
- let testSelectStore = new TestSelectStore(testRequest);
39
-
40
- export default testSelectStore;
@@ -1,2 +0,0 @@
1
- import Vue from "vue";
2
- export default Vue.prototype.$store.getters.selectStore;
Binary file
package/src/main.js DELETED
@@ -1,9 +0,0 @@
1
- import Vue from 'vue'
2
- import store from './store'
3
- import router from './router'
4
- Vue.config.productionTip = false
5
- new Vue({
6
- router,
7
- store,
8
- render: h => h(App)
9
- }).$mount('#app')
@@ -1,29 +0,0 @@
1
- import Vue from 'vue'
2
- import VueRouter from 'vue-router'
3
- import Home from '../views/Home.vue'
4
-
5
- Vue.use(VueRouter)
6
-
7
- const routes = [
8
- {
9
- path: '/',
10
- name: 'Home',
11
- component: Home
12
- },
13
- {
14
- path: '/about',
15
- name: 'About',
16
- // route level code-splitting
17
- // this generates a separate chunk (about.[hash].js) for this route
18
- // which is lazy-loaded when the route is visited.
19
- component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
20
- }
21
- ]
22
-
23
- const router = new VueRouter({
24
- mode: 'history',
25
- base: process.env.BASE_URL,
26
- routes
27
- })
28
-
29
- export default router
@@ -1,15 +0,0 @@
1
- import Vue from 'vue'
2
- import Vuex from 'vuex'
3
-
4
- Vue.use(Vuex)
5
-
6
- export default new Vuex.Store({
7
- state: {
8
- },
9
- mutations: {
10
- },
11
- actions: {
12
- },
13
- modules: {
14
- }
15
- })