欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子 SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 

程序员文章站 2022-03-03 13:46:12
...

We know that once we enable debug mode via “Ctrl+Alt+Shift+P”, this setting will be persisted: even if you turn off your laptop and launch the application tomorrow, the debug mode will still be there.

 

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 

 

In Chrome development tool, there is an Application tab which records this setting via key value pair using Local Storage.

 

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 

 

As usual we can still use debug to investigate what has happened when the checkbox “Use Debug Sources(reload)” is clicked. In Chrome development tool Elements tab, click the small arrow icon to enter the element inspection mode, then click the checkbox, then its html source code will be automatically navigate.

 

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 

 

Perform global search via keyword “useDbgSources”, and then we can find the event handler onUseDbgSources for debug mode set:

 

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 

 

Set a breakpoint on this function, then mark the checkbox in UI, breakpoint is triggered as expected:

 

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 

 

Within the function, we can know the debugging flag is set via localStoage API: window.localStorage.setItem

 

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 

 

This API will change the following file in my laptop:

 

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院 

 

If I open the changed file via some SQLite management tool, I can find the corresponding entry with key sap-ui-debug and value ‘X’ set:

 

SAP UI5应用的调试标志位的本地存储逻辑 - local storage使用的一个例子
            
    
    
        SAPSAP云平台SAP UI5JavaScriptSAP成都研究院