| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- let dataTemp = {}
- window.electronAPI.readFile({filename: 'data.json', encoding: "utf8"}).then(result => {
- if (result.success) {
- console.log(result.content);
- dataTemp = JSON.parse(result.content)
- } else {
- console.error('文件读取失败:', result.error);
- }
- });
- window.onInterceptedData = function (data) {
- console.log(data)
- if (data.url.includes('%E6%8F%90%E4%BA%A4%E7%AD%94%E6%A1%88')) {
- const pageID = data.requestBody['试题Id']
- const resb = JSON.parse(data.responseBody)
- console.log(resb['正确选项Id列表'], pageID)
- dataTemp[pageID] = resb['正确选项Id列表']
- const fileData = {
- filename: 'data.json',
- content: JSON.stringify(dataTemp)
- };
- // 调用保存方法
- window.electronAPI.saveFile(fileData).then(result => {
- if (result.success) {
- console.log('文件保存成功:', result.path);
- } else {
- console.error('文件保存失败:', result.error);
- }
- });
- }
- if (data.url.includes('%E5%BC%80%E5%A7%8B%E8%87%AA%E6%B5%8B')) {
- const resb = JSON.parse(data.responseBody)
- const dqst = resb['当前题目']['Id']
- if (dataTemp[dqst]) {
- setTimeout(() => {
- if (window.optionsArea) {
- dataTemp[dqst].forEach(creatID => {
- window.optionsArea.querySelector(`[data-option-id="${creatID}"]`).style.backgroundColor = 'aliceblue'
- });
-
- }
- }, 1000);
- }
-
- }
- if (data.url.includes('%E5%88%87%E6%8D%A2%E9%A2%98%E7%9B%AE')) {
- const resb = JSON.parse(data.responseBody)
- const dqst = resb['当前试题']['Id']
- if (dataTemp[dqst]) {
- setTimeout(() => {
- if (window.optionsArea) {
- dataTemp[dqst].forEach(creatID => {
- window.optionsArea.querySelector(`[data-option-id="${creatID}"]`).style.backgroundColor = 'aliceblue'
- });
-
- }
- }, 1000);
- }
-
- }
- };
|