feat(xq0002): 新增钉钉群通知推送功能,优化雇主险增减操作流程

This commit is contained in:
2026-10-05 09:42:56 +08:00
parent 2e514d54d1
commit 23e8082511
83 changed files with 11419 additions and 180 deletions
@@ -104,7 +104,7 @@ import { adminFileSources, adminFileSourceCreate, adminFileSourcePatch, adminFil
import PagerBar from '../components/PagerBar.vue'
import { usePagedList } from '../composables/usePagedList'
const CATS = ['shell', 'chrome']
const CATS = ['shell', 'chrome-x64', 'chrome-x86']
const categories = CATS
const filter = ref('')
const list = usePagedList((p, s) => adminFileSources(filter.value || '', p, s), { onError: e => message.error('读取失败:' + (e.message || e)) })
@@ -123,7 +123,7 @@ watch(rows, () => {
})
function catType(c) {
return { shell: 'success', chrome: 'warning' }[c] || 'info'
return { shell: 'success', 'chrome-x64': 'warning', 'chrome-x86': 'warning', chrome: 'warning' }[c] || 'info'
}
function openCreate() {
@@ -30,6 +30,16 @@ const _STATE = {
const VERSION_RE = /^\d+\.\d+\.\d+\.\d+$/;
// 系统位数:Chrome 安装包按位数分发(登记分类 chrome-x64 / chrome-x86)
function detectArch() {
const pa = (process.env.PROCESSOR_ARCHITECTURE || "").toLowerCase();
if (process.env.PROCESSOR_ARCHITEW6432) return "x64"; // 32 位进程跑在 64 位系统
if (pa === "amd64" || pa === "arm64" || pa === "ia64") return "x64";
if (pa === "x86") return "x86";
return "x64"; // 未知默认按 64 位
}
const ARCH = detectArch();
// 本机检测缓存:前端轮询 status 时避免每 2s 反复 spawn reg/powershell
let _localCache = { ts: 0, value: null };
const LOCAL_CACHE_TTL = 30 * 1000;
@@ -97,19 +107,22 @@ async function readVersion(exe) {
async function cloudInfo() {
if (!config.CONTROLPLANE_URL) return null;
try {
const r = await cp.request("GET", "/api/file-sources/chrome", { headers: cp.machineHeaders(), timeout: 5 });
if (!r.available) {
_STATE.cloud_available = false;
return null;
// 按位数请求对应分类:64 位 → chrome-x64,32 位 → chrome-x86;
// 未按位数登记时回退旧分类 chrome(兼容历史登记),保证老记录仍可用。
const cats = ARCH === "x86" ? ["chrome-x86", "chrome"] : ["chrome-x64", "chrome"];
for (const cat of cats) {
try {
const r = await cp.request("GET", `/api/file-sources/${cat}`, { headers: cp.machineHeaders(), timeout: 5 });
if (r.available) {
_STATE.cloud_available = true;
return { ...r, arch: ARCH, category: cat };
}
} catch (e) {
logger.info(`获取浏览器云端信息失败(${cat}):${e.message}`);
}
_STATE.cloud_available = true;
return r;
} catch (e) {
logger.info(`获取浏览器云端信息失败(离线跳过):${e.message}`);
_STATE.cloud_available = false;
return null;
}
_STATE.cloud_available = false;
return null;
}
async function status() {
@@ -124,6 +137,7 @@ async function status() {
}
const pkgOk = !!_pendingPkg && fs.existsSync(_pendingPkg);
return {
arch: ARCH,
installed: !!_STATE.installed,
version: _STATE.version || "",
// 已安装时不再暴露"安装包已就绪",避免前端误触发重新安装
@@ -162,7 +176,7 @@ async function startDownload() {
if (!info || !info.url) return;
const url = String(info.url).trim();
const expect = String(info.sha256 || "").toLowerCase();
const filename = String(info.filename || "ChromeStandaloneSetup64.exe").trim();
const filename = String(info.filename || (ARCH === "x86" ? "ChromeStandaloneSetup.exe" : "ChromeStandaloneSetup64.exe")).trim();
if (_downloading) return;
_downloading = true;
_STATE.dl_status = "downloading";
@@ -249,20 +263,27 @@ function install() {
throw Object.assign(new Error("未找到已下载的 Chrome 安装包"), { status: 404 });
}
_STATE.installing = true;
logger.info(`开始静默安装 Chrome:${_pendingPkg}`);
const child = spawn(_pendingPkg, ["/silent", "/install"], {
logger.info(`启动 Chrome 安装器(弹出窗口由用户完成安装):${_pendingPkg}`);
// 直接弹出官方安装器窗口、由用户点击完成安装(不下发静默参数):
// 新版 Chrome 安装器会静默忽略未知参数(旧版 /silent /install 组合),
// 后台无窗口执行会表现为「静默失败/灰屏无法点击」,交互式安装可根治该问题。
const child = spawn(_pendingPkg, [], {
cwd: path.dirname(_pendingPkg),
windowsHide: true,
windowsHide: false, // 保证安装器窗口可见,用户能正常操作
stdio: "ignore",
detached: true,
});
child.on("error", (e) => {
_STATE.installing = false;
logger.warning(`启动 Chrome 安装器失败:${e.message}`);
});
child.unref();
void pollInstall();
return { ok: true, installing: true };
}
async function pollInstall() {
for (let i = 0; i < 60; i++) {
for (let i = 0; i < 120; i++) { // 交互式安装由用户人工操作,时限放宽到 10 分钟
await new Promise((r) => setTimeout(r, 5000));
const local = await detectLocal();
if (local.installed) {
@@ -276,7 +297,7 @@ async function pollInstall() {
}
}
_STATE.installing = false;
logger.warning("等待 Chrome 安装完成超时");
logger.warning("等待 Chrome 安装完成超时(可能用户未完成安装器窗口操作)");
}
module.exports = { status, refresh, startDownload, install, detectLocal };
+2 -2
View File
@@ -211,7 +211,7 @@
<el-dialog v-model="chromeDlg" :title="chromeDlgTitle" width="420px"
:close-on-click-modal="false" align-center class="upd-dl-dialog">
<template v-if="chrome.value.installing">
<div class="dl-dlg-body"><span>正在静默安装 Chrome,请稍候…(可最小化到后台继续安装)</span></div>
<div class="dl-dlg-body"><span>已弹出 Chrome 安装器窗口,请在弹出的窗口中点击完成安装(如未弹出请查看任务栏)…</span></div>
</template>
<template v-else-if="chrome.value.dl?.status === 'downloading'">
<div class="dl-dlg-body">
@@ -431,7 +431,7 @@ const chromeLabel = computed(() => {
const chromeTip = computed(() => {
const c = chrome.value
if (c.installed) return `本机已安装 Chrome ${c.version},点击重新检测`
if (c.installing) return '正在安装 Chrome,请稍候…'
if (c.installing) return '已弹出 Chrome 安装器,请在弹出的窗口中完成安装'
if (c.downloaded) return 'Chrome 安装包已下载,点击安装'
if (c.dl?.status === 'downloading') return '正在下载 Chrome 安装包 ' + c.dl?.pct + '%'
if (!c.cloud_available) return '中心机暂未登记浏览器安装包,点击重新检测'