Skip to content

Commit 33c76cf

Browse files
committed
feat: Enhance Cookies & Platform for SSR global usage
1 parent f8dfc94 commit 33c76cf

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/plugins/cookies.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export function getObject (ctx = {}) {
139139
}
140140

141141
export default {
142+
parseSSR (/* ssrContext */ ssr) {
143+
return ssr ? getObject({ ssr }) : this
144+
},
145+
142146
install ({ $q, queues }) {
143147
if (isSSR) {
144148
queues.server.push((q, ctx) => {

src/plugins/platform.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,23 @@ export default {
205205
touch: false,
206206
webStorage: false
207207
},
208-
within: {
209-
iframe: false
208+
within: { iframe: false },
209+
210+
parseSSR (/* ssrContext */ ssr) {
211+
return ssr ? {
212+
is: getPlatform(ssr.req.headers['user-agent']),
213+
has: this.has,
214+
within: this.within
215+
} : {
216+
is: getPlatform(),
217+
...getClientProperties()
218+
}
210219
},
211220

212221
install ($q, queues, Vue) {
213222
if (isSSR) {
214223
queues.server.push((q, ctx) => {
215-
q.platform = {
216-
is: getPlatform(ctx.ssr.req.headers['user-agent']),
217-
has: {
218-
touch: false,
219-
webStorage: false
220-
},
221-
within: { iframe: false }
222-
}
224+
q.platform = this.parseSSR(ctx.ssr)
223225
})
224226
return
225227
}

0 commit comments

Comments
 (0)