This commit is contained in:
LingandRX 2024-12-20 23:25:00 +08:00
parent b9c7b52a4d
commit 82414ef213
4 changed files with 3689 additions and 3517 deletions

View File

@ -1,8 +1,11 @@
[
{
"databaseName": "hlk_touch_test_14920",
"data": [
{ "key": "HLK_TOUCH_account_mobile", "value": "17770720274" },
{
"key": "HLK_TOUCH_currentShop",
"value": { "14920": { "currentShopId": 26981, "timer": 1734622498195 } }
"value": { "14920": { "currentShopId": 26981, "timer": 1734703756648 } }
},
{
"key": "HLK_TOUCH_metadata",
@ -278,17 +281,6 @@
"status": "NORMAL",
"createTs": 1723709231000
},
{
"id": 51577,
"merchantId": 14920,
"shopId": 26981,
"no": "FIRST",
"name": "顾问",
"departmentNo": "1",
"seqNo": null,
"status": "NORMAL",
"createTs": 1723709536000
},
{
"id": 51771,
"merchantId": 14920,
@ -333,6 +325,17 @@
"status": "NORMAL",
"createTs": 1723709193000
},
{
"id": 51577,
"merchantId": 14920,
"shopId": 26981,
"no": "FIRST",
"name": "顾问",
"departmentNo": "1",
"seqNo": null,
"status": "NORMAL",
"createTs": 1723709536000
},
{
"id": 51578,
"merchantId": 14920,
@ -344,17 +347,6 @@
"status": "NORMAL",
"createTs": 1723709536000
},
{
"id": 51580,
"merchantId": 14920,
"shopId": 26982,
"no": "SECOND",
"name": "美容师",
"departmentNo": "1",
"seqNo": null,
"status": "NORMAL",
"createTs": 1723709546000
},
{
"id": 51571,
"merchantId": 14920,
@ -389,15 +381,15 @@
"createTs": 1723709545000
},
{
"id": 51574,
"id": 51580,
"merchantId": 14920,
"shopId": null,
"shopId": 26982,
"no": "SECOND",
"name": "医师",
"departmentNo": "2",
"name": "美容师",
"departmentNo": "1",
"seqNo": null,
"status": "NORMAL",
"createTs": 1723709389000
"createTs": 1723709546000
},
{
"id": 51565,
@ -433,15 +425,15 @@
"createTs": 1723709389000
},
{
"id": 51576,
"id": 51574,
"merchantId": 14920,
"shopId": 26981,
"shopId": null,
"no": "SECOND",
"name": "医师",
"departmentNo": "2",
"seqNo": null,
"status": "NORMAL",
"createTs": 1723709533000
"createTs": 1723709389000
},
{
"id": 51575,
@ -453,6 +445,17 @@
"seqNo": null,
"status": "NORMAL",
"createTs": 1723709533000
},
{
"id": 51576,
"merchantId": 14920,
"shopId": 26981,
"no": "SECOND",
"name": "医师",
"departmentNo": "2",
"seqNo": null,
"status": "NORMAL",
"createTs": 1723709533000
}
],
"merchantInterConfig": {
@ -663,15 +666,6 @@
"status": "NORMAL",
"createTs": 1723709545000
},
{
"id": 35583,
"merchantId": 14920,
"shopId": 26981,
"no": "2",
"name": "医美部",
"status": "NORMAL",
"createTs": 1723709533000
},
{
"id": 35582,
"merchantId": 14920,
@ -680,6 +674,15 @@
"name": "医美部",
"status": "NORMAL",
"createTs": 1723709389000
},
{
"id": 35583,
"merchantId": 14920,
"shopId": 26981,
"no": "2",
"name": "医美部",
"status": "NORMAL",
"createTs": 1723709533000
}
],
"user": [
@ -1116,7 +1119,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": "24082064254008068495",
"group": null,
@ -1160,7 +1168,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": "24082055976109612496",
"group": null,
@ -1204,7 +1217,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1248,7 +1266,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1292,7 +1315,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1336,7 +1364,12 @@
"departmentNo": "2",
"isServing": "Y",
"levels": [
{ "no": "38823192", "name": "医美咨询师", "departmentNo": "2", "positionNo": "FIRST" }
{
"no": "38823192",
"name": "医美咨询师",
"departmentNo": "2",
"positionNo": "FIRST"
}
],
"groupNo": "24082039599685473852",
"group": null,
@ -1380,7 +1413,12 @@
"departmentNo": "2",
"isServing": "Y",
"levels": [
{ "no": "38823192", "name": "医美咨询师", "departmentNo": "2", "positionNo": "FIRST" }
{
"no": "38823192",
"name": "医美咨询师",
"departmentNo": "2",
"positionNo": "FIRST"
}
],
"groupNo": "24082026153655700495",
"group": null,
@ -1424,7 +1462,12 @@
"departmentNo": "2",
"isServing": "Y",
"levels": [
{ "no": "38823192", "name": "医美咨询师", "departmentNo": "2", "positionNo": "FIRST" }
{
"no": "38823192",
"name": "医美咨询师",
"departmentNo": "2",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1468,7 +1511,12 @@
"departmentNo": "2",
"isServing": "Y",
"levels": [
{ "no": "38823192", "name": "医美咨询师", "departmentNo": "2", "positionNo": "FIRST" }
{
"no": "38823192",
"name": "医美咨询师",
"departmentNo": "2",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1512,7 +1560,12 @@
"departmentNo": "2",
"isServing": "Y",
"levels": [
{ "no": "38823192", "name": "医美咨询师", "departmentNo": "2", "positionNo": "FIRST" }
{
"no": "38823192",
"name": "医美咨询师",
"departmentNo": "2",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1556,7 +1609,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1600,7 +1658,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1644,7 +1707,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1688,7 +1756,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1732,7 +1805,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "26998199", "name": "美容顾问", "departmentNo": "1", "positionNo": "FIRST" }
{
"no": "26998199",
"name": "美容顾问",
"departmentNo": "1",
"positionNo": "FIRST"
}
],
"groupNo": null,
"group": null,
@ -1776,7 +1854,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -1820,7 +1903,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -1864,7 +1952,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -1908,7 +2001,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -1952,7 +2050,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -2216,7 +2319,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -2260,7 +2368,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -2304,7 +2417,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -2348,7 +2466,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -2392,7 +2515,12 @@
"departmentNo": "1",
"isServing": "Y",
"levels": [
{ "no": "41513283", "name": "美容师", "departmentNo": "1", "positionNo": "SECOND" }
{
"no": "41513283",
"name": "美容师",
"departmentNo": "1",
"positionNo": "SECOND"
}
],
"groupNo": null,
"group": null,
@ -2424,38 +2552,6 @@
"crmSn": null
}
],
"merchant": [
{
"id": 14920,
"name": "AT测试租户",
"brandLogo": "upload/14920/0/6f72381b2c734aac8d610a2e75d7fa60.jpg",
"brandName": "AT测试EEO",
"contact": "邬琴",
"phone": "13677997987",
"remark": ["测试租户"],
"adminExt": {
"serviceEmp": { "name": "", "id": "" },
"org": { "name": "" },
"city": { "name": "深圳", "id": "0755" },
"employee": { "name": "深圳公司", "id": "24" },
"group": { "name": "深圳_深圳公司", "id": "10" },
"payFace": {
"faceHandlerEmpName": "",
"posHandlerEmpId": "",
"faceChargeEmpId": "",
"faceHandlerEmpId": "",
"posHandlerEmpName": "",
"faceChargeEmpName": ""
}
},
"status": "NORMAL",
"createTs": 1723709147000,
"lastUpdateTs": 1733356105000,
"channelType": "HLK",
"enableRegion": "N"
}
],
"merchantRegion": [],
"paymentConfig": { "id": 17022, "merchantId": 14920, "channel": "DLB", "ext": {} },
"classify": [
{
@ -2997,6 +3093,37 @@
]
}
],
"merchant": [
{
"id": 14920,
"name": "AT测试租户",
"brandLogo": "upload/14920/0/6f72381b2c734aac8d610a2e75d7fa60.jpg",
"brandName": "AT测试EEO",
"contact": "邬琴",
"phone": "13677997987",
"remark": ["测试租户"],
"adminExt": {
"serviceEmp": { "name": "", "id": "" },
"org": { "name": "" },
"city": { "name": "深圳", "id": "0755" },
"employee": { "name": "深圳公司", "id": "24" },
"group": { "name": "深圳_深圳公司", "id": "10" },
"payFace": {
"faceHandlerEmpName": "",
"posHandlerEmpId": "",
"faceChargeEmpId": "",
"faceHandlerEmpId": "",
"posHandlerEmpName": "",
"faceChargeEmpName": ""
}
},
"status": "NORMAL",
"createTs": 1723709147000,
"lastUpdateTs": 1733356105000,
"channelType": "HLK",
"enableRegion": "N"
}
],
"billRemark": [
{
"id": 60781,
@ -3013,6 +3140,7 @@
"createTs": 1726121053000
}
],
"merchantRegion": [],
"paymentType": [
{
"id": 34308,
@ -3022,7 +3150,12 @@
"icon": "cash",
"isDefault": "Y",
"isCash": "Y",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1587028820000
},
@ -3034,7 +3167,12 @@
"icon": "card",
"isDefault": "Y",
"isCash": "N",
"ext": { "cardRecharge": false, "service": true, "goods": true, "cardPurchase": false },
"ext": {
"cardRecharge": false,
"service": true,
"goods": true,
"cardPurchase": false
},
"status": "NORMAL",
"createTs": 1587028821000
},
@ -3046,7 +3184,12 @@
"icon": "bonus",
"isDefault": "Y",
"isCash": "N",
"ext": { "cardRecharge": false, "service": true, "goods": true, "cardPurchase": false },
"ext": {
"cardRecharge": false,
"service": true,
"goods": true,
"cardPurchase": false
},
"status": "NORMAL",
"createTs": 1587028821000
},
@ -3058,7 +3201,12 @@
"icon": "wechat",
"isDefault": "Y",
"isCash": "Y",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1587028821000,
"isQR": true
@ -3071,7 +3219,12 @@
"icon": "alipay",
"isDefault": "Y",
"isCash": "Y",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1587028821000,
"isQR": true
@ -3084,7 +3237,12 @@
"icon": "union",
"isDefault": "Y",
"isCash": "Y",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1587028822000
},
@ -3096,7 +3254,12 @@
"icon": null,
"isDefault": "Y",
"isCash": "N",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1587028822000
},
@ -3108,7 +3271,12 @@
"icon": "zdy",
"isDefault": "Y",
"isCash": "N",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1587028823000
},
@ -3120,7 +3288,12 @@
"icon": "rebate",
"isDefault": "Y",
"isCash": "N",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1612397172000
},
@ -3132,7 +3305,12 @@
"icon": "zdy",
"isDefault": "Y",
"isCash": "N",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1639048591000
},
@ -3182,7 +3360,12 @@
"icon": "zdy",
"isDefault": "N",
"isCash": "N",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1724136423000
},
@ -3194,7 +3377,12 @@
"icon": "zdy",
"isDefault": "N",
"isCash": "N",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1724136424000
},
@ -3206,7 +3394,12 @@
"icon": "zdy",
"isDefault": "N",
"isCash": "Y",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1724136438000
},
@ -3218,7 +3411,12 @@
"icon": "zdy",
"isDefault": "N",
"isCash": "Y",
"ext": { "cardRecharge": true, "service": true, "goods": true, "cardPurchase": true },
"ext": {
"cardRecharge": true,
"service": true,
"goods": true,
"cardPurchase": true
},
"status": "NORMAL",
"createTs": 1731306816000
}
@ -3281,11 +3479,11 @@
"user": 1733356140386,
"userLevel": 1723709506551,
"department": 1723709546004,
"merchant": 1734622498141,
"merchantRegion": 1723709673591,
"billRemark": 1724045524248,
"classify": 1733355270554,
"paymentConfig": 1731500143334,
"merchant": 1734703771245,
"merchantRegion": 1723709673591,
"paymentType": 1731306816449,
"thdPaymentConfig": 1731393775960
},
@ -3311,14 +3509,14 @@
"mallTheme": 1733356114262,
"mallItemSeries": 1733356024585,
"serviceAssessments": 1724144392889,
"merchant": 1734622498313,
"merchant": 1734703771409,
"propertyDiscountRule": 1724136193571,
"mallShop": 1733356109640,
"weComTagGroup": 1729678945555,
"pack": 1725955985037,
"initWechatConfig": 1734622498426,
"vocationSchedule": 1734622498426,
"shiftConfig": 1734622498426,
"initWechatConfig": 1734703771475,
"vocationSchedule": 1734703771475,
"shiftConfig": 1734703771475,
"kpiType": 1724219649867,
"stockPropertyCapacityUnit": 1730702814870,
"stockSupplier": 1726125558988,
@ -3350,10 +3548,10 @@
"reservationProperty": 1723709147913,
"shopModule": 1729133328828,
"propertyType": 1733355385694,
"merchantPushConfig": 1734622498426,
"merchantPushConfig": 1734703771475,
"tagType": 1724143703296,
"userRankingConfig": 1723709148243,
"profitConfig": 1734622498426,
"profitConfig": 1734703771475,
"mallItemAttribute": 1733356038072,
"stockConfig": 1723795631389,
"department": 1723709546004,
@ -3364,7 +3562,7 @@
"channelCommissionConfig": 1724037860562,
"stockType": 1724038466165,
"cardType": 1732174899402,
"weComGroup": 1734622498426,
"weComGroup": 1734703771475,
"classifyType": 1724140192413,
"stockFactory": 1726125558988,
"thdApplication": 1733354225465,
@ -3381,4 +3579,7 @@
}
}
}
]
},
{ "databaseName": "hlk_touch_test_init", "data": [] }
]

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
import puppeteer from 'puppeteer';
import { read, readFileSync } from 'fs';
import { readFileSync } from 'fs';
(async () => {
// 读取 JSON 文件
@ -21,68 +21,13 @@ import { read, readFileSync } from 'fs';
}, localStorageData);
console.log('set localStorage success');
// const cookie = JSON.parse(readFileSync('cookie.json', 'utf8'));
// await page.setCookie(...cookie);
// console.log('cookie', cookie);
// console.log(JSON.stringify(jsonData, null, 2));
page.on('console', (msg) => {
for (let i = 0; i < msg.args().length; ++i) {
console.log(`${msg.args()[i]}`);
}
});
// await page.evaluate((jsonData) => {
// // 打开 IndexedDB 数据库
// const openRequest = indexedDB.open('hlk_touch_test_14920', 2);
// // 处理数据库版本升级
// openRequest.onupgradeneeded = (event) => {
// const db = event.target.result;
// // 创建对象存储,如果不存在的话
// if (!db.objectStoreNames.contains('keyvaluepairs')) {
// db.createObjectStore('keyvaluepairs');
// }
// if (!db.objectStoreNames.contains('local-forage-detect-blob-support')) {
// db.createObjectStore('local-forage-detect-blob-support');
// }
// };
// openRequest.onsuccess = (event) => {
// const db = event.target.result;
// const transaction = db.transaction(['keyvaluepairs'], 'readwrite');
// const objectStore = transaction.objectStore('keyvaluepairs'); // 使用硬编码的存储名
// console.log(jsonData[0].value);
// console.log('jsonData.length', jsonData.length);
// for (let i = 0; i < jsonData.length; i++) {
// const addObject = objectStore.put(jsonData[i].value, jsonData[i].key);
// addObject.onsuccess = (event) => {
// console.log('数据添加成功');
// };
// addObject.onerror = (event) => {
// console.error('数据添加失败:', event.target.error);
// };
// }
// // 事务错误处理
// transaction.onerror = (event) => {
// console.error('事务失败:', event.target.error);
// };
// };
// // 错误处理
// openRequest.onerror = (event) => {
// console.error('数据库打开失败:', event.target.error);
// };
// }, jsonData); // 将 jsonData 传递到浏览器上下文中
await page.evaluate((jsonData) => {
return new Promise((resolve, reject) => {
// 使用 async 函数来处理异步操作
const processDatabase = async (database) => {
try {
// 打开 IndexedDB 数据库
const openRequest = indexedDB.open('hlk_touch_test_14920', 2);
const openRequest = indexedDB.open(database.databaseName, 2);
// 处理数据库版本升级
openRequest.onupgradeneeded = (event) => {
@ -96,40 +41,44 @@ import { read, readFileSync } from 'fs';
}
};
openRequest.onsuccess = (event) => {
// 处理数据库打开成功
openRequest.onsuccess = async (event) => {
const db = event.target.result;
const table = database.data;
const transaction = db.transaction(['keyvaluepairs'], 'readwrite');
const objectStore = transaction.objectStore('keyvaluepairs'); // 使用硬编码的存储名
console.log(jsonData[0].value);
console.log('jsonData.length', jsonData.length);
console.log(table.value);
let completedOperations = 0;
const totalOperations = jsonData.length;
for (let i = 0; i < jsonData.length; i++) {
const addObject = objectStore.put(jsonData[i].value, jsonData[i].key);
const totalOperations = table.length;
// 使用 Promise.all 来确保所有的写入操作完成
const writeOperations = table.map((item, index) => {
return new Promise((innerResolve, innerReject) => {
const addObject = objectStore.put(item.value, item.key);
addObject.onsuccess = () => {
console.log('数据添加成功', jsonData[i].key);
console.log('数据添加成功', item.key);
completedOperations++;
// 如果所有操作完成,调用 resolve
if (completedOperations === totalOperations) {
resolve('所有数据写入成');
innerResolve('数据写入成');
}
};
addObject.onerror = (event) => {
console.error('数据添加失败:', event.target.error);
reject('数据添加失败');
innerReject('数据添加失败');
};
}
});
});
// 事务错误处理
transaction.onerror = (event) => {
console.error('事务失败:', event.target.error);
reject('事务失败');
};
// 等待所有写入操作完成
try {
await Promise.all(writeOperations);
console.log('所有数据写入完成');
resolve('所有数据写入完成');
} catch (error) {
reject('数据写入失败');
}
};
// 错误处理
@ -137,11 +86,22 @@ import { read, readFileSync } from 'fs';
console.error('数据库打开失败:', event.target.error);
reject('数据库打开失败');
};
} catch (error) {
reject('数据库操作失败: ' + error);
}
};
// 遍历所有数据库
Promise.all(jsonData.map((database) => processDatabase(database)))
.then(() => resolve('所有数据库操作完成'))
.catch((error) => reject('操作失败: ' + error));
});
}, jsonData); // 将 jsonData 传递到浏览器上下文中
console.log('end');
await new Promise((resolve) => setTimeout(resolve, 2000));
await page.goto('https://hlk.meiguanjia.net');
// await

View File

@ -62,47 +62,58 @@ import { resolve } from 'path';
// 获取浏览器中的 IndexedDB 数据
const result = await page.evaluate(async () => {
return new Promise((resolve, reject) => {
const request = indexedDB.open('hlk_touch_test_14920');
const databases = await indexedDB.databases();
const allData = [];
for (const db of databases) {
const databaseName = db.name;
// 打开数据库
const request = indexedDB.open(databaseName);
const databaseData = await new Promise((resolve, reject) => {
request.onsuccess = (event) => {
const db = event.target.result;
const transaction = db.transaction(db.objectStoreNames, 'readonly');
const objectStore = transaction.objectStore(db.objectStoreNames[0]);
const cursorRequest = objectStore.openCursor();
const allData = [];
const storeData = [];
cursorRequest.onsuccess = (event) => {
const cursor = event.target.result;
if (cursor) {
// console.log(cursor.key);
// console.log(JSON.stringify(value));
const key = cursor.key;
const value = cursor.value;
allData.push({ key, value });
storeData.push({ key: cursor.key, value: cursor.value });
cursor.continue();
} else {
resolve(allData);
resolve(storeData); // 执行 resolve返回数据
}
};
cursorRequest.onerror = (event) => {
reject(event.target.error); // 发生错误时 reject
};
};
request.onerror = (event) => {
reject(event.target.error);
reject(event.target.error); // 发生错误时 reject
};
});
// 将数据库数据存入 allData
allData.push({
databaseName,
data: databaseData,
});
}
return allData;
});
// console.log(result);
// const cookie = await page.cookies();
// fs.writeFileSync('./cookie.json', JSON.stringify(cookie));
const localStorageData = await page.evaluate(() => {
return JSON.stringify(localStorage); // 将 localStorage 转换为对象
});
fs.writeFileSync('./localStorage.json', localStorageData);
fs.writeFileSync('./indexedDB.json', JSON.stringify(result));
fs.writeFileSync('./localStorage.json', localStorageData);
}
await browser.close();