@tslib/vue-ext
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -1,31 +0,14 @@ | ||
import Vue, { VueConstructor } from "vue"; | ||
import Vue from "vue"; | ||
import { ComponentOptions } from "vue/types/options"; | ||
import { Store } from 'vuex'; | ||
export interface ExtOptions { | ||
module: string; | ||
name: string; | ||
index?: number; | ||
page?: string; | ||
icon?: string; | ||
description: string; | ||
timerInterval?: number; | ||
onTimer?: Function; | ||
} | ||
export declare type EXT_VUE_T = VueConstructor<ExtOptions & Vue>; | ||
export interface IModules { | ||
[k: string]: { | ||
pages: { | ||
[p: string]: EXT_VUE_T; | ||
}; | ||
components: { | ||
[c: string]: EXT_VUE_T; | ||
}; | ||
}; | ||
} | ||
export declare const store: Store<{ | ||
router: { | ||
module: string; | ||
page: string; | ||
}; | ||
login: {}; | ||
modules: IModules; | ||
}>; | ||
export { store } from "./globalStore"; | ||
import "./extTimer"; | ||
/** | ||
@@ -32,0 +15,0 @@ * 定义扩展方法 |
@@ -7,34 +7,12 @@ "use strict"; | ||
const vue_1 = __importDefault(require("vue")); | ||
const vuex_1 = __importDefault(require("vuex")); | ||
const debug_1 = __importDefault(require("debug")); | ||
const _d = debug_1.default('app:vueExt'); | ||
// 挂载vue store 扩展 | ||
vue_1.default.use(vuex_1.default); | ||
_d('init vueExt...'); | ||
// 初始化全局store | ||
exports.store = new vuex_1.default.Store({ | ||
state: { | ||
router: { | ||
module: '', | ||
page: '', | ||
}, | ||
login: {}, | ||
modules: {} // 已加载的组件列表 | ||
}, | ||
mutations: { | ||
login(state, value) { | ||
state.login = value; | ||
}, | ||
logout(state) { | ||
state.login = {}; | ||
}, | ||
setRouter(state, value) { | ||
state.router = value; | ||
}, | ||
registerPage(state, value) { | ||
state.modules; | ||
}, | ||
} | ||
}); | ||
// 初始化 | ||
const _d = debug_1.default("app:vueExt"); | ||
// 初始化store | ||
const globalStore_1 = require("./globalStore"); | ||
var globalStore_2 = require("./globalStore"); | ||
exports.store = globalStore_2.store; | ||
_d("init vueExt..."); | ||
// 初始化定时器 | ||
require("./extTimer"); | ||
// 初始化vue扩展 | ||
vue_1.default.extendVue = function (options) { | ||
@@ -44,49 +22,12 @@ // 如果option中有page选项,则注册为page,否则注册为component | ||
if (options) { | ||
if (options.page) { | ||
console.log('----', options.page); | ||
} | ||
else { | ||
exports.store.commit(`${options.module}/registerComponent`, VueExt); | ||
} | ||
globalStore_1.store.commit(`registerVueComponents`, { | ||
module: options.module, | ||
name: options.name, | ||
components: options.components, | ||
page: options.page | ||
}); | ||
} | ||
return VueExt; | ||
}; | ||
// const abc = new VueX(); | ||
// 创建自动销毁的定时器组件 | ||
vue_1.default.use({ | ||
install(Vue) { | ||
// console.warn('INIT VUE PLUGIN TIMER'); | ||
// 3. 注入组件 | ||
Vue.mixin({ | ||
data: function () { | ||
return { | ||
_timerId: -1, | ||
_timerCounter: 0, | ||
}; | ||
}, | ||
created: function () { | ||
const _this = this; | ||
if (_this.$options && _this.$options.onTimer) { | ||
// debugger; | ||
const timerFunc = _this.$options.onTimer.bind(_this); | ||
// 初始化运行一次,每秒执行一次 | ||
timerFunc(); | ||
_this.$data._timerId = setInterval(() => { | ||
timerFunc(); | ||
}, 1000); | ||
_d('SET Vue Timer', _this.$data._timerId); | ||
} | ||
}, | ||
destroyed: function () { | ||
const _this = this; | ||
if (_this.$data._timerId >= 0) { | ||
clearInterval(_this.$data._timerId); | ||
_d('Clear Vue Timer:', _this.$data._timerId); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
; | ||
exports.default = vue_1.default; | ||
//# sourceMappingURL=vueExt.js.map |
{ | ||
"name": "@tslib/vue-ext", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"private": false, | ||
@@ -23,2 +23,2 @@ "description": "config file loader for typescript", | ||
} | ||
} | ||
} |
import Vue, { VueConstructor } from "vue"; | ||
import { ExtendedVue } from "vue/types/vue"; | ||
import { ThisTypedComponentOptionsWithArrayProps, ThisTypedComponentOptionsWithRecordProps, FunctionalComponentOptions, RecordPropsDefinition, ComponentOptions } from "vue/types/options"; | ||
import Vuex,{ Store, Module } from 'vuex' | ||
import { ComponentOptions } from "vue/types/options"; | ||
import _ from 'lodash'; | ||
import debug from 'debug'; | ||
const _d = debug('app:vueExt'); | ||
import _ from "lodash"; | ||
import debug from "debug"; | ||
const _d = debug("app:vueExt"); | ||
// 挂载vue store 扩展 | ||
Vue.use(Vuex); | ||
_d('init vueExt...'); | ||
export interface ExtOptions { | ||
module:string, | ||
index?: number, | ||
page?: string, | ||
icon?: string, | ||
description: string, | ||
onTimer?: Function, | ||
module: string; | ||
name: string; | ||
index?: number; | ||
page?: string; | ||
icon?: string; | ||
timerInterval?: number; | ||
onTimer?: Function; | ||
} | ||
// 初始化store | ||
import { store } from "./globalStore"; | ||
export { store } from "./globalStore"; | ||
_d("init vueExt..."); | ||
export type EXT_VUE_T = VueConstructor<ExtOptions & Vue>; | ||
// 初始化定时器 | ||
import "./extTimer"; | ||
// 初始化vue扩展 | ||
Vue.extendVue = function(options?: ExtOptions & ComponentOptions<Vue>) { | ||
// 如果option中有page选项,则注册为page,否则注册为component | ||
const VueExt = Vue.extend(options); | ||
if (options) { | ||
store.commit(`registerVueComponents`, { | ||
module: options.module, | ||
name: options.name, | ||
components: options.components, | ||
page: options.page | ||
}); | ||
} | ||
return VueExt; | ||
}; | ||
export interface IModules { | ||
[k:string]:{ | ||
pages:{ | ||
[p: string]: EXT_VUE_T | ||
}, | ||
components:{ | ||
[c: string]: EXT_VUE_T | ||
} | ||
} | ||
} | ||
// 初始化全局store | ||
export const store = new Vuex.Store({ | ||
state: { | ||
router: { | ||
module: '',// 当前组件 | ||
page: '', // 当前页面 | ||
}, | ||
login: {}, | ||
modules: {} as IModules// 已加载的组件列表 | ||
}, | ||
mutations: { | ||
login(state, value) { | ||
state.login = value; | ||
}, | ||
logout(state) { | ||
state.login = {}; | ||
}, | ||
setRouter(state, value: {module:string,page:string}) { | ||
state.router = value; | ||
}, | ||
registerPage(state, value: EXT_VUE_T){ | ||
state.modules | ||
}, | ||
} | ||
}); | ||
// 初始化 | ||
Vue.extendVue = function (options?: ExtOptions & ComponentOptions<Vue>){ | ||
// 如果option中有page选项,则注册为page,否则注册为component | ||
const VueExt = Vue.extend(options); | ||
if(options){ | ||
if (options.page) { | ||
console.log('----', options.page); | ||
} else { | ||
store.commit(`${options.module}/registerComponent`, VueExt); | ||
} | ||
} | ||
return VueExt; | ||
} | ||
// const abc = new VueX(); | ||
// 创建自动销毁的定时器组件 | ||
Vue.use({ | ||
install(Vue) { | ||
// console.warn('INIT VUE PLUGIN TIMER'); | ||
// 3. 注入组件 | ||
Vue.mixin({ | ||
data: function () { | ||
return { | ||
_timerId: -1, // 定时器id | ||
_timerCounter:0,// 定时器执行计数器 | ||
} | ||
}, | ||
created: function () { | ||
const _this: any = this; | ||
if (_this.$options && _this.$options.onTimer) { | ||
// debugger; | ||
const timerFunc: Function = _this.$options.onTimer.bind(_this); | ||
// 初始化运行一次,每秒执行一次 | ||
timerFunc(); | ||
_this.$data._timerId = setInterval(() => { | ||
timerFunc(); | ||
}, 1000); | ||
_d('SET Vue Timer', _this.$data._timerId); | ||
} | ||
}, | ||
destroyed: function () { | ||
const _this: any = this; | ||
if (_this.$data._timerId>=0) { | ||
clearInterval(_this.$data._timerId); | ||
_d('Clear Vue Timer:', _this.$data._timerId); | ||
} | ||
} | ||
}) | ||
} | ||
}); | ||
/** | ||
@@ -125,7 +45,9 @@ * 定义扩展方法 | ||
declare module "vue/types/vue" { | ||
interface VueConstructor<V extends Vue> { | ||
extendVue(options?: ExtOptions & ComponentOptions<V>): ExtendedVue<V, {}, {}, {}, {}>; | ||
} | ||
}; | ||
interface VueConstructor<V extends Vue> { | ||
extendVue( | ||
options?: ExtOptions & ComponentOptions<V> | ||
): ExtendedVue<V, {}, {}, {}, {}>; | ||
} | ||
} | ||
export default Vue; |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
29784
16
365
1