hookehuyr

页面不操作会超时需要去登录页

...@@ -718,6 +718,55 @@ export default { ...@@ -718,6 +718,55 @@ export default {
718 getFlowData(flow_id); 718 getFlowData(flow_id);
719 } 719 }
720 720
721 + /************************ 页面操作超时 ****************************/
722 + var timeoutId;
723 + var timeoutDuration = 60 * 60 * 1000; // 设置超时时间,单位为毫秒
724 +
725 + // 监听用户的操作
726 + function resetTimeout() {
727 + clearTimeout(timeoutId); // 清除之前的定时器
728 + timeoutId = setTimeout(handleTimeout, timeoutDuration); // 设置新的定时器
729 + }
730 +
731 + const parseQueryString = url => {
732 + var json = {
733 + form_id: ''
734 + };
735 + var arr = url.indexOf('?') >= 0 ? url.substr(url.indexOf('?') + 1).split('&') : [];
736 + arr.forEach(item => {
737 + var tmp = item.split('=');
738 + json[tmp[0]] = decodeURIComponent(tmp[1]);
739 + });
740 + return json;
741 + }
742 +
743 + // 处理超时操作
744 + function handleTimeout() {
745 + ElMessageBox.alert('操作超时!将跳转到登录页面。', '温馨提示', {
746 + confirmButtonText: '确定',
747 + showClose: false,
748 + callback: action => {
749 + if (action === 'confirm') {
750 + localStorage.setItem('showConfirmation', '0'); // 屏蔽显示点击刷新按钮时的提示
751 + // 清除cookie
752 + document.cookie = `PHPSESSID=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
753 + // 拼接跳转地址,因为要返回到当前页面传入参数
754 + let url_params = parseQueryString(location.href);
755 + let str = `/admin/custom_flow/?form_id=${url_params.form_id}`;
756 + window.location.href = location.origin + '/admin/' + window.location.search + `&refer_url=${encodeURIComponent(str)}`;
757 + }
758 + }
759 + });
760 + }
761 +
762 + // 绑定事件处理程序到浏览器事件
763 + document.addEventListener("mousemove", resetTimeout);
764 + document.addEventListener("mousedown", resetTimeout);
765 + document.addEventListener("keypress", resetTimeout);
766 + document.addEventListener("touchstart", resetTimeout);
767 +
768 + /*********************************** END ***********************************/
769 +
721 // 显示提示框的标志位 770 // 显示提示框的标志位
722 onMounted(async () => { 771 onMounted(async () => {
723 document.title = '可视化流程设计器' 772 document.title = '可视化流程设计器'
......