@tslib/vue-ext
Advanced tools
Comparing version 1.0.8 to 1.0.9
import Vue, { VueConstructor } from "vue"; | ||
import { ThisTypedComponentOptionsWithArrayProps, ThisTypedComponentOptionsWithRecordProps, FunctionalComponentOptions, RecordPropsDefinition, ComponentOptions } from "vue/types/options"; | ||
import { ComponentOptions } from "vue/types/options"; | ||
import { Store } from 'vuex'; | ||
@@ -36,9 +36,5 @@ export interface ExtOptions { | ||
interface VueConstructor<V extends Vue> { | ||
extendVue<Data, Methods, Computed, PropNames extends string = never>(moduleName: string, options?: ExtOptions & ThisTypedComponentOptionsWithArrayProps<V, Data, Methods, Computed, PropNames>): ExtendedVue<V, Data, Methods, Computed, Record<PropNames, any>>; | ||
extendVue<Data, Methods, Computed, Props>(moduleName: string, options?: ExtOptions & ThisTypedComponentOptionsWithRecordProps<V, Data, Methods, Computed, Props>): ExtendedVue<V, Data, Methods, Computed, Props>; | ||
extendVue<PropNames extends string = never>(moduleName: string, definition: FunctionalComponentOptions<Record<PropNames, any>, PropNames[]>): ExtendedVue<V, {}, {}, {}, Record<PropNames, any>>; | ||
extendVue<Props>(moduleName: string, definition: FunctionalComponentOptions<Props, RecordPropsDefinition<Props>>): ExtendedVue<V, {}, {}, {}, Props>; | ||
extendVue(moduleName: string, options?: ExtOptions & ComponentOptions<V>): ExtendedVue<V, {}, {}, {}, {}>; | ||
extendVue(options?: ExtOptions & ComponentOptions<V>): ExtendedVue<V, {}, {}, {}, {}>; | ||
} | ||
} | ||
export default Vue; |
@@ -8,7 +8,7 @@ "use strict"; | ||
const vuex_1 = __importDefault(require("vuex")); | ||
const lodash_1 = __importDefault(require("lodash")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const _d = debug_1.default('vueExt'); | ||
const _d = debug_1.default('app:vueExt'); | ||
// 挂载vue store 扩展 | ||
vue_1.default.use(vuex_1.default); | ||
_d('init vueExt...'); | ||
// 初始化全局store | ||
@@ -40,16 +40,13 @@ exports.store = new vuex_1.default.Store({ | ||
// 初始化 | ||
vue_1.default.extendVue = function (moduleName, options) { | ||
vue_1.default.extendVue = function (options) { | ||
// 如果option中有page选项,则注册为page,否则注册为component | ||
const VueExt = vue_1.default.extend(options); | ||
if (lodash_1.default.isEmpty(options.name)) { | ||
console.error('define vue Component error', options); | ||
throw new Error('export Component MUST have name :'); | ||
if (options) { | ||
if (options.page) { | ||
console.log('----', options.page); | ||
} | ||
else { | ||
exports.store.commit(`${options.module}/registerComponent`, VueExt); | ||
} | ||
} | ||
if (options.page) { | ||
console.log('----', options.page); | ||
exports.store.commit(`${moduleName}/registerPage`, VueExt); | ||
} | ||
else { | ||
exports.store.commit(`${moduleName}/registerComponent`, VueExt); | ||
} | ||
return VueExt; | ||
@@ -56,0 +53,0 @@ }; |
{ | ||
"name": "@tslib/vue-ext", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "config file loader for typescript", |
Sorry, the diff of this file is not supported yet
26114
293