Added basic comments.

This commit is contained in:
2023-06-11 05:32:02 +02:00
parent 9a9b92a6b1
commit 0d5744e3ff
26 changed files with 441 additions and 89 deletions

View File

@@ -12,7 +12,7 @@ async function render(pageContext) {
const title = (documentProps && documentProps.title) || 'shack';
const desc = (documentProps && documentProps.description) || 'Shack';
const { app, store } = createApp(pageContext);
const { app } = createApp(pageContext);
const stream = renderToNodeStream(app);
const documentHtml = escapeInject`
@@ -38,14 +38,28 @@ async function render(pageContext) {
return {
documentHtml,
pageContext: {
initialState: store.state.value,
// initialState: store.state.value,
enableEagerStreaming: true,
},
};
}
async function onBeforeRender(pageContext) {
const pageData = await pageContext.exports.getPageData?.(pageContext, pageContext.session);
return {
pageContext: {
// initialState: store.state.value,
pageData,
user: pageContext.session.user,
now: new Date(),
},
};
}
export {
render,
onBeforeRender,
};
export const passToClient = ['urlPathname', 'initialState', 'pageData', 'pageProps', 'routeParams'];
export const passToClient = ['urlPathname', 'initialState', 'pageData', 'pageProps', 'routeParams', 'user', 'now'];

View File

@@ -33,20 +33,13 @@
</template>
<script setup>
// import { onMounted } from 'vue';
// import { usePageContext } from './usePageContext';
import { storeToRefs } from 'pinia';
import logo from '../assets/img/logo.svg?raw';
import logo from '../assets/img/logo.svg?raw'; // eslint-disable-line import/no-unresolved
import { del } from '../assets/js/api';
import { useUser } from '../stores/user';
import { usePageContext } from './usePageContext';
// const pageContext = usePageContext();
const { user } = usePageContext();
const version = CLIENT_VERSION;
const userStore = useUser();
const { user } = storeToRefs(userStore);
async function logout() {
await del('/api/session');
window.location.href = '/account/login';