提交 eb6d59ba 编写于 作者: Mosher's avatar Mosher

update:添加定时器销毁逻辑

上级 57c405a2
import { IParam } from "..";
/**
* @description 定时器服务接口
* @export
* @interface IAppCounterService
*/
export interface IAppCounterService {
/**
* 执行计数器
*
* @param {IParam} [context]
* @param {IParam} [viewParams]
* @return {*} {Promise<void>}
* @memberof IAppCounterService
*/
execute(context?: IParam, viewParams?: IParam): Promise<void>;
execute(): Promise<void>;
/**
* 销毁计数器
*
* @return {*} void
* @memberof IAppCounterService
*/
destory(): void;
}
\ No newline at end of file
import { Ref } from 'vue';
import { useRoute } from 'vue-router';
import { ViewPropsBase, ViewStateBase, UIBase, IParam, UIUtil, deepCopy, IActionParam } from '@core';
import { ViewPropsBase, ViewStateBase, UIBase, IParam, UIUtil, deepCopy, IActionParam, IAppCounterService } from '@core';
/**
* @description 视图基类
......@@ -203,14 +203,21 @@ export class ViewBase {
public useCounterService() {
const { appCounterRefs, context, viewParams } = this.state;
const { counterServices } = toRefs(this.state);
if (appCounterRefs && appCounterRefs.length) {
if (appCounterRefs && appCounterRefs.length && counterServices) {
appCounterRefs.forEach((counterRef: IParam) => {
const counterSerivce = App.getCounterService(counterRef, context, viewParams);
counterSerivce.execute().then(() => {
counterServices.value.push(counterSerivce);
counterServices.value?.push(counterSerivce);
});
});
}
onUnmounted(() => {
if (counterServices && counterServices.value && counterServices.value.length > 0) {
counterServices.value.forEach((service: IAppCounterService) => {
service.destory();
})
}
})
}
/**
......
import { Subject } from "rxjs";
import { IActionParam, IParam } from '@core';
import { IActionParam, IAppCounterService, IParam } from '@core';
/**
* @description 视图基类状态
......@@ -15,6 +15,13 @@ export interface ViewStateBase {
*/
context: IParam;
/**
* @description 计数器服务集合
* @type {IAppCounterService[]}
* @memberof ViewStateBase
*/
counterServices?: IAppCounterService[];
/**
* @description 视图标识
* @type {string}
......
......@@ -70,7 +70,7 @@ export class FormControl extends MainControl {
*
* @memberof FormControl
*/
public setAnchorDatas() {
private setAnchorDatas() {
const { detailsModel } = this.state;
Object.values(detailsModel).forEach((item: IParam) => {
if (item.enableAnchor) {
......
import { hasFunction, IParam } from "@core";
import { hasFunction, IAppCounterService, IParam } from "@core";
export class AppCounterService {
/**
* @description 应用计数器服务
* @export
* @class AppCounterService
* @implements {IAppCounterService}
*/
export class AppCounterService implements IAppCounterService {
/**
* @description 定时器延时时间
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册