画布页面判断如果存在编辑权,则进行浏览监控
This commit is contained in:
parent
fec2b28226
commit
c86afb5d02
@ -315,6 +315,13 @@
|
|||||||
//三员管理
|
//三员管理
|
||||||
var isHighSecurity = "<#isHighSecurity>";
|
var isHighSecurity = "<#isHighSecurity>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// BPMN所需参数
|
// BPMN所需参数
|
||||||
var BPMN_TYPE_START_EVENT = "<#BPMN_TYPE_START_EVENT>";
|
var BPMN_TYPE_START_EVENT = "<#BPMN_TYPE_START_EVENT>";
|
||||||
var AWS_ELEMENT_START_EVENT_MESSAGE_EVENT_DEFINITION = "<#AWS_ELEMENT_START_EVENT_MESSAGE_EVENT_DEFINITION>";
|
var AWS_ELEMENT_START_EVENT_MESSAGE_EVENT_DEFINITION = "<#AWS_ELEMENT_START_EVENT_MESSAGE_EVENT_DEFINITION>";
|
||||||
|
|||||||
@ -289,6 +289,154 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//判断如果当前页面有编辑权进行记录操作
|
||||||
|
if($('#checkoutTip').css('display') != 'block'){
|
||||||
|
|
||||||
|
// 页面停留时间统计
|
||||||
|
class PageStayTimeTracker {
|
||||||
|
constructor() {
|
||||||
|
this.startTime = null;
|
||||||
|
this.lastReportTime = null;
|
||||||
|
this.reportInterval = 10000; // 60秒报告一次
|
||||||
|
this.isActive = false;
|
||||||
|
this.isPageVisible = true; // 默认页面是可见的
|
||||||
|
this.visibilityBound = false; // 是否已绑定可见性事件
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 延迟绑定可见性事件
|
||||||
|
bindVisibilityEvents() {
|
||||||
|
if (this.visibilityBound) return;
|
||||||
|
|
||||||
|
document.addEventListener('visibilitychange', this.handleVisibilityChange.bind(this));
|
||||||
|
this.visibilityBound = true;
|
||||||
|
|
||||||
|
// 初始检查页面可见状态
|
||||||
|
this.isPageVisible = !document.hidden;
|
||||||
|
if (!this.isPageVisible) {
|
||||||
|
this.lastReportTime = new Date(); // 更新最后记录时间
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 开始跟踪
|
||||||
|
startTracking() {
|
||||||
|
if (this.isActive) return;
|
||||||
|
|
||||||
|
this.startTime = new Date();
|
||||||
|
this.lastReportTime = this.startTime;
|
||||||
|
this.isActive = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 设置定时器
|
||||||
|
this.intervalId = setInterval(() => {
|
||||||
|
if (this.isPageVisible) {
|
||||||
|
this.reportStayTime();
|
||||||
|
}
|
||||||
|
}, this.reportInterval);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 页面卸载前发送剩余时间
|
||||||
|
window.addEventListener('beforeunload', this.finalReport.bind(this));
|
||||||
|
|
||||||
|
|
||||||
|
// 延迟绑定可见性事件(在用户首次交互后)
|
||||||
|
const bindOnInteraction = () => {
|
||||||
|
this.bindVisibilityEvents();
|
||||||
|
// 移除所有交互监听器
|
||||||
|
['click', 'scroll', 'keydown', 'mousemove', 'touchstart'].forEach(event => {
|
||||||
|
window.removeEventListener(event, bindOnInteraction);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加多种交互监听
|
||||||
|
['click', 'scroll', 'keydown', 'mousemove', 'touchstart'].forEach(event => {
|
||||||
|
window.addEventListener(event, bindOnInteraction, { once: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 报告停留时间
|
||||||
|
reportStayTime() {
|
||||||
|
const now = new Date();
|
||||||
|
const elapsed = now - this.lastReportTime;
|
||||||
|
this.totalStayTime += elapsed;
|
||||||
|
this.lastReportTime = now;
|
||||||
|
|
||||||
|
this.sendStayTimeToServer(elapsed, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最终报告
|
||||||
|
finalReport() {
|
||||||
|
if (!this.isActive) return;
|
||||||
|
if (this.isPageVisible) {
|
||||||
|
const now = new Date();
|
||||||
|
const elapsed = now - this.lastReportTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.sendStayTimeToServer(elapsed, false);
|
||||||
|
this.cleanUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理页面可见性变化
|
||||||
|
handleVisibilityChange() {
|
||||||
|
var now = new Date();
|
||||||
|
if (document.hidden) {
|
||||||
|
if (this.isPageVisible) {
|
||||||
|
this.isPageVisible = false;
|
||||||
|
// 页面不可见,暂停计时
|
||||||
|
const now = new Date();
|
||||||
|
const elapsed = now - this.lastReportTime;
|
||||||
|
this.totalStayTime += elapsed;
|
||||||
|
this.sendStayTimeToServer(elapsed, false);
|
||||||
|
clearInterval(this.intervalId);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// 页面恢复可见
|
||||||
|
if (!this.isPageVisible) {
|
||||||
|
this.lastReportTime = now; // 重置最后记录时间
|
||||||
|
}
|
||||||
|
this.isPageVisible = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发送数据到服务器
|
||||||
|
sendStayTimeToServer(elapsedMs,isActive) {
|
||||||
|
$.ajax({
|
||||||
|
type : "POST",
|
||||||
|
url : "./w?sid=" + encodeURIComponent($('#sid').val()) + "&cmd=com.awspaas.user.apps.browsing_data.service.insertReadingLog",
|
||||||
|
data : "userId="+userId+"&userName="+userName+"&ruuid="+ruuid+"&fileName="+fileName+"&startTime="+new Date(this.startTime).getTime()+"¤tTime="+new Date().getTime()+"&browserId="+browserId+"&isActive="+isActive,
|
||||||
|
success : function(msg) {
|
||||||
|
if (msg.result == "error") {
|
||||||
|
$.simpleAlert("新增失败", "error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清理资源
|
||||||
|
cleanUp() {
|
||||||
|
clearInterval(this.intervalId);
|
||||||
|
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
||||||
|
window.removeEventListener('beforeunload', this.finalReport);
|
||||||
|
this.isActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用示例
|
||||||
|
const tracker = new PageStayTimeTracker();
|
||||||
|
tracker.startTracking();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// 导出流程手册
|
// 导出流程手册
|
||||||
function outputProcess() {
|
function outputProcess() {
|
||||||
$('li[data-name="processOutput"]').show();
|
$('li[data-name="processOutput"]').show();
|
||||||
|
|||||||
@ -472,7 +472,7 @@ function downloadFile(url,type) {
|
|||||||
"modelName": parent.fileName,
|
"modelName": parent.fileName,
|
||||||
"downloadType": fileExtension,
|
"downloadType": fileExtension,
|
||||||
"fileName":subFileName,
|
"fileName":subFileName,
|
||||||
"recordSource": "PAL画布->",
|
"recordSource": "PAL画布-附件下载",
|
||||||
"fileName":fileName.substring(0,fileName.lastIndexOf(".")),
|
"fileName":fileName.substring(0,fileName.lastIndexOf(".")),
|
||||||
"downloadsource": downloadsource
|
"downloadsource": downloadsource
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user