feat: 添加长连接检查和提示信息

This commit is contained in:
吴昊天 2026-09-24 17:03:30 +08:00 committed by sugar1569
parent bad134aa3f
commit c5233454b3
3 changed files with 34 additions and 1 deletions

View File

@ -155,6 +155,7 @@ class PublicController
};
$runtime = root_path('runtime');
$info['process'] = [
['name' => '长链接', 'require' => '开启', 'value' => $isHeartbeatFresh($runtime . '.workerman') || $checkLegacyPid('workerman')],
['name' => '定时任务', 'require' => '开启', 'value' => $isHeartbeatFresh($runtime . '.timer') || $checkLegacyPid('timer')],
['name' => '消息队列', 'require' => '开启', 'value' => sys_config('queue_open', 0) == 1 && $isHeartbeatFresh($runtime . '.queue_heartbeat')],
];

View File

@ -87,6 +87,7 @@ import 'swiper/css';
import 'swiper/css/pagination';
import { AccountLogin, loginInfoApi } from '@/api/account';
import { getWorkermanUrl } from '@/api/setting';
import { setCookies } from '@/libs/util';
import '@/assets/js/canvas-nest.min';
import Verify from '@/components/verifition/Verify';
@ -237,6 +238,7 @@ function closeModel(params) {
});
}, 0);
}
checkSocket();
} catch (e) {}
PrevLoading.start();
router.push({
@ -266,6 +268,31 @@ function formatTwoStageRoutes(arr) {
keepAliveNamesStore.setCacheKeepAlive(cacheList);
}
}
function checkSocket() {
getWorkermanUrl()
.then((res) => {
const url = res.data.admin;
let isNotice = false;
const socket = new window.WebSocket(url);
socket.onopen = () => {
isNotice = true;
socket.close();
};
socket.onerror = socket.onclose = () => {
if (!isNotice) {
isNotice = true;
ElNotification.warning({
title: '温馨提示',
message:
'您的【长连接】未开启,没有开启会导致系统默认客服无法使用,后台订单通知无法收到。请尽快执行命令开启!!<a href="https://doc.crmeb.com/single/v54/13667" target="_blank">点击查看开启方法</a>',
dangerouslyUseHTMLString: true,
duration: 30000,
});
}
};
})
.catch(() => {});
}
function getExpiresTime(expiresTime) {
const nowTimeNum = Math.round(Date.now() / 1000);
const expiresTimeNum = expiresTime - nowTimeNum;

View File

@ -36,8 +36,13 @@ import { copyrightList as copyrightListApi } from '@/api/system';
defineOptions({ name: 'system_auth' });
const tableList = ref([]);
// 与后端 process 数组顺序一一对应(长链接已移除):0=定时任务 1=消息队列
// 与后端 process 数组顺序一一对应:0=长链接 1=定时任务 2=消息队列
const trips = [
{
title: '温馨提示',
message:
'您的【长连接】未开启,没有开启会导致系统默认客服无法使用,后台订单通知无法收到。请尽快执行命令开启!!<a href="https://doc.crmeb.com/single/v54/13667" target="_blank">点击查看开启方法</a>',
},
{
title: '温馨提示',
message: