vue2-client 1.13.30 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursorrules +19 -19
- package/.env.gaslink +19 -19
- package/.env.his +19 -19
- package/.env.liuli +19 -19
- package/.env.scada +19 -19
- package/.eslintrc.js +90 -90
- package/CHANGELOG.md +824 -824
- package/Components.md +60 -60
- package/docs/Logic/345/207/275/346/225/260/344/275/277/347/224/250/347/233/270/345/205/263.md +45 -45
- package/docs/LowCode/lowcode.md +155 -155
- package/docs/LowCode/lowcodeForDeveloper.md +230 -230
- package/docs/index.md +30 -30
- package/index.js +31 -31
- package/jest-transform-stub.js +8 -8
- package/jest.setup.js +7 -7
- package/jsconfig.json +19 -19
- package/package.json +1 -1
- package/public/his/editor/editor.html +51 -51
- package/public/his/editor/mock/bind_data.html +779 -779
- package/public/his/editor/mock/data_table.html +40 -40
- package/public/his/editor/mock/sign.html +75 -75
- package/public/his/editor/vender/JsBarcode.all.js +3669 -3669
- package/public/his/editor/vender/date97/My97DatePicker.htm +65 -65
- package/public/his/editor/vender/date97/WdatePicker.js +677 -677
- package/public/his/editor/vender/date97/calendar.js +4 -4
- package/public/his/editor/vender/date97/lang/en.js +13 -13
- package/public/his/editor/vender/date97/lang/zh-cn.js +13 -13
- package/public/his/editor/vender/date97/lang/zh-tw.js +13 -13
- package/public/his/editor/vender/date97/skin/WdatePicker.css +10 -10
- package/public/his/editor/vender/date97/skin/default/datepicker.css +328 -328
- package/public/his/editor/vender/date97/skin/ext/datepicker.css +308 -308
- package/public/his/editor/vender/date97/skin/whyGreen/datepicker.css +255 -255
- package/public/his/editor/vender/diff.js +1627 -1627
- package/public/his/editor/vender/editor.js +1 -1
- package/public/his/editor/vender/fabric.js +31187 -31187
- package/public/his/editor/vender/jquery/jquery.base64.js +190 -190
- package/public/his/editor/vender/jquery/jquery.js +10872 -10872
- package/public/his/editor/vender/jquery/jquery.print.js +255 -255
- package/public/his/editor/vender/jquery/zTreeStyle/zTreeStyle.css +96 -96
- package/public/his/editor/vender/mui/mui.min.css +4 -4
- package/public/his/editor/vender/mui/mui.min.js +5 -5
- package/public/his/editor/vender/mui/mui.picker.min.css +6 -6
- package/public/his/editor/vender/mui/mui.picker.min.js +6 -6
- package/public/his/editor/vender/qrcode.js +7 -7
- package/public/his/editor/vender/requirejs/require.js +2145 -2145
- package/public/his/editor/vender/signature/jSignature.CompressorSVG.js +518 -518
- package/public/his/editor/vender/signature/jSignature.UndoButton.js +164 -164
- package/public/his/editor/vender/signature/jSignature.js +1486 -1486
- package/public/his/editor/vender/validator.js +5094 -5094
- package/public/his/editor/vender/weui/weui.css +5659 -5659
- package/public/his/editor/vender/weui/weui.min.css +4 -4
- package/public/his/editor/vender/weui/weui.min.js +11 -11
- package/public/index.html +27 -27
- package/src/ReportView.js +19 -19
- package/src/assets/img/querySlotDemo.svg +15 -15
- package/src/assets/svg/badtwo.svg +1 -1
- package/src/assets/svg/goodtwo.svg +1 -1
- package/src/base-client/components/AI/AskAiBtn.vue +136 -136
- package/src/base-client/components/AI/demo.vue +31 -31
- package/src/base-client/components/common/AMisRender/index.js +3 -3
- package/src/base-client/components/common/AMisRender/index.vue +263 -263
- package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +470 -470
- package/src/base-client/components/common/AddressSearchCombobox/IcMapIcon.vue +16 -16
- package/src/base-client/components/common/AddressSearchCombobox/demo.vue +36 -36
- package/src/base-client/components/common/AddressSearchCombobox/ic_map.svg +6 -6
- package/src/base-client/components/common/AmapMarker/AmapPointRendering.vue +120 -120
- package/src/base-client/components/common/CitySelect/index.js +3 -3
- package/src/base-client/components/common/CitySelect/index.md +109 -109
- package/src/base-client/components/common/CreateQuery/CreateQuery.vue +669 -669
- package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +1014 -1014
- package/src/base-client/components/common/CreateQuery/index.js +3 -3
- package/src/base-client/components/common/CreateQuery/index.md +42 -42
- package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQuery.vue +452 -452
- package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +511 -511
- package/src/base-client/components/common/CreateSimpleFormQuery/index.js +3 -3
- package/src/base-client/components/common/CreateSimpleFormQuery/index.md +42 -42
- package/src/base-client/components/common/FormGroupEdit/FormGroupEdit.vue +149 -149
- package/src/base-client/components/common/FormGroupEdit/index.js +3 -3
- package/src/base-client/components/common/FormGroupEdit/index.md +43 -43
- package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +166 -166
- package/src/base-client/components/common/FormGroupQuery/index.js +3 -3
- package/src/base-client/components/common/FormGroupQuery/index.md +43 -43
- package/src/base-client/components/common/JSONToTree/jsontotree.vue +271 -271
- package/src/base-client/components/common/LowCodeComponent/LowCodeEditorModal.vue +108 -108
- package/src/base-client/components/common/LowCodeComponent/LowCodeEditorPanel.vue +413 -413
- package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +502 -502
- package/src/base-client/components/common/LowCodeComponent/LowCodeRender.vue +728 -728
- package/src/base-client/components/common/LowCodeComponent/LowCodeRenderEnter.vue +29 -29
- package/src/base-client/components/common/LowCodeComponent/LowCodeUIStore.vue +219 -219
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeAddPageModal.vue +117 -117
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeCustomJSModal.vue +80 -80
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeEventEditorModal.vue +398 -398
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLifeCycleModal.vue +65 -65
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicCallbackModal.vue +64 -64
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeLogicParamModal.vue +73 -73
- package/src/base-client/components/common/LowCodeComponent/modal/lowCodeRunFunctionParamModal.vue +76 -76
- package/src/base-client/components/common/PersonSetting/PersonSetting.vue +208 -208
- package/src/base-client/components/common/PersonSetting/index.js +3 -3
- package/src/base-client/components/common/Recording/Recording.vue +243 -243
- package/src/base-client/components/common/Recording/index.js +3 -3
- package/src/base-client/components/common/Tree/Tree.vue +149 -149
- package/src/base-client/components/common/Tree/index.js +2 -2
- package/src/base-client/components/common/Upload/index.js +3 -3
- package/src/base-client/components/common/XAddForm/XAddForm.vue +113 -113
- package/src/base-client/components/common/XAddNativeForm/index.md +146 -146
- package/src/base-client/components/common/XAddNativeFormOA/XAddNativeFormOA.vue +303 -303
- package/src/base-client/components/common/XAddNativeFormOA/index.js +3 -3
- package/src/base-client/components/common/XAddNativeFormOA/index.md +146 -146
- package/src/base-client/components/common/XAddReport/index.js +3 -3
- package/src/base-client/components/common/XAddReport/index.md +56 -56
- package/src/base-client/components/common/XBadge/XBadge.vue +94 -94
- package/src/base-client/components/common/XButtons/XButtonDemo.vue +28 -28
- package/src/base-client/components/common/XButtons/XButtons.vue +71 -71
- package/src/base-client/components/common/XButtons/index.js +3 -3
- package/src/base-client/components/common/XButtons/index.md +61 -61
- package/src/base-client/components/common/XCard/XCard.vue +64 -64
- package/src/base-client/components/common/XCheckList/XCheckList.vue +106 -106
- package/src/base-client/components/common/XCheckList/XCheckListDemo.vue +41 -41
- package/src/base-client/components/common/XDataCard/index.js +3 -3
- package/src/base-client/components/common/XDataCard/index.md +1 -1
- package/src/base-client/components/common/XDataDrawer/XDataDrawer.vue +180 -180
- package/src/base-client/components/common/XDataDrawer/index.js +3 -3
- package/src/base-client/components/common/XDataDrawer/index.md +41 -41
- package/src/base-client/components/common/XDatePicker/demo.vue +153 -153
- package/src/base-client/components/common/XDescriptions/index.js +3 -3
- package/src/base-client/components/common/XDescriptions/index.md +83 -83
- package/src/base-client/components/common/XDetailsView/XDetailsView.vue +238 -238
- package/src/base-client/components/common/XDetailsView/index.js +3 -3
- package/src/base-client/components/common/XForm/XStatusButton.vue +54 -54
- package/src/base-client/components/common/XForm/index.md +178 -178
- package/src/base-client/components/common/XForm/itemComponent/XClickChangeBtn/index.vue +49 -49
- package/src/base-client/components/common/XFormGroup/index.js +3 -3
- package/src/base-client/components/common/XFormGroup/index.md +38 -38
- package/src/base-client/components/common/XFormGroupDetails/XFormGroupDetails.vue +72 -72
- package/src/base-client/components/common/XFormGroupDetails/index.js +3 -3
- package/src/base-client/components/common/XFormTable/XFormTable.vue +7 -1
- package/src/base-client/components/common/XFormTable/demo.vue +1 -1
- package/src/base-client/components/common/XFormTable/index.md +92 -92
- package/src/base-client/components/common/XImportExcel/XImportExcel.vue +167 -167
- package/src/base-client/components/common/XLabelSelect/XLabelSelect.vue +110 -110
- package/src/base-client/components/common/XLabelSelect/XLabelSelectDemo.vue +35 -35
- package/src/base-client/components/common/XLicensePlate/XLicensePlate.vue +193 -193
- package/src/base-client/components/common/XLicensePlate/XLicensePlateDemo.vue +48 -48
- package/src/base-client/components/common/XPrint/OpenInvoice.vue +21 -21
- package/src/base-client/components/common/XPrint/PrintBill.vue +302 -302
- package/src/base-client/components/common/XPrint/PrintHtml.js +98 -98
- package/src/base-client/components/common/XPrint/css/hiPrintCss.js +359 -359
- package/src/base-client/components/common/XPrint/css/lodopCss.js +26 -26
- package/src/base-client/components/common/XPrint/css/print-lock.css +351 -351
- package/src/base-client/components/common/XPrint/index.vue +97 -97
- package/src/base-client/components/common/XReport/XReport.vue +892 -892
- package/src/base-client/components/common/XReport/XReportDesign.vue +463 -463
- package/src/base-client/components/common/XReport/XReportJsonRender.vue +381 -381
- package/src/base-client/components/common/XReport/index.js +3 -3
- package/src/base-client/components/common/XReport/index.md +44 -44
- package/src/base-client/components/common/XReport/print.js +186 -186
- package/src/base-client/components/common/XReportDrawer/index.js +3 -3
- package/src/base-client/components/common/XReportGrid/index.js +3 -3
- package/src/base-client/components/common/XReportGrid/index.md +44 -44
- package/src/base-client/components/common/XReportSlot/XReportSlot.vue +110 -110
- package/src/base-client/components/common/XReportSlot/index.js +3 -3
- package/src/base-client/components/common/XReportSlot/index.md +48 -48
- package/src/base-client/components/common/XSimpleDescriptions/XSimpleDescriptions.vue +166 -166
- package/src/base-client/components/common/XSimpleDescriptions/index.js +3 -3
- package/src/base-client/components/common/XSimpleDescriptions/index.md +7 -7
- package/src/base-client/components/common/XStepView/XStepView.vue +252 -252
- package/src/base-client/components/common/XStepView/index.js +3 -3
- package/src/base-client/components/common/XStepView/index.md +31 -31
- package/src/base-client/components/common/XTab/XTabDemo.vue +22 -22
- package/src/base-client/components/common/XTab/index.js +3 -3
- package/src/base-client/components/common/XTable/CustomFuncCel.vue +51 -51
- package/src/base-client/components/common/XTable/TableCellRenderer.vue +161 -161
- package/src/base-client/components/common/XTable/index.md +255 -255
- package/src/base-client/components/common/XTagGroup/index.vue +52 -52
- package/src/base-client/components/common/XTree/XTree.vue +424 -424
- package/src/base-client/components/common/XTree/index.js +3 -3
- package/src/base-client/components/common/XTree/index.md +36 -36
- package/src/base-client/components/common/XTreeOne/XTreeOne.vue +113 -113
- package/src/base-client/components/common/XTreeOne/XTreeOnePro.vue +128 -128
- package/src/base-client/components/common/richTextModal/index.vue +56 -56
- package/src/base-client/components/common/richTextModal/richDemo.vue +48 -48
- package/src/base-client/components/his/XHDescriptions/XHDescriptions.vue +3 -2
- package/src/base-client/components/his/XHisEditor/index.js +3 -3
- package/src/base-client/components/his/XSidebar/XSidebar.vue +3 -3
- package/src/base-client/components/index.js +51 -51
- package/src/base-client/components/layout/XPageView/XErrorView.vue +11 -11
- package/src/base-client/components/layout/XPageView/XPageView.vue +155 -155
- package/src/base-client/components/layout/XPageView/index.js +3 -3
- package/src/base-client/components/layout/XPageView/index.md +38 -38
- package/src/base-client/components/layout/XTreeView/XTreeView.vue +130 -130
- package/src/base-client/components/layout/XTreeView/index.js +3 -3
- package/src/base-client/components/layout/XTreeView/index.md +46 -46
- package/src/base-client/components/system/DictionaryDetailsView/DictionaryDetailsView.vue +232 -232
- package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
- package/src/base-client/plugins/Config.js +19 -19
- package/src/base-client/plugins/GetLoginInfoService.js +183 -183
- package/src/base-client/plugins/Recording.js +258 -258
- package/src/base-client/plugins/index.js +23 -23
- package/src/base-client/plugins/tabs-page-plugin.js +39 -39
- package/src/bootstrap.js +10 -6
- package/src/components/Charts/Bar.vue +62 -62
- package/src/components/Charts/ChartCard.vue +134 -134
- package/src/components/Charts/Liquid.vue +67 -67
- package/src/components/Charts/MiniArea.vue +39 -39
- package/src/components/Charts/MiniBar.vue +39 -39
- package/src/components/Charts/MiniProgress.vue +75 -75
- package/src/components/Charts/MiniSmoothArea.vue +40 -40
- package/src/components/Charts/Radar.vue +68 -68
- package/src/components/Charts/RankList.vue +77 -77
- package/src/components/Charts/TagCloud.vue +113 -113
- package/src/components/Charts/TransferBar.vue +64 -64
- package/src/components/Charts/Trend.vue +82 -82
- package/src/components/Charts/chart.less +12 -12
- package/src/components/Charts/smooth.area.less +13 -13
- package/src/components/CodeMirror/inedx.vue +118 -118
- package/src/components/CodeMirror/setting.js +40 -40
- package/src/components/HeightScanner/index.vue +571 -571
- package/src/components/NumberInfo/NumberInfo.vue +54 -54
- package/src/components/NumberInfo/index.js +3 -3
- package/src/components/NumberInfo/index.less +54 -54
- package/src/components/NumberInfo/index.md +43 -43
- package/src/components/card/ChartCard.vue +79 -79
- package/src/components/chart/Bar.vue +60 -60
- package/src/components/chart/MiniArea.vue +67 -67
- package/src/components/chart/MiniBar.vue +59 -59
- package/src/components/chart/MiniProgress.vue +57 -57
- package/src/components/chart/Radar.vue +80 -80
- package/src/components/chart/RankingList.vue +60 -60
- package/src/components/chart/Trend.vue +79 -79
- package/src/components/chart/index.less +9 -9
- package/src/components/checkbox/ColorCheckbox.vue +157 -157
- package/src/components/checkbox/ImgCheckbox.vue +117 -117
- package/src/components/checkbox/ImgCheckboxGroup.vue +76 -76
- package/src/components/checkbox/index.js +9 -9
- package/src/components/exception/ExceptionPage.vue +70 -70
- package/src/components/g2Charts/constants.js +202 -202
- package/src/components/g2Charts/demo.vue +808 -808
- package/src/components/g2Charts/designer.vue +228 -228
- package/src/components/g2Charts/designerBaseConfig.vue +61 -61
- package/src/components/g2Charts/designerDataConfig.vue +259 -259
- package/src/components/g2Charts/designerStyleConfig.vue +16 -16
- package/src/components/g2Charts/index.vue +397 -397
- package/src/components/index.js +36 -36
- package/src/components/input/IInput.vue +66 -66
- package/src/components/menu/SideMenu.vue +75 -75
- package/src/components/menu/menu.js +273 -273
- package/src/components/setting/Setting.vue +234 -234
- package/src/components/tool/AStepItem.vue +60 -60
- package/src/config/CreateQueryConfig.js +325 -325
- package/src/config/default/antd.config.js +89 -89
- package/src/config/default/setting.config.js +55 -55
- package/src/font-style/font.css +4 -4
- package/src/layouts/CommonLayout.vue +56 -56
- package/src/layouts/PageLayout.vue +151 -151
- package/src/layouts/SinglePageView.vue +136 -136
- package/src/layouts/header/AdminHeader.vue +132 -132
- package/src/layouts/header/HeaderNotice.vue +177 -177
- package/src/layouts/header/InstitutionDetail.vue +181 -181
- package/src/layouts/tabs/TabsHead.vue +189 -189
- package/src/layouts/tabs/TabsView.vue +389 -389
- package/src/lib.js +1 -1
- package/src/main.js +34 -34
- package/src/mock/extend/index.js +84 -84
- package/src/mock/goods/index.js +108 -108
- package/src/pages/AMisDemo/AMisDemo.vue +325 -325
- package/src/pages/AMisDemo/AMisDemo2.vue +74 -74
- package/src/pages/DefaultExample/index.vue +77 -77
- package/src/pages/DynamicStatistics/ChartSelector.vue +331 -331
- package/src/pages/DynamicStatistics/DataTabs.vue +83 -83
- package/src/pages/DynamicStatistics/DynamicTable.vue +128 -128
- package/src/pages/DynamicStatistics/EvaluationArea.vue +69 -69
- package/src/pages/DynamicStatistics/FavoriteList.vue +50 -50
- package/src/pages/DynamicStatistics/QuestionHistoryAndFavorites.vue +591 -591
- package/src/pages/DynamicStatistics/SearchBar.vue +192 -192
- package/src/pages/DynamicStatistics/index.vue +282 -282
- package/src/pages/Example/childIndex.vue +15 -15
- package/src/pages/Example/index.vue +30 -30
- package/src/pages/NewDynamicStatistics/ChartSelector.vue +331 -331
- package/src/pages/NewDynamicStatistics/DataTabs.vue +122 -122
- package/src/pages/NewDynamicStatistics/DynamicTable.vue +128 -128
- package/src/pages/NewDynamicStatistics/EvaluationArea.vue +69 -69
- package/src/pages/NewDynamicStatistics/FavoriteList.vue +50 -50
- package/src/pages/NewDynamicStatistics/QuestionHistoryAndFavorites.vue +289 -289
- package/src/pages/NewDynamicStatistics/SearchBar.vue +193 -193
- package/src/pages/NewDynamicStatistics/index.vue +258 -258
- package/src/pages/Recording/index.vue +77 -77
- package/src/pages/ServiceReview/index.vue +284 -284
- package/src/pages/SubExample/index.vue +26 -26
- package/src/pages/WorkflowDetail/WorkflowPageDetail/LeaveMessage.vue +131 -131
- package/src/pages/WorkflowDetail/WorkflowPageDetail/TrimTextTail.vue +23 -23
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformation.vue +302 -302
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowBaseInformationDetails.vue +276 -276
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowHandleReso.vue +997 -997
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkFlowTimeline.vue +222 -222
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkOrderParentDetails.vue +233 -233
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowDetailResso.vue +261 -261
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowListResolution.vue +248 -248
- package/src/pages/WorkflowDetail/WorkflowPageDetail/WorkflowLog.vue +73 -73
- package/src/pages/XPageViewExample/index.vue +38 -38
- package/src/pages/XReportView/index.vue +64 -64
- package/src/pages/XTreeOneProExample/index.vue +67 -67
- package/src/pages/dashboard/workplace/WorkPlace.vue +141 -141
- package/src/pages/login/Login.vue +378 -378
- package/src/pages/login/LoginV3.vue +389 -389
- package/src/pages/lowCode/lowCodeEditor.vue +1219 -1219
- package/src/pages/lowCode/lowCodeRenderPage.vue +43 -43
- package/src/pages/report/ReportTable.js +124 -124
- package/src/pages/resourceManage/orgListManage.vue +98 -98
- package/src/pages/system/dictionary/index.vue +44 -44
- package/src/pages/system/monitor/loginInfor/index.vue +37 -37
- package/src/pages/system/monitor/operLog/index.vue +37 -37
- package/src/pages/system/settings/modifyPassword.vue +117 -117
- package/src/pages/system/ticket/index.vue +480 -480
- package/src/pages/system/ticket/submitTicketSuccess.vue +484 -484
- package/src/pages/userInfoDetailManage/ChangeMeterRecordQuery/index.vue +64 -64
- package/src/pages/userInfoDetailManage/FillCardRecordQuery/index.vue +76 -76
- package/src/pages/userInfoDetailManage/FillGasRecordQuery/index.vue +74 -74
- package/src/pages/userInfoDetailManage/InfoChangeRecordQuery/index.vue +64 -64
- package/src/pages/userInfoDetailManage/InstructRecordQuery/index.vue +64 -64
- package/src/pages/userInfoDetailManage/MachineRecordQuery/index.vue +74 -74
- package/src/pages/userInfoDetailManage/MeterParamRecordQuery/index.vue +64 -64
- package/src/pages/userInfoDetailManage/OtherChargeRecordQuery/index.vue +74 -74
- package/src/pages/userInfoDetailManage/TransferRecordQuery/index.vue +66 -66
- package/src/pages/userInfoDetailManage/UserHandRecordQuery/index.vue +86 -86
- package/src/pages/userInfoDetailManage/UserRecordQuery/index.vue +73 -73
- package/src/pages/userInfoDetailManage/WatchCollectionRecordQuery/index.vue +64 -64
- package/src/plugins/EventLogPlugin.js +33 -33
- package/src/plugins/FindParentsData.js +17 -17
- package/src/router/async/config.async.js +35 -35
- package/src/router/async/router.map.js +6 -3
- package/src/router/index.js +27 -27
- package/src/router.js +19 -19
- package/src/services/DataModel.js +30 -30
- package/src/services/LodopFuncs.js +137 -137
- package/src/services/api/TicketDetailsViewApi.js +46 -46
- package/src/services/api/cas.js +79 -79
- package/src/services/api/common.js +346 -346
- package/src/services/api/entity.js +18 -18
- package/src/services/api/index.js +17 -17
- package/src/services/api/restTools.js +145 -145
- package/src/services/api/workFlow.js +63 -63
- package/src/store/modules/account.js +115 -115
- package/src/store/modules/index.js +5 -5
- package/src/store/modules/lowCode.js +33 -33
- package/src/store/modules/setting.js +119 -119
- package/src/theme/default/style.less +58 -58
- package/src/theme/global.less +159 -159
- package/src/utils/authority-utils.js +85 -85
- package/src/utils/errorCode.js +6 -6
- package/src/utils/formatter.js +74 -74
- package/src/utils/htmlToPDF.js +108 -108
- package/src/utils/htmlToPDFApi.js +5 -5
- package/src/utils/indexedDB.js +339 -37
- package/src/utils/login.js +188 -188
- package/src/utils/lowcode/lowcodeComponentMixin.js +120 -120
- package/src/utils/lowcode/lowcodeLog.js +29 -29
- package/src/utils/lowcode/lowcodeUtils.js +373 -373
- package/src/utils/lowcode/registerComponentForEditor.js +1 -1
- package/src/utils/lowcode/registerComponentForRender.js +11 -11
- package/src/utils/map-utils.js +47 -47
- package/src/utils/reg.js +95 -95
- package/src/utils/runEvalFunction.js +14 -14
- package/src/utils/theme-color-replacer-extend.js +92 -92
- package/src/utils/util.js +329 -329
- package/src/utils/waterMark.js +31 -31
- package//350/277/201/347/247/273/346/227/245/345/277/227.md +15 -15
package/src/utils/indexedDB.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { post } from '@vue2-client/services/api'
|
|
2
2
|
|
|
3
|
+
// 内存缓存作为IndexedDB的备用方案,防止数据库损坏时应用崩溃
|
|
4
|
+
const MEMORY_CACHE = new Map()
|
|
5
|
+
const USE_MEMORY_CACHE = true // 是否启用内存缓存
|
|
6
|
+
|
|
3
7
|
const DB_CONFIG = {
|
|
4
8
|
NAME: window.__MICRO_APP_NAME__ ? `view_${window.__MICRO_APP_NAME__}` : 'view',
|
|
5
9
|
STORE_NAME: 'metaCache',
|
|
@@ -7,12 +11,16 @@ const DB_CONFIG = {
|
|
|
7
11
|
CURRENT_VERSION: 1
|
|
8
12
|
}
|
|
9
13
|
|
|
14
|
+
// 数据库健康状态标记,用于在数据库异常时切换到备用方案
|
|
15
|
+
let IS_DB_HEALTHY = true
|
|
16
|
+
|
|
10
17
|
const LIULI_WEB_DB_NAME = 'view_liuli_web'
|
|
11
18
|
|
|
12
19
|
export class IndexedDBManager {
|
|
13
20
|
constructor () {
|
|
14
21
|
this.db = undefined
|
|
15
|
-
this.locks =
|
|
22
|
+
this.locks = new Map()
|
|
23
|
+
this.requestTimeout = 10000
|
|
16
24
|
this.isInMicroApp = !!window.__MICRO_APP_NAME__
|
|
17
25
|
this.microAppName = window.__MICRO_APP_NAME__ || ''
|
|
18
26
|
this.indexedDB = window?.rawWindow?.indexedDB || window.indexedDB || window.webkitindexedDB
|
|
@@ -22,9 +30,16 @@ export class IndexedDBManager {
|
|
|
22
30
|
async openDatabase () {
|
|
23
31
|
try {
|
|
24
32
|
return await new Promise((resolve, reject) => {
|
|
33
|
+
// 添加超时机制,防止请求永久挂起
|
|
34
|
+
const timeout = setTimeout(() => {
|
|
35
|
+
console.error('[openDatabase] 请求超时,将尝试重建数据库')
|
|
36
|
+
reject(new Error('IndexedDB open timeout'))
|
|
37
|
+
}, 5000) // 5秒超时
|
|
38
|
+
|
|
25
39
|
const checkRequest = this.indexedDB.open(DB_CONFIG.NAME)
|
|
26
40
|
|
|
27
41
|
checkRequest.onsuccess = (e) => {
|
|
42
|
+
clearTimeout(timeout) // 清除超时
|
|
28
43
|
const db = e.target.result
|
|
29
44
|
const currentVersion = db.version
|
|
30
45
|
db.close()
|
|
@@ -32,9 +47,19 @@ export class IndexedDBManager {
|
|
|
32
47
|
DB_CONFIG.CURRENT_VERSION = Math.max(currentVersion, DB_CONFIG.VERSION)
|
|
33
48
|
const request = this.indexedDB.open(DB_CONFIG.NAME, DB_CONFIG.CURRENT_VERSION)
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
// 为第二次打开也添加超时
|
|
51
|
+
const openTimeout = setTimeout(() => {
|
|
52
|
+
console.error('[openDatabase] 二次打开请求超时')
|
|
53
|
+
reject(new Error('IndexedDB second open timeout'))
|
|
54
|
+
}, 5000)
|
|
55
|
+
|
|
56
|
+
request.onerror = (e) => {
|
|
57
|
+
clearTimeout(openTimeout)
|
|
58
|
+
reject(e.currentTarget.error)
|
|
59
|
+
}
|
|
36
60
|
|
|
37
61
|
request.onsuccess = (e) => {
|
|
62
|
+
clearTimeout(openTimeout)
|
|
38
63
|
const db = e.target.result
|
|
39
64
|
if (!db.objectStoreNames.contains(DB_CONFIG.STORE_NAME)) {
|
|
40
65
|
db.close()
|
|
@@ -46,6 +71,7 @@ export class IndexedDBManager {
|
|
|
46
71
|
}
|
|
47
72
|
|
|
48
73
|
request.onupgradeneeded = (e) => {
|
|
74
|
+
clearTimeout(openTimeout)
|
|
49
75
|
const db = e.target.result
|
|
50
76
|
if (!db.objectStoreNames.contains(DB_CONFIG.STORE_NAME)) {
|
|
51
77
|
db.createObjectStore(DB_CONFIG.STORE_NAME, { keyPath: 'key' })
|
|
@@ -53,15 +79,26 @@ export class IndexedDBManager {
|
|
|
53
79
|
}
|
|
54
80
|
}
|
|
55
81
|
|
|
56
|
-
checkRequest.onerror = (e) =>
|
|
82
|
+
checkRequest.onerror = (e) => {
|
|
83
|
+
clearTimeout(timeout)
|
|
84
|
+
reject(e.currentTarget.error)
|
|
85
|
+
}
|
|
57
86
|
})
|
|
58
87
|
} catch (error) {
|
|
59
|
-
console.error('打开数据库失败:', error)
|
|
88
|
+
console.error('[openDatabase] 打开数据库失败:', error)
|
|
89
|
+
|
|
90
|
+
// 如果是超时错误或版本错误,尝试自动重建数据库
|
|
91
|
+
if (error.message?.includes('timeout') || error.message?.includes('version')) {
|
|
92
|
+
await this.forceRecreateDatabase()
|
|
93
|
+
return this.openDatabase() // 递归调用,重新尝试打开
|
|
94
|
+
}
|
|
95
|
+
|
|
60
96
|
throw error
|
|
61
97
|
}
|
|
62
98
|
}
|
|
63
99
|
|
|
64
100
|
async upgradeDatabase (resolve, reject) {
|
|
101
|
+
console.warn('[upgradeDatabase] 升级数据库到版本:', DB_CONFIG.CURRENT_VERSION)
|
|
65
102
|
const request = this.indexedDB.open(DB_CONFIG.NAME, DB_CONFIG.CURRENT_VERSION)
|
|
66
103
|
|
|
67
104
|
request.onupgradeneeded = (e) => {
|
|
@@ -71,11 +108,28 @@ export class IndexedDBManager {
|
|
|
71
108
|
}
|
|
72
109
|
}
|
|
73
110
|
|
|
74
|
-
request.onsuccess = (e) =>
|
|
75
|
-
|
|
111
|
+
request.onsuccess = (e) => {
|
|
112
|
+
resolve(e.target.result)
|
|
113
|
+
}
|
|
114
|
+
request.onerror = (e) => {
|
|
115
|
+
reject(e.currentTarget.error)
|
|
116
|
+
}
|
|
76
117
|
}
|
|
77
118
|
|
|
78
119
|
async openDB (callback) {
|
|
120
|
+
// 如果数据库不健康,直接调用回调并返回
|
|
121
|
+
if (!IS_DB_HEALTHY) {
|
|
122
|
+
console.warn('[openDB] 数据库不健康,跳过数据库操作')
|
|
123
|
+
setTimeout(() => {
|
|
124
|
+
try {
|
|
125
|
+
callback(null)
|
|
126
|
+
} catch (e) {
|
|
127
|
+
console.error('[openDB] 回调执行错误:', e)
|
|
128
|
+
}
|
|
129
|
+
}, 0)
|
|
130
|
+
return
|
|
131
|
+
}
|
|
132
|
+
|
|
79
133
|
try {
|
|
80
134
|
if (this.db) {
|
|
81
135
|
const isAlive = await this.checkConnection()
|
|
@@ -85,13 +139,51 @@ export class IndexedDBManager {
|
|
|
85
139
|
}
|
|
86
140
|
}
|
|
87
141
|
|
|
88
|
-
|
|
89
|
-
|
|
142
|
+
// 添加超时机制,防止卡死
|
|
143
|
+
const openDbPromise = this.openDatabase()
|
|
144
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
|
145
|
+
setTimeout(() => reject(new Error('openDB timeout')), 5000)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
try {
|
|
149
|
+
this.db = await Promise.race([openDbPromise, timeoutPromise])
|
|
150
|
+
callback(this.db)
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error('[openDB] 打开数据库连接超时或失败', error)
|
|
153
|
+
// 标记数据库为不健康状态,后续操作使用备用方案
|
|
154
|
+
IS_DB_HEALTHY = false
|
|
155
|
+
try {
|
|
156
|
+
callback(null)
|
|
157
|
+
} catch (callbackError) {
|
|
158
|
+
console.error('[openDB] 回调执行错误:', callbackError)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
90
161
|
} catch (error) {
|
|
91
|
-
console.error('数据库操作失败:', error)
|
|
162
|
+
console.error('[openDB] 数据库操作失败:', error)
|
|
163
|
+
|
|
164
|
+
// 版本错误时尝试重建数据库
|
|
92
165
|
if (error.message?.includes('version')) {
|
|
93
|
-
|
|
94
|
-
|
|
166
|
+
try {
|
|
167
|
+
await this.recreateDatabase()
|
|
168
|
+
callback(this.db)
|
|
169
|
+
} catch (rebuildError) {
|
|
170
|
+
console.error('[openDB] 重建失败,标记数据库为不健康状态', rebuildError)
|
|
171
|
+
IS_DB_HEALTHY = false
|
|
172
|
+
try {
|
|
173
|
+
callback(null)
|
|
174
|
+
} catch (callbackError) {
|
|
175
|
+
console.error('[openDB] 回调执行错误:', callbackError)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
// 其他错误,标记为不健康并使用备用方案
|
|
180
|
+
IS_DB_HEALTHY = false
|
|
181
|
+
console.error('[openDB] 不可恢复的错误,标记数据库为不健康状态')
|
|
182
|
+
try {
|
|
183
|
+
callback(null)
|
|
184
|
+
} catch (callbackError) {
|
|
185
|
+
console.error('[openDB] 回调执行错误:', callbackError)
|
|
186
|
+
}
|
|
95
187
|
}
|
|
96
188
|
}
|
|
97
189
|
}
|
|
@@ -102,41 +194,93 @@ export class IndexedDBManager {
|
|
|
102
194
|
const store = transaction.objectStore(DB_CONFIG.STORE_NAME)
|
|
103
195
|
await this.promisifyRequest(store.add({ key: 'alive', data: true }))
|
|
104
196
|
return true
|
|
105
|
-
} catch {
|
|
197
|
+
} catch (error) {
|
|
106
198
|
return false
|
|
107
199
|
}
|
|
108
200
|
}
|
|
109
201
|
|
|
110
202
|
promisifyRequest (request) {
|
|
111
203
|
return new Promise((resolve, reject) => {
|
|
112
|
-
request.onsuccess = () =>
|
|
113
|
-
|
|
204
|
+
request.onsuccess = () => {
|
|
205
|
+
resolve(request.result)
|
|
206
|
+
}
|
|
207
|
+
request.onerror = () => {
|
|
208
|
+
reject(request.error)
|
|
209
|
+
}
|
|
114
210
|
})
|
|
115
211
|
}
|
|
116
212
|
|
|
117
213
|
async getByWeb (key, url, params, callback, processFun) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
214
|
+
// 数据库不健康时使用备用方案
|
|
215
|
+
if (!IS_DB_HEALTHY) {
|
|
216
|
+
console.warn(`[getByWeb] 数据库不健康,使用内存缓存或直接API调用`)
|
|
217
|
+
return this.getByWebWithoutDB(key, url, params, callback, processFun)
|
|
121
218
|
}
|
|
122
219
|
|
|
123
|
-
|
|
220
|
+
// 锁机制:防止同一键的并发请求
|
|
221
|
+
if (this.locks.has(key)) {
|
|
222
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
|
223
|
+
setTimeout(() => {
|
|
224
|
+
reject(new Error(`请求超时: ${key}`))
|
|
225
|
+
}, this.requestTimeout)
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
await Promise.race([this.locks.get(key), timeoutPromise])
|
|
230
|
+
return this.getByWeb(key, url, params, callback, processFun)
|
|
231
|
+
} catch (error) {
|
|
232
|
+
console.error(`[getByWeb] 等待锁期间出错或超时: ${error.message}`)
|
|
233
|
+
this.locks.delete(key)
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const lockPromise = (async () => {
|
|
124
238
|
try {
|
|
239
|
+
// 首先检查内存缓存
|
|
240
|
+
if (USE_MEMORY_CACHE && MEMORY_CACHE.has(key)) {
|
|
241
|
+
const cachedData = MEMORY_CACHE.get(key)
|
|
242
|
+
callback(cachedData)
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// 再检查IndexedDB缓存
|
|
125
247
|
const data = DB_CONFIG.NAME === LIULI_WEB_DB_NAME ? undefined : await this.getData(key)
|
|
248
|
+
|
|
126
249
|
if (!data && url) {
|
|
250
|
+
// 缓存未命中,请求网络数据
|
|
127
251
|
const res = await post(url, params)
|
|
128
252
|
const processedData = processFun ? processFun(res) : res
|
|
129
253
|
|
|
254
|
+
// 同时保存到内存缓存
|
|
255
|
+
if (USE_MEMORY_CACHE) {
|
|
256
|
+
MEMORY_CACHE.set(key, processedData)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// 生产环境或非移动配置时保存到IndexedDB
|
|
130
260
|
if (process.env.NODE_ENV === 'production' || key !== 'webMobileConfig') {
|
|
131
261
|
await this.add(key, processedData)
|
|
132
262
|
}
|
|
133
263
|
|
|
134
264
|
callback(processedData)
|
|
135
265
|
} else {
|
|
266
|
+
// 使用缓存数据
|
|
267
|
+
if (USE_MEMORY_CACHE && data) {
|
|
268
|
+
MEMORY_CACHE.set(key, data)
|
|
269
|
+
}
|
|
136
270
|
callback(data)
|
|
137
271
|
}
|
|
138
272
|
} catch (error) {
|
|
139
|
-
console.error(
|
|
273
|
+
console.error(`[getByWeb] 获取数据失败: ${error.message}`)
|
|
274
|
+
|
|
275
|
+
// IndexedDB操作失败时切换到备用方案
|
|
276
|
+
if (error.name === 'InvalidStateError' || error.message?.includes('database') || error.message?.includes('transaction')) {
|
|
277
|
+
console.error(`[getByWeb] 数据库操作失败,标记为不健康`)
|
|
278
|
+
IS_DB_HEALTHY = false
|
|
279
|
+
|
|
280
|
+
// 使用备用方案获取数据
|
|
281
|
+
return this.getByWebWithoutDB(key, url, params, callback, processFun)
|
|
282
|
+
}
|
|
283
|
+
|
|
140
284
|
if (process.env.NODE_ENV === 'production' && key !== 'webMobileConfig') {
|
|
141
285
|
await this.add(key, null)
|
|
142
286
|
}
|
|
@@ -144,65 +288,130 @@ export class IndexedDBManager {
|
|
|
144
288
|
}
|
|
145
289
|
})()
|
|
146
290
|
|
|
291
|
+
this.locks.set(key, lockPromise)
|
|
292
|
+
|
|
147
293
|
try {
|
|
148
|
-
|
|
294
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
|
295
|
+
setTimeout(() => {
|
|
296
|
+
reject(new Error(`操作超时: ${key}`))
|
|
297
|
+
}, this.requestTimeout)
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
await Promise.race([this.locks.get(key), timeoutPromise])
|
|
301
|
+
} catch (error) {
|
|
302
|
+
console.error(`[getByWeb] 执行期间出错或超时: ${error.message}`)
|
|
149
303
|
} finally {
|
|
150
|
-
|
|
304
|
+
this.locks.delete(key)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// 备用方法:不使用IndexedDB,直接使用内存缓存和API
|
|
309
|
+
async getByWebWithoutDB (key, url, params, callback, processFun) {
|
|
310
|
+
// 首先检查内存缓存
|
|
311
|
+
if (USE_MEMORY_CACHE && MEMORY_CACHE.has(key)) {
|
|
312
|
+
const cachedData = MEMORY_CACHE.get(key)
|
|
313
|
+
callback(cachedData)
|
|
314
|
+
return
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// 无URL则无法获取数据
|
|
318
|
+
if (!url) {
|
|
319
|
+
callback(null)
|
|
320
|
+
return
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 直接通过API获取数据
|
|
324
|
+
try {
|
|
325
|
+
const res = await post(url, params)
|
|
326
|
+
const processedData = processFun ? processFun(res) : res
|
|
327
|
+
|
|
328
|
+
// 保存到内存缓存
|
|
329
|
+
if (USE_MEMORY_CACHE) {
|
|
330
|
+
MEMORY_CACHE.set(key, processedData)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
callback(processedData)
|
|
334
|
+
} catch (error) {
|
|
335
|
+
console.error(`[getByWebWithoutDB] 获取数据失败: ${error.message}`)
|
|
336
|
+
callback(null)
|
|
151
337
|
}
|
|
152
338
|
}
|
|
153
339
|
|
|
154
340
|
async getData (key) {
|
|
155
341
|
return new Promise((resolve) => {
|
|
156
342
|
this.openDB((db) => {
|
|
343
|
+
if (!db) {
|
|
344
|
+
resolve(null)
|
|
345
|
+
return
|
|
346
|
+
}
|
|
157
347
|
const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
|
|
158
348
|
const request = store.get(key)
|
|
159
|
-
|
|
160
|
-
request.
|
|
349
|
+
|
|
350
|
+
request.onsuccess = (e) => {
|
|
351
|
+
resolve(e.target.result?.data)
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
request.onerror = () => {
|
|
355
|
+
resolve(null)
|
|
356
|
+
}
|
|
161
357
|
})
|
|
162
358
|
})
|
|
163
359
|
}
|
|
164
360
|
|
|
165
361
|
async add (key, data) {
|
|
166
362
|
this.openDB((db) => {
|
|
363
|
+
if (!db) return
|
|
364
|
+
|
|
167
365
|
const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
|
|
168
366
|
const request = store.add({ key, data })
|
|
169
|
-
|
|
367
|
+
|
|
368
|
+
request.onerror = () => {
|
|
369
|
+
// 添加失败时尝试更新
|
|
370
|
+
this.update(key, data)
|
|
371
|
+
}
|
|
170
372
|
})
|
|
171
373
|
}
|
|
172
374
|
|
|
173
375
|
async update (key, data) {
|
|
174
376
|
this.openDB((db) => {
|
|
377
|
+
if (!db) return
|
|
378
|
+
|
|
175
379
|
const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
|
|
176
|
-
|
|
177
|
-
request.onerror = () => console.error('数据更新失败')
|
|
380
|
+
store.put({ key, data })
|
|
178
381
|
})
|
|
179
382
|
}
|
|
180
383
|
|
|
181
384
|
async delete (key) {
|
|
182
385
|
this.openDB((db) => {
|
|
386
|
+
if (!db) return
|
|
387
|
+
|
|
183
388
|
const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
|
|
184
|
-
|
|
185
|
-
request.onerror = () => console.error('数据删除失败')
|
|
389
|
+
store.delete(key)
|
|
186
390
|
})
|
|
187
391
|
}
|
|
188
392
|
|
|
189
393
|
async clear (callback) {
|
|
190
394
|
this.openDB((db) => {
|
|
395
|
+
if (!db) {
|
|
396
|
+
if (typeof callback === 'function') callback()
|
|
397
|
+
return
|
|
398
|
+
}
|
|
399
|
+
|
|
191
400
|
const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
|
|
192
401
|
const request = store.clear()
|
|
402
|
+
|
|
193
403
|
request.onerror = () => {
|
|
194
|
-
|
|
195
|
-
callback()
|
|
404
|
+
if (typeof callback === 'function') callback()
|
|
196
405
|
}
|
|
406
|
+
|
|
197
407
|
request.onsuccess = () => {
|
|
198
|
-
if (typeof callback === 'function')
|
|
199
|
-
callback()
|
|
200
|
-
}
|
|
408
|
+
if (typeof callback === 'function') callback()
|
|
201
409
|
}
|
|
202
410
|
})
|
|
203
411
|
}
|
|
204
412
|
|
|
205
413
|
clearCache () {
|
|
414
|
+
// 清除缓存并刷新页面
|
|
206
415
|
if (this.indexedDB) {
|
|
207
416
|
this.clear(() => {
|
|
208
417
|
location.reload()
|
|
@@ -215,22 +424,115 @@ export class IndexedDBManager {
|
|
|
215
424
|
async getAll () {
|
|
216
425
|
return new Promise((resolve, reject) => {
|
|
217
426
|
this.openDB((db) => {
|
|
427
|
+
if (!db) {
|
|
428
|
+
resolve([])
|
|
429
|
+
return
|
|
430
|
+
}
|
|
431
|
+
|
|
218
432
|
const store = db.transaction(DB_CONFIG.STORE_NAME, 'readonly').objectStore(DB_CONFIG.STORE_NAME)
|
|
219
433
|
const request = store.getAll()
|
|
220
|
-
|
|
221
|
-
request.
|
|
434
|
+
|
|
435
|
+
request.onsuccess = (e) => {
|
|
436
|
+
resolve(e.target.result)
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
request.onerror = (e) => {
|
|
440
|
+
reject(e.target.error)
|
|
441
|
+
}
|
|
222
442
|
})
|
|
223
443
|
})
|
|
224
444
|
}
|
|
225
445
|
|
|
226
446
|
getAllLegacy (callback) {
|
|
227
447
|
this.openDB((res) => {
|
|
448
|
+
if (!res) {
|
|
449
|
+
callback(null, new Error('打开数据库失败'))
|
|
450
|
+
return
|
|
451
|
+
}
|
|
452
|
+
|
|
228
453
|
const store = res.transaction(DB_CONFIG.STORE_NAME, 'readonly').objectStore(DB_CONFIG.STORE_NAME)
|
|
229
454
|
const request = store.getAll()
|
|
230
|
-
|
|
231
|
-
request.
|
|
455
|
+
|
|
456
|
+
request.onerror = (e) => {
|
|
457
|
+
callback(null, e.target.error)
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
request.onsuccess = (e) => {
|
|
461
|
+
callback(e.target.result)
|
|
462
|
+
}
|
|
232
463
|
})
|
|
233
464
|
}
|
|
465
|
+
|
|
466
|
+
async recreateDatabase () {
|
|
467
|
+
try {
|
|
468
|
+
if (this.db) {
|
|
469
|
+
this.db.close()
|
|
470
|
+
this.db = undefined
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
await new Promise((resolve, reject) => {
|
|
474
|
+
const deleteRequest = this.indexedDB.deleteDatabase(DB_CONFIG.NAME)
|
|
475
|
+
|
|
476
|
+
deleteRequest.onsuccess = () => {
|
|
477
|
+
resolve()
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
deleteRequest.onerror = (e) => {
|
|
481
|
+
reject(e.target.error)
|
|
482
|
+
}
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
DB_CONFIG.CURRENT_VERSION = DB_CONFIG.VERSION
|
|
486
|
+
this.db = await this.openDatabase()
|
|
487
|
+
return this.db
|
|
488
|
+
} catch (error) {
|
|
489
|
+
console.error('重新创建数据库失败:', error)
|
|
490
|
+
throw error
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// 强制重建数据库的方法,带有超时保护
|
|
495
|
+
async forceRecreateDatabase () {
|
|
496
|
+
console.warn('[forceRecreateDatabase] 开始强制重建数据库')
|
|
497
|
+
try {
|
|
498
|
+
// 确保关闭所有连接
|
|
499
|
+
if (this.db) {
|
|
500
|
+
try {
|
|
501
|
+
this.db.close()
|
|
502
|
+
} catch (e) {
|
|
503
|
+
console.warn('[forceRecreateDatabase] 关闭现有连接出错')
|
|
504
|
+
}
|
|
505
|
+
this.db = undefined
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// 清空锁防止死锁
|
|
509
|
+
this.locks.clear()
|
|
510
|
+
|
|
511
|
+
// 强制删除数据库,带超时保护
|
|
512
|
+
await new Promise((resolve) => {
|
|
513
|
+
const deleteRequest = this.indexedDB.deleteDatabase(DB_CONFIG.NAME)
|
|
514
|
+
|
|
515
|
+
const timeout = setTimeout(() => {
|
|
516
|
+
resolve() // 即使超时也继续执行
|
|
517
|
+
}, 3000)
|
|
518
|
+
|
|
519
|
+
deleteRequest.onsuccess = () => {
|
|
520
|
+
clearTimeout(timeout)
|
|
521
|
+
resolve()
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
deleteRequest.onerror = () => {
|
|
525
|
+
clearTimeout(timeout)
|
|
526
|
+
resolve() // 即使出错也继续执行
|
|
527
|
+
}
|
|
528
|
+
})
|
|
529
|
+
|
|
530
|
+
// 重置版本
|
|
531
|
+
DB_CONFIG.CURRENT_VERSION = DB_CONFIG.VERSION
|
|
532
|
+
} catch (error) {
|
|
533
|
+
console.error('[forceRecreateDatabase] 强制重建过程中出错:', error)
|
|
534
|
+
}
|
|
535
|
+
}
|
|
234
536
|
}
|
|
235
537
|
|
|
236
538
|
export const indexedDB = new IndexedDBManager()
|