Files
fc/dev/project/assets/Scripts/nx/mods/trace/cmps/cmp.trace.sh.js
T

59 lines
1.5 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
* Copyright(C) 2019 - 2020 Nx Studio
*
* 埋点组件:界面开关
*
* 2018.05.18
******************************************************************/
const TDefine = require( "trace.define" );
const TTT = TDefine.TraceType;
cc.Class({
extends: cc.Component,
properties: {
wndName: { default: "", displayName: "窗体名" },
showType: { default: TTT.openWindow, type: TTT, displayName: "打开埋点" },
closeType: { default: TTT.closeWindow, type: TTT, displayName: "关闭埋点" },
},
// 编辑器特性
editor: {
// 允许当前组件在编辑器模式下运行
executeInEditMode: false,
// requireComponent 参数用来指定当前组件的依赖组件
requireComponent: cc.Button,
// 当本组件添加到节点上后,禁止同类型(含子类)的组件再添加到同一个节点,防止逻辑发生冲突
disallowMultiple: true,
// menu 用来将当前组件添加到组件菜单中,方便用户查找
menu: "Nx/埋点|界面开关",
},
// 显示
onEnable: function() {
// 打开埋点
if( nx.mTrace && nx.dt.strNEmpty( this.wndName ) && this.showType > 0 ) {
nx.mTrace.trace( this.showType, this.wndName );
}
},
// 隐藏
onDisable: function() {
// 关闭埋点
if( nx.mTrace && nx.dt.strNEmpty( this.wndName ) && this.closeType > 0 ) {
nx.mTrace.trace( this.closeType, this.wndName );
}
},
});