Browse Source

fit:1、浏览器插件优化和完善

master
pengwei 6 months ago
parent
commit
38f5947c17
  1. 22
      src/background/index.ts
  2. 253
      src/contentScript/ajhc/getInfo.ts
  3. 55
      src/contentScript/netComplaint/getInfo.ts
  4. 14
      src/contentScript/submit/getInfo.ts
  5. 8
      src/manifest.ts
  6. 2
      src/options/Options.vue
  7. 64
      src/utils/HtmlUtil.ts

22
src/background/index.ts

@ -8,12 +8,14 @@ import {
supervisionAjhcInfoUrl
} from "../../globalConfig";
import { ajax } from "../utils/ajax";
import request = chrome.permissions.request
console.log('后台开始运行');
// 当前申请案件办结的outerId
let curCompletionOuterId: string | null = null;
//捕获请求接口
chrome.webRequest.onBeforeRequest.addListener(
/*
--
@ -53,7 +55,8 @@ chrome.webRequest.onBeforeRequest.addListener(
}
}
}
} else if (details.url === "http://11.33.3.4/api/v5/gzzx/ajhc/zjxx") {
}
else if (details.url === "http://11.33.3.4/api/v5/gzzx/ajhc/zjxx") {
/*
--
*/
@ -88,7 +91,8 @@ chrome.webRequest.onBeforeRequest.addListener(
}
}
}
} else if (details.url === "http://11.33.3.4/api/v5/gzzx/ajcz") {
}
else if (details.url === "http://11.33.3.4/api/v5/gzzx/ajcz") {
/*
-
*/
@ -119,7 +123,8 @@ chrome.webRequest.onBeforeRequest.addListener(
}
}
}
} else if (details.url === "http://11.33.3.4/api/v5/gzzx/ajcz/czmx") {
}
else if (details.url === "http://11.33.3.4/api/v5/gzzx/ajcz/czmx") {
/*
-
*/
@ -156,7 +161,8 @@ chrome.webRequest.onBeforeRequest.addListener(
}
}
}
} else if (details.url.startsWith("http://11.33.3.4/api/v5/gzzx/bj/anqx/")) {
}
else if (details.url.startsWith("http://11.33.3.4/api/v5/gzzx/bj/anqx/")) {
/*
-id
*/
@ -207,16 +213,17 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
/*
-
*/
console.log('background-data---------')
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'sendAjhcData') {
console.log('案件核查-投诉受理数据上传')
const { caseNumber, caseSource, complaintTime, reporterName, reporterContact, verifiedObjectUnit, verifiedObjectUnitCode, verifiedObjectName, verifiedObjectPosition, briefCase, organization, complaintIssueNature, acceptanceLevel } = request.data;
// 使用 ajax 方法发送请求
ajax(supervisionAjhcInfoUrl, {
method: 'POST',
body: { caseNumber, caseSource, complaintTime, reporterName, reporterContact, verifiedObjectUnit, verifiedObjectUnitCode, verifiedObjectName, verifiedObjectPosition, briefCase, organization, complaintIssueNature, acceptanceLevel }
})
.then(response => response.json())
.then((data: any) => {
console.log('投诉受理数据上传Success:', data);
sendResponse({ status: 'success', data });
@ -229,8 +236,9 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
}
});
/*
-
* -
*/
// 监听来自 contentScript 的消息
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {

253
src/contentScript/ajhc/getInfo.ts

@ -1,113 +1,180 @@
import {ajhcInfoUrl, ajhcSysUrl} from "../../../globalConfig";
// 获取样本源头编号和问题发现时间
function getSampleData(): { sampleSourceNumber: string | null, issueDiscoveryTime: string | null } {
const elements = Array.from(document.querySelectorAll('div.col.col-6'));
let sampleSourceNumber: string | null = null;
let issueDiscoveryTime: string | null = null;
for (const element of elements) {
const labelElement = element.querySelector('label');
const spanElement = element.querySelector('span');
if (labelElement && spanElement) {
if (labelElement.textContent === '样本源头编号') {
sampleSourceNumber = spanElement.textContent;
} else if (labelElement.textContent === '问题发现时间') {
issueDiscoveryTime = spanElement.textContent;
}
}
}
return { sampleSourceNumber, issueDiscoveryTime };
}
// 发送样本源头编号和问题发现时间到指定接口
function sendData(sampleSourceNumber: string, issueDiscoveryTime: string) {
fetch(ajhcSysUrl + '/data/caseVerif', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ sampleSourceNumber, issueDiscoveryTime }),
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch((error) => console.error('Error:', error));
}
// 持续监控页面
function monitorPage() {
let lastSampleSourceNumber: string | null = null;
let lastIssueDiscoveryTime: string | null = null;
setInterval(() => {
const { sampleSourceNumber, issueDiscoveryTime } = getSampleData();
if (sampleSourceNumber && issueDiscoveryTime &&
(sampleSourceNumber !== lastSampleSourceNumber || issueDiscoveryTime !== lastIssueDiscoveryTime)) {
console.log('已找到样本源头编号和问题发现时间:', sampleSourceNumber, issueDiscoveryTime);
sendData(sampleSourceNumber, issueDiscoveryTime);
lastSampleSourceNumber = sampleSourceNumber; // 更新上次检测到的编号
lastIssueDiscoveryTime = issueDiscoveryTime; // 更新上次检测到的时间
}
}, 1000); // 每秒检查一次
}
let isMonitoring = false; // 添加标志位
// 使用 MutationObserver 监控 URL 变化
function observeUrlChange() {
const observer = new MutationObserver(() => {
if (!isMonitoring && window.location.href.includes(ajhcInfoUrl)) {
console.log('URL 包含指定路径,开始监控页面');
monitorPage();
isMonitoring = true; // 设置标志位为 true
observer.disconnect(); // 断开观察
}
checkAndShowWarning();
});
observer.observe(document.body, { childList: true, subtree: true });
}
// 执行 URL 监控函数
observeUrlChange();
// 创建警告消息的 div 元素
import {showNotification} from '../../utils/HtmlUtil'
// // import {ajhcInfoUrl, ajhcSysUrl} from "../../../globalConfig";
// //
// // // 获取样本源头编号和问题发现时间
// // function getSampleData(): { sampleSourceNumber: string | null, issueDiscoveryTime: string | null } {
// // const elements = Array.from(document.querySelectorAll('div.col.col-6'));
// // let sampleSourceNumber: string | null = null;
// // let issueDiscoveryTime: string | null = null;
// //
// // for (const element of elements) {
// // const labelElement = element.querySelector('label');
// // const spanElement = element.querySelector('span');
// //
// // if (labelElement && spanElement) {
// // if (labelElement.textContent === '样本源头编号') {
// // sampleSourceNumber = spanElement.textContent;
// // } else if (labelElement.textContent === '问题发现时间') {
// // issueDiscoveryTime = spanElement.textContent;
// // }
// // }
// // }
// //
// // return { sampleSourceNumber, issueDiscoveryTime };
// // }
// //
// // // 发送样本源头编号和问题发现时间到指定接口
// // function sendData(sampleSourceNumber: string, issueDiscoveryTime: string) {
// // fetch(ajhcSysUrl + '/data/caseVerif', {
// // method: 'POST',
// // headers: {
// // 'Content-Type': 'application/json',
// // },
// // body: JSON.stringify({ sampleSourceNumber, issueDiscoveryTime }),
// // })
// // .then(response => response.json())
// // .then(data => console.log('Success:', data))
// // .catch((error) => console.error('Error:', error));
// // }
// //
// // // 持续监控页面
// // function monitorPage() {
// // let lastSampleSourceNumber: string | null = null;
// // let lastIssueDiscoveryTime: string | null = null;
// //
// // setInterval(() => {
// // const { sampleSourceNumber, issueDiscoveryTime } = getSampleData();
// // if (sampleSourceNumber && issueDiscoveryTime &&
// // (sampleSourceNumber !== lastSampleSourceNumber || issueDiscoveryTime !== lastIssueDiscoveryTime)) {
// // console.log('已找到样本源头编号和问题发现时间:', sampleSourceNumber, issueDiscoveryTime);
// // sendData(sampleSourceNumber, issueDiscoveryTime);
// // lastSampleSourceNumber = sampleSourceNumber; // 更新上次检测到的编号
// // lastIssueDiscoveryTime = issueDiscoveryTime; // 更新上次检测到的时间
// // }
// // }, 1000); // 每秒检查一次
// // }
// //
// // let isMonitoring = false; // 添加标志位
// //
// // // 使用 MutationObserver 监控 URL 变化
// // function observeUrlChange() {
// // const observer = new MutationObserver(() => {
// // // console.log('打印内容')
// //
// // if (!isMonitoring && window.location.href.includes(ajhcInfoUrl)) {
// // console.log('URL 包含指定路径,开始监控页面');
// // monitorPage();
// // isMonitoring = true; // 设置标志位为 true
// // observer.disconnect(); // 断开观察
// // }else{
// // return;
// // }
// // // checkAndShowWarning();
// // });
// //
// // observer.observe(document.body, { childList: true, subtree: true });
// // }
// //
// // // 执行 URL 监控函数
// // observeUrlChange();
// //
// // // 创建警告消息的 div 元素
function createWarningDiv(): HTMLElement {
const warningDiv = document.createElement('div');
warningDiv.style.position = 'fixed';
warningDiv.style.top = '10px';
warningDiv.style.right = '100px';
warningDiv.style.color = 'red';
warningDiv.style.fontWeight = 'bold';
warningDiv.style.backgroundColor="white";
warningDiv.style.border="#ebeef5";
warningDiv.style.boxShadow="0px 0px 12px 0px";
warningDiv.style.padding="20px";
warningDiv.style.fontSize="12px";
warningDiv.style.borderRadius="10px";
warningDiv.style.overflowWrap="break-word";
warningDiv.textContent = '请登录插件,否则数据无法同步至一体化平台!';
warningDiv.classList.add('crx-login-warning');
warningDiv.style.display = 'none'; // 默认隐藏
document.body.appendChild(warningDiv);
return warningDiv;
}
// 创建一个通知栏函数
function showNotification(message:string, duration = 3000) {
// 创建通知栏的容器
let notificationDiv = document.createElement('div');
notificationDiv.id = 'notification'; // 设置一个唯一的ID以便后续操作
notificationDiv.style.position = 'fixed';
notificationDiv.style.top = '20px'; // 调整到你希望的位置
notificationDiv.style.right = '20px'; // 调整到你希望的位置
notificationDiv.style.backgroundColor = "white";
notificationDiv.style.border = "1px solid #ebeef5"; // 注意这里应该是border,而不是单独设置四个边的border
notificationDiv.style.boxShadow = "0px 0px 12px rgba(0, 0, 0, 0.1)"; // 增加了rgba颜色值来设置阴影的透明度
notificationDiv.style.padding = "20px";
notificationDiv.style.fontSize = "14px"; // 稍微增大了字体大小以提高可读性
notificationDiv.style.borderRadius = "8px"; // 调整了边框圆角的大小
notificationDiv.style.zIndex = "1000"; // 确保通知栏在其他内容之上
notificationDiv.style.transition = "opacity 0.3s ease, transform 0.3s ease"; // 添加过渡效果
notificationDiv.style.opacity = "1"; // 初始时完全可见
// 创建消息内容
const messageContent = document.createElement('div');
messageContent.textContent = message;
messageContent.style.margin = "0"; // 移除默认的margin
// 将消息内容添加到通知栏容器中
notificationDiv.appendChild(messageContent);
// 将通知栏容器添加到文档中
document.body.appendChild(notificationDiv);
// 设置定时器在指定时间后隐藏通知栏
setTimeout(() => {
notificationDiv.style.opacity = "0"; // 透明度逐渐变为0
notificationDiv.style.transform = "translateY(100%)"; // 向上移动出视线外
setTimeout(() => {
// 完全隐藏后从文档中移除
document.body.removeChild(notificationDiv);
}, 300); // 过渡效果的持续时间应与CSS中设置的transition时间相匹配
}, duration);
}
// 显示警告消息的函数
function showWarningMessage(warningDiv: HTMLElement, showMessage: boolean) {
warningDiv.style.display = showMessage ? 'block' : 'none';
}
// 检查并显示警告的函数
// // // 检查并显示警告的函数
function checkAndShowWarning() {
const warningDiv = createWarningDiv(); // 创建警告 div
setInterval(() => {
console.log('检查并显示警告');
if (window.location.href.includes(ajhcSysUrl)) {
chrome.storage.local.get(['srcAuthToken'], (result) => {
const token = result.srcAuthToken;
if (!token) {
console.log('未找到 srcAuthToken');
showWarningMessage(warningDiv, true); // 显示警告
} else {
showWarningMessage(warningDiv, false); // 隐藏警告
}
});
}
}, 5000); // 每5秒检查一次
// showWarningMessage(warningDiv, true); // 显示警告
showNotification('xxx的数据已抓取成功',3000)
}
checkAndShowWarning()
//
// import { ajhcInProgressUrl } from '../../../globalConfig'
//
// // function checkButtonAndExecute() {
// //
// //
// // setInterval(() => {
// //
// // chrome.runtime.sendMessage({action: 'ces'}, (response) => {
// // console.log(response)
// // });
// // // 发送消息到 popup
// // }, 5000); // 每2秒检查一次
// // }
//
//
//
// // chrome.
//
//
//
// // 执行定期检查函数
// checkButtonAndExecute();
//
//
//

55
src/contentScript/netComplaint/getInfo.ts

@ -1,5 +1,5 @@
import {ajhcOutInfoUrl} from "../../../globalConfig";
import {showNotification} from '../../utils/HtmlUtil'
/*
*/
@ -20,23 +20,19 @@ function getSampleData(): { caseNumber: string | null, caseSource: string | null
// 获取基本信息栏中的数据
const basicInfoTitle = findElementByText('div.ant-card-head-title', '基本信息');
console.log('获取到basicInfoTitle' + basicInfoTitle);
let caseNumber = null;
let caseSource = null;
let complaintTime = null;
if (basicInfoTitle) {
const basicInfoSection = basicInfoTitle.closest('.ant-card')?.querySelector('.ant-card-body');
console.log('获取到basicInfoSection' + basicInfoSection);
if (basicInfoSection) {
const caseNumberLabel = basicInfoSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="案件编号"])');
caseNumber = caseNumberLabel?.nextElementSibling?.querySelector('span.ant-form-item-children span')?.textContent || null;
console.log('获取到caseNumber' + caseNumber);
const caseSourceLabel = basicInfoSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="案件来源"])');
caseSource = caseSourceLabel?.nextElementSibling?.querySelector('span.ant-form-item-children')?.textContent || null;
console.log('获取到caseSource' + caseSource);
const complaintTimeLabel = basicInfoSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="投诉时间"])');
complaintTime = complaintTimeLabel?.nextElementSibling?.querySelector('span.ant-form-item-children')?.textContent || null;
console.log('获取到complaintTime' + complaintTime);
} else {
console.log('basicInfoSection没有找到');
}
@ -50,14 +46,14 @@ function getSampleData(): { caseNumber: string | null, caseSource: string | null
let reporterContact = null;
if (reporterInfoTitle) {
const reporterInfoSection = reporterInfoTitle.closest('.ant-card')?.querySelector('.ant-card-body');
console.log('获取到reporterInfoSection' + reporterInfoSection);
if (reporterInfoSection) {
const reporterNameLabel = reporterInfoSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="举报人姓名"])');
reporterName = reporterNameLabel?.nextElementSibling?.querySelector('span.ant-form-item-children')?.textContent || null;
console.log('获取到reporterName' + reporterName);
const reporterContactLabel = reporterInfoSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="联系方式"])');
reporterContact = reporterContactLabel?.nextElementSibling?.querySelector('span.ant-form-item-children')?.textContent || null;
console.log('获取到reporterContact' + reporterContact);
} else {
console.log('reporterInfoSection没有找到');
}
@ -73,11 +69,10 @@ function getSampleData(): { caseNumber: string | null, caseSource: string | null
let verifiedObjectPosition = null;
if (verifiedObjectTitle) {
const verifiedObjectSection = verifiedObjectTitle.closest('.ant-card')?.querySelector('.ant-card-body');
console.log('获取到verifiedObjectSection' + verifiedObjectSection);
if (verifiedObjectSection) {
const verifiedObjectUnitLabel = verifiedObjectSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="单位"])');
verifiedObjectUnit = verifiedObjectUnitLabel?.nextElementSibling?.querySelector('span.ant-form-item-children')?.textContent || null;
console.log('获取到verifiedObjectUnit' + verifiedObjectUnit);
const verifiedObjectUnitCodeString = verifiedObjectUnitLabel?.nextElementSibling?.querySelector('span.ant-form-item-children a')?.getAttribute('href') || null;
if (verifiedObjectUnitCodeString !== null) {
const verifiedObjectUnitCodeMatch = verifiedObjectUnitCodeString.match(/bjbdw_(\d+)/);
@ -85,13 +80,10 @@ function getSampleData(): { caseNumber: string | null, caseSource: string | null
verifiedObjectUnitCode = verifiedObjectUnitCodeMatch[1];
}
}
console.log('获取到verifiedObjectUnitCode' + verifiedObjectUnitCode);
const verifiedObjectNameLabel = verifiedObjectSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="姓名"])');
verifiedObjectName = verifiedObjectNameLabel?.nextElementSibling?.querySelector('span.ant-form-item-children')?.textContent || null;
console.log('获取到verifiedObjectName' + verifiedObjectName);
const verifiedObjectPositionLabel = verifiedObjectSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="职务"])');
verifiedObjectPosition = verifiedObjectPositionLabel?.nextElementSibling?.querySelector('span.ant-form-item-children')?.textContent || null;
console.log('获取到verifiedObjectPosition' + verifiedObjectPosition);
} else {
console.log('verifiedObjectSection没有找到');
}
@ -105,19 +97,16 @@ function getSampleData(): { caseNumber: string | null, caseSource: string | null
let briefCase = null;
if (complaintCaseTitle) {
const complaintCaseSection = complaintCaseTitle.closest('.ant-card')?.querySelector('.ant-card-body');
console.log('获取到complaintCaseSection' + complaintCaseSection);
if (complaintCaseSection) {
const organizationLabel = complaintCaseSection.querySelector('div.ant-col.ant-col-7.org-label');
if (organizationLabel && organizationLabel.textContent && organizationLabel.textContent.trim() === "组织机构:") {
organization = organizationLabel.nextElementSibling?.textContent || null;
console.log('获取到organization: ' + organization);
} else {
console.log('未找到"组织机构"标签');
}
const briefCaseLabel = complaintCaseSection.querySelector('div.ant-col.ant-col-5 span');
if (briefCaseLabel && briefCaseLabel.textContent && briefCaseLabel.textContent.trim() === "简要案情:") {
briefCase = briefCaseLabel?.parentElement?.nextElementSibling?.textContent || null;
console.log('获取到briefCase:', briefCase);
} else {
console.log('未找到"简要案情"标签');
}
@ -133,11 +122,11 @@ function getSampleData(): { caseNumber: string | null, caseSource: string | null
let complaintIssueNature = null;
if (questionTypeTitle) {
const questionTypeSection = questionTypeTitle.closest('.ant-card')?.querySelector('.ant-card-body');
console.log('获取到questionTypeSection' + questionTypeSection);
if (questionTypeSection) {
const complaintIssueNatureLabel = questionTypeSection.querySelector('div.ant-col.ant-form-item-label:has(label[title="投诉问题性质"])');
complaintIssueNature = complaintIssueNatureLabel?.nextElementSibling?.querySelector('ul.ant-select-selection__rendered')?.textContent || null;
console.log('获取到complaintIssueNature' + complaintIssueNature);
} else {
console.log('questionTypeSection没有找到');
}
@ -150,11 +139,11 @@ function getSampleData(): { caseNumber: string | null, caseSource: string | null
let acceptanceLevel = null;
if (acceptanceOpinionTitle) {
const acceptanceOpinionSection = acceptanceOpinionTitle.closest('.ant-card')?.querySelector('.ant-card-body');
console.log('获取到acceptanceOpinionSection' + acceptanceOpinionSection);
if (acceptanceOpinionSection) {
const acceptanceLevelLabel = acceptanceOpinionSection.querySelector('div.ant-col.ant-form-item-label:has(label.ant-form-item-required[title="拟办方式"])');
acceptanceLevel = acceptanceLevelLabel?.nextElementSibling?.querySelector('label.ant-radio-wrapper.ant-radio-wrapper-checked')?.textContent || "本级办理";
console.log('获取到acceptanceLevel' + acceptanceLevel);
} else {
console.log('acceptanceOpinionSection没有找到');
}
@ -165,14 +154,25 @@ function getSampleData(): { caseNumber: string | null, caseSource: string | null
return { caseNumber, caseSource, complaintTime, reporterName, reporterContact, verifiedObjectUnit, verifiedObjectUnitCode, verifiedObjectName, verifiedObjectPosition, briefCase, organization, complaintIssueNature, acceptanceLevel };
}
/*
*/
// 发送样本源头编号和问题发现时间到指定接口
function sendData(caseNumber: string | null, caseSource: string | null, complaintTime: string | null, reporterName: string | null, reporterContact: string | null, verifiedObjectUnit: string | null, verifiedObjectUnitCode: string | null, verifiedObjectName: string | null, verifiedObjectPosition: string | null, briefCase: string | null, organization: string | null, complaintIssueNature: string | null, acceptanceLevel: string | null) {
// 发送消息到 background 脚本
chrome.runtime.sendMessage({ action: 'sendAjhcData', data: { caseNumber, caseSource, complaintTime, reporterName, reporterContact, verifiedObjectUnit, verifiedObjectUnitCode, verifiedObjectName, verifiedObjectPosition, briefCase, organization, complaintIssueNature, acceptanceLevel } }, response => {
console.log('获取投诉受理数据结果:', response);
chrome.runtime.sendMessage({ action: "sendAjhcData", data: { caseNumber, caseSource, complaintTime, reporterName, reporterContact, verifiedObjectUnit, verifiedObjectUnitCode, verifiedObjectName, verifiedObjectPosition, briefCase, organization, complaintIssueNature, acceptanceLevel } },
response => {
console.log(response)
if(response.status === 'success' ){
console.log('获取投诉受理数据结果:', response);
}else{
console.log("获取投诉受理数据失败")
}
});
}
@ -181,6 +181,7 @@ function checkButtonAndExecute() {
let confirmButtonClickListener: () => void;
setInterval(() => {
const confirmButton = Array.from(document.querySelectorAll('button.ant-btn.ant-btn-primary'))
.find(button => button.querySelector('span')?.textContent === '确 认');
if (confirmButton && window.location.href.includes(ajhcOutInfoUrl)) {
@ -191,17 +192,23 @@ function checkButtonAndExecute() {
confirmButton.removeEventListener('click', confirmButtonClickListener);
}
// 定义新的事件监听器并添加
confirmButtonClickListener = () => {
const { caseNumber, caseSource, complaintTime, reporterName, reporterContact, verifiedObjectUnit, verifiedObjectUnitCode, verifiedObjectName, verifiedObjectPosition, briefCase, organization, complaintIssueNature, acceptanceLevel } = getSampleData();
console.log('已找到案件信息:', caseNumber, caseSource, complaintTime, reporterName, reporterContact, verifiedObjectUnit, verifiedObjectUnitCode, verifiedObjectName, verifiedObjectPosition, briefCase, organization, complaintIssueNature, acceptanceLevel);
showNotification(reporterName+"数据已抓取成功")
sendData(caseNumber, caseSource, complaintTime, reporterName, reporterContact, verifiedObjectUnit, verifiedObjectUnitCode, verifiedObjectName, verifiedObjectPosition, briefCase, organization, complaintIssueNature, acceptanceLevel);
};
//绑定点击事件
confirmButton.addEventListener('click', confirmButtonClickListener);
}
}, 1000); // 每1秒检查一次
}
// 执行定期检查函数
checkButtonAndExecute();

14
src/contentScript/submit/getInfo.ts

@ -60,24 +60,27 @@ function checkAndShowWarning() {
checkAndShowWarning(); // 在脚本加载时立即调用 checkAndShowWarning
/*
ID列表上传
ID列表上传 -- -
*/
let windowOn: boolean = false;
function checkAndCallUpdateDataRowKeys() {
if (window.location.href.includes(ajhcInProgressUrl)) {
const currentResult = document.querySelector('div.antd-pro-pages-workcenter-ajhc-ajhc-hcbg-index-hc');
updateDataRowKeys();
if (currentResult !== null && !windowOn) {
const currentResult = document.querySelector('div.antd-pro-pages-workcenter-ajhc-ajhc-hcbg-index-hc');
if (currentResult !== null && !windowOn) {
console.log('currentResult',currentResult)
//todo 不知道干啥,前面的人写的,先保留看看,console迁移到这里,减少打印的数量
}
windowOn = currentResult !== null;
}
}
//持续监听ID列表
setInterval(checkAndCallUpdateDataRowKeys, 1000);
const sentData = new Set<string>(); // 用于存储已经发送过的 caseNumber
//案件列表{ 案件编号 caseNumber,outerId } id 列表上传
function updateDataRowKeys() {
const scroll = document.querySelector('div.ant-table-scroll');
if (!scroll) {
@ -90,9 +93,9 @@ function updateDataRowKeys() {
return { caseNumber, outerId };
})
.filter(({ caseNumber }) => caseNumber !== null && caseNumber !== undefined && !sentData.has(caseNumber)); // 过滤掉已经发送过的 caseNumber
// 检查 dataRowKeyMaps 是否为空
if (dataRowKeyMaps.length > 0) {
console.log('dataRowKeyMaps',dataRowKeyMaps)
chrome.runtime.sendMessage({ action: 'fetchDataRowKeys', data: dataRowKeyMaps }, response => {
console.log('上传ID列表结果:', response);
if (response.status === "success") {
@ -174,4 +177,3 @@ function checkButtonAndExecute() {
checkButtonAndExecute();

8
src/manifest.ts

@ -63,10 +63,10 @@ export default defineManifest({
},
],
permissions: [
'alarms',
'sidePanel',
'storage',
'webRequest',
'alarms', //定时器
'sidePanel',//侧边栏
'storage', //本地存储
'webRequest',//web请求
'webRequestBlocking',
'activeTab',
'notifications',

2
src/options/Options.vue

@ -2,7 +2,7 @@
import { ref, onMounted } from 'vue'
const countSync = ref(0)
const link = ref('https://github.com/guocaoyi/create-chrome-ext')
// const link = ref('https://github.com/guocaoyi/create-chrome-ext')
onMounted(() => {
chrome.storage.sync.get(['count'], (result) => {

64
src/utils/HtmlUtil.ts

@ -0,0 +1,64 @@
/**
*
* @param message
* @param duration 3
* */
export const showNotification= (message:string, duration = 3000)=> {
// 创建通知栏的容器
let notificationDiv = document.createElement('div');
notificationDiv.id = 'notification'; // 设置一个唯一的ID以便后续操作
notificationDiv.style.position = 'fixed';
notificationDiv.style.top = '20px'; // 调整到你希望的位置
notificationDiv.style.right = '20px'; // 调整到你希望的位置
notificationDiv.style.backgroundColor = "white";
notificationDiv.style.border = "1px solid #ebeef5"; // 注意这里应该是border,而不是单独设置四个边的border
notificationDiv.style.boxShadow = "0px 0px 12px rgba(0, 0, 0, 0.1)"; // 增加了rgba颜色值来设置阴影的透明度
notificationDiv.style.padding = "20px";
notificationDiv.style.fontSize = "14px"; // 稍微增大了字体大小以提高可读性
notificationDiv.style.borderRadius = "8px"; // 调整了边框圆角的大小
notificationDiv.style.zIndex = "1000"; // 确保通知栏在其他内容之上
notificationDiv.style.transition = "opacity 0.3s ease, transform 0.3s ease"; // 添加过渡效果
notificationDiv.style.opacity = "1"; // 初始时完全可见
// 创建消息内容
const messageContent = document.createElement('div');
messageContent.textContent = message;
messageContent.style.margin = "0"; // 移除默认的margin
// 将消息内容添加到通知栏容器中
notificationDiv.appendChild(messageContent);
// 将通知栏容器添加到文档中
document.body.appendChild(notificationDiv);
// 设置定时器在指定时间后隐藏通知栏
setTimeout(() => {
notificationDiv.style.opacity = "0"; // 透明度逐渐变为0
notificationDiv.style.transform = "translateY(100%)"; // 向上移动出视线外
setTimeout(() => {
// 完全隐藏后从文档中移除
document.body.removeChild(notificationDiv);
}, 300); // 过渡效果的持续时间应与CSS中设置的transition时间相匹配
}, duration);
}
/**
*
* @param div
* @param content
* @param type
* */
export const addHintSpan=(div:HTMLDivElement,content="已同步",type="success")=>{
let message = document.createElement('span');
message.style.padding="2px";
message.style.display="inline-block";
message.style.color="white";
message.style.borderRadius="5px";
if(type==="success"){
message.style.border="1px solid blue";
message.style.backgroundColor="blue";
}else{
message.style.border="1px solid red";
message.style.backgroundColor="red";
}
message.textContent=content;
div.appendChild(message);
}
Loading…
Cancel
Save