forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(SSR): per instance Platform and Cookies
- Loading branch information
1 parent
9757996
commit 8b8c0aa
Showing
35 changed files
with
265 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { createApp } from './ssr.app' | ||
import { createApp } from './app' | ||
|
||
const { app, router } = createApp() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { ready } from './utils/dom' | ||
import { setBrand } from './utils/colors' | ||
|
||
function getBodyClasses ({ is, has, within }, cfg = {}) { | ||
const cls = [ | ||
process.env.THEME, | ||
is.desktop ? 'desktop' : 'mobile', | ||
has.touch ? 'touch' : 'no-touch', | ||
`platform-${is.ios ? 'ios' : 'mat'}` | ||
] | ||
|
||
if (is.cordova) { | ||
cls.push('cordova') | ||
|
||
if (is.ios && (cfg.cordova === void 0 || cfg.cordova.iosStatusBarPadding !== false)) { | ||
const | ||
ratio = window.devicePixelRatio || 1, | ||
width = window.screen.width * ratio, | ||
height = window.screen.height * ratio | ||
|
||
if (width !== 1125 && height !== 2001 /* 2436 for iPhoneX fullscreen */) { | ||
cls.push('q-ios-statusbar-padding') | ||
} | ||
} | ||
} | ||
within.iframe && cls.push('within-iframe') | ||
is.electron && cls.push('electron') | ||
|
||
return cls | ||
} | ||
|
||
function bodyInit (Platform, cfg) { | ||
const cls = getBodyClasses(Platform, cfg) | ||
|
||
if (Platform.is.ie && Platform.is.versionNumber === 11) { | ||
cls.forEach(c => document.body.classList.add(c)) | ||
} | ||
else { | ||
document.body.classList.add.apply(document.body.classList, cls) | ||
} | ||
|
||
if (Platform.is.ios) { | ||
// needed for iOS button active state | ||
document.body.addEventListener('touchstart', () => {}) | ||
} | ||
} | ||
|
||
function setColors (brand) { | ||
for (let color in brand) { | ||
setBrand(color, brand[color]) | ||
} | ||
} | ||
|
||
export function ssrUpdateBody (ssr) { | ||
const update = ssr.setBodyClasses | ||
if (typeof update === 'function') { | ||
update(getBodyClasses(ssr.app.$q.platform)) | ||
} | ||
} | ||
|
||
export function clientUpdateBody ({ $q, cfg }) { | ||
const init = cfg.brand && document.body | ||
init && setColors(cfg.brand) | ||
ready(() => { | ||
!init && setColors(cfg.brand) | ||
bodyInit($q.platform, cfg) | ||
}) | ||
} |
Oops, something went wrong.