Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(plugins/materials): fix new app with no page should not set url page id to undefined #1061

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/plugins/materials/src/composable/useResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,25 @@ const appSchemaState = reactive({
materialsDeps: { scripts: [], styles: new Set() }
})

function goPage(pageId) {
if (!pageId) {
return
}

const url = new URL(window.location)

url.searchParams.set('pageid', pageId)
window.history.pushState({}, '', url)
usePage().postLocationHistoryChanged({ pageId })
}

const initPage = (pageInfo) => {
try {
if (pageInfo.meta) {
const { occupier } = pageInfo.meta

useLayout().layoutState.pageStatus = getCanvasStatus(occupier)
goPage(pageInfo.meta?.id)
} else {
useLayout().layoutState.pageStatus = {
state: 'empty',
Expand All @@ -54,12 +67,6 @@ const initPage = (pageInfo) => {
pageInfo.id = pageInfo.meta?.id
} catch (error) {
console.log(error) // eslint-disable-line
} finally {
const url = new URL(window.location)

url.searchParams.set('pageid', pageInfo.id)
window.history.pushState({}, '', url)
usePage().postLocationHistoryChanged({ pageId: pageInfo.id })
}

const { id, meta, ...pageSchema } = pageInfo
Expand Down
Loading