File tree Expand file tree Collapse file tree 2 files changed +30
-9
lines changed
Expand file tree Collapse file tree 2 files changed +30
-9
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,10 @@ class DocumentationViewController: NSViewController {
195195 self . documentURL = URL ( string: location)
196196 hideSearchControl ( )
197197 }
198+
199+ private func handleAppReboot( ) {
200+ webView. reload ( )
201+ }
198202}
199203
200204// MARK:- WKUIDelegate
@@ -256,6 +260,8 @@ extension DocumentationViewController: WKScriptMessageHandler {
256260 return
257261 }
258262 handleLocationNotification ( args)
263+ case " appReboot " :
264+ handleAppReboot ( )
259265 default :
260266 return
261267 }
Original file line number Diff line number Diff line change 1- ( function ( ) {
1+ ( async function ( ) {
22 // Need to patch app.views.Mobile.detect internals to force desktop mode.
33 const original = window . matchMedia
44 const patcher = function ( ) {
55 return { matches : false }
66 }
77 window . matchMedia = patcher
88
9- const afterInit = function ( ) {
10- if ( window . app && window . app . settings ) {
11- window . matchMedia = original
12- window . webkit . messageHandlers . vcBus . postMessage ( { type : 'afterInit' } )
13- } else {
14- requestAnimationFrame ( afterInit )
15- }
9+ const globalDefined = ( attr ) => {
10+ return new Promise ( function ( resolve , reject ) {
11+ const checker = ( ) => {
12+ if ( Object . prototype . hasOwnProperty . call ( window , attr ) ) {
13+ resolve ( window [ attr ] )
14+ } else {
15+ requestAnimationFrame ( checker )
16+ }
17+ }
18+ requestAnimationFrame ( checker )
19+ } )
1620 }
17- requestAnimationFrame ( afterInit )
21+
22+ const app = await globalDefined ( 'app' )
23+ app . isMobile = ( ) => false
24+ app . views . Mobile . detect = ( ) => false
25+ app . reboot = ( ) => {
26+ window . webkit . messageHandlers . vcBus . postMessage ( {
27+ type : 'appReboot'
28+ } )
29+ }
30+
31+ window . matchMedia = original
32+ window . webkit . messageHandlers . vcBus . postMessage ( { type : 'afterInit' } )
1833} ( ) )
You can’t perform that action at this time.
0 commit comments